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 / legend-row.tsx
38 lines · 1.1 KBRaw
1/* @jsxRuntime classic */
2/* @jsx h */
3/* @jsxFrag Fragment */
4import type { RenderElement } from 'claude-code'
5
6import type Entries from '../entries'
7import type { Kit } from '../kit'
8import Layout from '../layout'
9import { diffStat } from './diff-stat'
10import { PATH_FLOOR } from './path-floor'
11import { STAT_CELLS } from './stat-cells'
12
13/**
14 * One row of the open pre-session section's legend (PreSessionSection): the
15 * file's dim name cut from its start, its counts at the right; no press.
16 *
17 * @param kit the elements and the width
18 * @param entry the pre-session file
19 * @returns the row
20 */
21export function legendRow(kit: Kit, entry: Entries.BodyEntry): RenderElement {
22 const { Box, Text } = kit.ui
23
24 return (
25 <Box flexDirection="row">
26 {[
27 <Text dimColor wrap="truncate-end">
28 {Layout.truncateStart(
29 Layout.sanitizeName(entry.displayPath),
30 Math.max(kit.columns - STAT_CELLS, PATH_FLOOR),
31 )}
32 </Text>,
33 <Box flexGrow={1} />,
34 diffStat(kit, entry.added, entry.removed),
35 ]}
36 </Box>
37 )
38}