**图谱视图**(`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 链接认领)。
92 lines
4.4 KiB
TypeScript
92 lines
4.4 KiB
TypeScript
/**
|
|
* 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 `<pre>`.
|
|
*/
|
|
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<string>
|
|
/** 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<string>(), 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 <section className={css.details} aria-label={t('graphDetails')}>
|
|
<strong className={css.detailSubject}>{entry.subject}</strong>
|
|
<div className={css.metaRow}>
|
|
<span className={css.metaGlyph} aria-hidden="true"><IconUserOutlineRegular size={12} /></span>
|
|
<span className={css.metaValue}>{entry.author}</span>
|
|
</div>
|
|
<div className={css.metaRow}>
|
|
<span className={css.metaGlyph} aria-hidden="true"><IconClockOutlineRegular size={12} /></span>
|
|
<span className={css.metaValue}>{relativeTime(entry.date)} · {entry.date}</span>
|
|
</div>
|
|
<div className={css.metaRow}>
|
|
<code className={css.hashChip}>{entry.hashFull}</code>
|
|
<IconButton size="sm" icon={<IconCopyOutlineRegular size={14} />} label={t('copyFullHash')}
|
|
onClick={() => { void writeClipboard(entry.hashFull) }} />
|
|
</div>
|
|
<div className={css.metaRow}>
|
|
<span className={css.metaLabel}>{t('graphParents')}</span>
|
|
<span className={css.parents}>
|
|
{entry.parents.length === 0
|
|
? <span className={css.dash}>—</span>
|
|
: entry.parents.map(parent => <code key={parent} className={css.parentChip}
|
|
title={parent}>{parent.slice(0, 7)}</code>)} </span>
|
|
</div>
|
|
{entry.refs.length > 0 && <div className={css.detailRefs}>
|
|
{refPills(entry.refs, remotes).map(pill => <RefPill key={pill.name} pill={pill} slot={slot} />)}
|
|
</div>}
|
|
{body !== '' && <div className={css.messageBody}>
|
|
<MarkdownText {...markdownTextProps(body, labels)} />
|
|
</div>}
|
|
</section>
|
|
} |