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 Detail from '../../detail' |
| 7 | import type { Kit } from '../../kit' |
| 8 | import Layout from '../../layout' |
| 9 | import { askKeyOf } from '../ask-key-of' |
| 10 | |
| 11 | /** |
| 12 | * A file's name row over its body (DiffDetailView's first line): the bold |
| 13 | * name cut from its start, its asides in dim, and its ask Button. |
| 14 | * |
| 15 | * The Button reads `asked ✓` while the file is armed; a file with no hunks |
| 16 | * to attach (a placeholder body) has none. |
| 17 | * |
| 18 | * @param kit the elements, the handlers, the width |
| 19 | * @param name the file, with whether it is truncated, armed and askable |
| 20 | * @returns the row |
| 21 | */ |
| 22 | export function nameRow(kit: Kit, name: Detail.NamedDetail): RenderElement { |
| 23 | const { Box, Text, Button } = kit.ui |
| 24 | |
| 25 | const asides = [ |
| 26 | name.isUntracked ? 'untracked' : null, |
| 27 | name.isTruncated ? 'truncated' : null, |
| 28 | ].filter(word => word !== null) |
| 29 | |
| 30 | const aside = asides.length === 0 ? '' : ` (${asides.join(', ')})` |
| 31 | |
| 32 | const ask = ( |
| 33 | <Button |
| 34 | key={askKeyOf(name.path)} |
| 35 | onPress={() => kit.actions.toggleAsk(name.path)} |
| 36 | > |
| 37 | {name.isArmed ? 'asked ✓' : 'ask'} |
| 38 | </Button> |
| 39 | ) |
| 40 | |
| 41 | return ( |
| 42 | <Box flexDirection="row"> |
| 43 | {[ |
| 44 | <Text bold wrap="truncate-start"> |
| 45 | {Layout.truncateStart( |
| 46 | Layout.sanitizeName(name.displayPath), |
| 47 | kit.columns, |
| 48 | )} |
| 49 | </Text>, |
| 50 | <Text dimColor>{aside}</Text>, |
| 51 | <Box flexGrow={1} />, |
| 52 | ...(name.isAskable ? [ask] : []), |
| 53 | ]} |
| 54 | </Box> |
| 55 | ) |
| 56 | } |