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
45 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 { closeButton } from './close-button'
10import { diffStat } from './diff-stat'
11
12/**
13 * The pane's first line (ReplDiffSidebar's header row): `N files changed
14 * +A -R`, or nothing over an empty state.
15 *
16 * The close `✕` sits at the right edge either way.
17 *
18 * @param kit the drawing's kit; its elements draw the line
19 * @param totals the header's counts, or null when there is nothing to count
20 * @returns the line
21 */
22export function headerView(
23 kit: Kit,
24 totals: PaneState.HeaderTotals | null,
25): RenderElement {
26 const { Box, Text } = kit.ui
27
28 return (
29 <Box flexDirection="row">
30 {[
31 ...(totals
32 ? [
33 <Text wrap="truncate-end">
34 <Text bold>{Layout.plural(totals.filesCount, 'file')}</Text>
35 {' changed '}
36 {diffStat(kit, totals.linesAdded, totals.linesRemoved)}
37 </Text>,
38 ]
39 : []),
40 <Box flexGrow={1} />,
41 closeButton(kit),
42 ]}
43 </Box>
44 )
45}