merge #1101: fix(changes) 视角切换改用公开 SegmentedControl,删除对宿主私有 CSS 哈希类名的依赖(#1098)

This commit is contained in:
Menghuan1918 committed 2026-11-04 20:33:57 +08:00
commit 5178cabcec
5 files changed
+22 -44

No files matched your search

+1 -1
View File
@@ -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:<uuid>`,按 `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 的预览面板「展开为独立页签」触发,同一渲染栈) |
+12 -31
View File
@@ -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 (
<div className={css.root}>
<div className={css.head}>
{/* ponytail: conversation Tabs are private in DSH 0.2.0-rc.2; reuse
their CSS classes until the host exports the component. */}
<div className="wSkVaW_tabs" role="tablist" aria-label={t('changes')}>
{(['git', 'session'] as const).map(value => (
<button
key={value}
id={`${lensId}-${value}`}
type="button"
role="tab"
aria-selected={lens === value}
aria-controls={`${lensId}-${value}-panel`}
tabIndex={lens === value ? 0 : -1}
className={`wSkVaW_tab${lens === value ? ' wSkVaW_tabActive' : ''}`}
onClick={() => { chooseLens(value) }}
onKeyDown={event => {
let next: Lens
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') next = value === 'git' ? 'session' : 'git'
else if (event.key === 'Home') next = 'git'
else if (event.key === 'End') next = 'session'
else return
event.preventDefault()
chooseLens(next)
event.currentTarget.parentElement?.querySelector<HTMLButtonElement>(`[id="${lensId}-${next}"]`)?.focus()
}}
>
{t(value === 'git' ? 'changesGitLens' : 'changesSessionLens')}
</button>
))}
</div>
<SegmentedControl
id={lensId}
value={lens === 'session' ? 'session' : 'git'}
options={[
{ value: 'git', label: t('changesGitLens') },
{ value: 'session', label: t('changesSessionLens') },
] as const}
onChange={chooseLens}
label={t('changes')}
/>
{/* The Git lens refreshes from its own Changes header (#944); only the
session lens needs the tab-level action. */}
{lens === 'session' && <IconButton
+2 -3
View File
@@ -124,9 +124,8 @@ export interface PaneTab {
* A compact tab strip — a real tablist with roving focus: the active tab is
* the only tab stop, and Left/Right/Home/End move focus AND selection (the
* standard automatic-activation model). Born as the bottom pane's strip
* (details / diff); the changes tab's header reuses it for the lens switcher
* so the page's two switchers read as one component. Rendered only when the
* caller hosts more than one view, so a diff-only preview never grows a strip.
* (details / diff). Rendered only when the caller hosts more than one view,
* so a diff-only preview never grows a strip.
*/
export function PaneTabStrip(props: { tabs: readonly PaneTab[]; active: string; onSelect(id: string): void; className?: string; label?: string }) {
const buttons = useRef<(HTMLButtonElement | null)[]>([])
-2
View File
@@ -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) ───────────────────────────────────── */
+7 -7
View File
@@ -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<HTMLButtonElement>('[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<HTMLElement>('[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<HTMLElement>('[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<HTMLButtonElement>(`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()