feat: optimize hub mobile layout with chat-first AI coach tabs
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -966,7 +966,47 @@
|
||||
gridEl.style.gridTemplateColumns = `repeat(${cols}, minmax(0, 1fr))`;
|
||||
}
|
||||
|
||||
const AI_MOBILE_TAB_KEY = "hub_ai_mobile_tab";
|
||||
|
||||
function applyAiMobileTab(tab) {
|
||||
const layout = document.querySelector(".ai-layout");
|
||||
const tabs = document.querySelectorAll(".ai-mobile-tab");
|
||||
if (!layout) return;
|
||||
const mobile = isMobileLayout();
|
||||
const active = mobile ? tab || localStorage.getItem(AI_MOBILE_TAB_KEY) || "chat" : "both";
|
||||
if (mobile) layout.dataset.aiMobileTab = active;
|
||||
else delete layout.dataset.aiMobileTab;
|
||||
tabs.forEach((btn) => {
|
||||
const on = mobile && btn.dataset.aiTab === active;
|
||||
btn.classList.toggle("is-active", on);
|
||||
btn.setAttribute("aria-selected", on ? "true" : "false");
|
||||
});
|
||||
if (mobile && active === "chat") {
|
||||
const box = document.getElementById("ai-chat-messages");
|
||||
if (box) requestAnimationFrame(() => { box.scrollTop = box.scrollHeight; });
|
||||
}
|
||||
}
|
||||
|
||||
function initAiMobileTabs() {
|
||||
const tabs = document.querySelectorAll(".ai-mobile-tab");
|
||||
if (!tabs.length) return;
|
||||
tabs.forEach((btn) => {
|
||||
btn.addEventListener("click", () => {
|
||||
const tab = btn.dataset.aiTab || "chat";
|
||||
localStorage.setItem(AI_MOBILE_TAB_KEY, tab);
|
||||
applyAiMobileTab(tab);
|
||||
if (tab === "chat") {
|
||||
const input = document.getElementById("ai-chat-input");
|
||||
if (input && isMobileLayout()) input.focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
window.addEventListener("resize", () => applyAiMobileTab());
|
||||
applyAiMobileTab();
|
||||
}
|
||||
|
||||
function initMobileLayout() {
|
||||
initAiMobileTabs();
|
||||
let resizeTimer = null;
|
||||
let wasMobile = isMobileLayout();
|
||||
window.addEventListener("resize", () => {
|
||||
@@ -3247,7 +3287,14 @@
|
||||
}
|
||||
|
||||
async function loadAiPage() {
|
||||
applyAiMobileTab();
|
||||
await Promise.all([loadAiSummary(), loadAiChatSession()]);
|
||||
if (isMobileLayout() && (localStorage.getItem(AI_MOBILE_TAB_KEY) || "chat") === "chat") {
|
||||
const input = document.getElementById("ai-chat-input");
|
||||
if (input && !aiChatLoading) {
|
||||
setTimeout(() => input.focus(), 80);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function generateAiSummary() {
|
||||
|
||||
Reference in New Issue
Block a user