From f265e636e98ec06d810d27bbd4c43122a93116a4 Mon Sep 17 00:00:00 2001 From: arookieofc Date: Fri, 30 Oct 2026 20:25:16 +0800 Subject: [PATCH] feat(agents): show the Changes pane only when it's useful, toggled from the task header (#421) The Changes pane took a fixed column next to every agent conversation, including tasks that changed nothing. It is now shown while the task has changes (so it appears when the agent first edits a file) and toggled from a Changes button with the file count in the task header; once toggled, the choice is kept per task. Co-authored-by: a-rookie-of-C-language <186315048+a-rookie-of-C-language@users.noreply.github.com> --- src/features/agents/Session.module.css | 38 +++++++++++++++++- src/features/agents/SessionEditor.tsx | 54 ++++++++++++++++++++++++++ src/platform/locales/text/zh.json | 2 + 3 files changed, 93 insertions(+), 1 deletion(-) diff --git a/src/features/agents/Session.module.css b/src/features/agents/Session.module.css index 045cb4b0..4cb8e2ae 100644 --- a/src/features/agents/Session.module.css +++ b/src/features/agents/Session.module.css @@ -3,7 +3,7 @@ min-height: 0; min-width: 0; display: grid; - grid-template-columns: minmax(0, 1fr) 280px; + grid-template-columns: minmax(0, 1fr) auto; background: var(--bg-editor); color: var(--fg); } @@ -558,6 +558,42 @@ flex-direction: column; min-height: 0; min-width: 0; + width: 280px; +} +.changesCollapsed { + width: 28px; + align-items: center; + padding-top: 4px; +} +.changesCollapsed > * { + flex: none; +} +.changesRail { + flex: 1; + min-height: 0; + align-self: stretch; + display: flex; + flex-direction: column; + align-items: center; + gap: 6px; + padding: 4px 0 8px; + border: none; + background: transparent; + color: var(--fg-subtle); + font: inherit; + cursor: pointer; +} +.changesRail:hover { + color: var(--fg-strong); +} +.changesRailLabel { + writing-mode: vertical-rl; + font-size: var(--fs-small); + letter-spacing: 0.02em; +} +.changesRailCount { + font-size: var(--fs-small); + color: var(--fg-muted); } .changesHeader { display: flex; diff --git a/src/features/agents/SessionEditor.tsx b/src/features/agents/SessionEditor.tsx index b80a9ae5..eace379a 100644 --- a/src/features/agents/SessionEditor.tsx +++ b/src/features/agents/SessionEditor.tsx @@ -1216,10 +1216,58 @@ const KIND_COLOR: Partial> = { conflicted: "var(--vcs-conflict)", }; +const CHANGES_COLLAPSED_KEY = "openidea.agents.changesCollapsed.v1"; + +function loadCollapsed(): boolean { + try { + const raw = globalThis.localStorage?.getItem(CHANGES_COLLAPSED_KEY); + // Collapsed on first run: the chat is the focus, the diff opens on demand. + return raw === null ? true : (JSON.parse(raw) as boolean); + } catch { + return true; + } +} + +function saveCollapsed(value: boolean) { + try { + globalThis.localStorage?.setItem(CHANGES_COLLAPSED_KEY, JSON.stringify(value)); + } catch { + /* storage unavailable */ + } +} + function ChangesPane({ task, changes, head }: { task: AgentTask; changes: AgentChange[] | null; head: string | null }) { const [selected, setSelected] = useState>(() => new Set()); + const [collapsed, setCollapsed] = useState(loadCollapsed); const added = changes?.reduce((n, c) => n + c.added, 0) ?? 0; const removed = changes?.reduce((n, c) => n + c.removed, 0) ?? 0; + const toggleCollapsed = (next: boolean) => { + setCollapsed(next); + saveCollapsed(next); + }; + if (collapsed) { + return ( + + ); + } return (