From 3ce803c6911dcb7c66e64d31865f52cee27debd6 Mon Sep 17 00:00:00 2001 From: Kunping Wang <146500293+wang-kaopu@users.noreply.github.com> Date: Mon, 2 Nov 2026 20:57:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(changes):=20=E4=BF=AE=E5=A4=8D=20Changes=20?= =?UTF-8?q?=E8=A7=86=E8=A7=92=E5=88=87=E6=8D=A2=E6=8C=89=E9=92=AE=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/external-plugin-guide.md | 2 +- src/client/changes/ChangesTab.tsx | 43 ++++++++------------------- src/client/changes/DiffPane.tsx | 5 ++-- src/client/changes/changes.module.css | 2 -- tests/changes-tab.spec.tsx | 14 ++++----- 5 files changed, 22 insertions(+), 44 deletions(-) diff --git a/docs/external-plugin-guide.md b/docs/external-plugin-guide.md index 2cad97d7..e6da186e 100644 --- a/docs/external-plugin-guide.md +++ b/docs/external-plugin-guide.md @@ -466,7 +466,7 @@ ctx.effect(() => { | id | order | single | hidden | 用途 | |---|---|---|---|---| | `editor` | 10 | 否(按 path 去重) | 否 | 唯一「文件窗口」(编辑/预览 + 资源管理)。chrome 恒合并形态:路径输入框 + 编辑器控件 + 可开关内嵌文件树(全局搜索 `fs.search`;状态存 `tab.meta.treeOpen/treeWidth`)。`editorExplorer`:关(默认)= 按 path 新开,无路径窗口 = 纯资源管理器;开 = 树点击/Enter 经 `updateTab` 原地切换(id/meta 不变),无路径窗口 = 带 chrome 空窗口。树右键「在新 Tab 中打开」「在侧边打开」(pane 右侧 split)。新会话 seed 空文件窗口(`title:'Files'`);旧 `explorer` tab 经 `sanitizeState` 迁移。树 listing 与文件名搜索应用 `explorerExclude` 排除模式(editor 卡片齿轮弹窗可编辑;host 侧过滤,匹配条目彻底移除且永不阻塞折叠);单目录链折叠为 `a/b/c` 面包屑行(POSIX 隐藏与排除条目不计入唯一子项判定) | -| `git` | 20 | 是 | 是(本轮文件操作数) | 「Git」统一 tab(id 保留 `git` 以兼容持久化布局):**Git 视角**(Source Control:独立折叠的 Changes / Graph;Changes 内为多行 Message + 仅填草稿的 Generate、Merge Changes → Staged Changes → Changes(资源组也独立折叠,计数常驻标题最右,文件行整行 hover);Git 刷新仅留在 Changes 标题,外层本轮文件刷新保留;真实 parent hashes 泳道图;常驻底栏为可点击分支 + `*`/`+`/`!` 标记、upstream 的 behind↓ / ahead↑ 及安全 Pull-then-Push 同步;Push/Pull 与 worktree·子仓库选择移入 More Actions;提交只消费已暂存项,冲突/空消息/无暂存时禁止,草稿按会话·仓库·worktree 隔离)+ **本轮文件视角**(原 file-trace:模型读/写/编辑实时折叠,按操作时间倒序平铺、不按文件分组,每行「操作 → 文件路径 → 大小/时间」,支持类型筛选);会话事件经插件自有宿主路由 `changes.ops` 供给(live 日志优先、冷会话回放持久化记录,`afterSeq` 增量),primed 后用 `wait` 挂在宿主侧等下一个工具事件而不是重放整窗),badge 读 tab 轮询写入的同步缓存。页头复用宿主会话页的下划线 Tabs 样式(`wSkVaW_tabs/tab/tabActive`,宿主尚未公开组件;支持左右方向键与 Home/End 切换)。两视角共用底部可拖拽预览面板(`tab.meta.lens/previewH` 持久化),diff 渲染统一走 `src/client/diff/`(`DiffRows`/`DiffFiles`:mod 配对 + 行内高亮 + 语法着色 + 上下文折叠);Git 目标可展开为独立 diff tab(落进工作台的 diff 分栏) | +| `git` | 20 | 是 | 是(本轮文件操作数) | 「Git」统一 tab(id 保留 `git` 以兼容持久化布局):**Git 视角**(Source Control:独立折叠的 Changes / Graph;Changes 内为多行 Message + 仅填草稿的 Generate、Merge Changes → Staged Changes → Changes(资源组也独立折叠,计数常驻标题最右,文件行整行 hover);Git 刷新仅留在 Changes 标题,外层本轮文件刷新保留;真实 parent hashes 泳道图;常驻底栏为可点击分支 + `*`/`+`/`!` 标记、upstream 的 behind↓ / ahead↑ 及安全 Pull-then-Push 同步;Push/Pull 与 worktree·子仓库选择移入 More Actions;提交只消费已暂存项,冲突/空消息/无暂存时禁止,草稿按会话·仓库·worktree 隔离)+ **本轮文件视角**(原 file-trace:模型读/写/编辑实时折叠,按操作时间倒序平铺、不按文件分组,每行「操作 → 文件路径 → 大小/时间」,支持类型筛选);会话事件经插件自有宿主路由 `changes.ops` 供给(live 日志优先、冷会话回放持久化记录,`afterSeq` 增量),primed 后用 `wait` 挂在宿主侧等下一个工具事件而不是重放整窗),badge 读 tab 轮询写入的同步缓存。页头使用宿主公开的 `@deepseek-ai/dsh-client-ui-primitives` 中的 `SegmentedControl`(36px 高度、主题 Token 样式;自动处理选中状态、ARIA 关系及左右方向键、Home/End 键盘导航)。两视角共用底部可拖拽预览面板(`tab.meta.lens/previewH` 持久化),diff 渲染统一走 `src/client/diff/`(`DiffRows`/`DiffFiles`:mod 配对 + 行内高亮 + 语法着色 + 上下文折叠);Git 目标可展开为独立 diff tab(落进工作台的 diff 分栏) | | `subagent` | 30 | 是 | 否 | 任务管理(工作流图/树、团队任务板、后台任务抽屉) | | `sidechat` | 35 | 否(`sidechat:`,按 `meta.threadId` 去重) | 否 | 侧边对话(每对话一 Tab):打开即建空线程(首条消息赢得标签并同步标题);线程 = 插件自建子会话(种子继承父会话上下文,进行中回合以 `interrupted` 闭合;种子带合法 `subagent/descriptor`,SubagentView 按 `Side: ` 前缀过滤),`origin:'subagent'` 隐藏于主列表;走 `/sidebar/api/sidechat.*` 路由;头部菜单切换/重开(`parkSidechatReopen` + 确定性 id),关 Tab 释放 live agent;重开经 `collectOwnEvents` 回源到种子边界;「保存为新会话」= `session.fork`(`this` 敏感)。[设计文档](plans/2026-08-20-sidechat-tab-design.md) | | `diff` | -1 | 否(按 id 去重) | 是 | 差异查看(changes tab 的预览面板「展开为独立页签」触发,同一渲染栈) | diff --git a/src/client/changes/ChangesTab.tsx b/src/client/changes/ChangesTab.tsx index c6b18475..dc2c7ba9 100644 --- a/src/client/changes/ChangesTab.tsx +++ b/src/client/changes/ChangesTab.tsx @@ -2,7 +2,7 @@ * The unified changes tab: one tab, two lenses on "what changed?" — Git * (repository truth: staged/unstaged files, commit box, history) and the * session round (agent truth: every file the model read, wrote, or edited). - * A 36px header carries the host conversation Tabs and the current + * A 36px header carries the public SegmentedControl and the current * lens's refresh action; both lenses preview their selections in a shared * resizable bottom pane ({@link DiffPane}), and git targets expand into the * dedicated diff tab docked in the workbench's diff pane. The bottom pane is @@ -22,7 +22,7 @@ * store owns its own poller). */ import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react' -import { IconRefreshOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives' +import { IconRefreshOutlineRegular, SegmentedControl } from '@deepseek-ai/dsh-client-ui-primitives' import type { SidebarSessionEvent } from '../../context-types.ts' import type { TabComponentProps } from '../service.ts' import { t } from '../locales.ts' @@ -248,35 +248,16 @@ export function ChangesTab({ ctx, store, scope, tab, visible, onOpenFile, onOpen return (
- {/* ponytail: conversation Tabs are private in DSH 0.2.0-rc.2; reuse - their CSS classes until the host exports the component. */} -
- {(['git', 'session'] as const).map(value => ( - - ))} -
+ {/* The Git lens refreshes from its own Changes header (#944); only the session lens needs the tab-level action. */} {lens === 'session' && ([]) diff --git a/src/client/changes/changes.module.css b/src/client/changes/changes.module.css index b45d2b37..e3c4c717 100644 --- a/src/client/changes/changes.module.css +++ b/src/client/changes/changes.module.css @@ -15,12 +15,10 @@ .head { flex: none; display: flex; align-items: stretch; gap: 8px; height: 36px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--dsw-alias-border-l1); } .headAction { margin-left: auto; align-self: center; } -.head :global(.wSkVaW_tabs) { gap: 24px; } .lensBody { flex: 1; min-height: 0; display: flex; flex-direction: column; } /* Retained but not on screen: `display: flex` above would otherwise win over the `hidden` attribute and two lenses would share the column. */ .lensBody[hidden] { display: none; } -.head :global(.wSkVaW_tab):focus-visible { outline: 2px solid var(--dsw-alias-interactive-bg-hover-accent); outline-offset: -2px; } /* ── Git lens (the former git panel) ───────────────────────────────────── */ diff --git a/tests/changes-tab.spec.tsx b/tests/changes-tab.spec.tsx index d5cfdc88..6add5a16 100644 --- a/tests/changes-tab.spec.tsx +++ b/tests/changes-tab.spec.tsx @@ -77,7 +77,7 @@ function mockGit(entries: GitStatusEntry[]): void { vi.spyOn(api, 'gitLog').mockResolvedValue([]) } -/** One lens tab of the header's official conversation Tabs. */ +/** One lens tab rendered by the header's public SegmentedControl. */ function lensTab(container: HTMLElement, label: string): HTMLButtonElement | undefined { return [...container.querySelectorAll('[role="tab"]')] .find(tab => tab.textContent === label) @@ -192,7 +192,7 @@ afterEach(() => { }) describe('ChangesTab', () => { - it('uses the official underline Tabs with keyboard navigation, persisted lens and refresh', async () => { + it('uses the public SegmentedControl with keyboard navigation, persisted lens and refresh', async () => { mockGit([]) const ops = vi.spyOn(api, 'changesOps').mockResolvedValue({ events: [], lastSeq: 0 }) const updateTab = vi.fn() @@ -207,13 +207,12 @@ describe('ChangesTab', () => { const tabs = container.querySelector('[role="tablist"]')! const git = lensTab(container, t('changesGitLens'))! const session = lensTab(container, t('changesSessionLens'))! - expect(tabs.classList.contains('wSkVaW_tabs')).toBe(true) expect(tabs.getAttribute('aria-label')).toBe(t('changes')) - expect(git.classList.contains('wSkVaW_tab')).toBe(true) + expect(tabs.className).not.toContain('wSkVaW') const panels = (): HTMLElement[] => [...container.querySelectorAll('[role="tabpanel"]')] const selected = (button: HTMLButtonElement): void => { - expect(button.classList.contains('wSkVaW_tabActive')).toBe(true) expect(button.getAttribute('aria-selected')).toBe('true') + expect(button.getAttribute('aria-controls')).toBe(`${button.id}-panel`) expect(button.tabIndex).toBe(0) // Both lenses own a panel (they stay mounted and swap `hidden`), so the // tab points at ITS panel, that panel points back, and exactly one of @@ -234,7 +233,6 @@ describe('ChangesTab', () => { await key(session, 'ArrowRight') // wraps to the first tab selected(git) expect(document.activeElement).toBe(git) - expect(session.classList.contains('wSkVaW_tabActive')).toBe(false) expect(session.getAttribute('aria-selected')).toBe('false') expect(updateTab).toHaveBeenLastCalledWith('git', { meta: { lens: 'git', previewH: 240 } }, 'session') await key(git, 'ArrowLeft') // wraps to the last tab @@ -249,8 +247,10 @@ describe('ChangesTab', () => { await act(async () => { container.querySelector(`button[aria-label="${t('refresh')}"]`)!.click() }) await flushEffects() expect(ops).toHaveBeenCalledTimes(calls + 1) + const source = readFileSync('src/client/changes/ChangesTab.tsx', 'utf8') const sheet = readFileSync('src/client/changes/changes.module.css', 'utf8') - expect(sheet).toMatch(/\.head :global\(\.wSkVaW_tabs\) \{ gap: 24px; \}/) + expect(source).not.toContain('wSkVaW') + expect(sheet).not.toContain('wSkVaW') } finally { act(() => { root.unmount() }) container.remove()