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
44 lines · 1.4 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'
10import { present } from './present'
11
12/**
13 * The pane's first line (ReplDiffSidebar's header row): `N files changed
14 * +A -R`, nothing over an empty state, and the pickers at its right edge.
15 *
16 * The pickers sit where the built-in draws its close mark, so every row
17 * below lands where the built-in's does; this pane's mark is the engine's.
18 *
19 * @param kit the drawing's kit; its elements draw the line
20 * @param totals the header's counts, or null when there is nothing to count
21 * @param controls the pickers (Sections.controlsView), or null for none
22 * @returns the line
23 */
24export function headerView(
25 kit: Kit,
26 totals: PaneState.HeaderTotals | null,
27 controls: RenderElement | null,
28): RenderElement {
29 const { Box, Text } = kit.ui
30
31 const countOf = (counted: PaneState.HeaderTotals): RenderElement => (
32 <Text wrap="truncate-end">
33 <Text bold>{Layout.plural(counted.filesCount, 'file')}</Text>
34 {' changed '}
35 {diffStat(kit, counted.linesAdded, counted.linesRemoved)}
36 </Text>
37 )
38
39 return (
40 <Box flexDirection="row" height={1}>
41 {present([totals && countOf(totals), <Box flexGrow={1} />, controls])}
42 </Box>
43 )
44}