fix(changes): 会话事件改走宿主 changes.ops 路由 + diff 展开二级设置 + 视觉迭代

CI 修复(plugin-mount 的 ctx.sessions.get TypeError ×1003):
- 客户端 runtime 无事件日志面——badge/SessionLens 原在客户端直读
  ctx.sessions.get(id).events / ctx.on('session/event'),全部不可达。
- 新增宿主路由 changes.ops:live 会话日志优先,冷会话回放
  sessionPersistence.inspect;afterSeq 增量(缺省游标含 seq 0,
  显式游标为 seq > afterSeq,同 sidechat.events 约定),窗口上限
  4000 与客户端累加器一致。
- ChangesTab 轮询(mount 一拉 + visible 2.5s 增量)折入 ops,写
  模块级 opCounts 缓存供 badge 同步读取;SessionLens 改纯展示。

diff 展开二级设置(changesDiffFloat,默认浮窗):
- prefs 四处接线 + git tab settings select(浮窗/面板,图标选项卡)
- 预览面板「展开为 diff tab」按设置落点:浮窗居中弹出或源 pane
  下方 split;i18n 全 21 词典同步。

视觉迭代(真机挂载截图审查后调整):
- Session 视角:kind 徽章为左轨,大小+相对时间右对齐元列;失败
  操作行红色内嵌条;文件组头降为三级标签并加组间距。
- Git 视角:untracked '?' 徽章与新增同绿色;stage 按钮改 plus 图标。
- diff 折叠行:可展开折叠带 › 箭头 + 次级对比度,静态 gap 不再
  显示 pointer/hover;预览头路径改尾部截断(RTL 技巧,保文件名)。

验证:typecheck ✓ / vitest 1123 ✓ / pnpm test:mount(钉 alpha.2 CLI)
14/14 ✓;真机挂载截图(badge=5、双视角、浮窗展开)0 console error。
This commit is contained in:
Menghuan1918
2026-08-31 17:52:59 +08:00
parent 24a3813c63
commit f024fbf092
40 changed files with 456 additions and 112 deletions
+33 -9
View File
@@ -16,14 +16,13 @@ import { openSidebarFile } from '../intercept.tsx'
import { EditorHost } from '../EditorHost.tsx'
import { OpenWithSettings } from '../open-with-settings.tsx'
import { lazyChunkComponent } from '../lazy-chunk.tsx'
import { ChangesTab } from '../changes/ChangesTab.tsx'
import { extractFileOps } from '../changes/ops.ts'
import { ChangesTab, opCountOf } from '../changes/ChangesTab.tsx'
import { DiffTab } from '../DiffTab.tsx'
import { SubagentView } from '../SubagentView.tsx'
import { consumeSidechatSeed, SideChatView, sidechatThreadIdOf } from '../SideChatView.tsx'
import { api } from '../api.ts'
import { BrowserView } from '../BrowserView.tsx'
import { IconTerminalOutline16, IconDiffOutline16, IconGlobeOutline16 } from '../icons.tsx'
import { IconTerminalOutline16, IconDiffOutline16, IconGlobeOutline16, IconFloatWindowOutline16, IconPanelBottomOutline16 } from '../icons.tsx'
import { TERMINAL_FONT_SIZE_MAX, TERMINAL_FONT_SIZE_MIN } from '../../prefs-shared.ts'
import type { ComponentType } from 'react'
import type { SessionScope } from '../api.ts'
@@ -144,17 +143,42 @@ export function builtinTabs(ctx: Context, options: BuiltinTabOptions = {}): read
// The unified changes tab (id kept as 'git' so persisted layouts keep
// resolving): the Git lens is the former source-control panel; the
// session lens is the former file-trace tab (PR #471). Both preview
// through one shared diff stack, and the badge counts this session's
// file ops (live from the event log — the git status itself needs a
// fetch, so it stays out of the badge).
// through one shared diff stack. The badge reads the op-count cache
// the tab's event poll publishes (the client ctx exposes no event
// log, and the git status needs a fetch — both stay out of the badge).
id: 'git',
title: () => t('changes'),
icon: (size: number) => <IconDiffOutline16 size={size} />,
order: 20,
single: true,
badge: (ctx, scope) => {
const events = ctx.sessions.get(scope.sessionId)?.events
return events === undefined ? null : extractFileOps(events).length
badge: (_ctx, scope) => {
const count = opCountOf(scope.sessionId)
return count === undefined || count === 0 ? null : count
},
// Declarative settings: the diff-open picker (free window vs docked
// pane) renders as an iconed select row under the changes card's gear
// in the Side card settings page.
settings: {
toggles: [{
key: 'changesDiffFloat',
type: 'select',
title: () => t('changesDiffOpenTitle'),
desc: () => t('changesDiffOpenDesc'),
options: [
{
value: true,
icon: (size: number) => <IconFloatWindowOutline16 size={size} />,
title: () => t('changesDiffOpenFloat'),
desc: () => t('changesDiffOpenFloatDesc'),
},
{
value: false,
icon: (size: number) => <IconPanelBottomOutline16 size={size} />,
title: () => t('changesDiffOpenPane'),
desc: () => t('changesDiffOpenPaneDesc'),
},
],
}],
},
component: ({ ctx, store, scope, tab, visible, onOpenFile, onOpenDiff }) => (
<ChangesTab