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 / turn-pane / turn-pane.tsx
87 lines · 2.1 KBRaw
1/* @jsxRuntime classic */
2/* @jsx h */
3/* @jsxFrag Fragment */
4import type { RenderElement } from 'claude-code'
5
6import PaneState from '../../pane-state'
7import type Turns from '../../turns'
8import Detail from '../detail'
9import type { Kit } from '../kit'
10import Layout from '../layout'
11import 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 */
22export function turnPane(
23 kit: Kit,
24 model: PaneState.PaneModel,
25 turn: Turns.TurnDiff,
26): RenderElement {
27 const { Box } = kit.ui
28
29 const selected =
30 turn.files.find(file => file.path === model.selectedPath) ??
31 turn.files[0] ??
32 null
33
34 const rows = turn.files.map(file =>
35 Sections.fileRow(
36 kit,
37 {
38 key: Sections.fileKeyOf(file.path),
39 path: file.path,
40 added: file.added,
41 removed: file.removed,
42 note: null,
43 isSelected: file.path === selected?.path,
44 },
45 () => kit.actions.selectFile(file.path),
46 ),
47 )
48
49 const detail = selected
50 ? [
51 Sections.divider(kit),
52 Detail.detailView(
53 kit,
54 {
55 words: model.words,
56 path: selected.path,
57 renamedFrom: null,
58 isUntracked: false,
59 isBinary: false,
60 body: {
61 hunks: selected.hunks,
62 isTruncated: selected.isTruncated,
63 isLarge: false,
64 },
65 bodyState: 'ready',
66 isArmed: model.armedPath === selected.path,
67 },
68 () => kit.actions.toggleAsk(selected.path),
69 ),
70 ]
71 : []
72
73 return (
74 <Box flexDirection="column">
75 {Sections.present([
76 Sections.headerView(kit, PaneState.turnTotalsOf(turn)),
77 Sections.dimNote(
78 kit,
79 `Turn ${turn.index} "${Layout.sanitizeName(turn.preview)}"`,
80 ),
81 Sections.controlsView(kit, model),
82 ...rows,
83 ...detail,
84 ])}
85 </Box>
86 )
87}