/** * 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 !== '' &&
}
}