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