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 PaneState from '../../pane-state' |
| 7 | import type Turns from '../../turns' |
| 8 | import Detail from '../detail' |
| 9 | import type { Kit } from '../kit' |
| 10 | import Layout from '../layout' |
| 11 | import Sections from '../sections' |
| 12 | |
| 13 | /** |
| 14 | * The pane over one past turn's edits (DiffDialog's T<n> tab): the turn's |
| 15 | * counts, its prompt's opening words, the pickers, its files, one body. |
| 16 | * |
| 17 | * @param kit the elements, the handlers, the width |
| 18 | * @param model the pane's state |
| 19 | * @param turn the turn picked |
| 20 | * @returns the pane's tree |
| 21 | */ |
| 22 | export function turnPane( |
| 23 | kit: Kit, |
| 24 | model: PaneState.PaneModel, |
| 25 | turn: Turns.TurnDiff, |
| 26 | ): RenderElement { |
| 27 | const { Box } = kit.ui |
| 28 | const selected = |
| 29 | turn.files.find(file => file.path === model.selectedPath) ?? |
| 30 | turn.files[0] ?? |
| 31 | null |
| 32 | const rows = turn.files.map(file => |
| 33 | Sections.fileRow( |
| 34 | kit, |
| 35 | { |
| 36 | key: Sections.fileKeyOf(file.path), |
| 37 | path: file.path, |
| 38 | added: file.added, |
| 39 | removed: file.removed, |
| 40 | note: null, |
| 41 | isSelected: file.path === selected?.path, |
| 42 | }, |
| 43 | () => kit.actions.selectFile(file.path), |
| 44 | ), |
| 45 | ) |
| 46 | const detail = selected |
| 47 | ? [ |
| 48 | Sections.divider(kit), |
| 49 | Detail.detailView( |
| 50 | kit, |
| 51 | { |
| 52 | words: model.words, |
| 53 | path: selected.path, |
| 54 | renamedFrom: null, |
| 55 | isUntracked: false, |
| 56 | isBinary: false, |
| 57 | body: { |
| 58 | hunks: selected.hunks, |
| 59 | isTruncated: selected.isTruncated, |
| 60 | isLarge: false, |
| 61 | }, |
| 62 | bodyState: 'ready', |
| 63 | isArmed: model.armedPath === selected.path, |
| 64 | }, |
| 65 | () => kit.actions.toggleAsk(selected.path), |
| 66 | ), |
| 67 | ] |
| 68 | : [] |
| 69 | |
| 70 | return ( |
| 71 | <Box flexDirection="column"> |
| 72 | {Sections.present([ |
| 73 | Sections.headerView(kit, PaneState.turnTotalsOf(turn)), |
| 74 | Sections.dimNote( |
| 75 | kit, |
| 76 | `Turn ${turn.index} "${Layout.sanitizeName(turn.preview)}"`, |
| 77 | ), |
| 78 | Sections.controlsView(kit, model), |
| 79 | ...rows, |
| 80 | ...detail, |
| 81 | ])} |
| 82 | </Box> |
| 83 | ) |
| 84 | } |