From 0d5a7d1437156d37e12fbd883821c994825a8a37 Mon Sep 17 00:00:00 2001 From: OrwellVII <56531592+OrwellVII@users.noreply.github.com> Date: Mon, 2 Nov 2026 12:19:50 +0800 Subject: [PATCH 1/2] fix(sidebar): clear the completed check once the session is opened The green check marked the most recently active sessions (the recent-runs limit), so it stayed on conversations already read and never went away. It now follows the per-browser unread set: a session that finishes in the background gets it, opening the session clears it, a session that finishes while open never gets one, and other tabs of the same browser follow through a storage listener. Nested rows re-render when a child's unread state changes. The pulsing "new activity" dot, which marked the same state, is gone; the running-only filter still keeps recently finished sessions. Rebased onto the host-aware sidebar. The running-to-idle comparison's two known boundaries (runs that finish while no tab is open; an old id left behind by a session move) are documented where the check is computed. --- CHANGELOG.md | 1 + components/SessionSidebar-chrome.tsx | 41 +---- components/SessionSidebar-rows.tsx | 26 +-- components/SessionSidebar.completed.test.mjs | 160 +++++++++++++++++++ components/SessionSidebar.tsx | 23 ++- lib/i18n/locales/en.json | 6 +- lib/i18n/locales/ja.json | 6 +- lib/i18n/locales/zh-CN.json | 6 +- lib/i18n/locales/zh-TW.json | 6 +- 9 files changed, 202 insertions(+), 73 deletions(-) create mode 100644 components/SessionSidebar.completed.test.mjs diff --git a/CHANGELOG.md b/CHANGELOG.md index 62801f331..747d58537 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -155,6 +155,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f - **Workspace profile names are validated before they can break sessions.** The profile inputs show the naming rule and reject invalid names, and the API rejects invalid profiles and reserved launch arguments. Existing invalid profiles and reserved arguments remain visible in the workspace launch configuration; an updated host daemon refuses to start a session until they are corrected or cleared, instead of silently switching profiles or passing an orphan argument. Update remote host daemons as well: older versions do not enforce this spawn-time check. - **A failed run no longer shows its error three times.** The duplicate "Request failed" toast is gone. A non-quota error already shown on the current run's assistant message does not also need a shelf notice; standalone errors and errors whose message cannot be confirmed remain visible in the shelf, even after partial output. If the matching assistant message is saved later, it replaces only that run's duplicate notice. Quota handling is unchanged and may show both an inline banner and a shelf notice. - **`send_to_session` with `delivery: "followUp"` queues the message.** It failed with "Unsupported command: followUp" instead of queueing the message after the target's running turn. +- **The sidebar's green check clears once you open the conversation.** The check marked the most recently active sessions (the "recent runs" limit, 10 by default), so it stayed on conversations you had already read and never went away. It now means "finished in the background and not opened yet": opening the session removes it, a session that finishes while you are viewing it never gets one, and other tabs of the same browser drop it too. The state is kept per browser, not synced across devices. The pulsing "new activity" dot, which marked the same state, is gone. The running-only filter still keeps recently finished sessions. --- diff --git a/components/SessionSidebar-chrome.tsx b/components/SessionSidebar-chrome.tsx index ff0ae801c..18f61691c 100644 --- a/components/SessionSidebar-chrome.tsx +++ b/components/SessionSidebar-chrome.tsx @@ -435,12 +435,13 @@ function ExitedSessionIndicator({ title, size = 14 }: { title: string; size?: nu ); } -function RecentlyCompletedIndicator({ size = 12 }: { size?: number }) { +/** A session that finished in the background and has not been opened since. */ +function CompletedUnreadIndicator({ size = 12 }: { size?: number }) { const { t } = useI18n(); return ( ); } - - -function UnreadSessionIndicator({ size = 14 }: { size?: number }) { - const { t } = useI18n(); - const reducedMotion = usePrefersReducedMotion(); - return ( - - - - ); -} export { OmpWebTitle, PathLabel, ExitedSessionIndicator, RunningSessionIndicator, - RecentlyCompletedIndicator, + CompletedUnreadIndicator, SIDEBAR_BUTTON_TRANSITION, SidebarIconButton, SidebarPortalMenu, - UnreadSessionIndicator, useScramble, }; diff --git a/components/SessionSidebar-rows.tsx b/components/SessionSidebar-rows.tsx index 6b14c3ebd..2f5eb157b 100644 --- a/components/SessionSidebar-rows.tsx +++ b/components/SessionSidebar-rows.tsx @@ -18,13 +18,12 @@ import { type SessionTreeNode, } from "./SessionSidebar-helpers"; import { + CompletedUnreadIndicator, ExitedSessionIndicator, - RecentlyCompletedIndicator, RunningSessionIndicator, SIDEBAR_BUTTON_TRANSITION, SidebarIconButton, SidebarPortalMenu, - UnreadSessionIndicator, } from "./SessionSidebar-chrome"; /** @@ -103,7 +102,6 @@ interface ProjectRowProps { runningSessionIds: Set; awaitingInputIds: Set; unreadSessionIds: Set; - recentlyCompletedIds?: Set; exitedSessions: Map; relativeTimeNow: number; onActivate: (project: ManagedProject) => void; @@ -143,7 +141,6 @@ function ProjectRow({ runningSessionIds, awaitingInputIds, unreadSessionIds, - recentlyCompletedIds, exitedSessions, relativeTimeNow, onActivate, @@ -487,7 +484,6 @@ function ProjectRow({ awaitingInputIds={awaitingInputIds} unreadSessionIds={unreadSessionIds} exitedSessions={exitedSessions} - recentlyCompletedIds={recentlyCompletedIds} relativeTimeNow={relativeTimeNow} onSelectSession={onSelectSession} onRenamed={onRenamed} @@ -541,7 +537,6 @@ const SessionTreeItem = memo(function SessionTreeItem({ awaitingInputIds, unreadSessionIds, exitedSessions, - recentlyCompletedIds, relativeTimeNow, onSelectSession, onRenamed, @@ -556,7 +551,6 @@ const SessionTreeItem = memo(function SessionTreeItem({ awaitingInputIds: Set; unreadSessionIds: Set; exitedSessions: Map; - recentlyCompletedIds?: Set; relativeTimeNow: number; onSelectSession: (s: SessionInfo) => void; onRenamed?: () => void; @@ -577,7 +571,6 @@ const SessionTreeItem = memo(function SessionTreeItem({ const isRunning = runningSessionIds.has(sessionId); const isAwaitingInput = awaitingInputIds.has(sessionId); const isUnread = unreadSessionIds.has(sessionId); - const isRecentlyCompleted = !isRunning && (recentlyCompletedIds?.has(sessionId) ?? false); const exited = exitedSessions.get(sessionId); // Stable callbacks: depend only on primitives / stable parent callbacks so @@ -619,7 +612,6 @@ const SessionTreeItem = memo(function SessionTreeItem({ isAwaitingInput={isAwaitingInput} isUnread={isUnread} exited={exited} - isRecentlyCompleted={isRecentlyCompleted} relativeTimeNow={relativeTimeNow} onClick={handleClick} onRenamed={onRenamed} @@ -646,7 +638,6 @@ const SessionTreeItem = memo(function SessionTreeItem({ awaitingInputIds={awaitingInputIds} unreadSessionIds={unreadSessionIds} exitedSessions={exitedSessions} - recentlyCompletedIds={recentlyCompletedIds} relativeTimeNow={relativeTimeNow} onSelectSession={onSelectSession} onRenamed={onRenamed} @@ -676,11 +667,10 @@ const SessionTreeItem = memo(function SessionTreeItem({ const id = prev.node.session.id; if (prev.awaitingInputIds.has(id) !== next.awaitingInputIds.has(id)) return false; } - if (prev.recentlyCompletedIds !== next.recentlyCompletedIds) { - const id = prev.node.session.id; - if ((prev.recentlyCompletedIds?.has(id) ?? false) !== (next.recentlyCompletedIds?.has(id) ?? false)) return false; - } if (prev.unreadSessionIds !== next.unreadSessionIds) { + // Nested rows render inside this memo boundary, so a parent must pass a + // changed set down even when only a descendant's unread state flipped. + if (prev.node.children.length > 0) return false; const id = prev.node.session.id; if (prev.unreadSessionIds.has(id) !== next.unreadSessionIds.has(id)) return false; } @@ -700,7 +690,6 @@ const SessionItem = memo(function SessionItem({ isAwaitingInput, isUnread, exited, - isRecentlyCompleted, onClick, onRenamed, onDeleted, @@ -718,7 +707,6 @@ const SessionItem = memo(function SessionItem({ isAwaitingInput?: boolean; isUnread?: boolean; exited?: ExitedRpcSession; - isRecentlyCompleted?: boolean; onClick: () => void; onRenamed?: () => void; onDeleted?: (id: string) => void; @@ -910,15 +898,13 @@ const SessionItem = memo(function SessionItem({ {session.worktreeBranch && } {hasChildren && }
- {(isRunning || exited || isRecentlyCompleted || isUnread) && ( + {(isRunning || exited || isUnread) && ( {isRunning ? : exited ? - : isRecentlyCompleted - ? - : } + : } )}
diff --git a/components/SessionSidebar.completed.test.mjs b/components/SessionSidebar.completed.test.mjs new file mode 100644 index 000000000..a93e4fef0 --- /dev/null +++ b/components/SessionSidebar.completed.test.mjs @@ -0,0 +1,160 @@ +import "../tests/setup-dom.mjs"; +import assert from "node:assert/strict"; +import test, { afterEach, before } from "node:test"; +import React from "react"; +const { act, cleanup, render, screen, waitFor, within } = await import("@testing-library/react/pure.js"); +const { default: userEvent } = await import("@testing-library/user-event"); + +// The sidebar's green check means "finished in the background, not opened +// since": it follows the persisted unread set, never recency ranking. + +const { SessionSidebar } = await import("./SessionSidebar.tsx"); + +const UNREAD_KEY = "omp-web:unread-session-ids"; +const CHECK = "Finished — not opened yet"; +const PROJECT = "/work/alpha"; + +function session(id, firstMessage, minutesAgo) { + const at = new Date(Date.now() - minutesAgo * 60_000).toISOString(); + return { path: `${PROJECT}/${id}.jsonl`, id, cwd: PROJECT, projectRoot: PROJECT, created: at, modified: at, messageCount: 2, firstMessage }; +} +const SESSIONS = [ + session("s-bg", "Background task", 1), + session("s-open", "Open task", 2), + session("s-seen", "Seen task", 3), +]; +/** What /api/sessions serves; a test may swap it before mounting. */ +let sessions = SESSIONS; + +/** The tab side of the shared event-stream worker (lib/event-stream.ts), so a + * test can push `running` frames on the channel the sidebar opened. */ +const eventStreams = new Map(); +const eventWorker = { + onmessage: null, + onerror: null, + postMessage(message) { + if (message.op === "open") eventStreams.set(message.id, message.channel); + else if (message.op === "close") eventStreams.delete(message.id); + }, +}; +function deliverRunning(runningSessionIds) { + const id = [...eventStreams].findLast(([, channel]) => channel.kind === "running")?.[0]; + assert.ok(id, "the sidebar must hold a running channel"); + act(() => { + eventWorker.onmessage({ data: { id, type: "message", data: JSON.stringify({ type: "running", runningSessionIds, exitedSessions: [] }) } }); + }); +} + +/** Responses still being consumed; drained before each test ends so no state + * update lands after the DOM globals are torn down. */ +const inflight = new Set(); +before(() => { + globalThis.Worker = function Worker() { return eventWorker; }; + window.HTMLElement.prototype.scrollIntoView = () => {}; + globalThis.fetch = (url) => { + const path = String(url).split("?")[0]; + const body = path === "/api/sessions" + ? { sessions, runningSessionIds: [] } + : path === "/api/projects" ? { projects: [{ path: PROJECT }] } : {}; + const response = Promise.resolve(new Response(JSON.stringify(body), { status: 200, headers: { "Content-Type": "application/json" } })); + inflight.add(response); + void response.then(() => setTimeout(() => inflight.delete(response), 0)); + return response; + }; +}); +afterEach(async () => { + await act(async () => { + while (inflight.size > 0) await new Promise((resolve) => setTimeout(resolve, 5)); + }); + cleanup(); + localStorage.clear(); + sessions = SESSIONS; +}); + +function Harness({ initialSelected }) { + const [selected, setSelected] = React.useState(initialSelected); + return React.createElement(SessionSidebar, { + selectedSessionId: selected, + onSelectSession: (s) => setSelected(s.id), + addProjectOpen: false, + setAddProjectOpen: () => {}, + onOpenArchive: () => {}, + skipInitialProjectSelection: true, + }); +} + +async function mount({ selected = null, unread } = {}) { + localStorage.setItem("omp-web:expanded-projects", JSON.stringify([PROJECT])); + if (unread) localStorage.setItem(UNREAD_KEY, JSON.stringify(unread)); + render(React.createElement(Harness, { initialSelected: selected })); + await screen.findByText("Seen task"); +} + +const row = (title) => screen.getByText(title).closest(".session-item-row"); +/** Any check mark in the row, whatever its label (main labelled it "Recently completed"). */ +const hasCheck = (title) => row(title).querySelector("svg.lucide-check") !== null; + +test("a session that finishes in the background shows the check until it is opened", async () => { + await mount(); + deliverRunning(["s-bg"]); + assert.equal(hasCheck("Background task"), false, "running sessions show the spinner, not the check"); + deliverRunning([]); + await waitFor(() => assert.equal(hasCheck("Background task"), true)); + assert.ok(within(row("Background task")).getByLabelText(CHECK)); + assert.deepEqual(JSON.parse(localStorage.getItem(UNREAD_KEY)), ["s-bg"]); + + await userEvent.click(screen.getByText("Background task")); + await waitFor(() => assert.equal(hasCheck("Background task"), false)); + assert.equal(localStorage.getItem(UNREAD_KEY), null, "opening it clears the persisted marker"); +}); + +test("a session that finishes while it is open never shows the check", async () => { + await mount({ selected: "s-open" }); + deliverRunning(["s-open"]); + deliverRunning([]); + await waitFor(() => assert.equal(localStorage.getItem(UNREAD_KEY), null)); + assert.equal(hasCheck("Open task"), false); +}); + +test("recent but already seen sessions show no check and stay in the running-only filter", async () => { + await mount(); + for (const title of ["Background task", "Open task", "Seen task"]) assert.equal(hasCheck(title), false, title); + + await userEvent.click(screen.getByRole("button", { name: "Show running sessions only" })); + // Nothing runs, yet the recent-runs retention keeps the finished sessions listed. + assert.ok(screen.getByText("Seen task")); + assert.equal(hasCheck("Seen task"), false); +}); + +test("opening the session in another tab clears the check here", async () => { + await mount({ unread: ["s-bg"] }); + assert.equal(hasCheck("Background task"), true); + + localStorage.removeItem(UNREAD_KEY); + act(() => { window.dispatchEvent(new window.StorageEvent("storage", { key: UNREAD_KEY, oldValue: '["s-bg"]', newValue: null })); }); + assert.equal(hasCheck("Background task"), false); +}); + +test("a check adopted from another tab skips the session open in this tab", async () => { + await mount({ selected: "s-open" }); + localStorage.setItem(UNREAD_KEY, JSON.stringify(["s-bg", "s-open"])); + act(() => { window.dispatchEvent(new window.StorageEvent("storage", { key: UNREAD_KEY, newValue: '["s-bg","s-open"]' })); }); + assert.equal(hasCheck("Background task"), true); + assert.equal(hasCheck("Open task"), false); + assert.deepEqual(JSON.parse(localStorage.getItem(UNREAD_KEY)), ["s-bg"], "the open session is written back as seen"); +}); + +test("a nested child's check updates when only the child becomes unread", async () => { + sessions = [...SESSIONS, { ...session("s-child", "Child task", 0), parentSessionId: "s-bg" }]; + await mount(); + assert.equal(hasCheck("Child task"), false); + // Let every startup fetch land so only the unread set changes below. + await act(async () => { + while (inflight.size > 0) await new Promise((resolve) => setTimeout(resolve, 5)); + }); + + localStorage.setItem(UNREAD_KEY, JSON.stringify(["s-child"])); + act(() => { window.dispatchEvent(new window.StorageEvent("storage", { key: UNREAD_KEY, newValue: '["s-child"]' })); }); + await waitFor(() => assert.equal(hasCheck("Child task"), true)); + assert.equal(hasCheck("Background task"), false, "the parent itself stays unmarked"); +}); diff --git a/components/SessionSidebar.tsx b/components/SessionSidebar.tsx index f7e67aeff..6abf4a4d6 100644 --- a/components/SessionSidebar.tsx +++ b/components/SessionSidebar.tsx @@ -34,6 +34,7 @@ import { INITIAL_RESTORE_MAX_ATTEMPTS, INITIAL_RESTORE_RETRY_MS, MAX_PROJECT_SESSIONS, + UNREAD_SESSIONS_STORAGE_KEY, buildSessionTree, livePlace, loadExpandedProjects, @@ -499,6 +500,14 @@ export const SessionSidebar = memo(function SessionSidebar({ selectedSessionId, }; }, [loadSessions]); + // The green check ("finished in the background, not opened yet") comes from + // this running-to-idle comparison, per browser. Two known boundaries: + // - A run that starts and finishes while every tab of this browser is closed + // is never seen leaving the running set, so it gets no check. + // - When omp moves a running conversation to a new session id, the running + // channel lists only the new id, so (by reading the code) the old id can + // read as finished here and its preserved file get a check. Telling a move + // from a finish needs the channel to carry the move, which it does not. useEffect(() => { const previous = previousRunningSessionIdsRef.current; const allCompleted = [...previous].filter((id) => !runningSessionIds.has(id)); @@ -547,6 +556,19 @@ export const SessionSidebar = memo(function SessionSidebar({ selectedSessionId, return next; }); }, [selectedSessionId]); + // Keep this browser's other tabs in step: opening a finished session in one + // tab clears its check everywhere. The session open in this tab counts as + // seen, so it never adopts a check (dropping it is written back). + useEffect(() => { + const onStorage = (event: StorageEvent) => { + if (event.key !== null && event.key !== UNREAD_SESSIONS_STORAGE_KEY) return; + const stored = loadUnreadSessionIds(); + if (selectedSessionId) stored.delete(selectedSessionId); + setUnreadSessionIds((prev) => (prev.size === stored.size && [...stored].every((id) => prev.has(id)) ? prev : stored)); + }; + window.addEventListener("storage", onStorage); + return () => window.removeEventListener("storage", onStorage); + }, [selectedSessionId]); const restoredRef = useRef(false); @@ -1828,7 +1850,6 @@ export const SessionSidebar = memo(function SessionSidebar({ selectedSessionId, awaitingInputIds={awaitingInputIds} unreadSessionIds={unreadSessionIds} exitedSessions={exitedSessions} - recentlyCompletedIds={effectiveRecentCompletedSet} relativeTimeNow={relativeTimeNow} onActivate={activateProject} onToggleExpand={toggleProjectExpanded} diff --git a/lib/i18n/locales/en.json b/lib/i18n/locales/en.json index 13c9788c6..13111560d 100644 --- a/lib/i18n/locales/en.json +++ b/lib/i18n/locales/en.json @@ -1179,7 +1179,7 @@ "pluginsConfig.update": "Update", "pluginsConfig.updating": "Updating...", "pluginsConfig.version": "Version", - "projects.activity": "{running} running, {unread} unread, {exited} exited unexpectedly", + "projects.activity": "{running} running, {unread} finished and not opened yet, {exited} exited unexpectedly", "projects.add": "Add workspace", "projects.addTitle": "Add a workspace directory to the sidebar", "projects.collapseProject": "Collapse {name}", @@ -1256,8 +1256,6 @@ "sessionSidebar.loading": "Loading...", "sessionSidebar.mainBadge": "main", "sessionSidebar.new": "New Session", - "sessionSidebar.newActivity": "New activity", - "sessionSidebar.newSessionActivity": "New session activity", "sessionSidebar.newSessionIn": "New session in {cwd}", "sessionSidebar.newWorktree": "New worktree…", "sessionSidebar.newWorktreeTitle": "Create a worktree checkout for a branch", @@ -1295,7 +1293,7 @@ "sessionSidebar.searchPlaceholder": "Search sessions…", "sessionSidebar.filterRunning": "Show running sessions only", "sessionSidebar.filterRunningTitle": "Show active and recently completed sessions (up to {count})", - "sessionSidebar.recentlyCompleted": "Recently completed", + "sessionSidebar.completedUnread": "Finished — not opened yet", "sessionSidebar.noMatches": "No matching sessions", "sessionSidebar.searchingTranscripts": "Searching transcripts… results may move as better matches are found", "sessionSidebar.searchStopped": "Search stopped. Transcript results may be incomplete.", diff --git a/lib/i18n/locales/ja.json b/lib/i18n/locales/ja.json index 44a54aa19..b268df1ee 100644 --- a/lib/i18n/locales/ja.json +++ b/lib/i18n/locales/ja.json @@ -1139,7 +1139,7 @@ "pluginsConfig.update": "更新", "pluginsConfig.updating": "更新中...", "pluginsConfig.version": "バージョン", - "projects.activity": "{running} 実行中、{unread} 未読、{exited} 異常終了", + "projects.activity": "{running} 実行中、{unread} 完了・未表示、{exited} 異常終了", "projects.add": "ワークスペースを追加", "projects.addTitle": "サイドバーにワークスペースディレクトリを追加", "projects.collapseProject": "{name} を折りたたむ", @@ -1216,8 +1216,6 @@ "sessionSidebar.loading": "読み込み中...", "sessionSidebar.mainBadge": "main", "sessionSidebar.new": "新しいセッション", - "sessionSidebar.newActivity": "新しいアクティビティ", - "sessionSidebar.newSessionActivity": "新しいセッションアクティビティ", "sessionSidebar.newSessionIn": "{cwd} で新しいセッション", "sessionSidebar.newWorktree": "新しいワークツリー…", "sessionSidebar.newWorktreeTitle": "ブランチのワークツリーチェックアウトを作成します", @@ -1252,7 +1250,7 @@ "sessionSidebar.searchPlaceholder": "セッションを検索…", "sessionSidebar.filterRunning": "実行中のセッションのみ表示", "sessionSidebar.filterRunningTitle": "実行中および最近完了したセッションを表示(最大{count}件)", - "sessionSidebar.recentlyCompleted": "最近完了", + "sessionSidebar.completedUnread": "完了 — まだ開いていません", "sessionSidebar.noMatches": "一致するセッションがありません", "sessionSidebar.searchingTranscripts": "会話内容を検索中… より良い一致が見つかると順位が変わることがあります", "sessionSidebar.searchStopped": "検索を停止しました。会話内容の結果は不完全な可能性があります。", diff --git a/lib/i18n/locales/zh-CN.json b/lib/i18n/locales/zh-CN.json index a6e71796e..3f8b0624e 100644 --- a/lib/i18n/locales/zh-CN.json +++ b/lib/i18n/locales/zh-CN.json @@ -1139,7 +1139,7 @@ "pluginsConfig.update": "更新", "pluginsConfig.updating": "更新中...", "pluginsConfig.version": "版本", - "projects.activity": "{running} 个运行中,{unread} 个未读,{exited} 个异常退出", + "projects.activity": "{running} 个运行中,{unread} 个已完成未查看,{exited} 个异常退出", "projects.add": "添加工作区", "projects.addTitle": "将工作区目录添加到侧边栏", "projects.collapseProject": "折叠 {name}", @@ -1216,8 +1216,6 @@ "sessionSidebar.loading": "加载中...", "sessionSidebar.mainBadge": "main", "sessionSidebar.new": "新建会话", - "sessionSidebar.newActivity": "新活动", - "sessionSidebar.newSessionActivity": "新的会话活动", "sessionSidebar.newSessionIn": "在 {cwd} 新建会话", "sessionSidebar.newWorktree": "新建工作树…", "sessionSidebar.newWorktreeTitle": "为某个分支创建工作树检出", @@ -1252,7 +1250,7 @@ "sessionSidebar.searchPlaceholder": "搜索会话…", "sessionSidebar.filterRunning": "仅显示运行中的会话", "sessionSidebar.filterRunningTitle": "显示正在运行和最近完成的会话(最多{count}个)", - "sessionSidebar.recentlyCompleted": "最近完成", + "sessionSidebar.completedUnread": "已完成,尚未查看", "sessionSidebar.noMatches": "没有匹配的会话", "sessionSidebar.searchingTranscripts": "正在搜索会话内容… 找到更好的匹配时结果顺序可能变化", "sessionSidebar.searchStopped": "搜索已停止。会话内容结果可能不完整。", diff --git a/lib/i18n/locales/zh-TW.json b/lib/i18n/locales/zh-TW.json index d40f40c72..878d9424f 100644 --- a/lib/i18n/locales/zh-TW.json +++ b/lib/i18n/locales/zh-TW.json @@ -1178,7 +1178,7 @@ "pluginsConfig.update": "更新", "pluginsConfig.updating": "更新中...", "pluginsConfig.version": "版本", - "projects.activity": "{running} 個執行中,{unread} 個未讀,{exited} 個意外結束", + "projects.activity": "{running} 個執行中,{unread} 個已完成尚未查看,{exited} 個意外結束", "projects.add": "新增工作區", "projects.addTitle": "將工作區目錄新增至側邊欄", "projects.collapseProject": "摺疊 {name}", @@ -1256,8 +1256,6 @@ "sessionSidebar.loading": "載入中...", "sessionSidebar.mainBadge": "主要", "sessionSidebar.new": "新對話", - "sessionSidebar.newActivity": "新動態", - "sessionSidebar.newSessionActivity": "新對話動態", "sessionSidebar.newSessionIn": "在 {cwd} 中建立新對話", "sessionSidebar.newWorktree": "新增工作樹…", "sessionSidebar.newWorktreeTitle": "為分支建立工作樹簽出(worktree checkout)", @@ -1295,7 +1293,7 @@ "sessionSidebar.searchPlaceholder": "搜尋對話…", "sessionSidebar.filterRunning": "僅顯示執行中的對話", "sessionSidebar.filterRunningTitle": "顯示進行中與最近完成的對話(最多 {count} 個)", - "sessionSidebar.recentlyCompleted": "最近完成", + "sessionSidebar.completedUnread": "已完成,尚未查看", "sessionSidebar.noMatches": "沒有相符的對話", "sessionSidebar.searchingTranscripts": "正在搜尋逐字稿… 隨著找到更佳相符結果,順序可能會變動", "sessionSidebar.searchStopped": "搜尋已停止。逐字稿搜尋結果可能不完整。", From 8697745e6fe79b315cbf512591e532ac4cbf01d4 Mon Sep 17 00:00:00 2001 From: OrwellVII <56531592+OrwellVII@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:21:44 +0800 Subject: [PATCH 2/2] fix(sidebar): write back the open session's check even when this tab's set is unchanged Another tab can mark the session open here as finished while this tab's unread set is empty. Dropping it left the set unchanged, so the persistence effect never ran and the other tab kept the check. The storage listener now saves the set whenever it drops the open session. --- components/SessionSidebar.completed.test.mjs | 9 +++++++++ components/SessionSidebar.tsx | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/components/SessionSidebar.completed.test.mjs b/components/SessionSidebar.completed.test.mjs index a93e4fef0..4f27ca4c6 100644 --- a/components/SessionSidebar.completed.test.mjs +++ b/components/SessionSidebar.completed.test.mjs @@ -144,6 +144,15 @@ test("a check adopted from another tab skips the session open in this tab", asyn assert.deepEqual(JSON.parse(localStorage.getItem(UNREAD_KEY)), ["s-bg"], "the open session is written back as seen"); }); +test("a check another tab writes for the session open here alone is written back as seen", async () => { + await mount({ selected: "s-open" }); + // This tab's set is empty, so dropping the open session changes no state here. + localStorage.setItem(UNREAD_KEY, JSON.stringify(["s-open"])); + act(() => { window.dispatchEvent(new window.StorageEvent("storage", { key: UNREAD_KEY, newValue: '["s-open"]' })); }); + assert.equal(hasCheck("Open task"), false); + assert.equal(localStorage.getItem(UNREAD_KEY), null, "the other tab is told the open session is seen"); +}); + test("a nested child's check updates when only the child becomes unread", async () => { sessions = [...SESSIONS, { ...session("s-child", "Child task", 0), parentSessionId: "s-bg" }]; await mount(); diff --git a/components/SessionSidebar.tsx b/components/SessionSidebar.tsx index 6abf4a4d6..71a5b0671 100644 --- a/components/SessionSidebar.tsx +++ b/components/SessionSidebar.tsx @@ -563,7 +563,9 @@ export const SessionSidebar = memo(function SessionSidebar({ selectedSessionId, const onStorage = (event: StorageEvent) => { if (event.key !== null && event.key !== UNREAD_SESSIONS_STORAGE_KEY) return; const stored = loadUnreadSessionIds(); - if (selectedSessionId) stored.delete(selectedSessionId); + // Write the drop back here: when this tab's set already equals the rest, + // no state change would reach the persistence effect. + if (selectedSessionId && stored.delete(selectedSessionId)) saveUnreadSessionIds(stored); setUnreadSessionIds((prev) => (prev.size === stored.size && [...stored].every((id) => prev.has(id)) ? prev : stored)); }; window.addEventListener("storage", onStorage);