diff --git a/dist-exe/cc-web-bun-linux-x64-baseline.tar.gz b/dist-exe/cc-web-bun-linux-x64-baseline.tar.gz index d37ded2..0dffcb7 100644 Binary files a/dist-exe/cc-web-bun-linux-x64-baseline.tar.gz and b/dist-exe/cc-web-bun-linux-x64-baseline.tar.gz differ diff --git a/public/app.js b/public/app.js index e6be654..75b958e 100644 --- a/public/app.js +++ b/public/app.js @@ -66,7 +66,8 @@ codexapp: 'Codex App', }; - const DEFAULT_AGENT = 'claude'; + const PRIMARY_UI_AGENT = 'codexapp'; + const DEFAULT_AGENT = PRIMARY_UI_AGENT; const SESSION_CACHE_LIMIT = 4; const SESSION_CACHE_MAX_WEIGHT = 1_500_000; const SIDEBAR_SWIPE_TRIGGER = 72; @@ -178,8 +179,8 @@ let hasGrouped = false; // 本次输出是否已触发过折叠 let cmdMenuIndex = -1; let currentMode = 'yolo'; - let currentModel = 'opus'; - let currentAgent = AGENT_LABELS[localStorage.getItem('cc-web-agent')] ? localStorage.getItem('cc-web-agent') : DEFAULT_AGENT; + let currentModel = ''; + let currentAgent = DEFAULT_AGENT; let currentTheme = (document.documentElement.dataset.theme || localStorage.getItem('cc-web-theme') || 'washi'); let showAgentDividerTime = localStorage.getItem(DIVIDER_TIME_STORAGE_KEY) !== '0'; let codexConfigCache = null; @@ -268,6 +269,7 @@ const chatSessionIdBtn = $('#chat-session-id-btn'); const chatAgentBtn = $('#chat-agent-btn'); const chatAgentMenu = $('#chat-agent-menu'); + const chatAgentPicker = chatAgentBtn?.closest('.chat-agent-picker') || chatAgentMenu?.closest('.chat-agent-picker') || null; const chatRuntimeState = $('#chat-runtime-state'); const chatCwd = $('#chat-cwd'); const userOutlineBtn = $('#user-outline-btn'); @@ -308,6 +310,14 @@ return AGENT_LABELS[agent] ? agent : DEFAULT_AGENT; } + function normalizeUiAgent() { + return PRIMARY_UI_AGENT; + } + + function isPrimaryUiAgent(agent) { + return normalizeAgent(agent) === PRIMARY_UI_AGENT; + } + function isCodexLikeAgent(agent) { const normalized = normalizeAgent(agent); return normalized === 'codex' || normalized === 'codexapp'; @@ -3750,7 +3760,7 @@ } function getVisibleSessions() { - return sessions.filter((s) => normalizeAgent(s.agent) === currentAgent); + return sessions.filter((s) => isPrimaryUiAgent(s.agent)); } function normalizeSessionSearchQuery(query) { @@ -4123,9 +4133,11 @@ } function updateAgentScopedUI() { + if (chatAgentPicker) chatAgentPicker.hidden = true; + if (chatAgentMenu) chatAgentMenu.hidden = true; if (chatAgentBtn) { chatAgentBtn.textContent = AGENT_LABELS[currentAgent]; - chatAgentBtn.setAttribute('aria-expanded', chatAgentMenu && !chatAgentMenu.hidden ? 'true' : 'false'); + chatAgentBtn.setAttribute('aria-expanded', 'false'); } if (chatAgentMenu) { chatAgentMenu.querySelectorAll('.chat-agent-option').forEach((btn) => { @@ -4144,7 +4156,7 @@ } function setCurrentAgent(agent) { - currentAgent = normalizeAgent(agent); + currentAgent = normalizeUiAgent(agent); localStorage.setItem('cc-web-agent', currentAgent); currentMode = localStorage.getItem(getAgentModeStorageKey(currentAgent)) || 'yolo'; modeSelect.value = currentMode; @@ -4160,6 +4172,7 @@ function toggleAgentMenu() { if (!chatAgentMenu || !chatAgentBtn) return; + if (chatAgentPicker?.hidden) return; const willOpen = chatAgentMenu.hidden; chatAgentMenu.hidden = !willOpen; chatAgentBtn.setAttribute('aria-expanded', willOpen ? 'true' : 'false'); @@ -4199,8 +4212,13 @@ } function applySessionSnapshot(snapshot, options = {}) { - if (!snapshot) return; + if (!snapshot) return false; const snapshotAgent = normalizeAgent(snapshot.agent); + if (!isPrimaryUiAgent(snapshotAgent)) { + if (currentSessionId === snapshot.sessionId) resetChatView(PRIMARY_UI_AGENT); + renderSessionList(); + return false; + } if (fileBrowserState && (fileBrowserState.sessionId !== snapshot.sessionId || (snapshot.cwd && fileBrowserState.rootPath !== snapshot.cwd))) { closeFileBrowser(); } @@ -4260,10 +4278,11 @@ if (snapshot.hasUnread && !options.suppressUnreadToast) { showToast('后台任务已完成', snapshot.sessionId); } + return true; } function syncViewForAgent(agent, options = {}) { - const targetAgent = normalizeAgent(agent); + const targetAgent = normalizeUiAgent(agent); const { preserveCurrent = true, loadLast = true } = options; setCurrentAgent(targetAgent); closeUserOutlinePanel(); @@ -4530,6 +4549,7 @@ function showCachedSession(sessionId) { const snapshot = buildCachedSessionSnapshot(sessionId); if (!snapshot) return false; + if (!isPrimaryUiAgent(snapshot.agent)) return false; if (currentSessionId && currentSessionId !== sessionId) { send({ type: 'detach_view' }); } @@ -4537,12 +4557,17 @@ closeCcwebPromptOutlinePanel(); clearSessionLoading(); touchSessionCache(sessionId); - applySessionSnapshot(snapshot, { immediate: true, suppressUnreadToast: true }); - return true; + return applySessionSnapshot(snapshot, { immediate: true, suppressUnreadToast: true }); } function openSession(sessionId, options = {}) { if (!sessionId) return; + const meta = getSessionMeta(sessionId); + const cachedAgent = sessionCache.get(sessionId)?.snapshot?.agent; + if ((meta && !isPrimaryUiAgent(meta.agent)) || (!meta && cachedAgent && !isPrimaryUiAgent(cachedAgent))) { + renderSessionList(); + return; + } closeUserOutlinePanel(); closeCcwebPromptOutlinePanel(); if (options.forceSync) { @@ -5230,11 +5255,16 @@ pendingNewSessionRequest = null; if (!matchesActiveLoad) clearSessionLoading(); } - applySessionSnapshot(snapshot, { + const appliedSnapshot = applySessionSnapshot(snapshot, { immediate: isBlockingSessionLoad(msg.sessionId), suppressUnreadToast: false, preserveStreaming: msg.sessionId === currentSessionId && msg.isRunning, }); + if (!appliedSnapshot) { + if (!msg.historyPending) cacheSessionSnapshot(snapshot); + if (matchesActiveLoad) clearSessionLoading(msg.sessionId); + break; + } if (msg.sessionId === currentSessionId) { setCurrentSessionRunningState(!!msg.isRunning); } @@ -9348,6 +9378,7 @@ } function showSettingsPanel() { + setCurrentAgent(PRIMARY_UI_AGENT); if (isCodexLikeAgent(currentAgent)) { showCodexSettingsPanel(); return; @@ -9912,7 +9943,7 @@ function requestNewSession(options = {}) { const cwd = options.cwd || null; const rawCwd = options.rawCwd !== undefined ? options.rawCwd : (cwd || ''); - const agent = normalizeAgent(options.agent || currentAgent); + const agent = normalizeUiAgent(options.agent || currentAgent); const mode = ['default', 'plan', 'yolo'].includes(options.mode) ? options.mode : currentMode; const model = typeof options.model === 'string' ? options.model.trim() : ''; const title = typeof options.title === 'string' ? options.title.trim() : ''; @@ -9945,8 +9976,7 @@ let _onCwdSuggestions = null; function showNewSessionModal(options = {}) { - const targetAgent = normalizeAgent(options.agent || currentAgent); - const targetLabel = AGENT_LABELS[targetAgent] || AGENT_LABELS.claude; + const targetAgent = normalizeUiAgent(options.agent || currentAgent); const recentCwds = getRecentCwds(); const requestedMode = ['default', 'plan', 'yolo'].includes(options.mode) ? options.mode : currentMode; let suggestionsRequested = false; @@ -9961,11 +9991,10 @@ overlay.innerHTML = `