Merge pull request #1236 from omdsh-dev/fix/changes-lens-underline-tabs

fix(changes): 「Git / 本轮文件」切换恢复会话页的下划线 Tabs
This commit is contained in:
Hairy authored and GitHub committed 2026-11-21 14:02:57 +08:00
commit ddcd435f5f
6 files changed
+97 -18

No files matched your search

+3
View File
@@ -4,6 +4,9 @@
### 未发布
- 🎛 **Changes 的「Git / 本轮文件」切换恢复会话页的下划线 Tabs**([#1235](https://github.com/omdsh-dev/DSH-better-sidebar/issues/1235)):#1101 为摆脱宿主私有哈希类名(#1098)改用公开的 `SegmentedControl`,视觉随之退回灰底胶囊——与会话页页头的下划线 Tabs 不是一套,#939 的结论等于丢了。现在这条切换由插件自己的样式表绘制:13px/500、未选中三级文字、选中态品牌色 + 2px 下划线压在页头分隔线上、24px 间距(#939 的审阅结论),ARIA 关联与左右方向键 / Home / End 漫游焦点照旧;不引用任何宿主私有类名,宿主改版不再影响它。
- 🧪 测试:`tests/changes-tab.spec.tsx` 断言页签条是插件自己的 `lensTabs/lensTab`、下划线由 `changes.module.css` 的主题 Token 画出,并保留键盘 / 持久化 / 刷新用例。
- 🧷 **安装下限改由 `package.json#engines.dsh` 独立裁决(`>=0.2.2-rc.3 <0.3.0`)**:宿主预检先读该字段,字段存在时不再看 14 条 DSH peer,因此停在 0.2.1 及更早宿主的安装失败会被插件市场判成「先升级 DSH」,不再当作插件缺陷自动开 issue。0.2.2-rc.2 及更早的 0.2.2 宿主继续使用 v0.32.1。
- 🧩 **DSH master(0.2.2-rc.3 之后)删除 `connection.requestRejection` 后,`/sidebar/*` 不再全部裸 400**([#1204](https://github.com/omdsh-dev/DSH-better-sidebar/issues/1204)):HTTP/WS 准入改为先调用 `requestRejection`(rc.1–rc.3 行为不变),该方法缺席时改用官方替代 `admit` 并读同一个 `rejection` 字段;两者都没有时仍然直接抛错,不重建信任表。此前宿主删掉该方法后,每个请求在第一句就抛 `TypeError`,被宿主兜底成空 body 的 400,界面只剩 `HTTP 400`。
+3
View File
@@ -6,6 +6,9 @@
### Unreleased
- 🎛 **The Changes lens switcher is back to the conversation page's underline tabs** ([#1235](https://github.com/omdsh-dev/DSH-better-sidebar/issues/1235)): #1101 dropped the host's private hashed classes (#1098) in favour of the public `SegmentedControl`, which also brought the grey capsule back — a different look from the conversation header's underline tabs, so #939's outcome was lost. The strip is now drawn by the plugin's own sheet: 13px/500, tertiary idle ink, brand ink plus a 2px bar riding the header rule when selected, 24px gap (the reviewed spacing from #939), with the same ARIA wiring and Arrow/Home/End roving focus. No host-private class names, so host releases cannot break it.
- 🧪 Tests: `tests/changes-tab.spec.tsx` pins the strip to the plugin's own `lensTabs/lensTab` classes and the themed underline in `changes.module.css`, keeping the keyboard / persistence / refresh cases.
- 🧷 **The install floor is now arbitrated by `package.json#engines.dsh` alone (`>=0.2.2-rc.3 <0.3.0`)**: the host precheck reads that field first and, when present, ignores the 14 DSH peers, so an install that fails on a 0.2.1-or-older host is classified by the plugin market as "upgrade DSH first" instead of being filed against this plugin. Hosts on 0.2.2-rc.2 or earlier 0.2.2 prereleases stay on v0.32.1.
- 🧩 **`/sidebar/*` no longer answers a bare 400 once DSH master (after 0.2.2-rc.3) removed `connection.requestRejection`** ([#1204](https://github.com/omdsh-dev/DSH-better-sidebar/issues/1204)): HTTP/WS admission calls `requestRejection` while it exists (rc.1–rc.3 behaviour unchanged) and otherwise uses the official replacement `admit`, reading the same `rejection` field; when neither exists it still throws instead of rebuilding a trust list. Before this, every request threw a `TypeError` on its first line and the host's fallback turned that into an empty-body 400, leaving only `HTTP 400` on screen.
+1 -1
View File
@@ -478,7 +478,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 任何页签**(右侧栏归宿主,插件只投 tab 类型;首开落在宿主开始页,即本插件接管的 `guideTakeover` 页面);旧 `explorer` tab 经 `sanitizeState` 迁移为无路径的 `editor` 页签(`title:'Files'`、`meta.treeOpen:true`)。树 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 轮询写入的同步缓存。页头使用宿主公开的 `@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 分栏) |
| `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(与宿主会话页同一视觉:13px/500、未选中三级文字、选中态品牌色 + 2px 下划线压在页头分隔线上、24px 间距;`role="tablist"` + `aria-selected`/`aria-controls` 关联、左右方向键与 Home/End 漫游焦点)。宿主没有公开的下划线 Tabs 组件,早期复用的宿主私有哈希类名会随宿主升级失效(#1098),所以样式只落在 `changes.module.css` 的主题 Token 上。两视角共用底部可拖拽预览面板(`tab.meta.lens/previewH` 持久化),diff 渲染统一走 `src/client/diff/`(`DiffRows`/`DiffFiles`:mod 配对 + 行内高亮 + 语法着色 + 上下文折叠);Git 目标可展开为独立 diff tab(落进工作台的 diff 分栏) |
| `subagent` | 30 | 是 | 否 | 任务管理(工作流图/树、团队任务板、后台任务抽屉) |
| `sidechat` | 35 | 否(`sidechat:<uuid>`,按 `meta.threadId` 去重) | 否 | 侧边对话(默认共用一页;设置可切换「每个对话独立页」):共用页再次打开聚焦同一页并回到本会话最近线程;独立页每个线程一个原生 occurrence,按 contentId 精确恢复。打开即建空线程(首条消息赢得标签并同步标题);线程 = 插件自建子会话(种子继承父会话上下文,进行中回合以 `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 的预览面板「展开为独立页签」触发,同一渲染栈) |
+45 -15
View File
@@ -2,9 +2,10 @@
* 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 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
* A 36px header carries the underline lens tabs — the host conversation
* page's strip, drawn from theme tokens in this tab's own sheet — 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
* ONE region with a tab strip when a Git Graph commit supplies a second view:
* `details` (that commit's card, {@link CommitDetails}) and `diff` (the shared
@@ -21,8 +22,8 @@
* git lens has no use for the session event log (and the shared git-status
* store owns its own poller).
*/
import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react'
import { IconRefreshOutlineRegular, SegmentedControl } from '@deepseek-ai/dsh-client-ui-primitives'
import { useCallback, useEffect, useId, useMemo, useRef, useState, type KeyboardEvent } 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'
@@ -212,6 +213,23 @@ export function ChangesTab({ ctx, scope, tab, visible, onOpenFile, onOpenDiff }:
patchMeta({ lens: next })
}
/** The strip's roving focus: the arrows wrap between the two lenses and
* Home/End jump to the ends, the same keys the host's conversation tabs
* answer. Selection follows focus (automatic activation). */
const onLensKeyDown = (event: KeyboardEvent<HTMLButtonElement>, value: Lens): void => {
const next: Lens | null = event.key === 'ArrowLeft' || event.key === 'ArrowRight'
? (value === 'git' ? 'session' : 'git')
: event.key === 'Home' ? 'git'
: event.key === 'End' ? 'session'
: null
if (next === null) return
event.preventDefault()
chooseLens(next)
event.currentTarget.parentElement
?.querySelector<HTMLButtonElement>(`[id="${lensId}-${next}"]`)
?.focus()
}
/** Preview one git change (worktree file or commit) from the Git lens. */
const previewGit = (ref: SidebarDiffRef): void => {
setSelection({ kind: 'git', ref })
@@ -248,16 +266,28 @@ export function ChangesTab({ ctx, scope, tab, visible, onOpenFile, onOpenDiff }:
return (
<div className={css.root}>
<div className={css.head}>
<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 host conversation page's underline tabs, drawn from theme
tokens in this tab's own sheet: the host's Tabs is not a public
component, and borrowing its hashed CSS-module classes broke on
host upgrades (#1098). */}
<div className={css.lensTabs} 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={css.lensTab}
onClick={() => { chooseLens(value) }}
onKeyDown={event => { onLensKeyDown(event, value) }}
>
{t(value === 'git' ? 'changesGitLens' : 'changesSessionLens')}
</button>
))}
</div>
{/* The Git lens refreshes from its own Changes header (#944); only the
session lens needs the tab-level action. */}
{lens === 'session' && <IconButton
+33
View File
@@ -15,6 +15,39 @@
.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; }
/* The lens switcher: the host conversation page's underline tabs, drawn here
from theme tokens. The host's Tabs is not a public component, and borrowing
its hashed CSS-module classes broke on host upgrades (#1098), so this strip
owns its sheet classes and mirrors the conversation header's metrics —
13px/500, tertiary ink that turns brand-coloured when selected, and a 2px
bar riding the header rule. The 24px gap is the reviewed spacing (#939). */
.lensTabs { flex: none; display: flex; align-items: stretch; gap: 24px; min-width: 0; }
.lensTab {
position: relative;
display: inline-flex;
align-items: center;
padding: 0;
border: none;
background: transparent;
font: var(--dsw-font-xs-13);
font-weight: 500;
color: var(--dsw-alias-label-tertiary);
cursor: pointer;
}
.lensTab::after {
content: '';
position: absolute;
right: 0;
bottom: -1px;
left: 0;
height: 2px;
border-radius: 2px;
background: transparent;
}
.lensTab[aria-selected='true'] { color: var(--dsw-alias-state-business-primary); }
.lensTab[aria-selected='true']::after { background: var(--dsw-alias-state-business-primary); }
.lensTab:focus-visible { outline: 2px solid var(--dsw-alias-interactive-bg-hover-accent); outline-offset: -2px; }
.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. */
+12 -2
View File
@@ -80,7 +80,7 @@ function mockGit(entries: GitStatusEntry[]): void {
vi.spyOn(api, 'gitLog').mockResolvedValue([])
}
/** One lens tab rendered by the header's public SegmentedControl. */
/** One lens tab rendered by the header's underline strip. */
function lensTab(container: HTMLElement, label: string): HTMLButtonElement | undefined {
return [...container.querySelectorAll<HTMLButtonElement>('[role="tab"]')]
.find(tab => tab.textContent === label)
@@ -195,7 +195,7 @@ afterEach(() => {
})
describe('ChangesTab', () => {
it('uses the public SegmentedControl with keyboard navigation, persisted lens and refresh', async () => {
it('renders the underline lens tabs with keyboard navigation, persisted lens and refresh', async () => {
mockGit([])
const ops = vi.spyOn(api, 'changesOps').mockResolvedValue({ events: [], lastSeq: 0 })
const updateTab = vi.fn()
@@ -211,7 +211,12 @@ describe('ChangesTab', () => {
const git = lensTab(container, t('changesGitLens'))!
const session = lensTab(container, t('changesSessionLens'))!
expect(tabs.getAttribute('aria-label')).toBe(t('changes'))
// The strip is the plugin's OWN underline tabs (the host conversation
// page's look, theme tokens in changes.module.css) — never the host's
// private hashed classes, which go stale on every host upgrade (#1098).
expect(tabs.className).toContain('lensTabs')
expect(tabs.className).not.toContain('wSkVaW')
expect(git.className).toContain('lensTab')
const panels = (): HTMLElement[] => [...container.querySelectorAll<HTMLElement>('[role="tabpanel"]')]
const selected = (button: HTMLButtonElement): void => {
expect(button.getAttribute('aria-selected')).toBe('true')
@@ -254,6 +259,11 @@ describe('ChangesTab', () => {
const sheet = readFileSync('src/client/changes/changes.module.css', 'utf8')
expect(source).not.toContain('wSkVaW')
expect(sheet).not.toContain('wSkVaW')
// The underline itself: the selected tab paints a 2px bar in the brand
// ink over the header rule, and the idle ink is the tertiary label.
expect(sheet).toMatch(/\.lensTab::after\s*\{[^}]*height: 2px/)
expect(sheet).toMatch(/\.lensTab\[aria-selected='true'\]::after\s*\{\s*background: var\(--dsw-alias-state-business-primary\)/)
expect(sheet).toContain('color: var(--dsw-alias-label-tertiary)')
} finally {
act(() => { root.unmount() })
container.remove()