spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / diff / hooks / views / sections / header-view.tsx
43 lines · 1.2 KBRaw
1/* @jsxRuntime classic */
2/* @jsx h */
3/* @jsxFrag Fragment */
4import type { RenderElement } from 'claude-code'
5
6import type PaneState from '../../pane-state'
7import type { Kit } from '../kit'
8import Layout from '../layout'
9import { diffStat } from './diff-stat'
10
11/**
12 * The pane's first line: `N files changed +A -R`, or the empty headline in
13 * its place when there is nothing to count (ReplDiffSidebar's header).
14 *
15 * The headline may name a branch the repository chose, so it is drawn as
16 * a name: no control or format character survives.
17 *
18 * @param kit the drawing's kit; its elements draw the line
19 * @param headline the empty headline, or null to draw the counts
20 * @param totals the header's counts
21 * @returns the line
22 */
23export function headerView(
24 kit: Kit,
25 headline: string | null,
26 totals: PaneState.HeaderTotals,
27): RenderElement {
28 const { Text } = kit.ui
29 const empty = (
30 <Text dimColor wrap="truncate-end">
31 {Layout.sanitizeName(headline ?? '')}
32 </Text>
33 )
34 const counts = (
35 <Text wrap="truncate-end">
36 <Text bold>{Layout.plural(totals.filesCount, 'file')}</Text>
37 {' changed '}
38 {diffStat(kit, totals.linesAdded, totals.linesRemoved)}
39 </Text>
40 )
41
42 return headline === null ? counts : empty
43}