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
| 1 | /* @jsxRuntime classic */ |
| 2 | /* @jsx h */ |
| 3 | /* @jsxFrag Fragment */ |
| 4 | import type { RenderElement } from 'claude-code' |
| 5 | |
| 6 | import type { Kit } from '../../kit' |
| 7 | import Layout from '../../layout' |
| 8 | import { diffStat } from '../diff-stat' |
| 9 | import type { FileRowModel } from '../file-row-model' |
| 10 | import { POINTER } from '../pointer' |
| 11 | import { STAT_CELLS } from '../stat-cells' |
| 12 | |
| 13 | /** |
| 14 | * One file of the list (ReplDiffSidebar FileSummaryRow): a plain Button |
| 15 | * with the start-truncated path, its counts or note at the right. |
| 16 | * |
| 17 | * The pointer marks the selected one. |
| 18 | * |
| 19 | * @param kit the elements, the handlers, the width |
| 20 | * @param row the file |
| 21 | * @param onPress selects the file |
| 22 | * @returns the row element |
| 23 | */ |
| 24 | export function fileRow( |
| 25 | kit: Kit, |
| 26 | row: FileRowModel, |
| 27 | onPress: () => void, |
| 28 | ): RenderElement { |
| 29 | const { Box, Text, Button } = kit.ui |
| 30 | const room = Math.max(kit.columns - STAT_CELLS, STAT_CELLS) |
| 31 | const mark = row.isSelected ? POINTER : ' ' |
| 32 | |
| 33 | const note = ( |
| 34 | <Text dimColor italic> |
| 35 | {row.note ?? ''} |
| 36 | </Text> |
| 37 | ) |
| 38 | |
| 39 | const hasNote = row.note !== null |
| 40 | const tail = hasNote ? note : diffStat(kit, row.added, row.removed) |
| 41 | |
| 42 | return ( |
| 43 | <Box flexDirection="row"> |
| 44 | <Button key={row.key} plain onPress={onPress}> |
| 45 | {`${mark} ${Layout.truncateStart(Layout.sanitizeName(row.path), room)}`} |
| 46 | </Button> |
| 47 | <Box flexGrow={1} /> |
| 48 | {tail} |
| 49 | </Box> |
| 50 | ) |
| 51 | } |