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 / pane-view.tsx
52 lines · 1.5 KBRaw
1/* @jsxRuntime classic */
2/* @jsx h */
3/* @jsxFrag Fragment */
4import type { RenderElement } from 'claude-code'
5
6import Limits from '../limits'
7import Names from '../names'
8import PaneState from '../pane-state'
9import { currentPane } from './current-pane'
10import { insetOf } from './inset-of'
11import type { Kit } from './kit'
12import Sections from './sections'
13import { turnPane } from './turn-pane'
14
15/**
16 * The diff pane's body for one `ui.render`: the repository's diff now, or
17 * the picked turn's edits while that turn still exists (a rewind drops it).
18 *
19 * Seated inline, only the built-in's wider-terminal line, as it shows no
20 * panel there; docked, the built-in's blank row above the header and blank
21 * last column, so rows sit and wrap where the built-in's do.
22 *
23 * @param kit the elements, the handlers, the width
24 * @param model the pane's state
25 * @param placement where the surface seated the pane (`props.placement`)
26 * @returns the tree
27 */
28export function paneView(
29 kit: Kit,
30 model: PaneState.PaneModel,
31 placement: 'dock' | 'inline',
32): RenderElement {
33 const { Box } = kit.ui
34 const turn = PaneState.pickedTurnOf(model)
35 const isCurrent = turn === undefined
36
37 if (placement === 'inline') {
38 return <Box>{Sections.dimNote(kit, Names.RESIZE_TERMINAL_TEXT)}</Box>
39 }
40
41 const inset = insetOf(kit)
42
43 return (
44 <Box
45 flexDirection="column"
46 paddingTop={Limits.PANE_TOP_PAD_ROWS}
47 paddingRight={Limits.PANE_RIGHT_PAD_COLUMNS}
48 >
49 {isCurrent ? currentPane(inset, model) : turnPane(inset, model, turn)}
50 </Box>
51 )
52}