From a64f5cd8e9a43b0fc7c1b24cec1dcafe90b5d0cd Mon Sep 17 00:00:00 2001 From: vlln Date: Thu, 15 Oct 2026 19:56:28 -0700 Subject: [PATCH] =?UTF-8?q?feat(git-graph):=20=E5=9B=BE=E8=B0=B1=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=E4=B8=8E=E7=BB=9F=E4=B8=80=E7=9A=84=E5=BA=95=E9=83=A8?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=EF=BC=88=E8=AF=A6=E6=83=85=20/=20=E5=86=85?= =?UTF-8?q?=E5=AE=B9=20/=20=E5=B7=AE=E5=BC=82=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **图谱视图**(`GitGraphLens`):分支下拉框只筛选历史,不做任何写操作;提交行 是一行 28px——泳道连线 + 引用徽章 + 标题。徽章带图标(本地分支 = 分支图标、 远程跟踪分支 = 地球),`HEAD` 不单独成徽章,而是折叠进当前分支的徽章里做前置 ✓;徽章的颜色就是它所在车道的颜色,和连线、圆点走同一个五色映射。行上不再 有短 hash 与作者时间:hover 350 ms 弹一张中等密度的卡片(标题、徽章、作者· 相对时间、短 hash + 绝对日期),点击后看到的「详情」才是完整信息(完整 hash、 父提交、Markdown 正文)。列表到底自动加载下一页(IntersectionObserver + 在飞守卫),并保留手动按钮作为兜底。 **底部面板**:三个视角共用同一个可拖拽区域,标签集合**固定**为 `提交详情 / 内容 / 差异`,不随上方视角或选中项变化;没有内容的标签显示空态 (未选择提交 / 读取没有差异 / 此视图暂无内容)而不是消失——此前按选中项推导 标签集合,同一个面板看起来像三个不同的面板。选择、高度、激活标签都持久化。 **内容视图**:操作记录(read 的带行号源码;md/html/pdf 用插件自己的渲染器) 与 git 工作区文件(`fs.read` 读文件本身,二进制/超大走既有下载面板)并列。 读取是懒加载的:只为看 diff 打开文件时不会去读整个文档。md 默认渲染,html 默认源码、点了才渲染 iframe(沿用「选中不自动加载 iframe」的沙箱契约)。 **配色**:五个色槽全部用状态色令牌(business/success/warn/error + 次级灰)。 原来槽位 0 用 `brand-primary`,实测在深色主题下是 rgb(15,17,21),主线几乎 不可见——状态色是给细线和小字设计的,两种主题下都能读。 顺带:Git 视角把当前仓库 / 工作树报给父组件(`onTargetChange`),图谱与预览 才能跟着同一个目标走。 测试:`tests/git-graph-ui.spec.tsx`(19 项:请求时机、错误与重试、分页游标、 竞态与中止、行结构、HEAD 折叠、hover 卡片、自动加载)、`tests/changes-tab.spec.tsx` (固定三标签在各视角一致、内容视图懒加载、箭头键在标签间移动)、 `tests/markdown-surface.spec.tsx`(内容视图里的 markdown 链接认领)。 --- src/client/changes/ChangesTab.tsx | 173 ++++++-- src/client/changes/CommitDetails.tsx | 92 +++++ src/client/changes/DiffPane.tsx | 441 ++++++++++++++------ src/client/changes/GitGraphLens.tsx | 312 +++++++++++++++ src/client/changes/GitLens.tsx | 10 +- src/client/changes/changes.module.css | 35 +- src/client/changes/graph.module.css | 127 ++++++ src/client/locales-ar.ts | 16 +- src/client/locales-de.ts | 16 +- src/client/locales-fr.ts | 16 +- src/client/locales-hi.ts | 16 +- src/client/locales-id.ts | 16 +- src/client/locales-it.ts | 16 +- src/client/locales-ja.ts | 16 +- src/client/locales-ko.ts | 16 +- src/client/locales-nl.ts | 16 +- src/client/locales-pl.ts | 16 +- src/client/locales-pt.ts | 16 +- src/client/locales-ru.ts | 16 +- src/client/locales-sv.ts | 16 +- src/client/locales-th.ts | 16 +- src/client/locales-tr.ts | 16 +- src/client/locales-vi.ts | 16 +- src/client/locales-zh-HK.ts | 16 +- src/client/locales-zh-MO.ts | 16 +- src/client/locales-zh-TW.ts | 16 +- src/client/locales.ts | 32 +- tests/changes-tab.spec.tsx | 552 +++++++++++++++++++++++++- tests/git-graph-ui.spec.tsx | 509 ++++++++++++++++++++++++ tests/markdown-surface.spec.tsx | 7 +- 30 files changed, 2357 insertions(+), 237 deletions(-) create mode 100644 src/client/changes/CommitDetails.tsx create mode 100644 src/client/changes/GitGraphLens.tsx create mode 100644 src/client/changes/graph.module.css create mode 100644 tests/git-graph-ui.spec.tsx diff --git a/src/client/changes/ChangesTab.tsx b/src/client/changes/ChangesTab.tsx index 48c369c0..aeab99e5 100644 --- a/src/client/changes/ChangesTab.tsx +++ b/src/client/changes/ChangesTab.tsx @@ -2,12 +2,17 @@ * 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 - * lens's refresh action; both lenses preview their selections in a shared + * A slim 28px header carries the lens switcher — the same compact tab strip + * the bottom pane uses ({@link PaneTabStrip}) — 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 - * the pane height persist in the tab's meta, so the tab reopens exactly where - * it was left. + * 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 + * preview). Every other preview — a worktree file, a history row, a session op + * — keeps the pane diff-only, exactly as before. The active lens, the pane + * height and the pane tab persist in the tab's meta, so the tab reopens + * exactly where it was left. * * The session events ride the host's `changes.ops` route (the client runtime * exposes no event-log face): the tab pulls the delta past its cursor and @@ -18,7 +23,7 @@ * store owns its own poller). */ import { useCallback, useEffect, useMemo, useRef, useState } from 'react' -import { IconRefreshOutlineRegular, SegmentedControl } from '@deepseek-ai/dsh-client-ui-primitives' +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' @@ -27,8 +32,11 @@ import { usePolling } from '../use-polling.ts' import type { SidebarDiffRef } from '../state.ts' import { IconButton, Notice } from '../ui/index.ts' import { GitLens } from './GitLens.tsx' +import { CommitDetails } from './CommitDetails.tsx' +import { GitGraphLens, type GraphDetailsSelection } from './GitGraphLens.tsx' +import graphCss from './graph.module.css' import { SessionLens } from './SessionLens.tsx' -import { DiffPane, clampPaneHeight, diffTabOf, type ChangesPreview } from './DiffPane.tsx' +import { DiffPane, PaneTabStrip, clampPaneHeight, diffTabOf, type ChangesPreview } from './DiffPane.tsx' import { extractFileOps, knownContentBefore, type FileOp } from './ops.ts' import css from './changes.module.css' @@ -49,12 +57,20 @@ export function opCountOf(sessionId: string): number | undefined { return opCounts.get(sessionId) } -type Lens = 'git' | 'session' +type Lens = 'git' | 'graph' | 'session' + +/** The bottom pane's views: `details` (a graph commit's card, hosted while a + * graph selection lives), `content` (an op target's file-content view) and + * `diff` (what changed). Which of the latter two exist depends on the target + * — a read op has no diff — so an id persisted here may be unlisted for the + * current target; the pane falls back to its built-in home then. */ +type PaneTabId = 'details' | 'content' | 'diff' /** The persisted tab meta (JSON-serializable; rides the layout). */ interface ChangesMeta { lens?: Lens previewH?: number + paneTab?: PaneTabId } /** What the user selected to preview: a git ref, or the IDENTITY of a session @@ -67,13 +83,39 @@ type PreviewSelection = export function ChangesTab({ ctx, store, scope, tab, visible, onOpenFile, onOpenDiff }: TabComponentProps) { const meta = (tab.meta ?? {}) as ChangesMeta - const [lens, setLens] = useState(meta.lens === 'session' ? 'session' : 'git') + const [lens, setLens] = useState(meta.lens === 'session' || meta.lens === 'graph' ? meta.lens : 'git') const [selection, setSelection] = useState(null) + /** The Git Graph's selected commit (its card + the ref tones it needs), or + * null while nothing is selected there. Null keeps the pane diff-only. */ + const [graphDetails, setGraphDetails] = useState(null) + /** The pane's active tab: null only before anything picks one, so the FIRST + * graph commit lands on `details` while a tab already chosen (including one + * restored from the meta) is kept — the `diff` default with no strip. */ + const [bottomTab, setBottomTab] = useState( + meta.paneTab === 'details' || meta.paneTab === 'content' || meta.paneTab === 'diff' ? meta.paneTab : null, + ) const [paneHeight, setPaneHeight] = useState(() => clampPaneHeight( typeof meta.previewH === 'number' ? meta.previewH : PANE_HEIGHT_DEFAULT, )) /** The header refresh action for the Git lens (the lens owns its own queue). */ const [gitRefresh, setGitRefresh] = useState(0) + const [graphRefresh, setGraphRefresh] = useState(0) + const [gitTarget, setGitTarget] = useState<{ repoRoot?: string; worktree?: string }>({}) + const scopeKey = `${scope.sessionId}\0${scope.cwd ?? ''}` + const [targetScope, setTargetScope] = useState(scopeKey) + // Render-phase scope reset avoids exposing old targets to child effects while + // retaining GitLens itself (its per-scope draft map must survive A→B→A). + if (targetScope !== scopeKey) { + setTargetScope(scopeKey) + setGitTarget({}) + setSelection(null) + setGraphDetails(null) + } + const targetChanged = useCallback((target: { repoRoot?: string; worktree?: string }) => { + setGitTarget(previous => previous.repoRoot === target.repoRoot && previous.worktree === target.worktree ? previous : target) + }, []) + useEffect(() => { setSelection(null); setGraphDetails(null) }, + [scope.sessionId, scope.cwd, gitTarget.repoRoot, gitTarget.worktree]) // ── Session-event accumulation: one catch-up pull when the tab becomes // visible, then a 2.5s delta poll while the SESSION lens is on screen. @@ -127,7 +169,7 @@ export function ChangesTab({ ctx, store, scope, tab, visible, onOpenFile, onOpen // only while nothing has ever loaded. if (generation === pollGen.current && signal?.aborted !== true) setOpsError(true) } finally { - pullingRef.current = false + if (generation === pollGen.current) pullingRef.current = false } // Granular scope fields: the scope object's identity churns, only its // sessionId / cwd fields gate the poll target. @@ -135,10 +177,12 @@ export function ChangesTab({ ctx, store, scope, tab, visible, onOpenFile, onOpen }, [scope.sessionId, scope.cwd]) useEffect(() => { pollGen.current += 1 + pullingRef.current = false eventsRef.current = [] opsRef.current = [] seqRef.current = 0 setOpsError(false) + return () => { pollGen.current += 1 } }, [scope.sessionId]) // One catch-up whenever the tab becomes visible (the badge count follows the // tab being opened); the CADENCE below runs only while this lens is showing. @@ -158,13 +202,29 @@ export function ChangesTab({ ctx, store, scope, tab, visible, onOpenFile, onOpen return { kind: 'op', path: selection.path, op, prior: knownContentBefore(ops, selection.path, op) } }, [selection, ops]) - /** Persist a meta patch onto the tab (lens choice, pane height). */ + /** Persist a meta patch onto the tab (lens choice, pane height, pane tab). */ const patchMeta = (patch: ChangesMeta): void => { ctx.get('betterSidebar')?.updateTab(tab.id, { meta: { ...(tab.meta as ChangesMeta | undefined ?? {}), ...patch }, }, scope.sessionId) } + /** Switch the bottom pane's tab (a strip click) and persist the choice + * beside lens / previewH, so the pane reopens on the same view. */ + const chooseBottomTab = (next: PaneTabId): void => { + if (next === bottomTab) return + setBottomTab(next) + patchMeta({ paneTab: next }) + } + + /** The graph lens's selected commit, or null. Its arrival is what arms the + * pane's two-tab strip, and the FIRST one of a tab's life lands on `details` + * (the graph's own card); a tab the user already worked on keeps its tab. */ + const reportGraphDetails = (selection: GraphDetailsSelection | null): void => { + setGraphDetails(selection) + if (selection !== null && bottomTab === null) chooseBottomTab('details') + } + const chooseLens = (next: Lens): void => { if (next === lens) return setLens(next) @@ -176,17 +236,29 @@ export function ChangesTab({ ctx, store, scope, tab, visible, onOpenFile, onOpen * session lens re-pulls its event delta. */ const refreshCurrent = (): void => { if (lens === 'git') setGitRefresh(value => value + 1) + else if (lens === 'graph') setGraphRefresh(value => value + 1) else void pull() } - /** Preview one git change (worktree file or commit) from the Git lens. */ + /** Preview one git change from the GIT lens (worktree file or history row): + * another source than the graph, so the pane lands on the diff. */ const previewGit = (ref: SidebarDiffRef): void => { setSelection({ kind: 'git', ref }) + chooseBottomTab('diff') + } + + /** Preview one commit from the GRAPH lens: the pane stays on whatever tab + * the user is on (the default is decided when the entry arrives). */ + const previewGraphCommit = (ref: SidebarDiffRef): void => { + setSelection({ kind: 'git', ref }) } - /** Preview one session op by callId (the tab re-derives it each render). */ + /** Preview one session op by callId (the tab re-derives it each render). A + * READ lands on the content tab — nothing changed, so there is no diff — + * a write/edit lands on the diff. */ const previewOp = (path: string, op: FileOp): void => { setSelection({ kind: 'op', path, callId: op.callId }) + chooseBottomTab(op.kind === 'read' ? 'content' : 'diff') } /** Expand the current git preview into the dedicated diff tab, docked @@ -205,44 +277,42 @@ export function ChangesTab({ ctx, store, scope, tab, visible, onOpenFile, onOpen return (
- { chooseLens(id as Lens) }} /> } + size="sm" + icon={} label={t('refresh')} onClick={refreshCurrent} />
- {lens === 'git' - ? ( - { /* no-op */ })} - onPreview={previewGit} - selectedRef={previewTarget !== null && previewTarget.kind === 'git' ? previewTarget.ref : null} - /> - ) - : ( - - )} + + + {lens === 'session' && } {previewTarget !== null && ( { setPaneHeight(height); patchMeta({ previewH: height }) }} onClose={() => { setSelection(null) }} onExpand={expandPreview} + // The tab set is PINNED, not derived: the three views are the same + // panel in every lens (details of the selected commit, the file's own + // content, the patch). A view with nothing to show renders its empty + // state instead of vanishing, and the lens above never changes the + // strip. + tabs={[ + { id: 'details', label: t('graphDetails') }, + { id: 'content', label: t('changesContentTab') }, + { id: 'diff', label: t('changesDiffTab') }, + ]} + activeTab={bottomTab ?? 'diff'} + onSelectTab={(id) => { if (id === 'details' || id === 'content' || id === 'diff') chooseBottomTab(id) }} + bodies={{ + details: graphDetails === null + ?
{t('changesNoCommit')}
+ : , + }} /> )} {selection !== null && selection.kind === 'op' && previewTarget === null && ( diff --git a/src/client/changes/CommitDetails.tsx b/src/client/changes/CommitDetails.tsx new file mode 100644 index 00000000..b89951bb --- /dev/null +++ b/src/client/changes/CommitDetails.tsx @@ -0,0 +1,92 @@ +/** + * The bottom pane's `details` tab: the commit card the graph lens used to + * render under its own list (title, author, date, full hash + copy, parents, + * refs, message), lifted out of {@link GitGraphLens} so selecting a commit no + * longer stacks a second pane below the shared diff preview — the two views are + * now tabs of ONE pane (see `ChangesTab` / `DiffPane`). + * + * Frameless by design: the pane frame, the tab strip and the height belong to + * the shared bottom region, so this fills whatever body it is given and scrolls + * itself — there is no inner height cap and no nested scroller any more, and + * the message is rendered through the same `MarkdownText` the rest of the + * plugin uses instead of a `
`.
+ */
+import {
+  IconClockOutlineRegular, IconCopyOutlineRegular, IconUserOutlineRegular, MarkdownText, writeClipboard,
+} from '@deepseek-ai/dsh-client-ui-primitives'
+import { relativeTime, t } from '../locales.ts'
+import { markdownTextProps } from '../markdown-labels.tsx'
+import { IconButton } from '../ui/index.ts'
+import { refPills, RefPill, type GraphEntry } from './GitGraphLens.tsx'
+import css from './graph.module.css'
+
+export interface CommitDetailsProps {
+  /** The graph page's entry for the selected commit. */
+  entry: GraphEntry
+  /** The graph's remote ref names, so `origin/main`-style pills read muted;
+   *  only the lens holds the branch inventory this set is derived from. */
+  remotes?: ReadonlySet
+  /** The palette slot of the commit's lane, so the card's pills wear the same
+   *  colour as the graph row the commit sits on. */
+  slot?: number
+}
+
+/**
+ * `git log %B` is the RAW body: its first line is the very subject the card
+ * already shows as its title, so the markdown block renders only what follows
+ * (the split GitHub's commit page makes). When the first line is not the
+ * subject — a hand-written message whose `%s` was folded differently — the
+ * whole body renders rather than silently dropping a line.
+ */
+export function messageBodyOf(entry: GraphEntry): string {
+  const lines = entry.message.replace(/\r\n/g, '\n').split('\n')
+  const head = (lines[0] ?? '').trim()
+  const rest = head === entry.subject.trim() ? lines.slice(1) : lines
+  return rest.join('\n').trim()
+}
+
+export function CommitDetails({ entry, remotes = new Set(), slot }: CommitDetailsProps) {
+  const body = messageBodyOf(entry)
+  // The host renderer falls back to hardcoded Chinese when the nested chrome
+  // labels are omitted, so the code-card labels ride the plugin dictionary.
+  const labels = {
+    copyLabel: t('copy'),
+    copiedLabel: t('copied'),
+    codeLabel: t('codeBlockTitle'),
+    wrapLabel: t('codeBlockWrap'),
+    unwrapLabel: t('codeBlockUnwrap'),
+  }
+  // No section band here: the pane's tab already says "commit details", so the
+  // card opens with the commit's own title instead of repeating that label.
+  // The section keeps the label for assistive tech only (aria-label, not text).
+  return 
+ {entry.subject} +
+ + {entry.author} +
+
+ + {relativeTime(entry.date)} · {entry.date} +
+
+ {entry.hashFull} + } label={t('copyFullHash')} + onClick={() => { void writeClipboard(entry.hashFull) }} /> +
+
+ {t('graphParents')} + + {entry.parents.length === 0 + ? — + : entry.parents.map(parent => {parent.slice(0, 7)})} +
+ {entry.refs.length > 0 &&
+ {refPills(entry.refs, remotes).map(pill => )} +
} + {body !== '' &&
+ +
} +
+} \ No newline at end of file diff --git a/src/client/changes/DiffPane.tsx b/src/client/changes/DiffPane.tsx index 34d1a1b7..976b7f2d 100644 --- a/src/client/changes/DiffPane.tsx +++ b/src/client/changes/DiffPane.tsx @@ -3,16 +3,24 @@ * worktree change, a commit patch, or a session file op — rendered through * the unified diff stack (the same one the diff tab uses). Git targets load * through the shared {@link useGitDiffTarget} hook (refreshable, with the - * untracked full-addition fallback); op targets are pure snapshots (diff / - * read view / error text). The pane is resizable by drag (clamped; the - * height commits to the tab's persisted meta on release) and by keyboard; - * git targets can expand into a dedicated diff tab via the shell. + * untracked full-addition fallback); op targets are pure snapshots. The pane + * is resizable by drag (clamped; the height commits to the tab's persisted + * meta on release) and by keyboard; git targets can expand into a dedicated + * diff tab via the shell. + * + * The pane's views are TABS, one per question: `content` answers "what is in + * the file" (every read op, and the rendered view for md/html/pdf ops — the + * plugin's renderers no longer hide behind a toggle inside the diff view), + * `diff` answers "what changed" (git targets, write/edit ops), and extra + * views the caller hosts (the graph commit's `details` card) sit ahead of + * both. A read op has no `diff` tab — nothing changed. With one or zero tabs + * the pane is byte-for-byte the strip-less preview of before. */ -import { useEffect, useMemo, useRef, useState, type PointerEvent as ReactPointerEvent } from 'react' +import { useEffect, useMemo, useRef, useState, type PointerEvent as ReactPointerEvent, type ReactNode } from 'react' import { IconCloseOutlineRegular, IconRefreshOutlineRegular, IconRightUpOutlineRegular, MarkdownDelegateProvider, MarkdownText } from '@deepseek-ai/dsh-client-ui-primitives' import type { Context } from '../../context-types.ts' import type { SessionScope } from '../api.ts' -import { htmlUrl } from '../api.ts' +import { api, htmlUrl } from '../api.ts' import { hostTransportBase } from '../desktop-env.ts' import { t } from '../locales.ts' import { baseName } from '../paths.ts' @@ -21,6 +29,7 @@ import { HTML_IFRAME_SANDBOX } from '../html-preview.ts' import type { SidebarDiffRef, SidebarTab } from '../state.ts' import { DiffRows, ReadRows } from '../diff/DiffRows.tsx' import { PdfView } from '../PdfView.tsx' +import { BinaryDownload } from '../binary-download.tsx' import { DiffFiles } from '../diff/DiffFiles.tsx' import { langOfPath } from '../diff/highlight.ts' import { buildDiffSegments, diffLines, diffStats, parseUnifiedDiff, unifiedSegments, type DiffRow } from '../diff/rows.ts' @@ -105,6 +114,55 @@ function PaneToggle(props: { on: boolean; label: string; title?: string; onClick return {props.label} } +/** One tab of the pane's optional strip. */ +export interface PaneTab { + readonly id: string + readonly label: string +} + +/** + * 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. + */ +export function PaneTabStrip(props: { tabs: readonly PaneTab[]; active: string; onSelect(id: string): void; className?: string; label?: string }) { + const buttons = useRef<(HTMLButtonElement | null)[]>([]) + const move = (to: number): void => { + const count = props.tabs.length + if (count === 0) return + const index = ((to % count) + count) % count + props.onSelect(props.tabs[index]!.id) + buttons.current[index]?.focus() + } + return ( +
+ {props.tabs.map((tab, index) => ( + + ))} +
+ ) +} + /** The reading-mode body of one markdown op target: the shared MarkdownText * pass (local image destinations already rewritten to the media route by * the caller). Mermaid fences render through the same chunk-resident @@ -174,14 +232,103 @@ export interface DiffPaneProps { onClose: () => void /** Expand the current git target into a dedicated diff tab. */ onExpand: () => void + /** The pane's views. The host may PIN the set (the changes tab pins + * details/content/diff so the panel is identical in every lens; a pinned + * id with nothing to show renders its empty state instead of vanishing). + * Omitted, the set is composed from what this target actually offers. */ + tabs?: readonly PaneTab[] + /** Bodies for ids the pane does not build itself (the caller's views). */ + bodies?: Readonly> + /** The active tab id; an id not listed lands on the built-in home. */ + activeTab?: string + onSelectTab?(id: string): void } -export function DiffPane({ target, ctx, scope, height, onHeightCommit, onClose, onExpand }: DiffPaneProps) { +/** One tab's "nothing here" body — a page-level empty notice. */ +function PaneEmpty({ text }: { text: string }) { + return
{text}
+} + +export function DiffPane({ target, ctx, scope, height, onHeightCommit, onClose, onExpand, tabs, bodies, activeTab, onSelectTab }: DiffPaneProps) { // ── Git target loading (the shared loader: staged-side fallback, the // untracked full-addition fallback, refresh by tick, fold cache). ───── const gitRef = target.kind === 'git' ? target.ref : null + /** The git target when it is a WORKTREE file (the only git target with a + * content view, and the only one carrying a `path`). */ + const gitWorktree = gitRef !== null && gitRef.kind === 'worktree' ? gitRef : null const { loading, error, diffText, untracked, refresh, resolveFold } = useGitDiffTarget(gitRef, scope) + // ── The pane's views, resolved BEFORE anything loads: which tabs exist and + // which one is on screen. Computed from raw target facts (`kind` and + // `isError` do not change under redaction), so the loaders below can + // defer their work for views that are not on screen. ────────────────── + /** The path the content view is about: a worktree file's, or an op's. */ + const targetPath = gitWorktree !== null ? gitWorktree.path : target.kind === 'op' ? target.path : '' + /** A target whose content view may RENDER: a non-error op, or a worktree + * file (the plugin's renderers are the reason the content tab exists). */ + const renderable = (target.kind === 'op' && !target.op.isError) || gitWorktree !== null + const mdOp = renderable && /\.(md|markdown|mdx)$/i.test(targetPath) + const htmlOp = renderable && /\.(html?)$/i.test(targetPath) + const pdfOp = renderable && /\.pdf$/i.test(targetPath) + /** Source vs rendered inside the CONTENT tab. Markdown starts rendered (the + * sanitized MarkdownText is the point of the tab); html starts on SOURCE — + * selecting a row must never auto-load an iframe without an explicit click + * (the sandbox spec pins this). */ + const [contentRaw, setContentRaw] = useState(htmlOp) + const opKind = target.kind === 'op' ? target.op.kind : null + const opError = target.kind === 'op' && target.op.isError + /** What this target can offer: every read op has a content view, md/html/pdf + * ops have one whatever they did, and a git WORKTREE file has one too (the + * file itself, next to its patch). */ + const hasContentTab = target.kind === 'git' + ? target.ref.kind === 'worktree' + : opKind !== null && !opError && (opKind === 'read' || mdOp || htmlOp || pdfOp) + const hasDiffTab = target.kind === 'git' || (opKind !== null && (opKind !== 'read' || opError)) + /** The host may PIN the tab set (the changes tab pins details/content/diff + * so the panel is identical in every lens); otherwise the set is composed + * from what this target offers. An unlisted / absent active id lands on the + * built-in home (`diff`, else `content`, else the first pinned view). */ + const allTabs: PaneTab[] = tabs !== undefined + ? [...tabs] + : [ + ...(hasContentTab ? [{ id: 'content', label: t('changesContentTab') }] : []), + ...(hasDiffTab ? [{ id: 'diff', label: t('changesDiffTab') }] : []), + ] + const hasStrip = allTabs.length > 1 + const active = activeTab !== undefined && allTabs.some(tab => tab.id === activeTab) + ? activeTab + : hasDiffTab ? 'diff' : hasContentTab ? 'content' : allTabs[0]?.id ?? 'diff' + const activeExtra = active !== 'diff' && active !== 'content' + + // ── The `content` tab of a GIT target: the worktree file itself (the diff + // tab answers "what changed"; this one answers "what is in it"). Loaded + // lazily — only while the content view is actually on screen — through + // the same `fs.read` the editor uses, with the same path resolution the + // diff loader applies to a worktree file. ────────────────────────────── + const [gitContent, setGitContent] = useState< + { status: 'idle' | 'loading' | 'binary' | 'large' } | { status: 'text'; text: string } | { status: 'error'; error: string } + >({ status: 'idle' }) + useEffect(() => { + if (gitWorktree === null) { setGitContent({ status: 'idle' }); return } + // Deferred until the content view is the one on screen: opening a file to + // read its DIFF must not pull the whole document. + if (active !== 'content') return + const controller = new AbortController() + setGitContent({ status: 'loading' }) + api.fsRead(scope, resolveSidebarPath(gitWorktree.repoRoot ?? gitWorktree.worktree ?? scope.cwd, gitWorktree.path), controller.signal) + .then((result) => { + if (controller.signal.aborted) return + if (result.kind === 'text') setGitContent({ status: 'text', text: result.content }) + else if (result.kind === 'binary') setGitContent({ status: 'binary' }) + else setGitContent({ status: 'large' }) + }) + .catch((reason: unknown) => { + if (controller.signal.aborted) return + setGitContent({ status: 'error', error: reason instanceof Error ? reason.message : String(reason) }) + }) + return () => { controller.abort() } + }, [gitWorktree, scope, active]) + // ── Op target material (pure snapshots; the prior content came with the // target so a running op shows what is already known). ──────────────── const opRaw = target.kind === 'op' ? target.op : null @@ -239,14 +386,13 @@ export function DiffPane({ target, ctx, scope, height, onHeightCommit, onClose, [op], ) - // ── Markdown reading mode: .md op targets (read/write/edit, non-error) - // toggle between the raw/diff view and the rendered document — the same - // shared MarkdownText pass the editor preview uses, with local image - // destinations rewritten through the /sidebar/file media route. ────── - const mdOp = target.kind === 'op' && !target.op.isError && /\.(md|markdown|mdx)$/i.test(target.path) - const [reading, setReading] = useState(false) - const readingSrc = useMemo(() => { - if (!mdOp || op === null) return '' + // ── Content tab material: the file's full text, its source lines and the + // rendered variants (the tab set itself was resolved at the top). ────── + /** The textual source behind the content view — the op's snapshot for op + * targets, the file on disk for a git worktree file. */ + const contentSrc = useMemo(() => { + if (gitWorktree !== null) return gitContent.status === 'text' ? gitContent.text : '' + if (target.kind !== 'op' || op === null) return '' if (op.kind === 'read') return parseReadContent(op.read ?? '') if (op.kind === 'write') return op.content ?? '' if (op.kind === 'edit' && op.edit !== undefined) { @@ -256,38 +402,33 @@ export function DiffPane({ target, ctx, scope, height, onHeightCommit, onClose, return op.edit.newString } return '' - }, [mdOp, op, prior]) - const readingText = useMemo( - () => (mdOp && reading && readingSrc !== '' && target.kind === 'op' - ? rewriteLocalImageUrls(readingSrc, scope, target.path, hostTransportBase()) + }, [gitWorktree, target.kind, op, prior, gitContent]) + /** The display path (for the language highlighter) and the resolved path the + * media/html routes need — a child-repo path is relative to its repo root, + * exactly as the diff loader resolves it. */ + const contentPath = targetPath + const contentAbs = useMemo( + () => (gitWorktree !== null + ? resolveSidebarPath(gitWorktree.repoRoot ?? gitWorktree.worktree ?? scope.cwd, gitWorktree.path) + : resolveSidebarPath(scope.cwd, contentPath)), + [gitWorktree, scope, contentPath], + ) + /** Source lines: a read keeps its ORIGINAL numbering (`opReadLines`), a + * whole-file source is renumbered from 1. */ + const contentLines = useMemo( + () => (contentSrc === '' ? [] : contentSrc.split('\n').map((text, index) => ({ line: index + 1, text }))), + [contentSrc], + ) + const contentText = useMemo( + () => (mdOp && !contentRaw && contentSrc !== '' + ? rewriteLocalImageUrls(contentSrc, scope, contentPath, hostTransportBase()) : ''), - [mdOp, reading, readingSrc, scope, target], + [mdOp, contentRaw, contentSrc, scope, contentPath], + ) + const htmlRenderSrc = useMemo( + () => (htmlOp && contentAbs !== '' ? htmlUrl(scope, contentAbs) : ''), + [htmlOp, scope, contentAbs], ) - - // ── HTML render mode: .html/.htm op targets (the editor html viewer's - // ext set) load the SAVED file through the same /sidebar/html route the - // editor's html viewer uses — relative assets (./style.css, img/x.png) - // resolve inside the route, and a segmented read still renders the - // whole document (the route serves the file, not the op snapshot). The - // frame is always sandboxed (the attribute plus the route's CSP sandbox - // header); the editor tab owns the warned no-sandbox escape hatch. ── - const htmlOp = target.kind === 'op' && !target.op.isError && /\.(html?)$/i.test(target.path) - const [rendering, setRendering] = useState(false) - const htmlRenderSrc = useMemo(() => { - if (!htmlOp || target.kind !== 'op') return '' - return htmlUrl(scope, resolveSidebarPath(scope.cwd, target.path)) - }, [htmlOp, scope, target]) - - // ── PDF render mode: .pdf op targets (read / write / edit, non-error) reuse - // the editor's PdfView verbatim — media-route bytes wrapped into an - // explicitly-typed Blob so the browser's native PDF viewer opens (a - // direct iframe src can fall back to a download). ────────────────────── - const pdfOp = target.kind === 'op' && !target.op.isError && /\.pdf$/i.test(target.path) - const [renderingPdf, setRenderingPdf] = useState(false) - const pdfRenderPath = useMemo(() => { - if (!pdfOp || target.kind !== 'op') return '' - return resolveSidebarPath(scope.cwd, target.path) - }, [pdfOp, scope, target]) // Header stats for git targets come off the parsed patch text. const gitStats = useMemo(() => { @@ -339,20 +480,80 @@ export function DiffPane({ target, ctx, scope, height, onHeightCommit, onClose, : target.ref.kind === 'worktree' ? target.ref.path : `${target.ref.hash} ${target.ref.subject}` const stats = gitStats ?? (target.kind === 'op' && op !== null && op.kind !== 'read' && !op.isError ? opStats : null) + const handle = ( +
{ + if (event.key === 'ArrowUp') { event.preventDefault(); onHeightCommit(clamp(paneHeight + HEIGHT_STEP)) } + if (event.key === 'ArrowDown') { event.preventDefault(); onHeightCommit(clamp(paneHeight - HEIGHT_STEP)) } + }} + /> + ) + const strip = hasStrip ? {})} /> : null + + // A caller-hosted view (the graph commit's card) takes over the head AND + // the body: same frame, same handle, same height behaviour — only the + // content inside the frame changes. Nothing available → its empty state. + if (activeExtra) { + return ( +
+ {handle} + {strip} +
{bodies?.[active] ?? }
+
+ ) + } + + /** Which rendering the content view uses. Resolved up front so this stays a + * single switch (an aliased-condition narrowing would turn `target` into + * `never` in the remaining branch). */ + const contentView: 'pdf' | 'html' | 'md' | 'source' = + pdfOp && contentAbs !== '' ? 'pdf' + : htmlOp && !contentRaw && htmlRenderSrc !== '' ? 'html' + : mdOp && !contentRaw && contentText !== '' ? 'md' + : 'source' + /** The `content` tab's body: the plugin's rendered view for md/html/pdf + * (with the source toggle for md/html), line-numbered source otherwise, and + * the worktree file itself for a git target — the diff tab keeps the patch. */ + const contentBody = ( + contentView === 'pdf' + ? ( +
+ +
+ ) + : contentView === 'html' + ? + : contentView === 'md' + ? + : gitWorktree !== null + ? (gitContent.status === 'loading' || gitContent.status === 'idle' + ?
{t('loading')}
+ : gitContent.status === 'error' + ?
{t('diffLoadError')}: {gitContent.error}
+ : gitContent.status === 'binary' || gitContent.status === 'large' + ?
+ : ( +
+ +
+ )) + : ( +
+ +
+ ) + ) + return (
-
{ - if (event.key === 'ArrowUp') { event.preventDefault(); onHeightCommit(clamp(paneHeight + HEIGHT_STEP)) } - if (event.key === 'ArrowDown') { event.preventDefault(); onHeightCommit(clamp(paneHeight - HEIGHT_STEP)) } - }} - /> + {handle} + {strip}
{target.kind === 'op' && ( @@ -366,7 +567,7 @@ export function DiffPane({ target, ctx, scope, height, onHeightCommit, onClose, {target.ref.hash} )} {title} - {stats !== null && (stats.added > 0 || stats.deleted > 0) && ( + {active === 'diff' && stats !== null && (stats.added > 0 || stats.deleted > 0) && ( {stats.added > 0 && +{String(stats.added)}} {stats.deleted > 0 && −{String(stats.deleted)}} @@ -400,25 +601,19 @@ export function DiffPane({ target, ctx, scope, height, onHeightCommit, onClose, onClick={toggleRedaction} /> )} - {mdOp && ( + {/* The rendered/source toggle belongs to the CONTENT tab alone. */} + {active === 'content' && mdOp && ( { setReading(value => !value) }} + on={!contentRaw} + label={t(contentRaw ? 'changesMdReading' : 'changesMdRaw')} + onClick={() => { setContentRaw(value => !value) }} /> )} - {htmlOp && ( + {active === 'content' && htmlOp && ( { setRendering(value => !value) }} - /> - )} - {pdfOp && ( - { setRenderingPdf(value => !value) }} + on={!contentRaw} + label={t(contentRaw ? 'changesHtmlRender' : 'changesHtmlRaw')} + onClick={() => { setContentRaw(value => !value) }} /> )}
- {target.kind === 'op' && htmlOp && rendering && htmlRenderSrc !== '' - ? - : target.kind === 'op' && pdfOp && renderingPdf && pdfRenderPath !== '' - ? ( -
- -
- ) - : target.kind === 'op' && mdOp && reading && readingText !== '' - ? - : target.kind === 'op' && op !== null && op.isError - ? ( -
- - {op.errorText ?? t('changesError')} - -
- ) - : target.kind === 'op' && op !== null && op.kind === 'read' + {active === 'content' + ? (hasContentTab ? contentBody : ) + : active === 'diff' + ? (opError ? (
- + + {op?.errorText ?? t('changesError')} +
) - : target.kind === 'op' - ? ( -
- {op !== null && op.kind === 'write' - && prior === undefined - && {t('changesPriorUnknown')}} - -
- ) - : loading - ?
{t('loading')}
- : error !== null - ? ( -
- {t('diffLoadError')}: {error} -
- ) - : ( -
- {/* The untracked fallback has NO diff text (git diff never - lists the file): its content is the whole render. */} - {((diffText !== null && diffText !== '') || untracked !== undefined) && ( - - )} - {diffText === '' && untracked === undefined && ( - {t('diffEmpty')} - )} -
- )} + : opKind === 'read' + // A read changed nothing: the diff view says so plainly instead of + // rendering an empty patch. + ? + : target.kind === 'op' + ? ( +
+ {op !== null && op.kind === 'write' + && prior === undefined + && {t('changesPriorUnknown')}} + +
+ ) + : loading + ?
{t('loading')}
+ : error !== null + ? ( +
+ {t('diffLoadError')}: {error} +
+ ) + : ( +
+ {/* The untracked fallback has NO diff text (git diff never + lists the file): its content is the whole render. */} + {((diffText !== null && diffText !== '') || untracked !== undefined) && ( + + )} + {diffText === '' && untracked === undefined && ( + {t('diffEmpty')} + )} +
+ )) + : (bodies?.[active] ?? )}
) } diff --git a/src/client/changes/GitGraphLens.tsx b/src/client/changes/GitGraphLens.tsx new file mode 100644 index 00000000..3143be0a --- /dev/null +++ b/src/client/changes/GitGraphLens.tsx @@ -0,0 +1,312 @@ +/** Read-only history. No status subscription or timer: visibility, refresh, + * branch selection and explicit paging are the only request triggers. */ +import { useEffect, useMemo, useRef, useState } from 'react' +import { + Button, IconBranchOutlineRegular, IconCheckOutlineRegular, IconGlobeOutlineRegular, +} from '@deepseek-ai/dsh-client-ui-primitives' +import { api, SidebarApiError, type SessionScope } from '../api.ts' +import type { SidebarDiffRef } from '../state.ts' +import { relativeTime, t } from '../locales.ts' +import { Notice } from '../ui/index.ts' +import { AnchoredPopover } from '../AnchoredPopover.tsx' +import { edgePath, layoutGraph } from './graph-layout.ts' +import css from './graph.module.css' + +type GraphPage = Awaited> +/** One commit row of the graph page. */ +export type GraphEntry = GraphPage['entries'][number] +type Branch = GraphPage['branches'][number] + +/** The selected graph commit plus the render context only the lens owns: the + * remote ref names that tone the details card's ref pills, and the palette + * slot of the selected row's lane so the card's pills match the graph. */ +export interface GraphDetailsSelection { + readonly entry: GraphEntry + readonly remotes: ReadonlySet + readonly slot: number +} + +export interface GitGraphLensProps { + scope: SessionScope + worktree?: string + visible: boolean + refreshTick?: number + onPreview: (ref: SidebarDiffRef) => void + selectedRef: SidebarDiffRef | null + onClearPreview?: () => void + /** The selected commit, reported upward for the changes tab's bottom pane + * (`details` tab). Fires on every selection change — a refresh that drops + * the entry included — and unmounting ends it at `null`. HIDING the lens + * deliberately does not clear it: the bottom pane is one region shared by + * all three lenses, independent of which lens is on top. */ + onDetailsChange?: (selection: GraphDetailsSelection | null) => void +} + +/** One-line rows: the GitLens-style picture is rail + ref pills + subject on + * a single 28px line; author, date and hash live in the details card (and + * the row's tooltip). */ +const ROW_HEIGHT = 28 +/** The lane palette is five theme slots. Every painter — lane paths, the node + * dot and the ref pills — resolves through this ONE mapping; the colors + * themselves live in `graph.module.css` (`[data-color]`). */ +const PALETTE_SIZE = 5 +const colorSlot = (colorIndex: number): number => colorIndex % PALETTE_SIZE +const laneX = (lane: number): number => 10 + lane * 12 + +/** The `origin/main`-style refs of the loaded page, told apart from local + * branches by the inventory's own full refs (a local branch may contain `/`). */ +function remoteRefNames(branches: readonly Branch[]): ReadonlySet { + return new Set(branches.filter(item => item.ref.startsWith('refs/remotes/')).map(item => item.name)) +} + +/** HEAD is the local-current marker; remote refs read muted, local ones brand. + * Exported for {@link CommitDetails}, which renders the same pills. */ +export function refTone(ref: string, remotes: ReadonlySet): 'head' | 'remote' | 'local' { + if (ref === 'HEAD') return 'head' + return remotes.has(ref) ? 'remote' : 'local' +} + +/** One ref pill's paint model: the display name, the tone rung and whether it + * carries the "currently checked out" check. */ +export interface RefPillModel { + readonly name: string + readonly tone: 'head' | 'remote' | 'local' + readonly current: boolean +} + +/** The pills one entry's refs render as, in the refs' own order. A literal + * `HEAD` never becomes a pill of its own — it folds into the current local + * branch's pill as a leading check, the convention every graph tool shares + * (GitLens, GitKraken, …); only a DETACHED head renders it standalone. The + * current branch's pill takes the emphasised `head` tone. */ +export function refPills(refs: readonly string[], remotes: ReadonlySet): RefPillModel[] { + const atHead = refs.includes('HEAD') + const named = refs.filter(ref => ref !== 'HEAD') + const current = atHead ? named.find(ref => !remotes.has(ref)) : undefined + const pills = named.map(name => ({ + name, + tone: (name === current ? 'head' : refTone(name, remotes)) as RefPillModel['tone'], + current: name === current, + })) + if (atHead && current === undefined) pills.unshift({ name: 'HEAD', tone: 'head', current: true }) + return pills +} + +/** One pill: the ref-kind icon (branch / remote globe) plus the name, with a + * leading check when this is the branch the worktree stands on. `slot` paints + * the pill in the commit's LANE colour (the same palette mapping the edges + * and the node dot resolve through), so a branch head is recognisable by + * colour alone. Shared by the graph rows, the hover card and the details + * card so a ref reads the same everywhere. */ +export function RefPill({ pill, slot }: { pill: RefPillModel; slot?: number }) { + return + {pill.current && } + {pill.tone === 'remote' ? : } + {pill.name} + +} + +export function GitGraphLens({ scope, worktree, visible, refreshTick = 0, onPreview, selectedRef, onClearPreview, onDetailsChange }: GitGraphLensProps) { + const [branch, setBranch] = useState('') + const [page, setPage] = useState(null) + const [branches, setBranches] = useState([]) + const selectionRef = useRef(selectedRef) + selectionRef.current = selectedRef + const clearPreviewRef = useRef(onClearPreview) + clearPreviewRef.current = onClearPreview + const [loading, setLoading] = useState(false) + const [error, setError] = useState(null) + const [stale, setStale] = useState(false) + const [retry, setRetry] = useState(0) + const generation = useRef(0) + const active = useRef(null) + const pageRef = useRef(null) + const failedAppend = useRef(false) + /** One append in flight at a time: the end sentinel can re-intersect while a + * page is still arriving, and two appends over one cursor would ask for the + * same rows twice. */ + const appending = useRef(false) + const scrollRef = useRef(null) + const sentinelRef = useRef(null) + /** Row hover preview: the middle information rung between the one-line row + * (pills + subject) and the details card (everything). It opens only after + * a short dwell so scrolling past rows never flashes cards; the pointer + * leaving the row closes it (Escape / off-screen are AnchoredPopover's). */ + const hoverTimer = useRef | null>(null) + const [hover, setHover] = useState<{ entry: GraphEntry; anchor: HTMLElement; slot: number } | null>(null) + const cancelHover = (): void => { + if (hoverTimer.current !== null) { clearTimeout(hoverTimer.current); hoverTimer.current = null } + setHover(null) + } + useEffect(() => cancelHover, []) + const request = async (append: boolean): Promise => { + if (!visible) return + if (append && appending.current) return + if (append) appending.current = true + active.current?.abort() + const controller = new AbortController() + active.current = controller + const gen = ++generation.current + const previous = pageRef.current + setLoading(true) + setError(null) + setStale(false) + try { + const result = await api.gitGraph(scope, { + branch: branch || undefined, count: 50, + cursor: append ? previous?.nextCursor : undefined, + }, worktree, controller.signal) + if (controller.signal.aborted || gen !== generation.current) return + const next = append && previous ? { + ...result, + entries: [...previous.entries, ...result.entries.filter(entry => !previous.entries.some(old => old.hashFull === entry.hashFull))], + } : result + pageRef.current = next + setPage(next) + setBranches(next.branches) + const selection = selectionRef.current + if (!append && selection?.kind === 'commit' + && selection.worktree === worktree + && (selection.repoRoot ?? '') === (scope.repoRoot ?? next.root ?? '') + && !next.entries.some(entry => entry.hashFull === selection.hashFull)) { + clearPreviewRef.current?.() + } + } catch (reason) { + if (controller.signal.aborted || gen !== generation.current) return + failedAppend.current = append + setStale(reason instanceof SidebarApiError && reason.code === 'graph-stale') + setError(reason instanceof Error ? reason.message : String(reason)) + } finally { + if (!controller.signal.aborted && gen === generation.current) { + setLoading(false) + appending.current = false + } + } + } + useEffect(() => { + // Clear history on real target/filter changes, never show another repo's rows. + pageRef.current = null + setPage(null) + setBranch('') + setBranches([]) + }, [scope.sessionId, scope.cwd, scope.repoRoot, worktree]) + useEffect(() => { + if (visible) void request(false) + return () => { generation.current += 1; active.current?.abort() } + // Scope identity is deliberately excluded: its scalar fields are the key. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [visible, scope.sessionId, scope.cwd, scope.repoRoot, worktree, branch, refreshTick, retry]) + + /** Infinite scroll: the next page is requested as soon as the end sentinel + * scrolls into view. The button below the rows stays as the fallback path + * (and the only path where IntersectionObserver is unavailable). */ + const requestRef = useRef(request) + requestRef.current = request + useEffect(() => { + const node = sentinelRef.current + if (node === null || !visible || !(page?.hasMore ?? false) || stale) return + if (typeof IntersectionObserver !== 'function') return + const observer = new IntersectionObserver((entries) => { + if (entries.some(entry => entry.isIntersecting)) void requestRef.current(true) + }, { root: scrollRef.current ?? undefined, rootMargin: '200px' }) + observer.observe(node) + return () => { observer.disconnect() } + // entries.length re-arms the observer after each appended page so a list + // still shorter than the viewport keeps filling; appending guards the race. + }, [visible, page?.hasMore, page?.entries.length, page?.nextCursor, stale]) + + const rows = useMemo(() => layoutGraph(page?.entries ?? []), [page?.entries]) + const width = Math.max(28, ...rows.map(row => laneX(row.laneCount) + 2)) + const remotes = useMemo(() => remoteRefNames(branches), [branches]) + const selectedIndex = selectedRef?.kind === 'commit' + && selectedRef.worktree === worktree + && (selectedRef.repoRoot ?? '') === (scope.repoRoot ?? page?.root ?? '') + ? page?.entries.findIndex(entry => entry.hashFull === selectedRef.hashFull) ?? -1 : -1 + const selected = selectedIndex >= 0 ? page?.entries[selectedIndex] : undefined + /** The selected row's palette slot: the details card's pills wear the same + * lane colour as the graph row the commit sits on. */ + const selectedSlot = selectedIndex >= 0 ? colorSlot(rows[selectedIndex]!.colorIndex) : 0 + /** Report the selection upward for the changes tab's bottom pane. The + * callback rides a ref so a fresh parent closure cannot re-fire the effect; + * its deps are the selection itself. A HIDDEN lens keeps its report — the + * pane below is shared by all lenses and stays put when the view above + * switches; unmounting (tab close, scope change) is what clears it. */ + const detailsRef = useRef(onDetailsChange) + detailsRef.current = onDetailsChange + useEffect(() => { + if (!visible) return + detailsRef.current?.(selected === undefined ? null : { entry: selected, remotes, slot: selectedSlot }) + }, [visible, selected, remotes, selectedSlot]) + useEffect(() => () => { detailsRef.current?.(null) }, []) + const select = (entry: GraphEntry): void => onPreview({ + kind: 'commit', hash: entry.hash, hashFull: entry.hashFull, subject: entry.subject, + worktree, repoRoot: scope.repoRoot ?? page?.root, + }) + const chooseBranch = (value: string): void => { + onClearPreview?.() + active.current?.abort() + generation.current += 1 + cancelHover() + setBranch(value) + pageRef.current = null + setPage(null) + } + + return
+
+ +
+
+ {error !== null &&
+ {stale ? t('graphStale') : t('graphLoadError')}{!stale && `: ${error}`} + +
} + {loading &&
{t('loading')}
} + {!loading && !error && page !== null && page.entries.length === 0 &&
{t(page.isRepo ? 'graphEmpty' : 'notRepo')}
} + {page?.entries.map((entry, index) => { + const row = rows[index]! + const slot = colorSlot(row.colorIndex) + return + })} + {page?.hasMore && !stale &&
+ +
} +
+ {/* The middle information rung: more than the one-line row (author, both + * times, short hash), less than the details card (full hash, parents, + * the message). Replaces the native tooltip entirely. */} + + {hover !== null &&
+
{hover.entry.subject}
+ {hover.entry.refs.length > 0 &&
+ {refPills(hover.entry.refs, remotes).map(pill => )} +
} +
{hover.entry.author} · {relativeTime(hover.entry.date)}
+
{hover.entry.hash} {hover.entry.date}
+
} +
+
+} \ No newline at end of file diff --git a/src/client/changes/GitLens.tsx b/src/client/changes/GitLens.tsx index 253e9a53..84ca658c 100644 --- a/src/client/changes/GitLens.tsx +++ b/src/client/changes/GitLens.tsx @@ -354,6 +354,8 @@ export interface GitLensProps { onPreview: (ref: SidebarDiffRef) => void /** The ref currently previewed (row highlight); null when the pane is closed. */ selectedRef: SidebarDiffRef | null + /** Report the selected read target without transferring mutation ownership. */ + onTargetChange?: (target: { repoRoot?: string; worktree?: string }) => void /** Poll the inventory only while the tab is actually visible. */ visible: boolean /** Bumped by the tab header's refresh action (0 = never asked). */ @@ -379,6 +381,10 @@ export function GitLens(props: GitLensProps) { const [worktrees, setWorktrees] = useState([]) const [selectedWorktree, setSelectedWorktree] = useState() const [repoRoot, setRepoRoot] = useState() + const onTargetChange = props.onTargetChange + useEffect(() => { + onTargetChange?.({ repoRoot, worktree: selectedWorktree }) + }, [repoRoot, selectedWorktree, onTargetChange]) /** Every repository of the session workspace, kept once discovered: the * status of a SELECTED child reports only itself, so the selector's option * list cannot be re-derived from the current snapshot alone. */ @@ -867,6 +873,7 @@ export function GitLens(props: GitLensProps) { if (selectedRef === null || selectedRef.kind !== 'worktree') return false return selectedRef.path === path && selectedRef.staged === staged && (selectedRef.worktree ?? '') === (selectedWorktree ?? '') + && (selectedRef.repoRoot ?? '') === (repoRoot ?? '') } const entries = snapshot?.entries ?? NO_ENTRIES @@ -1111,7 +1118,8 @@ export function GitLens(props: GitLensProps) { role="button" tabIndex={0} className={css.logRow} - data-selected={selectedRef?.kind === 'commit' && selectedRef.hashFull === entry.hashFull ? 'true' : undefined} + data-selected={selectedRef?.kind === 'commit' && selectedRef.hashFull === entry.hashFull + && selectedRef.worktree === selectedWorktree && selectedRef.repoRoot === repoRoot ? 'true' : undefined} title={`${entry.author} · ${entry.date}\n${entry.hashFull}`} onClick={() => { onPreview(commitRefOf(entry)) }} onKeyDown={(event) => { diff --git a/src/client/changes/changes.module.css b/src/client/changes/changes.module.css index cc9cea32..e1ac914a 100644 --- a/src/client/changes/changes.module.css +++ b/src/client/changes/changes.module.css @@ -13,8 +13,13 @@ /* ── 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; } +/* One slim 28px bar: the lens switcher is the SAME compact tab strip the + bottom pane uses (a flush variant without its own hairline), so the page's + two switchers read as one component and the bar no longer crowds the native + tab chips above it. */ +.head { flex: none; display: flex; align-items: stretch; gap: 4px; height: 28px; padding: 0 4px 0 8px; border-bottom: 1px solid var(--dsw-alias-border-l1); } +.headAction { align-self: center; margin-left: auto; } +.head .lensTabs { flex: 1; min-width: 0; height: auto; padding: 0; border-bottom: 0; } /* ── Git lens (the former git panel) ───────────────────────────────────── */ @@ -581,6 +586,32 @@ .dragHandle { flex: none; height: 8px; cursor: ns-resize; position: relative; background: var(--dsw-alias-bg-base); } .dragHandle::after { content: ''; position: absolute; left: calc(50% - 18px); top: 3px; width: 36px; height: 2px; border-radius: 1px; background: var(--dsw-alias-border-l2); } .dragHandle:hover::after, .dragHandle:focus-visible::after { background: var(--dsw-alias-state-business-primary); } + +/* ── Bottom pane tab strip (VS Code-style panel) ─────────────────────────── + Only rendered when the pane really hosts two views (a graph commit's + `details` + its diff); a diff-only preview keeps the strip-less head. The + strip sits under the drag handle, so the handle stays the pane's top edge + and the strip doubles as the row that names the active view. */ +.paneTabs { flex: none; display: flex; align-items: center; gap: 2px; height: 28px; padding: 0 8px; border-bottom: 1px solid var(--dsw-alias-border-l1); } +.paneTab { + align-self: stretch; + display: inline-flex; + align-items: center; + padding: 0 8px; + border: none; + border-bottom: 2px solid transparent; + background: transparent; + color: var(--dsw-alias-label-secondary); + font: var(--dsw-font-xxxs-strong-11); + cursor: pointer; +} +.paneTab:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); } +.paneTab[data-active='true'] { color: var(--dsw-alias-label-primary); border-bottom-color: var(--dsw-alias-brand-primary); } +.paneTab:focus-visible { outline: 2px solid var(--dsw-alias-interactive-bg-hover-accent); outline-offset: -2px; } + +/* The non-diff tab's body: the pane owns the frame, the content fills it and + scrolls itself (CommitDetails' own section is the scroller). */ +.altBody { flex: 1; min-height: 0; display: flex; flex-direction: column; } .diffHead { display: flex; align-items: center; gap: 6px; padding: 3px 8px 3px 10px; border-bottom: 1px solid var(--dsw-alias-border-l1); } /* The path keeps its tail (the file name is the identity; directories are context): an RTL paragraph renders an ASCII path in reading order while diff --git a/src/client/changes/graph.module.css b/src/client/changes/graph.module.css new file mode 100644 index 00000000..abc48e7f --- /dev/null +++ b/src/client/changes/graph.module.css @@ -0,0 +1,127 @@ +.lens { display: flex; flex: 1; flex-direction: column; min-height: 0; min-width: 0; } +.lens[hidden] { display: none; } +.root { display: flex; flex: 1; flex-direction: column; min-height: 0; min-width: 0; font: var(--dsw-font-xxs-12); color: var(--dsw-alias-label-primary); } +.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 12px; } +.select { flex: 1; min-width: 0; max-width: 100%; height: 28px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 3px; background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); font: inherit; } +.hint { color: var(--dsw-alias-label-secondary); font: var(--dsw-font-xxxs-11); } +.scroll { flex: 1; min-height: 0; overflow: auto; } +/* A commit row is ONE 28px line — rail, ref pills, subject (the GitLens-style + picture): author, date and hash live in the details card, with the tooltip + still carrying them. Selected keeps the active fill AND the 2px accent + marker, so hover and selection read as two different pictures. */ +.row { position: relative; display: flex; align-items: center; width: 100%; min-width: 0; height: 28px; padding: 0 8px 0 4px; border: 0; text-align: start; background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); font: inherit; cursor: pointer; } +.row[aria-pressed="true"] { background: var(--dsw-alias-interactive-bg-active); } +.row[aria-pressed="true"]::before { + content: ''; + position: absolute; + left: 0; + top: 3px; + bottom: 3px; + width: 2px; + border-radius: 1px; + background: var(--dsw-alias-state-business-primary); +} +.row:hover { background: var(--dsw-alias-interactive-bg-hover); } +.row:focus-visible { outline: 1px solid var(--dsw-alias-border-l2); outline-offset: -1px; } +/* `overflow: visible` matters: a join edge crosses over at the row boundary + (y = row height), and an SVG root clips by default — the outer half of that + 1.5px stroke would be cut off, rendering the crossing as a hairline that + reads "thinner than every other line". The content itself never overflows + (the box is the viewBox, stretched to fit by preserveAspectRatio="none"). */ +.graph { flex-shrink: 0; max-width: 45%; overflow: visible; } +.graph path { fill: none; stroke: currentColor; stroke-width: 1.5; } +.graph circle { fill: currentColor; } +/* The pills sit between the rail and the subject, capped so a decorated merge + cannot starve the message; each pill ellipsizes itself. */ +.refs { display: flex; flex: none; align-items: center; gap: 4px; min-width: 0; max-width: 55%; padding-left: 6px; overflow: hidden; } +.ref { display: inline-flex; flex: none; align-items: center; gap: 3px; min-width: 0; max-width: 140px; height: 16px; padding: 0 5px; border: 1px solid currentColor; border-radius: 3px; font: var(--dsw-font-xxxs-strong-11); color: var(--dsw-alias-label-primary); white-space: nowrap; } +.ref svg { flex: none; } +.refName { min-width: 0; overflow: hidden; text-overflow: ellipsis; } +/* The current branch's pill is filled so it still reads first among several + same-coloured pills on one commit; border and text come from the lane. */ +.ref[data-tone="head"] { background: var(--dsw-alias-interactive-bg-active); } +.subject { flex: 1; min-width: 0; padding-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--dsw-font-xxs-12); color: var(--dsw-alias-label-primary); } +.notice { padding: 8px 12px; } + +/* ── Floating card (commit hover) ────────────────────────────────────────── */ + +/* The one card skeleton of the graph page (same skeleton as the tasks page's + cards): the one surface that carries the elevation shadow. */ +.card { + display: flex; + flex-direction: column; + gap: 6px; + padding: 8px 10px; + box-sizing: border-box; + background: var(--dsw-alias-bg-layer-1); + border: 1px solid var(--dsw-alias-border-l2); + border-radius: 4px; + box-shadow: var(--dsw-shadow-lv3); + font: var(--dsw-font-xxs-12); + color: var(--dsw-alias-label-primary); +} +.hoverSubject { font: var(--dsw-font-xxs-strong-12); color: var(--dsw-alias-label-primary); overflow-wrap: anywhere; } +.hoverMeta { display: flex; align-items: center; gap: 4px; min-width: 0; color: var(--dsw-alias-label-tertiary); font: var(--dsw-font-xxxs-11); overflow-wrap: anywhere; } +/* The shared "nothing here" dash (the details card's empty parents list). */ +.dash { color: var(--dsw-alias-label-tertiary); font: var(--dsw-font-xxxs-11); } + +/* The lane palette: five theme slots, shared by every painter — the graph + edges and node dots and the ref pills. Colours follow the LANE, never the + branch: a colour says "a different line", not "a unique branch" (lanes can + outlive the branches that opened them), which is why there is deliberately + NO legend — the ref pills on the rows are the only branch key, the + convention every graph tool shares. The five are all STATE colours: they + are the tokens designed to stay legible as thin lines and small text on + both theme families — `brand-primary` is a surface-scale navy that reads as + a hole on the dark theme, so it is deliberately NOT a lane colour. */ +.graph [data-color="0"], .ref[data-color="0"] { color: var(--dsw-alias-state-business-primary, var(--dsw-alias-label-primary)); } +.graph [data-color="1"], .ref[data-color="1"] { color: var(--dsw-alias-state-success-primary, var(--dsw-alias-label-primary)); } +.graph [data-color="2"], .ref[data-color="2"] { color: var(--dsw-alias-state-warn-primary, var(--dsw-alias-label-primary)); } +.graph [data-color="3"], .ref[data-color="3"] { color: var(--dsw-alias-state-error-primary, var(--dsw-alias-label-primary)); } +.graph [data-color="4"], .ref[data-color="4"] { color: var(--dsw-alias-label-secondary); } + +/* ── Commit details ────────────────────────────────────────────────────── + Rendered as the changes tab's bottom-pane `details` tab (CommitDetails), + never inside the lens any more: the pane frame, the height and the tab strip + belong to the shared bottom region, so this is frameless — it fills its body + and scrolls itself. */ + +/* The card IS the scroller: no inner wrapper holds a height cap any more, so + the details tab uses every pixel the resizable pane gives it. */ +.details { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; padding: 8px 12px 10px; overflow-y: auto; overflow-wrap: anywhere; } +/* The card's title IS the commit subject (the pane tab already carries the + "commit details" label), so it reads one step above the meta ladder. */ +.detailSubject { font: var(--dsw-font-xs-strong-13); color: var(--dsw-alias-label-primary); } +.metaRow { display: flex; align-items: center; gap: 6px; min-width: 0; } +.metaGlyph { flex: none; display: inline-flex; color: var(--dsw-alias-label-tertiary); } +.metaLabel { flex: none; color: var(--dsw-alias-label-tertiary); font: var(--dsw-font-xxxs-strong-11); } +.metaValue { min-width: 0; color: var(--dsw-alias-label-secondary); font: var(--dsw-font-xxxs-11); } +.hashChip { + padding: 1px 4px; + border-radius: 2px; + background: var(--dsw-alias-interactive-bg-hover); + color: var(--dsw-alias-label-secondary); + font: var(--dsw-font-markdown-code-block-small); + overflow-wrap: anywhere; +} +.parents { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; } +.parentChip { + padding: 1px 4px; + border-radius: 2px; + background: var(--dsw-alias-interactive-bg-hover); + color: var(--dsw-alias-label-secondary); + font: var(--dsw-font-markdown-code-block-small); +} +.detailRefs { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; } +/* The message itself: rendered as markdown in the card's own reading column + (no cap, no own scrollbar — the card scrolls), so a long body is just more + page. A hairline separates it from the metadata block. */ +.messageBody { + min-width: 0; + margin-top: 2px; + padding-top: 8px; + border-top: 1px solid var(--dsw-alias-border-l1); + color: var(--dsw-alias-label-primary); + font: var(--dsw-font-xs-regular-13); + line-height: 1.6; +} \ No newline at end of file diff --git a/src/client/locales-ar.ts b/src/client/locales-ar.ts index 5d49a376..1182e0f7 100644 --- a/src/client/locales-ar.ts +++ b/src/client/locales-ar.ts @@ -29,8 +29,6 @@ export const ar: Record = { changesMdReading: 'قراءة', changesHtmlRender: "عرض", changesHtmlRaw: "المصدر", - changesPdfRender: "عرض", - changesPdfRaw: "المصدر", changesMdRaw: 'الخام', changesWrite: 'كتابة', changesEdit: 'تحرير', @@ -236,10 +234,24 @@ export const ar: Record = { history: 'السجل', changes: 'تغييرات الملفات', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'كل الفروع', + graphBranchFilter: 'تصفية حسب الفرع', + graphEmpty: 'لا توجد التزامات', + graphLoadError: 'تعذر تحميل سجل الالتزامات', + graphStale: 'تغيّر السجل. يرجى التحديث للمتابعة.', + graphDetails: 'تفاصيل الالتزام', + graphParents: 'الالتزامات الأصلية', + graphLoadMore: 'تحميل المزيد', changesSessionLens: 'الجلسة', changesFilterAll: 'الكل', changesFilterEmpty: 'لا توجد عمليات من هذا النوع', changesOpenDiffTab: 'فتح في تبويب diff منفصل', + changesDiffTab: 'الفروق', + changesContentTab: 'المحتوى', + changesNoCommit: 'لم يتم اختيار commit', + changesNoContent: 'لا يوجد شيء لعرضه هنا', + changesReadNoDiff: 'القراءة بلا فروقات', changesClosePreview: 'إغلاق المعاينة', changesResizePreview: 'تغيير حجم المعاينة', changesLoadError: 'سجلات ملفات الجلسة غير متاحة الآن', diff --git a/src/client/locales-de.ts b/src/client/locales-de.ts index bffbbe03..6c6826c2 100644 --- a/src/client/locales-de.ts +++ b/src/client/locales-de.ts @@ -14,8 +14,6 @@ export const de: Record = { changesMdReading: 'Lesen', changesHtmlRender: "Rendern", changesHtmlRaw: "Quelltext", - changesPdfRender: "Rendern", - changesPdfRaw: "Quelltext", changesMdRaw: 'Rohfassung', changesWrite: 'Schreiben', changesEdit: 'Bearbeiten', @@ -221,10 +219,24 @@ export const de: Record = { history: 'Verlauf', changes: 'Dateiänderungen', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'Alle Branches', + graphBranchFilter: 'Branch-Filter', + graphEmpty: 'Keine Commits', + graphLoadError: 'Commit-Verlauf konnte nicht geladen werden', + graphStale: 'Der Verlauf hat sich geändert. Bitte aktualisieren.', + graphDetails: 'Commit-Details', + graphParents: 'Übergeordnete Commits', + graphLoadMore: 'Mehr laden', changesSessionLens: 'Sitzung', changesFilterAll: 'Alle', changesFilterEmpty: 'Keine Vorgänge dieser Art', changesOpenDiffTab: 'In eigenem Tab öffnen', + changesDiffTab: 'Diff', + changesContentTab: 'Inhalt', + changesNoCommit: 'Kein Commit ausgewählt', + changesNoContent: 'Hier gibt es nichts anzuzeigen', + changesReadNoDiff: 'Ein Lesevorgang hat keinen Diff', changesClosePreview: 'Vorschau schließen', changesResizePreview: 'Vorschauhöhe anpassen', changesLoadError: 'Sitzungsdatei-Aufzeichnungen sind derzeit nicht verfügbar', diff --git a/src/client/locales-fr.ts b/src/client/locales-fr.ts index 8a2965be..d763e9d0 100644 --- a/src/client/locales-fr.ts +++ b/src/client/locales-fr.ts @@ -21,8 +21,6 @@ export const fr: Record = { changesMdReading: 'Lecture', changesHtmlRender: "Rendu", changesHtmlRaw: "Source", - changesPdfRender: "Rendu", - changesPdfRaw: "Source", changesMdRaw: 'Brut', changesWrite: 'Écriture', changesEdit: 'Modification', @@ -228,10 +226,24 @@ export const fr: Record = { history: 'Historique', changes: 'Modifications', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'Toutes les branches', + graphBranchFilter: 'Filtre par branche', + graphEmpty: 'Aucun commit', + graphLoadError: 'Impossible de charger l’historique des commits', + graphStale: 'L’historique a changé. Veuillez actualiser.', + graphDetails: 'Détails du commit', + graphParents: 'Commits parents', + graphLoadMore: 'Charger plus', changesSessionLens: 'Session', changesFilterAll: 'Tout', changesFilterEmpty: 'Aucune opération de ce type', changesOpenDiffTab: 'Ouvrir dans un onglet diff', + changesDiffTab: 'Diff', + changesContentTab: 'Contenu', + changesNoCommit: 'Aucun commit sélectionné', + changesNoContent: 'Rien à afficher ici', + changesReadNoDiff: 'Une lecture n’a pas de diff', changesClosePreview: 'Fermer l\'aperçu', changesResizePreview: 'Redimensionner l\'aperçu', changesLoadError: 'Les enregistrements de fichiers de la session sont indisponibles', diff --git a/src/client/locales-hi.ts b/src/client/locales-hi.ts index b7ec789b..aa112497 100644 --- a/src/client/locales-hi.ts +++ b/src/client/locales-hi.ts @@ -28,8 +28,6 @@ export const hi: Record = { changesMdReading: 'पठन', changesHtmlRender: "रेंडर", changesHtmlRaw: "मूल", - changesPdfRender: "रेंडर", - changesPdfRaw: "मूल", changesMdRaw: 'मूल पाठ', changesWrite: 'लिखना', changesEdit: 'संपादन', @@ -235,10 +233,24 @@ export const hi: Record = { history: 'इतिहास', changes: 'फ़ाइल परिवर्तन', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'सभी ब्रांच', + graphBranchFilter: 'ब्रांच फ़िल्टर', + graphEmpty: 'कोई कमिट नहीं', + graphLoadError: 'कमिट इतिहास लोड नहीं हो सका', + graphStale: 'इतिहास बदल गया है। कृपया रीफ़्रेश करें।', + graphDetails: 'कमिट का विवरण', + graphParents: 'पैरेंट कमिट', + graphLoadMore: 'और लोड करें', changesSessionLens: 'सेशन', changesFilterAll: 'सभी', changesFilterEmpty: 'इस प्रकार का कोई ऑपरेशन नहीं', changesOpenDiffTab: 'अलग diff टैब में खोलें', + changesDiffTab: 'डिफ़', + changesContentTab: 'सामग्री', + changesNoCommit: 'कोई कमिट चयनित नहीं', + changesNoContent: 'यहाँ दिखाने के लिए कुछ नहीं', + changesReadNoDiff: 'पढ़ने का कोई डिफ़ नहीं', changesClosePreview: 'पूर्वावलोकन बंद करें', changesResizePreview: 'पूर्वावलोकन का आकार बदलें', changesLoadError: 'सेशन फ़ाइल रिकॉर्ड अभी अनुपलब्ध हैं', diff --git a/src/client/locales-id.ts b/src/client/locales-id.ts index 570f3616..17818c89 100644 --- a/src/client/locales-id.ts +++ b/src/client/locales-id.ts @@ -26,8 +26,6 @@ export const id: Record = { changesMdReading: 'Baca', changesHtmlRender: "Render", changesHtmlRaw: "Sumber", - changesPdfRender: "Render", - changesPdfRaw: "Sumber", changesMdRaw: 'Mentah', changesWrite: 'Tulis', changesEdit: 'Edit', @@ -233,10 +231,24 @@ export const id: Record = { history: 'Riwayat', changes: 'Perubahan berkas', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'Semua branch', + graphBranchFilter: 'Filter branch', + graphEmpty: 'Tidak ada commit', + graphLoadError: 'Gagal memuat riwayat commit', + graphStale: 'Riwayat telah berubah. Silakan muat ulang.', + graphDetails: 'Detail commit', + graphParents: 'Commit induk', + graphLoadMore: 'Muat lebih banyak', changesSessionLens: 'Sesi', changesFilterAll: 'Semua', changesFilterEmpty: 'Tidak ada operasi jenis ini', changesOpenDiffTab: 'Buka di tab diff terpisah', + changesDiffTab: 'Diff', + changesContentTab: 'Konten', + changesNoCommit: 'Tidak ada commit dipilih', + changesNoContent: 'Tidak ada yang ditampilkan', + changesReadNoDiff: 'Pembacaan tidak punya diff', changesClosePreview: 'Tutup pratinjau', changesResizePreview: 'Ubah ukuran pratinjau', changesLoadError: 'Catatan berkas sesi sedang tidak tersedia', diff --git a/src/client/locales-it.ts b/src/client/locales-it.ts index d0d96686..00bd1506 100644 --- a/src/client/locales-it.ts +++ b/src/client/locales-it.ts @@ -19,8 +19,6 @@ export const it: Record = { changesMdReading: 'Lettura', changesHtmlRender: "Render", changesHtmlRaw: "Sorgente", - changesPdfRender: "Render", - changesPdfRaw: "Sorgente", changesMdRaw: 'Grezzo', changesWrite: 'Scrittura', changesEdit: 'Modifica', @@ -226,10 +224,24 @@ export const it: Record = { history: 'Cronologia', changes: 'Modifiche', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'Tutti i rami', + graphBranchFilter: 'Filtro per ramo', + graphEmpty: 'Nessun commit', + graphLoadError: 'Impossibile caricare la cronologia dei commit', + graphStale: 'La cronologia è cambiata. Aggiorna per continuare.', + graphDetails: 'Dettagli del commit', + graphParents: 'Commit genitori', + graphLoadMore: 'Carica altro', changesSessionLens: 'Sessione', changesFilterAll: 'Tutti', changesFilterEmpty: 'Nessuna operazione di questo tipo', changesOpenDiffTab: 'Apri in una scheda diff', + changesDiffTab: 'Diff', + changesContentTab: 'Contenuto', + changesNoCommit: 'Nessun commit selezionato', + changesNoContent: 'Niente da mostrare qui', + changesReadNoDiff: 'Una lettura non ha diff', changesClosePreview: 'Ridimensiona l\'anteprima', changesResizePreview: 'Ridimensiona anteprima', changesLoadError: 'I record dei file della sessione non sono disponibili', diff --git a/src/client/locales-ja.ts b/src/client/locales-ja.ts index fb2ed832..e5f1ea9e 100644 --- a/src/client/locales-ja.ts +++ b/src/client/locales-ja.ts @@ -28,8 +28,6 @@ export const ja: Record = { changesMdReading: '閲覧', changesHtmlRender: "レンダリング", changesHtmlRaw: "原文", - changesPdfRender: "レンダリング", - changesPdfRaw: "原文", changesMdRaw: '原文', changesWrite: '書き込み', changesEdit: '編集', @@ -235,10 +233,24 @@ export const ja: Record = { history: '履歴', changes: 'ファイル変更', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'すべてのブランチ', + graphBranchFilter: 'ブランチの絞り込み', + graphEmpty: 'コミットはありません', + graphLoadError: 'コミット履歴を読み込めませんでした', + graphStale: '履歴が変更されました。更新してください。', + graphDetails: 'コミットの詳細', + graphParents: '親コミット', + graphLoadMore: 'さらに読み込む', changesSessionLens: 'セッション', changesFilterAll: 'すべて', changesFilterEmpty: 'この種類の操作はありません', changesOpenDiffTab: '独立タブで開く', + changesDiffTab: '差分', + changesContentTab: 'コンテンツ', + changesNoCommit: 'コミットが選択されていません', + changesNoContent: '表示できる内容がありません', + changesReadNoDiff: '読み取りに差分はありません', changesClosePreview: 'プレビューを閉じる', changesResizePreview: 'プレビューの高さを変更', changesLoadError: 'セッションのファイル記録は現在利用できません', diff --git a/src/client/locales-ko.ts b/src/client/locales-ko.ts index e261b504..46bb0ea9 100644 --- a/src/client/locales-ko.ts +++ b/src/client/locales-ko.ts @@ -20,8 +20,6 @@ export const ko: Record = { changesMdReading: '읽기', changesHtmlRender: "렌더링", changesHtmlRaw: "원문", - changesPdfRender: "렌더링", - changesPdfRaw: "원문", changesMdRaw: '원문', changesWrite: '쓰기', changesEdit: '편집', @@ -227,10 +225,24 @@ export const ko: Record = { history: '기록', changes: '파일 변경', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: '모든 브랜치', + graphBranchFilter: '브랜치 필터', + graphEmpty: '커밋이 없습니다', + graphLoadError: '커밋 기록을 불러오지 못했습니다', + graphStale: '기록이 변경되었습니다. 새로고침하세요.', + graphDetails: '커밋 상세 정보', + graphParents: '부모 커밋', + graphLoadMore: '더 불러오기', changesSessionLens: '세션', changesFilterAll: '모두', changesFilterEmpty: '이 종류의 작업이 없습니다', changesOpenDiffTab: '별도 탭에서 열기', + changesDiffTab: '차이', + changesContentTab: '콘텐츠', + changesNoCommit: '선택된 커밋 없음', + changesNoContent: '표시할 내용이 없습니다', + changesReadNoDiff: '읽기에는 diff가 없습니다', changesClosePreview: '미리보기 닫기', changesResizePreview: '미리보기 높이 조정', changesLoadError: '세션 파일 기록을 지금 사용할 수 없습니다', diff --git a/src/client/locales-nl.ts b/src/client/locales-nl.ts index 456f232e..f32ea895 100644 --- a/src/client/locales-nl.ts +++ b/src/client/locales-nl.ts @@ -26,8 +26,6 @@ export const nl: Record = { changesMdReading: 'Lezen', changesHtmlRender: "Renderen", changesHtmlRaw: "Bron", - changesPdfRender: "Renderen", - changesPdfRaw: "Bron", changesMdRaw: 'Brontekst', changesWrite: 'Schrijven', changesEdit: 'Bewerken', @@ -233,10 +231,24 @@ export const nl: Record = { history: 'Geschiedenis', changes: 'Bestandswijzigingen', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'Alle branches', + graphBranchFilter: 'Branchfilter', + graphEmpty: 'Geen commits', + graphLoadError: 'Commitgeschiedenis laden mislukt', + graphStale: 'De geschiedenis is gewijzigd. Vernieuw om door te gaan.', + graphDetails: 'Commitdetails', + graphParents: 'Bovenliggende commits', + graphLoadMore: 'Meer laden', changesSessionLens: 'Sessie', changesFilterAll: 'Alles', changesFilterEmpty: 'Geen bewerkingen van dit soort', changesOpenDiffTab: 'In eigen diff-tabblad openen', + changesDiffTab: 'Diff', + changesContentTab: 'Inhoud', + changesNoCommit: 'Geen commit geselecteerd', + changesNoContent: 'Niets om hier te tonen', + changesReadNoDiff: 'Een read heeft geen diff', changesClosePreview: 'Voorbeeld sluiten', changesResizePreview: 'Voorbeeld vergroten/verkleinen', changesLoadError: 'Sessiebestandsregistraties zijn nu niet beschikbaar', diff --git a/src/client/locales-pl.ts b/src/client/locales-pl.ts index 144400ed..f5c6c735 100644 --- a/src/client/locales-pl.ts +++ b/src/client/locales-pl.ts @@ -30,8 +30,6 @@ export const pl: Record = { changesMdReading: 'Czytanie', changesHtmlRender: "Renderuj", changesHtmlRaw: "Źródło", - changesPdfRender: "Renderuj", - changesPdfRaw: "Źródło", changesMdRaw: 'Źródło', changesWrite: 'Zapis', changesEdit: 'Edycja', @@ -237,10 +235,24 @@ export const pl: Record = { history: 'Historia', changes: 'Zmiany plików', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'Wszystkie gałęzie', + graphBranchFilter: 'Filtr gałęzi', + graphEmpty: 'Brak commitów', + graphLoadError: 'Nie udało się wczytać historii commitów', + graphStale: 'Historia uległa zmianie. Odśwież, aby kontynuować.', + graphDetails: 'Szczegóły commita', + graphParents: 'Commity nadrzędne', + graphLoadMore: 'Wczytaj więcej', changesSessionLens: 'Sesja', changesFilterAll: 'Wszystko', changesFilterEmpty: 'Brak operacji tego rodzaju', changesOpenDiffTab: 'Otwórz w osobnej karcie', + changesDiffTab: 'Diff', + changesContentTab: 'Treść', + changesNoCommit: 'Nie wybrano commita', + changesNoContent: 'Nie ma tu nic do pokazania', + changesReadNoDiff: 'Odczyt nie ma diffa', changesClosePreview: 'Zamknij podgląd', changesResizePreview: 'Zmień wysokość podglądu', changesLoadError: 'Zapisy plików sesji są teraz niedostępne', diff --git a/src/client/locales-pt.ts b/src/client/locales-pt.ts index 38553497..5742f42e 100644 --- a/src/client/locales-pt.ts +++ b/src/client/locales-pt.ts @@ -11,8 +11,6 @@ export const pt: Record = { changesMdReading: 'Leitura', changesHtmlRender: "Renderizar", changesHtmlRaw: "Fonte", - changesPdfRender: "Renderizar", - changesPdfRaw: "Fonte", changesMdRaw: 'Bruto', changesWrite: 'Escrita', changesEdit: 'Edição', @@ -218,10 +216,24 @@ export const pt: Record = { history: 'Histórico', changes: 'Alterações', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'Todas as branches', + graphBranchFilter: 'Filtro de branch', + graphEmpty: 'Nenhum commit', + graphLoadError: 'Falha ao carregar o histórico de commits', + graphStale: 'O histórico mudou. Atualize para continuar.', + graphDetails: 'Detalhes do commit', + graphParents: 'Commits pais', + graphLoadMore: 'Carregar mais', changesSessionLens: 'Sessão', changesFilterAll: 'Tudo', changesFilterEmpty: 'Nenhuma operação deste tipo', changesOpenDiffTab: 'Abrir em uma aba de diff', + changesDiffTab: 'Diff', + changesContentTab: 'Conteúdo', + changesNoCommit: 'Nenhum commit selecionado', + changesNoContent: 'Nada para mostrar aqui', + changesReadNoDiff: 'Uma leitura não tem diff', changesClosePreview: 'Fechar prévia', changesResizePreview: 'Ajustar altura da prévia', changesLoadError: 'Os registros de arquivos da sessão estão indisponíveis no momento', diff --git a/src/client/locales-ru.ts b/src/client/locales-ru.ts index 3e90ad71..f92e0ff7 100644 --- a/src/client/locales-ru.ts +++ b/src/client/locales-ru.ts @@ -24,8 +24,6 @@ export const ru: Record = { changesMdReading: 'Чтение', changesHtmlRender: "Рендер", changesHtmlRaw: "Исходник", - changesPdfRender: "Рендер", - changesPdfRaw: "Исходник", changesMdRaw: 'Исходный текст', changesWrite: 'Запись', changesEdit: 'Изменение', @@ -231,10 +229,24 @@ export const ru: Record = { history: 'История', changes: 'Изменения файлов', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'Все ветки', + graphBranchFilter: 'Фильтр по ветке', + graphEmpty: 'Нет коммитов', + graphLoadError: 'Не удалось загрузить историю коммитов', + graphStale: 'История изменилась. Обновите для продолжения.', + graphDetails: 'Сведения о коммите', + graphParents: 'Родительские коммиты', + graphLoadMore: 'Загрузить ещё', changesSessionLens: 'Сессия', changesFilterAll: 'Все', changesFilterEmpty: 'Нет операций этого типа', changesOpenDiffTab: 'Открыть в отдельной вкладке', + changesDiffTab: 'Дифф', + changesContentTab: 'Содержимое', + changesNoCommit: 'Коммит не выбран', + changesNoContent: 'Здесь нечего показать', + changesReadNoDiff: 'У чтения нет diff', changesClosePreview: 'Закрыть просмотр', changesResizePreview: 'Изменить высоту просмотра', changesLoadError: 'Записи файлов сессии сейчас недоступны', diff --git a/src/client/locales-sv.ts b/src/client/locales-sv.ts index 8ac41c05..72b1d2d0 100644 --- a/src/client/locales-sv.ts +++ b/src/client/locales-sv.ts @@ -11,8 +11,6 @@ export const sv: Record = { changesMdReading: 'Läsning', changesHtmlRender: "Rendera", changesHtmlRaw: "Källa", - changesPdfRender: "Rendera", - changesPdfRaw: "Källa", changesMdRaw: 'Råtext', changesWrite: 'Skriv', changesEdit: 'Redigera', @@ -218,10 +216,24 @@ export const sv: Record = { history: 'Historik', changes: 'Filändringar', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'Alla grenar', + graphBranchFilter: 'Grenfilter', + graphEmpty: 'Inga commits', + graphLoadError: 'Kunde inte läsa in commit-historiken', + graphStale: 'Historiken har ändrats. Uppdatera för att fortsätta.', + graphDetails: 'Commit-detaljer', + graphParents: 'Föräldracommits', + graphLoadMore: 'Läs in fler', changesSessionLens: 'Session', changesFilterAll: 'Alla', changesFilterEmpty: 'Inga åtgärder av denna typ', changesOpenDiffTab: 'Öppna i egen diff-flik', + changesDiffTab: 'Diff', + changesContentTab: 'Innehåll', + changesNoCommit: 'Ingen commit vald', + changesNoContent: 'Inget att visa här', + changesReadNoDiff: 'En läsning har ingen diff', changesClosePreview: 'Stäng förhandsvisning', changesResizePreview: 'Ändra storlek på förhandsvisningen', changesLoadError: 'Sessionens filposter är inte tillgängliga just nu', diff --git a/src/client/locales-th.ts b/src/client/locales-th.ts index 045ac476..97a1d856 100644 --- a/src/client/locales-th.ts +++ b/src/client/locales-th.ts @@ -28,8 +28,6 @@ export const th: Record = { changesMdReading: 'อ่าน', changesHtmlRender: "เรนเดอร์", changesHtmlRaw: "ต้นฉบับ", - changesPdfRender: "เรนเดอร์", - changesPdfRaw: "ต้นฉบับ", changesMdRaw: 'ดิบ', changesWrite: 'เขียน', changesEdit: 'แก้ไข', @@ -235,10 +233,24 @@ export const th: Record = { history: 'ประวัติ', changes: 'การเปลี่ยนแปลงไฟล์', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'ทุก branch', + graphBranchFilter: 'ตัวกรอง branch', + graphEmpty: 'ไม่มี commit', + graphLoadError: 'โหลดประวัติ commit ไม่สำเร็จ', + graphStale: 'ประวัติมีการเปลี่ยนแปลง โปรดรีเฟรช', + graphDetails: 'รายละเอียด commit', + graphParents: 'commit แม่', + graphLoadMore: 'โหลดเพิ่มเติม', changesSessionLens: 'เซสชัน', changesFilterAll: 'ทั้งหมด', changesFilterEmpty: 'ไม่มีการดำเนินการประเภทนี้', changesOpenDiffTab: 'เปิดในแท็บ diff แยก', + changesDiffTab: 'Diff', + changesContentTab: 'เนื้อหา', + changesNoCommit: 'ยังไม่ได้เลือกคอมมิต', + changesNoContent: 'ไม่มีเนื้อหาให้แสดง', + changesReadNoDiff: 'การอ่านไม่มีความต่าง', changesClosePreview: 'ปิดตัวอย่าง', changesResizePreview: 'ปรับขนาดตัวอย่าง', changesLoadError: 'บันทึกไฟล์ของเซสชันยังใช้ไม่ได้ตอนนี้', diff --git a/src/client/locales-tr.ts b/src/client/locales-tr.ts index 1a6c8343..2410f068 100644 --- a/src/client/locales-tr.ts +++ b/src/client/locales-tr.ts @@ -28,8 +28,6 @@ export const tr: Record = { changesMdReading: 'Okuma', changesHtmlRender: "Render", changesHtmlRaw: "Kaynak", - changesPdfRender: "Render", - changesPdfRaw: "Kaynak", changesMdRaw: 'Ham', changesWrite: 'Yazma', changesEdit: 'Düzenleme', @@ -235,10 +233,24 @@ export const tr: Record = { history: 'Geçmiş', changes: 'Dosya değişiklikleri', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'Tüm dallar', + graphBranchFilter: 'Dal filtresi', + graphEmpty: 'Commit yok', + graphLoadError: 'Commit geçmişi yüklenemedi', + graphStale: 'Geçmiş değişti. Devam etmek için yenileyin.', + graphDetails: 'Commit ayrıntıları', + graphParents: 'Üst commit’ler', + graphLoadMore: 'Daha fazla yükle', changesSessionLens: 'Oturum', changesFilterAll: 'Tümü', changesFilterEmpty: 'Bu türde işlem yok', changesOpenDiffTab: 'Ayrı bir diff sekmesinde aç', + changesDiffTab: 'Fark', + changesContentTab: 'İçerik', + changesNoCommit: 'Commit seçilmedi', + changesNoContent: 'Burada gösterilecek bir şey yok', + changesReadNoDiff: 'Okumanın diff’i yok', changesClosePreview: 'Önizlemeyi kapat', changesResizePreview: 'Önizlemeyi boyutlandır', changesLoadError: 'Oturum dosya kayıtları şu anda kullanılamıyor', diff --git a/src/client/locales-vi.ts b/src/client/locales-vi.ts index 4e590dd2..8ecd0cc4 100644 --- a/src/client/locales-vi.ts +++ b/src/client/locales-vi.ts @@ -28,8 +28,6 @@ export const vi: Record = { changesMdReading: 'Đọc', changesHtmlRender: "Kết xuất", changesHtmlRaw: "Nguyên văn", - changesPdfRender: "Kết xuất", - changesPdfRaw: "Nguyên văn", changesMdRaw: 'Gốc', changesWrite: 'Ghi', changesEdit: 'Chỉnh sửa', @@ -235,10 +233,24 @@ export const vi: Record = { history: 'Lịch sử', changes: 'Thay đổi tệp', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'Tất cả các nhánh', + graphBranchFilter: 'Bộ lọc nhánh', + graphEmpty: 'Không có commit', + graphLoadError: 'Không thể tải lịch sử commit', + graphStale: 'Lịch sử đã thay đổi. Vui lòng làm mới.', + graphDetails: 'Chi tiết commit', + graphParents: 'Commit cha', + graphLoadMore: 'Tải thêm', changesSessionLens: 'Phiên', changesFilterAll: 'Tất cả', changesFilterEmpty: 'Không có thao tác thuộc loại này', changesOpenDiffTab: 'Mở trong tab diff riêng', + changesDiffTab: 'Diff', + changesContentTab: 'Nội dung', + changesNoCommit: 'Chưa chọn commit', + changesNoContent: 'Không có nội dung để hiển thị', + changesReadNoDiff: 'Lần đọc không có diff', changesClosePreview: 'Đóng xem trước', changesResizePreview: 'Điều chỉnh kích thước xem trước', changesLoadError: 'Bản ghi tệp phiên hiện không khả dụng', diff --git a/src/client/locales-zh-HK.ts b/src/client/locales-zh-HK.ts index a6c299ac..68ce9ea0 100644 --- a/src/client/locales-zh-HK.ts +++ b/src/client/locales-zh-HK.ts @@ -43,8 +43,6 @@ export const zhHK: Record = { changesMdReading: '閱讀', changesHtmlRender: "渲染", changesHtmlRaw: "原文", - changesPdfRender: "渲染", - changesPdfRaw: "原文", changesMdRaw: '原文', changesWrite: '寫入', changesEdit: '編輯', @@ -250,10 +248,24 @@ export const zhHK: Record = { history: '歷史', changes: '檔案變動', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: '所有分支', + graphBranchFilter: '分支篩選', + graphEmpty: '尚無提交', + graphLoadError: '載入提交歷史失敗', + graphStale: '提交歷史已變更,請重新整理', + graphDetails: '提交詳情', + graphParents: '父提交', + graphLoadMore: '載入更多', changesSessionLens: '本輪檔案', changesFilterAll: '全部', changesFilterEmpty: '沒有此類操作', changesOpenDiffTab: '在獨立分頁中開啟', + changesDiffTab: '差異', + changesContentTab: '內容', + changesNoCommit: '未選擇提交', + changesNoContent: '此檢視暫無內容', + changesReadNoDiff: '讀取沒有差異', changesClosePreview: '關閉預覽', changesResizePreview: '調整預覽高度', changesLoadError: '工作階段檔案記錄暫不可用', diff --git a/src/client/locales-zh-MO.ts b/src/client/locales-zh-MO.ts index 3cff37f7..1dcd562b 100644 --- a/src/client/locales-zh-MO.ts +++ b/src/client/locales-zh-MO.ts @@ -43,8 +43,6 @@ export const zhMO: Record = { changesMdReading: '閱讀', changesHtmlRender: "渲染", changesHtmlRaw: "原文", - changesPdfRender: "渲染", - changesPdfRaw: "原文", changesMdRaw: '原文', changesWrite: '寫入', changesEdit: '編輯', @@ -250,10 +248,24 @@ export const zhMO: Record = { history: '歷史', changes: '檔案變動', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: '所有分支', + graphBranchFilter: '分支篩選', + graphEmpty: '尚無提交', + graphLoadError: '載入提交歷史失敗', + graphStale: '提交歷史已變更,請重新整理', + graphDetails: '提交詳情', + graphParents: '父提交', + graphLoadMore: '載入更多', changesSessionLens: '本輪檔案', changesFilterAll: '全部', changesFilterEmpty: '沒有此類操作', changesOpenDiffTab: '在獨立分頁中開啟', + changesDiffTab: '差異', + changesContentTab: '內容', + changesNoCommit: '未選擇提交', + changesNoContent: '此檢視暫無內容', + changesReadNoDiff: '讀取沒有差異', changesClosePreview: '關閉預覽', changesResizePreview: '調整預覽高度', changesLoadError: '工作階段檔案記錄暫不可用', diff --git a/src/client/locales-zh-TW.ts b/src/client/locales-zh-TW.ts index 453c7505..e80cde59 100644 --- a/src/client/locales-zh-TW.ts +++ b/src/client/locales-zh-TW.ts @@ -43,8 +43,6 @@ export const zhTW: Record = { changesMdReading: '閱讀', changesHtmlRender: "渲染", changesHtmlRaw: "原文", - changesPdfRender: "渲染", - changesPdfRaw: "原文", changesMdRaw: '原文', changesWrite: '寫入', changesEdit: '編輯', @@ -250,10 +248,24 @@ export const zhTW: Record = { history: '歷史', changes: '檔案變動', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: '所有分支', + graphBranchFilter: '分支篩選', + graphEmpty: '尚無提交', + graphLoadError: '載入提交歷史失敗', + graphStale: '提交歷史已變更,請重新整理', + graphDetails: '提交詳情', + graphParents: '父提交', + graphLoadMore: '載入更多', changesSessionLens: '本輪檔案', changesFilterAll: '全部', changesFilterEmpty: '沒有此類操作', changesOpenDiffTab: '在獨立頁籤中開啟', + changesDiffTab: '差異', + changesContentTab: '內容', + changesNoCommit: '未選擇提交', + changesNoContent: '此檢視暫無內容', + changesReadNoDiff: '讀取沒有差異', changesClosePreview: '關閉預覽', changesResizePreview: '調整預覽高度', changesLoadError: '工作階段檔案記錄暫不可用', diff --git a/src/client/locales.ts b/src/client/locales.ts index 89b3f726..dabafa1b 100644 --- a/src/client/locales.ts +++ b/src/client/locales.ts @@ -36,8 +36,6 @@ export const zh = { changesMdRaw: '原文', changesHtmlRender: '渲染', changesHtmlRaw: '原文', - changesPdfRender: '渲染', - changesPdfRaw: '原文', changesWrite: '写入', changesEdit: '编辑', changesRunning: '执行中', @@ -246,10 +244,24 @@ export const zh = { history: '历史', changes: '文件变动', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: '所有分支', + graphBranchFilter: '分支筛选', + graphEmpty: '暂无提交', + graphLoadError: '加载提交历史失败', + graphStale: '提交历史已变化,请刷新', + graphDetails: '提交详情', + graphParents: '父提交', + graphLoadMore: '加载更多', changesSessionLens: '本轮文件', changesFilterAll: '全部', changesFilterEmpty: '没有此类操作', changesOpenDiffTab: '在独立页签中打开', + changesDiffTab: '差异', + changesContentTab: '内容', + changesNoCommit: '未选择提交', + changesNoContent: '此视图暂无内容', + changesReadNoDiff: '读取没有差异', changesClosePreview: '关闭预览', changesResizePreview: '调整预览高度', changesLoadError: '会话文件记录暂不可用', @@ -638,8 +650,6 @@ export const en: Record = { changesMdRaw: 'Raw', changesHtmlRender: 'Render', changesHtmlRaw: 'Raw', - changesPdfRender: 'Render', - changesPdfRaw: 'Raw', changesWrite: 'Write', changesEdit: 'Edit', changesRunning: 'running', @@ -848,10 +858,24 @@ export const en: Record = { history: 'History', changes: 'Changes', changesGitLens: 'Git', + changesGraphLens: 'Git Graph', + graphAllBranches: 'All branches', + graphBranchFilter: 'Branch filter', + graphEmpty: 'No commits', + graphLoadError: 'Failed to load commit history', + graphStale: 'History has changed. Refresh to continue.', + graphDetails: 'Commit details', + graphParents: 'Parents', + graphLoadMore: 'Load more', changesSessionLens: 'Session', changesFilterAll: 'All', changesFilterEmpty: 'No operations of this kind', changesOpenDiffTab: 'Open in a diff tab', + changesDiffTab: 'Diff', + changesContentTab: 'Content', + changesNoCommit: 'No commit selected', + changesNoContent: 'Nothing to show here', + changesReadNoDiff: 'A read has no diff', changesClosePreview: 'Close preview', changesResizePreview: 'Resize preview', changesLoadError: 'Session file records are unavailable right now', diff --git a/tests/changes-tab.spec.tsx b/tests/changes-tab.spec.tsx index d8cef920..1b893b81 100644 --- a/tests/changes-tab.spec.tsx +++ b/tests/changes-tab.spec.tsx @@ -3,7 +3,9 @@ * Git lens for the session lens, a Git-lens file row opens the shared preview * pane (loaded through the mocked git API, rendered by the shared DiffFiles * stack), and the session ops ride the mocked `changes.ops` poll — the event - * poll, the op fold and the badge cache all live in the tab. + * poll, the op fold and the badge cache all live in the tab. The Git Graph's + * commit selection turns that SAME pane into the tabbed bottom region (the + * `details` card + the diff), which the last describe covers. * * The copy assertions below pin the zh strings (the test environment's * navigator may be a real Node one with an en locale), so a bare substring @@ -14,10 +16,10 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { readFileSync } from 'node:fs' import { createElement } from 'react' import { createRoot, type Root } from 'react-dom/client' -import { act } from 'react-dom/test-utils' +import { act, Simulate } from 'react-dom/test-utils' import { ChangesTab, opCountOf } from '../src/client/changes/ChangesTab.tsx' import { createSidebarStore } from '../src/client/state.ts' -import { api, type GitStatusEntry, type GitStatusResult, type GitWorktree } from '../src/client/api.ts' +import { api, type GitGraphEntry, type GitStatusEntry, type GitStatusResult, type GitWorktree } from '../src/client/api.ts' import { t } from '../src/client/locales.ts' import type { Context } from '../src/context-types.ts' import type { SidebarTab } from '../src/client/state.ts' @@ -41,10 +43,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, @@ -55,6 +57,12 @@ function mount(root: Root, tab: SidebarTab = { id: 'git', type: 'git', title: 'C }) } +/** A tab context whose `betterSidebar.updateTab` is observable: the pane tab + * choice is persisted through it, exactly like `lens` / `previewH`. */ +function metaContext(updateTab: (id: string, patch: unknown, sessionId?: string) => void): Context { + return { get: (name: string) => (name === 'betterSidebar' ? { updateTab } : undefined) } as unknown as Context +} + function mockGit(entries: GitStatusEntry[]): void { vi.spyOn(api, 'gitWorktrees').mockResolvedValue([ { path: MAIN, branch: 'main', current: true, changes: entries.length }, @@ -77,6 +85,95 @@ async function flushEffects(): Promise { await act(async () => { await Promise.resolve() }) } +// ── The Git Graph fixtures driving the tabbed bottom region ─────────────── +/** A real 40-char SHA-1: the details card's chip renders the full hash while + * the row and the commit badge carry 7 chars, so the length itself is the + * evidence the card is the one on screen. */ +const GRAPH_HASH = 'a1'.repeat(20) +const GRAPH_SUBJECT = 'graph commit subject' +const GRAPH_MESSAGE = 'graph commit subject\n\n## Retry loop\n\n- bullet' +const COMMIT_DIFF = [ + 'diff --git a/src/a.ts b/src/a.ts', + '--- a/src/a.ts', + '+++ b/src/a.ts', + '@@ -1 +1 @@', + '-old line', + '+graph-only-diff-line', + '', +].join('\n') +const WORKTREE_DIFF = [ + 'diff --git a/src/a.ts b/src/a.ts', + '--- a/src/a.ts', + '+++ b/src/a.ts', + '@@ -1 +1 @@', + '-old line', + '+worktree-only-diff-line', + '', +].join('\n') + +function graphEntry(): GitGraphEntry { + return { + hash: GRAPH_HASH.slice(0, 7), + hashFull: GRAPH_HASH, + parents: [], + subject: GRAPH_SUBJECT, + author: 'Ada', + date: '2026-01-01', + refs: ['HEAD', 'origin/main', 'topic'], + message: GRAPH_MESSAGE, + } +} + +/** The graph page the graph lens loads, plus the commit patch its diff tab + * renders. `branches` carries the remote ref so the card's pill tones are + * observable end to end (the set is derived from this inventory). */ +function mockGraph(): void { + vi.spyOn(api, 'gitGraph').mockResolvedValue({ + isRepo: true, + root: MAIN, + entries: [graphEntry()], + branches: [ + { ref: 'refs/heads/main', name: 'main', hashFull: GRAPH_HASH }, + { ref: 'refs/remotes/origin/main', name: 'origin/main', hashFull: GRAPH_HASH }, + ], + hasMore: false, + snapshot: 'one', + }) + vi.spyOn(api, 'gitCommitDiff').mockResolvedValue({ diff: COMMIT_DIFF }) +} + +/** The open bottom pane's frame: the drag handle's parent (the pane root). */ +function paneOf(container: HTMLElement): HTMLElement { + const handle = container.querySelector('[role="separator"]') + expect(handle, 'the bottom pane frame is open').not.toBeNull() + return handle!.parentElement as HTMLElement +} + +/** The pane's OWN strip tabs. Scoped through the frame on purpose: the + * header's lens SegmentedControl is also a `role="tablist"`, so an unscoped + * query would let it satisfy the assertion. */ +function paneTabs(container: HTMLElement): HTMLButtonElement[] { + return [...paneOf(container).querySelectorAll('[role="tab"]')] +} + +/** The graph lens reports its selection one effect after the row click, and + * the first `onTargetChange` remounts it (its key carries the target), so a + * commit needs a couple of flushes to settle. */ +async function settle(): Promise { + await flushEffects() + await flushEffects() +} + +/** Switch to the graph lens and select its one commit. */ +async function openGraphCommit(container: HTMLElement): Promise { + await act(async () => { lensTab(container, t('changesGraphLens'))!.click() }) + await settle() + const row = container.querySelector(`[data-graph-commit="${GRAPH_HASH}"]`) + expect(row, 'the mocked graph page rendered its commit row').not.toBeNull() + await act(async () => { row!.click() }) + await settle() +} + beforeEach(() => { Object.defineProperty(globalThis.navigator, 'language', { value: 'zh-CN', configurable: true }) }) @@ -87,6 +184,69 @@ afterEach(() => { }) describe('ChangesTab', () => { + it('never sends the previous worktree when the graph follows a new session', async () => { + mockGit([]) + const graph = vi.spyOn(api, 'gitGraph').mockResolvedValue({ isRepo: true, root: MAIN, entries: [], branches: [], hasMore: false, snapshot: 'one' }) + const container = document.createElement('div'); document.body.append(container) + const root = createRoot(container) + try { + mount(root); await flushEffects() + await act(async () => { lensTab(container, t('changesGraphLens'))!.click() }) + expect(graph.mock.calls.at(-1)![2]).toBe(MAIN) + act(() => { root.render(createElement(ChangesTab, { + ctx: fakeContext(), store: createSidebarStore(), scope: { sessionId: 'new-session', cwd: '/other' }, + tab: { id: 'git', type: 'git', title: 'Changes' }, visible: true, + })) }) + await flushEffects() + const calls = graph.mock.calls.filter(call => call[0].sessionId === 'new-session') + expect(calls.length).toBeGreaterThan(0) + for (const call of calls) { expect(call[2]).toBeUndefined(); expect(call[0].repoRoot).toBeUndefined() } + } finally { act(() => { root.unmount() }); container.remove() } + }) + + it('retains per-session commit drafts across A→B→A through the changes shell', async () => { + mockGit([]) + const container = document.createElement('div'); document.body.append(container) + const root = createRoot(container) + const render = (sessionId: string) => act(() => { root.render(createElement(ChangesTab, { + ctx: fakeContext(), store: createSidebarStore(), scope: { sessionId, cwd: MAIN }, + tab: { id: 'git', type: 'git', title: 'Changes' }, visible: true, + })) }) + try { + render('A'); await flushEffects() + const draft = container.querySelector('textarea')! + act(() => { draft.value = 'Draft A'; Simulate.change(draft) }) + render('B'); await flushEffects() + expect(container.querySelector('textarea')!.value).toBe('') + render('A'); await flushEffects() + expect(container.querySelector('textarea')!.value).toBe('Draft A') + } finally { act(() => { root.unmount() }); container.remove() } + }) + + it('retains the Git commit draft while graph is visible and persists graph lens', async () => { + mockGit([]) + const graph = vi.spyOn(api, 'gitGraph').mockResolvedValue({ isRepo: true, root: MAIN, entries: [], branches: [], hasMore: false, snapshot: 'one' }) + const container = document.createElement('div') + document.body.append(container) + const root = createRoot(container) + try { + mount(root); await flushEffects() + expect(graph).not.toHaveBeenCalled() + const draft = container.querySelector('textarea')! + expect(draft).not.toBeNull() + act(() => { draft.value = 'Unsubmitted draft'; Simulate.change(draft) }) + const gitRoot = container.querySelector('[data-git-root]')! + await act(async () => { lensTab(container, t('changesGraphLens'))!.click() }) + expect(graph).toHaveBeenCalledTimes(1) + expect(gitRoot.isConnected).toBe(true) + expect(gitRoot.closest('[hidden]')).not.toBeNull() + await act(async () => { lensTab(container, t('changesGitLens'))!.click() }) + await flushEffects() + expect(container.querySelector('textarea')!.value).toBe('Unsubmitted draft') + expect(gitRoot.closest('[hidden]')).toBeNull() + } 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({ @@ -238,15 +398,83 @@ describe('ChangesTab', () => { expect(container.textContent).toContain('src/a.ts') const chips = [...container.querySelectorAll('button[aria-pressed]')] expect(chips.some(chip => /写入\s*2|Write\s*2/.test(chip.textContent ?? ''))).toBe(true) - // The git lens (its branch picker) is unmounted by the switch. - expect(container.querySelector('select')).toBeNull() + // Retained lenses preserve drafts/targets but every picker is hidden. + for (const picker of container.querySelectorAll('select')) { + expect(picker.closest('[hidden]')).not.toBeNull() + } } finally { act(() => { root.unmount() }) container.remove() } }) - it('renders a .md read op in reading mode through the shared MarkdownText', async () => { + it('keeps the pinned strip for op previews too: content renders the file, diff the patch', async () => { + mockGit([]) + mockGraph() + vi.spyOn(api, 'changesOps').mockResolvedValue({ + events: [ + { type: 'tool/call', seq: 1, time: 1, data: { name: 'write', callId: 'w1', arguments: JSON.stringify({ file_path: 'C:/repo/main/notes.md', content: '# Hello\n\nbody' }) } }, + { type: 'tool/result', seq: 2, time: 2, data: { message: { source: { kind: 'tool', callId: 'w1' }, content: [{ type: 'tool-result', content: [{ type: 'text', text: 'ok' }] }] } } }, + { type: 'tool/call', seq: 3, time: 3, data: { name: 'read', callId: 'r1', arguments: JSON.stringify({ file_path: 'C:/repo/main/plain.txt' }) } }, + { type: 'tool/result', seq: 4, time: 4, data: { message: { source: { kind: 'tool', callId: 'r1' }, content: [{ type: 'tool-result', content: [{ type: 'text', text: '\n1: alpha\n2: beta\n' }] }] } } }, + ], + lastSeq: 4, + }) + + const container = document.createElement('div') + document.body.append(container) + const root: Root = createRoot(container) + try { + mount(root) + await flushEffects() + // A graph selection arms the details view first. + await openGraphCommit(container) + + // Session lens, md WRITE op: the SAME three tabs, landing on the diff. + await act(async () => { lensTab(container, t('changesSessionLens'))!.click() }) + await settle() + // The op rows carry no path text — the path is the group label's title. + const opRow = (pathPart: string, kind: string): HTMLButtonElement => { + const label = [...container.querySelectorAll('div[title]')] + .find(el => el.getAttribute('title')?.includes(pathPart))! + return label.parentElement!.querySelector(`button[data-op-kind="${kind}"]`)! + } + await act(async () => { opRow('notes.md', 'write').click() }) + await settle() + expect(paneTabs(container).map(tab => tab.textContent)).toEqual([t('graphDetails'), t('changesContentTab'), t('changesDiffTab')]) + expect(paneTabs(container).map(tab => tab.getAttribute('aria-selected'))).toEqual(['false', 'false', 'true']) + // The diff view is the diff — the rendered document is NOT mixed into it. + // (The pane element is REPLACED on target switches — re-query, never + // hold a reference across a click.) + expect(paneOf(container).querySelector('h1')).toBeNull() + expect(paneOf(container).textContent).toContain('Hello') + // The content tab carries the rendered document (and the source toggle). + await act(async () => { paneTabs(container)[1]!.click() }) + await settle() + expect(paneOf(container).querySelector('h1')?.textContent).toContain('Hello') + + // A plain-text READ op: content is the source, and its diff view says a + // read has no diff instead of rendering an empty patch. + await act(async () => { opRow('plain.txt', 'read').click() }) + await settle() + expect(paneTabs(container).map(tab => tab.textContent)).toEqual([t('graphDetails'), t('changesContentTab'), t('changesDiffTab')]) + expect(paneTabs(container).map(tab => tab.getAttribute('aria-selected'))).toEqual(['false', 'true', 'false']) + expect(paneOf(container).textContent).toContain('alpha') + expect(paneOf(container).textContent).toContain('beta') + await act(async () => { paneTabs(container)[2]!.click() }) + await settle() + expect(paneOf(container).textContent).toContain(t('changesReadNoDiff')) + // The details card is still one tab away (the pane outlives lens switches). + await act(async () => { paneTabs(container)[0]!.click() }) + await settle() + expect(paneOf(container).querySelector(`section[aria-label="${t('graphDetails')}"]`)).not.toBeNull() + } finally { + act(() => { root.unmount() }) + container.remove() + } + }) + + it('renders a .md read op on the CONTENT tab — rendered first, source one toggle away', async () => { mockGit([]) const md = ['# Title', '', '| A | B |', '| --- | --- |', '| 1 | 2 |', '', '![pic](./img.png)', ''].join('\n') const numbered = md.split('\n').map((line, i) => String(i + 1) + ': ' + line).join('\n') @@ -266,7 +494,8 @@ describe('ChangesTab', () => { mount(root) await flushEffects() - // Session lens: open the read op's preview. + // Session lens: open the read op's preview. A read has no diff, so the + // pane's only view is `content` — no strip, no mixing into a diff view. const sessionTab = lensTab(container, t('changesSessionLens')) await act(async () => { sessionTab!.click() }) const row = container.querySelector('button[data-op-kind="read"]') @@ -275,24 +504,26 @@ describe('ChangesTab', () => { await act(async () => { row!.click() }) await flushEffects() - // Reading toggle: raw first (line-numbered rows), then rendered GFM. - const toggle = [...container.querySelectorAll('button')] - .find(button => (button.textContent ?? '').match(/阅读|Reading/)) - expect(toggle).toBeDefined() - expect(container.querySelector('h1')).toBeNull() - await act(async () => { toggle!.click() }) - await flushEffects() + // Rendered GFM immediately (the plugin's renderer is the point of the + // content tab) — no raw detour first. expect(container.querySelector('h1')?.textContent).toContain('Title') expect(container.querySelector('table')).not.toBeNull() // The local image destination was rewritten to the media route. const img = container.querySelector('img') expect(img?.getAttribute('src')).toContain('/sidebar/file?') - // Toggling back restores the raw line view. + // The source toggle lives on the content view; flipping it shows the + // line-numbered source, flipping back re-renders. const rawToggle = [...container.querySelectorAll('button')] .find(button => (button.textContent ?? '').match(/原文|Raw/)) + expect(rawToggle).toBeDefined() await act(async () => { rawToggle!.click() }) await flushEffects() expect(container.querySelector('h1')).toBeNull() + const readingToggle = [...container.querySelectorAll('button')] + .find(button => (button.textContent ?? '').match(/阅读|Reading/)) + await act(async () => { readingToggle!.click() }) + await flushEffects() + expect(container.querySelector('h1')?.textContent).toContain('Title') } finally { act(() => { root.unmount() }) container.remove() @@ -611,3 +842,290 @@ describe('ChangesTab', () => { } }) }) + +/** + * The bottom region's tab strip. The set is PINNED to the same three views for + * every preview and every lens — `details` (the selected commit), `content` + * (the file itself, rendered for md/html/pdf) and `diff` (the patch) — so the + * panel above which lens is active is always the same one; a view with nothing + * to show renders its empty state rather than vanishing. The choice persists + * as `meta.paneTab` beside `lens` / `previewH`. + */ +describe('ChangesTab bottom pane tabs', () => { + it('opens ONE pane whose tablist is the same [details, content, diff] everywhere, details active by default', async () => { + mockGit([]) + mockGraph() + + const container = document.createElement('div') + document.body.append(container) + const root: Root = createRoot(container) + try { + mount(root) + await flushEffects() + await openGraphCommit(container) + + // ONE region: a single drag handle, and the strip is its sibling INSIDE + // that same frame (the header's lens control is outside it). + expect(container.querySelectorAll('[role="separator"]')).toHaveLength(1) + const pane = paneOf(container) + expect(pane.children[0]!.getAttribute('role')).toBe('separator') + expect(pane.children[1]!.getAttribute('role')).toBe('tablist') + const tabs = paneTabs(container) + expect(tabs.map(tab => tab.textContent)).toEqual([t('graphDetails'), t('changesContentTab'), t('changesDiffTab')]) + // Details is the default for the FIRST graph selection; roving tabIndex + // makes it the only tab stop. + expect(tabs.map(tab => tab.getAttribute('aria-selected'))).toEqual(['true', 'false', 'false']) + expect(tabs.map(tab => tab.tabIndex)).toEqual([0, -1, -1]) + + // The card lives inside the pane frame, NOT inside the graph lens. + const details = pane.querySelector(`section[aria-label="${t('graphDetails')}"]`) + expect(details).not.toBeNull() + expect(container.querySelector('[data-git-graph]')!.contains(details!)).toBe(false) + expect(details!.querySelector('strong')!.textContent).toBe(GRAPH_SUBJECT) + // Full 40-char hash chip, and the message as MARKDOWN in its own block: + // the raw body's first line (the subject) was split off, so the body + // carries only the heading + the list — and never a duplicated title. + expect(details!.querySelector('code')!.textContent).toBe(GRAPH_HASH) + const body = details!.querySelector('[class*="messageBody"]')! + expect(body).not.toBeNull() + expect(body.querySelector('h2')!.textContent).toContain('Retry loop') + expect(body.querySelector('li')!.textContent).toContain('bullet') + expect(body.textContent).not.toContain(GRAPH_SUBJECT) + expect(details!.querySelector('pre')).toBeNull() + // The lens's remote inventory reached the card, so origin/main reads muted + // rather than local, and HEAD folded into the current branch's pill (the + // emphasised tone + the current marker) instead of a pill of its own. + const tones = [...details!.querySelectorAll('[data-tone]')] + expect(tones.map(pill => [pill.textContent, pill.getAttribute('data-tone'), pill.getAttribute('data-current')])).toEqual([ + ['origin/main', 'remote', null], + ['topic', 'head', 'true'], + ]) + } finally { + act(() => { root.unmount() }) + container.remove() + } + }) + + it('swaps the pane head/body for the active tab and restores the card on the way back', async () => { + mockGit([]) + mockGraph() + + const container = document.createElement('div') + document.body.append(container) + const root: Root = createRoot(container) + const detailsSelector = `section[aria-label="${t('graphDetails')}"]` + try { + mount(root) + await flushEffects() + await openGraphCommit(container) + expect(paneOf(container).querySelector(detailsSelector)).not.toBeNull() + + // The CONTENT tab of a commit target has no file to show: its empty + // state stands in rather than the tab disappearing. + await act(async () => { paneTabs(container)[1]!.click() }) + await settle() + expect(paneOf(container).querySelector(detailsSelector)).toBeNull() + expect(paneOf(container).textContent).toContain(t('changesNoContent')) + + // The diff tab renders the pane's OWN head and body for the commit. + await act(async () => { paneTabs(container)[2]!.click() }) + await settle() + const pane = paneOf(container) + expect(paneTabs(container).map(tab => tab.getAttribute('aria-selected'))).toEqual(['false', 'false', 'true']) + expect(pane.querySelector(detailsSelector)).toBeNull() + // The head carries the short hash + subject, the body the loaded patch. + expect(pane.textContent).toContain(GRAPH_SUBJECT) + expect(pane.textContent).toContain('graph-only-diff-line') + // The full hash is the details card's chip only. + expect(pane.textContent).not.toContain(GRAPH_HASH) + + // Back to details: the card returns, the diff body is gone. + await act(async () => { paneTabs(container)[0]!.click() }) + await settle() + expect(paneOf(container).querySelector(detailsSelector)).not.toBeNull() + expect(paneOf(container).textContent).not.toContain('graph-only-diff-line') + } finally { + act(() => { root.unmount() }) + container.remove() + } + }) + + it('shows the SAME pinned strip for a Git-lens file preview (content + diff, no commit selected)', async () => { + mockGit([{ path: 'src/a.ts', xy: ' M' }]) + vi.spyOn(api, 'gitDiff').mockResolvedValue({ diff: WORKTREE_DIFF }) + + const container = document.createElement('div') + document.body.append(container) + const root: Root = createRoot(container) + try { + mount(root) + await flushEffects() + const row = container.querySelector('button[data-path="src/a.ts"]')! + await act(async () => { row.click() }) + await flushEffects() + + expect(container.querySelectorAll('[role="separator"]')).toHaveLength(1) + const pane = paneOf(container) + // Same strip as everywhere else — the lens above does not change it. + expect(paneTabs(container).map(tab => tab.textContent)).toEqual([t('graphDetails'), t('changesContentTab'), t('changesDiffTab')]) + // …landing on the diff, because that is what clicking a file means. + expect(paneTabs(container).map(tab => tab.getAttribute('aria-selected'))).toEqual(['false', 'false', 'true']) + expect(pane.textContent).toContain('src/a.ts') + expect(pane.textContent).toContain('worktree-only-diff-line') + // With no commit selected the details view explains itself. + await act(async () => { paneTabs(container)[0]!.click() }) + await settle() + expect(paneOf(container).textContent).toContain(t('changesNoCommit')) + } finally { + act(() => { root.unmount() }) + container.remove() + } + }) + + it('renders the FILE ITSELF on the content tab of a git worktree target (fs.read, no diff)', async () => { + mockGit([{ path: 'src/notes.md', xy: ' M' }]) + vi.spyOn(api, 'gitDiff').mockResolvedValue({ diff: WORKTREE_DIFF }) + const read = vi.spyOn(api, 'fsRead').mockResolvedValue({ + kind: 'text', content: '# Live file\n\nbody line\n', size: 26, + }) + + const container = document.createElement('div') + document.body.append(container) + const root: Root = createRoot(container) + try { + mount(root) + await flushEffects() + const row = container.querySelector('button[data-path="src/notes.md"]')! + await act(async () => { row.click() }) + await flushEffects() + + // Opening the file for its DIFF must not pull the document: the content + // loader is deferred until that view is the one on screen. + expect(read).not.toHaveBeenCalled() + expect(paneOf(container).textContent).toContain('worktree-only-diff-line') + + // The content view reads the live file and renders markdown (the plugin + // renderer), not a diff and not a
.
+      await act(async () => { paneTabs(container)[1]!.click() })
+      await settle()
+      expect(read).toHaveBeenCalledTimes(1)
+      await settle()
+      const pane = paneOf(container)
+      expect(pane.querySelector('h1')?.textContent).toContain('Live file')
+      expect(pane.textContent).toContain('body line')
+      expect(pane.textContent).not.toContain('worktree-only-diff-line')
+    } finally {
+      act(() => { root.unmount() })
+      container.remove()
+    }
+  })
+
+  it('restores a persisted diff tab and writes the chosen tab back through the meta', async () => {
+    mockGit([])
+    mockGraph()
+    const updateTab = vi.fn()
+
+    const container = document.createElement('div')
+    document.body.append(container)
+    const root: Root = createRoot(container)
+    const detailsSelector = `section[aria-label="${t('graphDetails')}"]`
+    try {
+      mount(root, { id: 'git', type: 'git', title: 'Changes', meta: { paneTab: 'diff' } }, metaContext(updateTab))
+      await flushEffects()
+      await openGraphCommit(container)
+
+      // Restored, not re-defaulted to details.
+      expect(paneTabs(container).map(tab => tab.getAttribute('aria-selected'))).toEqual(['false', 'false', 'true'])
+      expect(paneOf(container).querySelector(detailsSelector)).toBeNull()
+      expect(paneOf(container).textContent).toContain('graph-only-diff-line')
+      // The only meta write so far is the lens switch, and it carried the
+      // restored `diff` — nothing re-defaulted the pane tab to `details`.
+      expect(updateTab.mock.calls.every(call =>
+        (call[1] as { meta: { paneTab?: string } }).meta.paneTab === 'diff')).toBe(true)
+
+      // Choosing a tab persists it beside lens / previewH, on the tab meta.
+      await act(async () => { paneTabs(container)[0]!.click() })
+      await settle()
+      expect(paneOf(container).querySelector(detailsSelector)).not.toBeNull()
+      expect(updateTab).toHaveBeenLastCalledWith('git', { meta: { paneTab: 'details' } }, 'session')
+    } finally {
+      act(() => { root.unmount() })
+      container.remove()
+    }
+  })
+
+  it('keeps the details tab when the lens switches — the bottom pane is ONE shared region', async () => {
+    mockGit([])
+    mockGraph()
+
+    const container = document.createElement('div')
+    document.body.append(container)
+    const root: Root = createRoot(container)
+    const detailsSelector = `section[aria-label="${t('graphDetails')}"]`
+    try {
+      mount(root)
+      await flushEffects()
+      await openGraphCommit(container)
+      expect(paneTabs(container)).toHaveLength(3)
+      expect(paneOf(container).querySelector(detailsSelector)).not.toBeNull()
+
+      // The pane below is independent of the lens above: switching to the
+      // session lens must NOT disarm the strip or drop the commit card — the
+      // selection lives until the graph itself loses the commit (or the tab
+      // goes away), not until the lens hides.
+      await act(async () => { lensTab(container, t('changesSessionLens'))!.click() })
+      await settle()
+      const pane = paneOf(container)
+      expect(pane.querySelector('[role="tablist"]')).not.toBeNull()
+      expect(paneTabs(container).map(tab => tab.textContent)).toEqual([t('graphDetails'), t('changesContentTab'), t('changesDiffTab')])
+      expect(pane.querySelector(detailsSelector)).not.toBeNull()
+      // The graph's own diff preview is still the diff tab's body.
+      await act(async () => { paneTabs(container)[2]!.click() })
+      await flushEffects()
+      expect(pane.textContent).toContain('graph-only-diff-line')
+      // … and the details card comes back without any graph round-trip.
+      await act(async () => { paneTabs(container)[0]!.click() })
+      await flushEffects()
+      expect(pane.querySelector(detailsSelector)).not.toBeNull()
+    } finally {
+      act(() => { root.unmount() })
+      container.remove()
+    }
+  })
+
+  it('moves the active tab with ArrowLeft / ArrowRight / Home / End', async () => {
+    mockGit([])
+    mockGraph()
+
+    const container = document.createElement('div')
+    document.body.append(container)
+    const root: Root = createRoot(container)
+    try {
+      mount(root)
+      await flushEffects()
+      await openGraphCommit(container)
+      const selected = (): (string | null)[] =>
+        paneTabs(container).map(tab => tab.getAttribute('aria-selected'))
+      const press = async (index: number, key: string): Promise => {
+        await act(async () => { Simulate.keyDown(paneTabs(container)[index]!, { key }) })
+      }
+      expect(selected()).toEqual(['true', 'false', 'false'])
+      await press(0, 'ArrowRight')
+      expect(selected()).toEqual(['false', 'true', 'false'])
+      await press(1, 'ArrowRight')
+      expect(selected()).toEqual(['false', 'false', 'true'])
+      await press(2, 'ArrowLeft')
+      expect(selected()).toEqual(['false', 'true', 'false'])
+      // End / Home jump to the last / first tab.
+      await press(1, 'End')
+      expect(selected()).toEqual(['false', 'false', 'true'])
+      await press(2, 'Home')
+      expect(selected()).toEqual(['true', 'false', 'false'])
+      // The roving tabIndex followed the selection all the way back.
+      expect(paneTabs(container).map(tab => tab.tabIndex)).toEqual([0, -1, -1])
+    } finally {
+      act(() => { root.unmount() })
+      container.remove()
+    }
+  })
+})
diff --git a/tests/git-graph-ui.spec.tsx b/tests/git-graph-ui.spec.tsx
new file mode 100644
index 00000000..1bff1b13
--- /dev/null
+++ b/tests/git-graph-ui.spec.tsx
@@ -0,0 +1,509 @@
+// @vitest-environment jsdom
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { createElement } from 'react'
+import { act } from 'react-dom/test-utils'
+import { api, SidebarApiError } from '../src/client/api.ts'
+import { CommitDetails, messageBodyOf } from '../src/client/changes/CommitDetails.tsx'
+import { GitGraphLens, type GitGraphLensProps } from '../src/client/changes/GitGraphLens.tsx'
+import { relativeTime, t } from '../src/client/locales.ts'
+import { renderRoot, setupReactAct } from './test-utils.ts'
+setupReactAct()
+const entry = (hashFull: string, parents: string[] = []) => ({ hash: hashFull.slice(0, 7), hashFull, parents, subject: `subject ${hashFull}`, author: 'Author', date: '2026-01-01', refs: ['main'], message: 'Full commit message' })
+const page = (hash = 'a', more = false) => ({ isRepo: true, root: '/repo', entries: [entry(hash)], branches: [{ ref: 'refs/heads/topic', name: 'topic', hashFull: hash }], hasMore: more, nextCursor: more ? 'opaque' : undefined, snapshot: 'snapshot' })
+const defaults: GitGraphLensProps = { scope: { sessionId: 'one', cwd: '/repo', repoRoot: '/repo' }, worktree: '/linked', visible: true, onPreview: () => {}, selectedRef: null }
+const flush = async () => { await act(async () => { await Promise.resolve() }) }
+function button(container: HTMLElement, text: string): HTMLButtonElement {
+  return [...container.querySelectorAll('button')].find(node => node.textContent === text)!
+}
+/** jsdom ships no IntersectionObserver, so the sentinel effect is inert there;
+ *  these tests install a fake one on globalThis and restore the saved value. */
+interface FakeObserver {
+  callback: IntersectionObserverCallback
+  options?: IntersectionObserverInit
+  targets: Element[]
+  disconnected: boolean
+}
+function installIntersectionObserver(): { observers: FakeObserver[]; restore: () => void } {
+  const original = (globalThis as Record).IntersectionObserver
+  const observers: FakeObserver[] = []
+  class FakeIntersectionObserver {
+    root: Element | Document | null = null
+    rootMargin = ''
+    thresholds: number[] = []
+    targets: Element[] = []
+    disconnected = false
+    constructor(public callback: IntersectionObserverCallback, public options?: IntersectionObserverInit) { observers.push(this) }
+    observe(target: Element): void { this.targets.push(target) }
+    unobserve(): void {}
+    disconnect(): void { this.disconnected = true }
+    takeRecords(): IntersectionObserverEntry[] { return [] }
+  }
+  ;(globalThis as Record).IntersectionObserver = FakeIntersectionObserver
+  return {
+    observers,
+    restore: () => {
+      if (original === undefined) delete (globalThis as Record).IntersectionObserver
+      else (globalThis as Record).IntersectionObserver = original
+    },
+  }
+}
+/** Deliver one intersection callback to `observer` the way the browser would. */
+const intersect = async (observer: FakeObserver, isIntersecting = true): Promise => {
+  await act(async () => {
+    observer.callback([{ isIntersecting } as IntersectionObserverEntry], observer as unknown as IntersectionObserver)
+  })
+}
+afterEach(() => { vi.restoreAllMocks(); vi.useRealTimers() })
+describe('read-only graph', () => {
+  it('loads only when visible and has no timer-driven requests', async () => {
+    vi.useFakeTimers()
+    const graph = vi.spyOn(api, 'gitGraph').mockResolvedValue(page())
+    const mounted = renderRoot(createElement(GitGraphLens, { ...defaults, visible: false }))
+    try {
+      await flush(); expect(graph).not.toHaveBeenCalled()
+      mounted.rerender(createElement(GitGraphLens, defaults)); await flush()
+      expect(graph).toHaveBeenCalledTimes(1)
+      await act(async () => { vi.advanceTimersByTime(120_000) })
+      expect(graph).toHaveBeenCalledTimes(1)
+    } finally { mounted.unmount() }
+  })
+  it('shows loading, error and retry rather than an empty-history lie', async () => {
+    let reject!: (reason: Error) => void
+    const graph = vi.spyOn(api, 'gitGraph').mockImplementationOnce(() => new Promise((_, no) => { reject = no })).mockResolvedValue(page())
+    const mounted = renderRoot(createElement(GitGraphLens, defaults))
+    try {
+      expect(mounted.container.textContent).toContain(t('loading'))
+      await act(async () => { reject(new Error('offline')) })
+      expect(mounted.container.textContent).toContain('offline')
+      expect(mounted.container.textContent).not.toContain(t('graphEmpty'))
+      await act(async () => { button(mounted.container, t('retry')).click() })
+      expect(graph).toHaveBeenCalledTimes(2)
+      expect(mounted.container.textContent).toContain('subject a')
+    } finally { mounted.unmount() }
+  })
+  it('filters full branch refs without checkout and pages with the opaque cursor', async () => {
+    const graph = vi.spyOn(api, 'gitGraph').mockResolvedValueOnce(page('a', true)).mockResolvedValueOnce(page('b')).mockResolvedValue(page('c'))
+    const checkout = vi.spyOn(api, 'gitCheckout')
+    const clear = vi.fn()
+    const preview = vi.fn()
+    const mounted = renderRoot(createElement(GitGraphLens, { ...defaults, onPreview: preview, onClearPreview: clear }))
+    try {
+      await flush()
+      await act(async () => { button(mounted.container, t('graphLoadMore')).click() })
+      expect(graph.mock.calls[1]![1]?.cursor).toBe('opaque')
+      expect(mounted.container.querySelectorAll('[data-graph-commit]')).toHaveLength(2)
+      await act(async () => { mounted.container.querySelector('[data-graph-commit]')!.click() })
+      expect(preview).toHaveBeenCalledWith(expect.objectContaining({ kind: 'commit', worktree: '/linked', repoRoot: '/repo', hashFull: 'a' }))
+      await act(async () => { const select = mounted.container.querySelector('select')!; select.value = 'refs/heads/topic'; select.dispatchEvent(new Event('change', { bubbles: true })) })
+      expect(clear).toHaveBeenCalled()
+      expect(graph.mock.calls.at(-1)![1]).toMatchObject({ branch: 'refs/heads/topic', cursor: undefined })
+      expect(checkout).not.toHaveBeenCalled()
+      expect(mounted.container.textContent).not.toContain('subject a')
+    } finally { mounted.unmount() }
+  })
+  it('aborts hidden and old-session requests and ignores late answers', async () => {
+    let resolve!: (value: ReturnType) => void
+    const graph = vi.spyOn(api, 'gitGraph').mockImplementationOnce(() => new Promise(yes => { resolve = yes })).mockResolvedValue(page('new'))
+    const mounted = renderRoot(createElement(GitGraphLens, defaults))
+    try {
+      const signal = graph.mock.calls[0]![3]!
+      mounted.rerender(createElement(GitGraphLens, { ...defaults, visible: false }))
+      expect(signal.aborted).toBe(true)
+      mounted.rerender(createElement(GitGraphLens, { ...defaults, scope: { sessionId: 'two', cwd: '/other' } }))
+      await flush()
+      await act(async () => { resolve(page('old')) })
+      expect(mounted.container.textContent).toContain('subject new')
+      expect(mounted.container.textContent).not.toContain('subject old')
+      expect(graph.mock.calls.at(-1)![0].sessionId).toBe('two')
+    } finally { mounted.unmount() }
+  })
+  it('cancels an old branch request even when its transport delivers late', async () => {
+    let resolve!: (value: ReturnType) => void
+    const graph = vi.spyOn(api, 'gitGraph').mockResolvedValueOnce(page('a')).mockImplementationOnce(() => new Promise(yes => { resolve = yes })).mockResolvedValue(page('all'))
+    const mounted = renderRoot(createElement(GitGraphLens, defaults))
+    try {
+      await flush()
+      const change = async (value: string) => act(async () => { const select = mounted.container.querySelector('select')!; select.value = value; select.dispatchEvent(new Event('change', { bubbles: true })) })
+      await change('refs/heads/topic')
+      const signal = graph.mock.calls[1]![3]!
+      await change('')
+      expect(signal.aborted).toBe(true)
+      await act(async () => { resolve(page('late-topic')) })
+      expect(mounted.container.textContent).toContain('subject all')
+      expect(mounted.container.textContent).not.toContain('late-topic')
+    } finally { mounted.unmount() }
+  })
+
+  it('clears an absent commit preview after refresh but preserves a surviving selection', async () => {
+    vi.spyOn(api, 'gitGraph').mockResolvedValueOnce(page('a')).mockResolvedValueOnce(page('a')).mockResolvedValueOnce(page('b'))
+    const clear = vi.fn()
+    const props: GitGraphLensProps = { ...defaults, onClearPreview: clear, selectedRef: { kind: 'commit', hash: 'a', hashFull: 'a', subject: 'subject a', repoRoot: '/repo', worktree: '/linked' } }
+    const mounted = renderRoot(createElement(GitGraphLens, props))
+    try {
+      await flush()
+      mounted.rerender(createElement(GitGraphLens, { ...props, refreshTick: 1 })); await flush()
+      expect(clear).not.toHaveBeenCalled()
+      mounted.rerender(createElement(GitGraphLens, { ...props, refreshTick: 2 })); await flush()
+      expect(clear).toHaveBeenCalledTimes(1)
+    } finally { mounted.unmount() }
+  })
+
+  it('refreshes from the beginning after a stale cursor', async () => {
+    const graph = vi.spyOn(api, 'gitGraph').mockResolvedValueOnce(page('a', true)).mockRejectedValueOnce(new SidebarApiError('graph-stale', 'changed')).mockResolvedValue(page('fresh'))
+    const mounted = renderRoot(createElement(GitGraphLens, defaults))
+    try {
+      await flush()
+      await act(async () => { button(mounted.container, t('graphLoadMore')).click() })
+      expect(mounted.container.textContent).toContain(t('graphStale'))
+      await act(async () => { button(mounted.container, t('retry')).click() })
+      expect(graph.mock.calls.at(-1)![1]?.cursor).toBeUndefined()
+      expect(mounted.container.textContent).not.toContain('subject a')
+    } finally { mounted.unmount() }
+  })
+})
+
+/** The restyle deleted the `graphReadOnly` copy key (and the toolbar hint the
+ *  select's tooltip used to carry) from every dictionary, so it can no longer
+ *  be read back through `t()` — the two released wordings are pinned literally
+ *  instead. zh is included because which one renders depends on the locale. */
+const REMOVED_READ_ONLY_HINTS = ['Filters only — never switches branches', '仅筛选,不切换分支']
+/** The merge note the details card used to carry (`graphFirstParent`) was
+ *  deleted from every dictionary, so it can no longer be read back through
+ *  `t()` — the two released wordings are pinned literally instead (zh is
+ *  included because which one would render depends on the locale). */
+const REMOVED_MERGE_NOTES = ['Merge diff compared with the first parent', '合并提交的差异与第一个父提交比较']
+/** Real 40-char SHA-1 shapes (git's own length): the details card's hash chip
+ *  renders the full hash while the row and the parent chips carry 7 chars, so a
+ *  fixture that is one char too long would let a truncation bug hide. */
+const HASH_A = 'aaaaaaa111111111111111111111111111111111'
+const HASH_B = 'bbbbbbb222222222222222222222222222222222'
+const HASH_C = 'ccccccc333333333333333333333333333333333'
+type GraphEntry = ReturnType
+type GraphPage = Awaited>
+/** `entry()` with the per-test refs (and optionally the parent list) filled in:
+ *  the shared fixture always answers `refs: ['main']`, while the tone and
+ *  colour cases need to control exactly which names a row carries. */
+const commit = (hashFull: string, refs: string[], parents: string[] = []): GraphEntry => ({ ...entry(hashFull, parents), refs })
+/** A page of hand-built rows; `page()` carries only one synthetic commit. */
+const graphPage = (entries: GraphEntry[], branches: GraphPage['branches'] = []): GraphPage => ({ isRepo: true, root: '/repo', entries, branches, hasMore: false, nextCursor: undefined, snapshot: 'snapshot' })
+const dialog = (): HTMLElement | null => document.body.querySelector('[role="dialog"]')
+
+describe('graph toolbar', () => {
+  it('carries ONLY the branch select — no hints, no legend, no extra actions', async () => {
+    // The legend was removed outright: a colour says "a different line", not
+    // "a unique branch" (lanes outlive the branches that opened them), so a
+    // colour legend answers a question nobody should be asking — the ref
+    // pills on the rows are the only branch key, the convention every graph
+    // tool shares. The three released wordings are pinned literally because
+    // the keys no longer exist to be read back through `t()`.
+    const REMOVED_LEGEND = ['Branch colors', '分支颜色说明', 'Colors follow the line, not the branch', '颜色跟随连线,不跟随分支', 'No branches loaded', '暂无分支']
+    vi.spyOn(api, 'gitGraph').mockResolvedValue(graphPage([], [{ ref: 'refs/heads/topic', name: 'topic', hashFull: HASH_A }]))
+    const mounted = renderRoot(createElement(GitGraphLens, defaults))
+    try {
+      await flush()
+      const select = mounted.container.querySelector(`select[aria-label="${t('graphBranchFilter')}"]`)!
+      expect(select).not.toBeNull()
+      expect([...select.options].map(option => option.textContent)).toEqual([t('graphAllBranches'), 'topic'])
+      const toolbar = select.parentElement!
+      // The select is the toolbar's ONLY interactive control — a re-added
+      // hint, legend trigger or action has to fail here.
+      expect([...toolbar.querySelectorAll('select, button, input, textarea, a[href], [role="button"]')]).toEqual([select])
+      for (const hint of REMOVED_READ_ONLY_HINTS) expect(mounted.container.textContent).not.toContain(hint)
+      for (const wording of REMOVED_LEGEND) expect(mounted.container.textContent).not.toContain(wording)
+      // The old select tooltip carried the removed read-only copy.
+      expect(select.getAttribute('title')).toBeNull()
+      // Nothing in the lens opens a floating card on hover any more …
+      await act(async () => { toolbar.dispatchEvent(new MouseEvent('mouseover', { bubbles: true, relatedTarget: null })) })
+      expect(dialog()).toBeNull()
+    } finally { mounted.unmount() }
+  })
+
+  it('still reports an empty repository without any legend affordance', async () => {
+    vi.spyOn(api, 'gitGraph').mockResolvedValue(graphPage([]))
+    const mounted = renderRoot(createElement(GitGraphLens, defaults))
+    try {
+      await flush()
+      expect(mounted.container.textContent).toContain(t('graphEmpty'))
+      expect(mounted.container.querySelector('button')).toBeNull()
+    } finally { mounted.unmount() }
+  })
+
+  it('folds HEAD into the current branch pill and tones remotes apart from locals', async () => {
+    // Entries carry the SHORT names the component renders; only the branch
+    // inventory holds the full refs, and it is what marks a name as remote.
+    const branches = [
+      { ref: 'refs/heads/topic', name: 'topic', hashFull: HASH_A },
+      { ref: 'refs/remotes/origin/main', name: 'origin/main', hashFull: HASH_A },
+    ]
+    const rows = [
+      commit(HASH_A, ['HEAD', 'origin/main', 'topic']),
+      // A DETACHED head has no local branch to fold into: only then does the
+      // HEAD pill render standalone, still carrying the current marker.
+      commit(HASH_B, ['HEAD', 'origin/main'], [HASH_A]),
+    ]
+    vi.spyOn(api, 'gitGraph').mockResolvedValue(graphPage(rows, branches))
+    const mounted = renderRoot(createElement(GitGraphLens, defaults))
+    try {
+      await flush()
+      const row = mounted.container.querySelector(`[data-graph-commit="${HASH_A}"]`)!
+      const pills = [...row.querySelectorAll('[data-tone]')]
+      // `data-tone` is the component's paint contract (graph.module.css maps
+      // remote to the muted rung and head to the emphasised one) — jsdom loads
+      // no stylesheet, so the tone attribute is what a spec can observe.
+      expect(pills.map(pill => [pill.textContent, pill.getAttribute('data-tone'), pill.getAttribute('data-current')])).toEqual([
+        ['origin/main', 'remote', null],
+        ['topic', 'head', 'true'],
+      ])
+      // The current branch's pill carries TWO glyphs — the check, then the
+      // branch icon; a remote pill carries just the globe. Both wear the
+      // row's lane colour (slot 0 on the first tip, slot 1 on the second).
+      expect(pills[1]!.querySelectorAll('svg')).toHaveLength(2)
+      expect(pills[0]!.querySelectorAll('svg')).toHaveLength(1)
+      expect(pills.map(pill => pill.getAttribute('data-color'))).toEqual(['0', '0'])
+      const detached = mounted.container.querySelector(`[data-graph-commit="${HASH_B}"]`)!
+      const detachedPills = [...detached.querySelectorAll('[data-tone]')]
+      expect(detachedPills.map(pill => [pill.textContent, pill.getAttribute('data-tone'), pill.getAttribute('data-current')])).toEqual([
+        ['HEAD', 'head', 'true'],
+        ['origin/main', 'remote', null],
+      ])
+      expect(detachedPills.map(pill => pill.getAttribute('data-color'))).toEqual(['1', '1'])
+    } finally { mounted.unmount() }
+  })
+})
+
+describe('graph commit rows and details', () => {
+  it('lays a commit row out as ONE line: rail, ref pills, then the subject', async () => {
+    // The GitLens-style picture: no hash chip and no author·time on the row —
+    // those live in the details card and the hover card (tested below), which
+    // is also why the row carries NO native tooltip any more.
+    const date = new Date(Date.now() - 5.5 * 60_000).toISOString()
+    const row = { ...entry(HASH_A), subject: 'Fix the flaky test', author: 'Ada Lovelace', date, refs: ['main'] }
+    vi.spyOn(api, 'gitGraph').mockResolvedValue(graphPage([row]))
+    const mounted = renderRoot(createElement(GitGraphLens, defaults))
+    try {
+      await flush()
+      const rowNode = mounted.container.querySelector(`[data-graph-commit="${HASH_A}"]`)!
+      // Exactly three cells on one line: the rail svg, the pills, the subject.
+      expect(rowNode.children).toHaveLength(3)
+      expect(rowNode.children[0]!.tagName.toLowerCase()).toBe('svg')
+      const pills = [...rowNode.querySelectorAll('[data-tone]')]
+      expect(pills.map(pill => [pill.textContent, pill.getAttribute('data-tone')])).toEqual([['main', 'local']])
+      expect(pills[0]!.querySelectorAll('svg')).toHaveLength(1)
+      const subject = rowNode.children[2] as HTMLElement
+      expect(subject.textContent).toBe('Fix the flaky test')
+      expect(subject.className).toContain('subject')
+      // The row says nothing about hash or author any more …
+      expect(rowNode.textContent).not.toContain(HASH_A.slice(0, 7))
+      expect(rowNode.textContent).not.toContain('Ada Lovelace')
+      expect(rowNode.textContent).not.toContain(relativeTime(date))
+      // … and the browser's own tooltip is gone: the hover card replaced it.
+      expect(rowNode.getAttribute('title')).toBeNull()
+    } finally { mounted.unmount() }
+  })
+
+  it('opens a medium-density hover card after a dwell and closes it on leave', async () => {
+    // The information ladder: row < hover card < details card. The card shows
+    // the author, both times and the SHORT hash — never the full one, which
+    // belongs to the details pane alone.
+    vi.useFakeTimers()
+    const date = new Date(Date.now() - 5.5 * 60_000).toISOString()
+    const row = { ...entry(HASH_A), subject: 'Fix the flaky test', author: 'Ada Lovelace', date, refs: ['main'] }
+    vi.spyOn(api, 'gitGraph').mockResolvedValue(graphPage([row]))
+    const mounted = renderRoot(createElement(GitGraphLens, defaults))
+    try {
+      await flush()
+      const rowNode = mounted.container.querySelector(`[data-graph-commit="${HASH_A}"]`)!
+      // A passing pointer opens nothing: the dwell has to elapse first.
+      await act(async () => { rowNode.dispatchEvent(new MouseEvent('mouseover', { bubbles: true })) })
+      await act(async () => { vi.advanceTimersByTime(349) })
+      expect(dialog()).toBeNull()
+      await act(async () => { vi.advanceTimersByTime(1) })
+      const card = dialog()
+      expect(card).not.toBeNull()
+      expect(card!.textContent).toContain('Fix the flaky test')
+      expect(card!.textContent).toContain('Ada Lovelace')
+      expect(card!.textContent).toContain(relativeTime(date))
+      expect(card!.textContent).toContain(HASH_A.slice(0, 7))
+      expect(card!.textContent).not.toContain(HASH_A)
+      // The pill inside the card wears the row's lane colour.
+      const pill = card!.querySelector('[data-tone]')!
+      expect(pill.textContent).toBe('main')
+      expect(pill.getAttribute('data-color')).toBe(rowNode.querySelector('circle')!.getAttribute('data-color'))
+      // Leaving the row closes the card.
+      await act(async () => { rowNode.dispatchEvent(new MouseEvent('mouseout', { bubbles: true })) })
+      expect(dialog()).toBeNull()
+    } finally { mounted.unmount() }
+  })
+
+  it('renders the commit card for a single-parent commit with a markdown body and no merge note', async () => {
+    // The card moved out of the lens into `CommitDetails` (the changes tab now
+    // hosts it in its bottom pane's `details` tab), so it is asserted where it
+    // lives: rendered directly with the graph page's entry for the selection.
+    // `renderRoot` keeps the div-detached cycle; nothing here fetches.
+    const message = 'Fix the flaky test\n\n## Retry loop\n\n- bullet'
+    const selected = { ...entry(HASH_A, [HASH_B]), subject: 'Fix the flaky test', author: 'Ada Lovelace', message }
+    const mounted = renderRoot(createElement(CommitDetails, { entry: selected }))
+    try {
+      const details = mounted.container.querySelector(`section[aria-label="${t('graphDetails')}"]`)!
+      expect(details).not.toBeNull()
+      // The header is the section's accessible name only: the pane's tab
+      // already says "commit details", so the card draws no band repeating it.
+      expect(details.getAttribute('aria-label')).toBe(t('graphDetails'))
+      expect(details.textContent).not.toContain(t('graphDetails'))
+      expect(details.querySelector('strong')!.textContent).toBe('Fix the flaky test')
+      const codes = [...details.querySelectorAll('code')]
+      // The hash chip is the FULL 40-char hash, not the row's 7-char label.
+      const chip = codes.find(code => code.getAttribute('title') === null)!
+      expect(chip.textContent).toBe(HASH_A)
+      expect(chip.textContent).toHaveLength(40)
+      // Parent chips are truncated to 7 chars, the full hash riding the title.
+      const parents = codes.filter(code => code.getAttribute('title') !== null)
+      expect(parents.map(code => [code.textContent, code.getAttribute('title')])).toEqual([[HASH_B.slice(0, 7), HASH_B]])
+      // The message renders as MARKDOWN in its own block — a heading and a list,
+      // not a 
. The raw body's first line is the subject the title above
+      // already shows, so the split dropped it: the card never duplicates it.
+      const body = details.querySelector('[class*="messageBody"]')!
+      expect(body).not.toBeNull()
+      expect(body.querySelector('h2')!.textContent).toContain('Retry loop')
+      expect(body.querySelector('li')!.textContent).toContain('bullet')
+      expect(body.textContent).not.toContain('Fix the flaky test')
+      expect(details.querySelector('pre')).toBeNull()
+      // One parent only — no first-parent note, and its copy is gone entirely.
+      expect(details.querySelector('[class*="hint"]')).toBeNull()
+      for (const note of REMOVED_MERGE_NOTES) expect(details.textContent).not.toContain(note)
+    } finally { mounted.unmount() }
+  })
+
+  it("shows the merge commit's parents and no explanatory note", async () => {
+    const merge = { ...entry(HASH_A, [HASH_B, HASH_C]), subject: 'Merge topic', message: 'Merge topic\n\nMerge branch topic' }
+    const mounted = renderRoot(createElement(CommitDetails, { entry: merge }))
+    try {
+      const details = mounted.container.querySelector(`section[aria-label="${t('graphDetails')}"]`)!
+      const parents = [...details.querySelectorAll('code[title]')]
+      expect(parents.map(code => code.getAttribute('title'))).toEqual([HASH_B, HASH_C])
+      expect(parents.map(code => code.textContent)).toEqual([HASH_B.slice(0, 7), HASH_C.slice(0, 7)])
+      // The parents are all the card says about a merge: the old first-parent
+      // hint line is gone, so no hint element and none of the released
+      // wordings can reappear.
+      expect(details.querySelector('[class*="hint"]')).toBeNull()
+      for (const note of REMOVED_MERGE_NOTES) expect(details.textContent).not.toContain(note)
+    } finally { mounted.unmount() }
+  })
+
+  it('splits the raw body on a first line equal to the subject, else renders it whole', async () => {
+    // (a) `git log %B` repeats the subject as its first line: the card shows
+    // that line once (as its title), so the body must drop it.
+    const withSubjectLine = { ...entry(HASH_A), subject: 'Fix the flaky test', message: 'Fix the flaky test\n\n## Retry loop\n\n- bullet' }
+    expect(messageBodyOf(withSubjectLine)).toBe('## Retry loop\n\n- bullet')
+    // (b) A first line that is NOT the subject is real content and survives
+    // whole — dropping it would silently lose a line.
+    const withOwnHeadline = { ...entry(HASH_B), subject: 'Rename helper', message: '# Old title\n\n- kept line' }
+    expect(messageBodyOf(withOwnHeadline)).toBe('# Old title\n\n- kept line')
+    // (c) Nothing left after the split → the card renders no message block.
+    const subjectOnly = { ...entry(HASH_C), subject: 'Only a subject', message: 'Only a subject' }
+    expect(messageBodyOf(subjectOnly)).toBe('')
+
+    // The split is what the DOM renders: branch (b) keeps its own headline as
+    // a heading, branch (c) renders no block at all.
+    const mounted = renderRoot(createElement('div', null,
+      createElement(CommitDetails, { entry: withOwnHeadline }),
+      createElement(CommitDetails, { entry: subjectOnly }),
+    ))
+    try {
+      const [kept, empty] = [...mounted.container.querySelectorAll('section')]
+      expect(kept!.querySelector('h1')!.textContent).toContain('Old title')
+      expect(kept!.querySelector('li')!.textContent).toContain('kept line')
+      expect(empty!.querySelector('[class*="messageBody"]')).toBeNull()
+    } finally { mounted.unmount() }
+  })
+
+  it('tones the card\'s pills the same way the rows do, HEAD folded into the current branch', async () => {
+    // The lens owns the branch inventory that tells a remote name apart from a
+    // local one; the card can only paint it because the selection carries the
+    // set. Rendering the same entry WITHOUT `remotes` flips `origin/main` to
+    // `local`, so the assertion pins the prop is really consumed.
+    const selected = commit(HASH_A, ['HEAD', 'origin/main', 'topic'])
+    const mounted = renderRoot(createElement(CommitDetails, {
+      entry: selected, remotes: new Set(['origin/main']), slot: 3,
+    }))
+    try {
+      const details = mounted.container.querySelector(`section[aria-label="${t('graphDetails')}"]`)!
+      const pills = [...details.querySelectorAll('[data-tone]')]
+      expect(pills.map(pill => [pill.textContent, pill.getAttribute('data-tone'), pill.getAttribute('data-current')])).toEqual([
+        ['origin/main', 'remote', null],
+        ['topic', 'head', 'true'],
+      ])
+      // The current branch's pill opens with the check glyph, and the pills
+      // wear the lane colour the lens reported for the selected row.
+      expect(pills[1]!.querySelectorAll('svg')).toHaveLength(2)
+      expect(pills.map(pill => pill.getAttribute('data-color'))).toEqual(['3', '3'])
+    } finally { mounted.unmount() }
+  })
+})
+
+describe('graph end-sentinel auto-load', () => {
+  it('appends one page with the opaque cursor when the sentinel intersects', async () => {
+    const graph = vi.spyOn(api, 'gitGraph').mockResolvedValueOnce(page('a', true)).mockResolvedValue(page('b'))
+    const io = installIntersectionObserver()
+    const mounted = renderRoot(createElement(GitGraphLens, defaults))
+    try {
+      await flush()
+      const observer = io.observers[0]!
+      const sentinel = mounted.container.querySelector('[data-graph-sentinel]')
+      expect(sentinel).not.toBeNull()
+      expect(observer.targets).toEqual([sentinel])
+      expect(observer.options?.root).toBe(mounted.container.querySelector('[aria-busy]'))
+      expect(observer.options?.rootMargin).toBe('200px')
+      await intersect(observer)
+      await flush()
+      expect(graph).toHaveBeenCalledTimes(2)
+      expect(graph.mock.calls[1]![1]?.cursor).toBe('opaque')
+      expect(mounted.container.querySelectorAll('[data-graph-commit]')).toHaveLength(2)
+      expect(mounted.container.textContent).toContain('subject b')
+    } finally { mounted.unmount(); io.restore() }
+  })
+  it('ignores a second intersection while an append is already in flight', async () => {
+    let resolveAppend!: (value: ReturnType) => void
+    const graph = vi.spyOn(api, 'gitGraph').mockResolvedValueOnce(page('a', true)).mockImplementationOnce(() => new Promise(yes => { resolveAppend = yes })).mockResolvedValue(page('c'))
+    const io = installIntersectionObserver()
+    const mounted = renderRoot(createElement(GitGraphLens, defaults))
+    try {
+      await flush()
+      const observer = io.observers[0]!
+      await intersect(observer)
+      await flush()
+      expect(graph).toHaveBeenCalledTimes(2)
+      await intersect(observer)
+      await flush()
+      expect(graph).toHaveBeenCalledTimes(2)
+      await act(async () => { resolveAppend(page('b')) })
+      await flush()
+      expect(graph.mock.calls.map(call => call[1]?.cursor)).toEqual([undefined, 'opaque'])
+      expect(mounted.container.querySelectorAll('[data-graph-commit]')).toHaveLength(2)
+    } finally { mounted.unmount(); io.restore() }
+  })
+  it('never arms auto-load without a next page or while the lens is hidden', async () => {
+    const graph = vi.spyOn(api, 'gitGraph').mockResolvedValueOnce(page('a')).mockResolvedValueOnce(page('b', true)).mockResolvedValue(page('c'))
+    const io = installIntersectionObserver()
+    const exhausted = renderRoot(createElement(GitGraphLens, defaults))
+    try {
+      await flush()
+      expect(graph).toHaveBeenCalledTimes(1)
+      expect(exhausted.container.querySelector('[data-graph-sentinel]')).toBeNull()
+      expect(io.observers).toHaveLength(0)
+    } finally { exhausted.unmount() }
+    const hidden = renderRoot(createElement(GitGraphLens, defaults))
+    try {
+      await flush()
+      expect(io.observers).toHaveLength(1)
+      hidden.rerender(createElement(GitGraphLens, { ...defaults, visible: false }))
+      await flush()
+      expect(io.observers).toHaveLength(1)
+      expect(io.observers[0]!.disconnected).toBe(true)
+      await intersect(io.observers[0]!)
+      await flush()
+      expect(graph).toHaveBeenCalledTimes(2)
+      expect(graph.mock.calls.every(call => call[1]?.cursor === undefined)).toBe(true)
+    } finally { hidden.unmount(); io.restore() }
+  })
+})
diff --git a/tests/markdown-surface.spec.tsx b/tests/markdown-surface.spec.tsx
index c37ed3f9..444a15cb 100644
--- a/tests/markdown-surface.spec.tsx
+++ b/tests/markdown-surface.spec.tsx
@@ -136,11 +136,8 @@ function mountReadingPane(path: string, markdown: string, sessionId: string = ne
     onClose: () => {},
     onExpand: () => {},
   }))
-  // Reading mode is off by default: the raw diff is what a change shows first.
-  const toggle = [...mounted.container.querySelectorAll('button')]
-    .find(button => button.textContent === 'Reading')
-  if (toggle === undefined) throw new Error('reading toggle not found')
-  click(toggle)
+  // The pane's content tab renders markdown by default (the reading view IS
+  // the content view now) — no toggle click needed to reach the surface.
   return { container: mounted.container, tabs, unmount: mounted.unmount }
 }