Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/external-plugin-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,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 | 是 | 是(本轮文件操作数) | 「文件变动」统一 tab(id 保留 `git` 以兼容持久化布局):**Git 视角**(原 Git 面板:staged/unstaged / 提交 / 历史 / worktree·子仓库选择)+ **本轮文件视角**(原 file-trace:模型读/写/编辑实时折叠,按文件分组、类型筛选);会话事件经插件自有宿主路由 `changes.ops` 供给(live 日志优先、冷会话回放持久化记录,`afterSeq` 增量),badge 读 tab 轮询写入的同步缓存。两视角共用底部可拖拽预览面板(`tab.meta.lens/previewH` 持久化),diff 渲染统一走 `src/client/diff/`(`DiffRows`/`DiffFiles`:mod 配对 + 行内高亮 + 语法着色 + 上下文折叠);Git 目标可展开为独立 diff tab(落进工作台的 diff 分栏) |
| `git` | 20 | 是 | 是(本轮文件操作数) | 「文件变动」统一 tab(id 保留 `git` 以兼容持久化布局):**Git 视角**(原 Git 面板:staged/unstaged / 提交 / 历史 / worktree·子仓库选择)+ **本轮文件视角**(原 file-trace:模型读/写/编辑实时折叠,按文件分组、类型筛选);会话事件经插件自有宿主路由 `changes.ops` 供给(live 日志优先、冷会话回放持久化记录,`afterSeq` 增量),badge 读 tab 轮询写入的同步缓存。页头复用宿主会话页的下划线 Tabs 样式(`wSkVaW_tabs/tab/tabActive`,宿主尚未公开组件;支持左右方向键与 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 的预览面板「展开为独立页签」触发,同一渲染栈) |
Expand Down
90 changes: 56 additions & 34 deletions src/client/changes/ChangesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {@link SegmentedControl} and the current
* A 36px header carries the host conversation Tabs 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 active lens and
Expand All @@ -17,8 +17,8 @@
* git lens has no use for the session event log (and the shared git-status
* store owns its own poller).
*/
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { IconRefreshOutlineRegular, SegmentedControl } from '@deepseek-ai/dsh-client-ui-primitives'
import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react'
import { IconRefreshOutlineRegular } 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'
Expand Down Expand Up @@ -67,6 +67,7 @@ type PreviewSelection =

export function ChangesTab({ ctx, store, scope, tab, visible, onOpenFile, onOpenDiff }: TabComponentProps) {
const meta = (tab.meta ?? {}) as ChangesMeta
const lensId = useId()
const [lens, setLens] = useState<Lens>(meta.lens === 'session' ? 'session' : 'git')
const [selection, setSelection] = useState<PreviewSelection | null>(null)
const [paneHeight, setPaneHeight] = useState<number>(() => clampPaneHeight(
Expand Down Expand Up @@ -205,44 +206,65 @@ export function ChangesTab({ ctx, store, scope, tab, visible, onOpenFile, onOpen
return (
<div className={css.root}>
<div className={css.head}>
<SegmentedControl
id={`changes-lens-${tab.id}`}
value={lens}
options={[
{ value: 'git', label: t('changesGitLens') },
{ value: 'session', label: t('changesSessionLens') },
]}
onChange={chooseLens}
label={t('changes')}
/>
{/* 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}-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>
<IconButton
className={css.headAction}
icon={<IconRefreshOutlineRegular />}
label={t('refresh')}
onClick={refreshCurrent}
/>
</div>
{lens === 'git'
? (
<GitLens
ctx={ctx}
scope={scope}
store={store}
visible={visible}
refreshTick={gitRefresh}
onOpenFile={onOpenFile ?? (() => { /* no-op */ })}
onPreview={previewGit}
selectedRef={previewTarget !== null && previewTarget.kind === 'git' ? previewTarget.ref : null}
/>
)
: (
<SessionLens
ops={ops}
loadError={opsError && ops.length === 0}
onPreview={previewOp}
selectedCallId={selection !== null && selection.kind === 'op' ? selection.callId : null}
/>
)}
<div className={css.lensBody} id={`${lensId}-panel`} role="tabpanel" aria-labelledby={`${lensId}-${lens}`}>
{lens === 'git'
? (
<GitLens
ctx={ctx}
scope={scope}
store={store}
visible={visible}
refreshTick={gitRefresh}
onOpenFile={onOpenFile ?? (() => { /* no-op */ })}
onPreview={previewGit}
selectedRef={previewTarget !== null && previewTarget.kind === 'git' ? previewTarget.ref : null}
/>
)
: (
<SessionLens
ops={ops}
loadError={opsError && ops.length === 0}
onPreview={previewOp}
selectedCallId={selection !== null && selection.kind === 'op' ? selection.callId : null}
/>
)}
</div>
{previewTarget !== null && (
<DiffPane
key={previewKey(previewTarget)}
Expand Down
7 changes: 5 additions & 2 deletions src/client/changes/changes.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@

/* ── Lens header ───────────────────────────────────────────────────────── */

.head { flex: none; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--dsw-alias-border-l1); }
.headAction { margin-left: auto; }
.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; }
.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) ───────────────────────────────────── */

Expand Down
66 changes: 63 additions & 3 deletions tests/changes-tab.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ function fakeContext(): Context {
} as unknown as Context
}

function mount(root: Root, tab: SidebarTab = { id: 'git', type: 'git', title: 'Changes' }): void {
function mount(root: Root, tab: SidebarTab = { id: 'git', type: 'git', title: 'Changes' }, ctx: Context = fakeContext()): void {
act(() => {
root.render(createElement(ChangesTab, {
ctx: fakeContext(),
ctx,
store: createSidebarStore(),
scope: { sessionId: 'session', cwd: MAIN },
tab,
Expand All @@ -66,7 +66,7 @@ function mockGit(entries: GitStatusEntry[]): void {
vi.spyOn(api, 'gitLog').mockResolvedValue([])
}

/** One lens tab of the header's segmented control. */
/** One lens tab of the header's official conversation Tabs. */
function lensTab(container: HTMLElement, label: string): HTMLButtonElement | undefined {
return [...container.querySelectorAll<HTMLButtonElement>('[role="tab"]')]
.find(tab => tab.textContent === label)
Expand All @@ -87,6 +87,66 @@ afterEach(() => {
})

describe('ChangesTab', () => {
it('uses the official underline Tabs with keyboard navigation, persisted lens and refresh', async () => {
mockGit([])
const ops = vi.spyOn(api, 'changesOps').mockResolvedValue({ events: [], lastSeq: 0 })
const updateTab = vi.fn()
const ctx = { get: () => ({ updateTab }) } as unknown as Context
const container = document.createElement('div')
document.body.append(container)
const root: Root = createRoot(container)
try {
mount(root, { id: 'git', type: 'git', title: 'Changes', meta: { lens: 'session', previewH: 240 } }, ctx)
await flushEffects()

const tabs = container.querySelector<HTMLElement>('[role="tablist"]')!
const git = lensTab(container, t('changesGitLens'))!
const session = lensTab(container, t('changesSessionLens'))!
const panel = container.querySelector<HTMLElement>('[role="tabpanel"]')!
expect(tabs.classList.contains('wSkVaW_tabs')).toBe(true)
expect(tabs.getAttribute('aria-label')).toBe(t('changes'))
expect(git.classList.contains('wSkVaW_tab')).toBe(true)
const selected = (button: HTMLButtonElement): void => {
expect(button.classList.contains('wSkVaW_tabActive')).toBe(true)
expect(button.getAttribute('aria-selected')).toBe('true')
expect(button.tabIndex).toBe(0)
expect(button.getAttribute('aria-controls')).toBe(panel.id)
expect(panel.getAttribute('aria-labelledby')).toBe(button.id)
}
selected(session)
expect(git.tabIndex).toBe(-1)
session.focus()
const key = async (button: HTMLButtonElement, name: string): Promise<void> => {
const event = new KeyboardEvent('keydown', { key: name, bubbles: true, cancelable: true })
await act(async () => { button.dispatchEvent(event) })
expect(event.defaultPrevented).toBe(true)
}
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
selected(session)
await key(session, 'Home')
selected(git)
await key(git, 'End')
selected(session)
expect(updateTab).toHaveBeenLastCalledWith('git', { meta: { lens: 'session', previewH: 240 } }, 'session')

const calls = ops.mock.calls.length
await act(async () => { container.querySelector<HTMLButtonElement>(`button[aria-label="${t('refresh')}"]`)!.click() })
await flushEffects()
expect(ops).toHaveBeenCalledTimes(calls + 1)
const sheet = readFileSync('src/client/changes/changes.module.css', 'utf8')
expect(sheet).toMatch(/\.head :global\(\.wSkVaW_tabs\) \{ gap: 24px; \}/)
} finally {
act(() => { root.unmount() })
container.remove()
}
})

it('renders the git lens by default and previews a file row in the pane', async () => {
mockGit([{ path: 'src/a.ts', xy: ' M' }])
vi.spyOn(api, 'gitDiff').mockResolvedValue({
Expand Down
Loading