feat(git-graph): 图谱视图与统一的底部面板(详情 / 内容 / 差异)

**图谱视图**(`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 链接认领)。
This commit is contained in:
vlln committed 2026-10-15 20:44:33 -07:00
1 parent ff373c81ed
commit a64f5cd8e9
30 files changed
+2357 -237

No files matched your search

+33 -2
View File
@@ -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