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
55 lines · 1.6 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 type PaneState from '../pane-state'
9import { dialogPane } from './dialog-pane'
10import { insetOf } from './inset-of'
11import type { Kit } from './kit'
12import type { PaneSeat } from './pane-seat'
13import Sections from './sections'
14import { sidebarPane } from './sidebar-pane'
15
16/**
17 * The diff pane's body for one `ui.render`: docked, the built-in panel's
18 * layout (sidebarPane); inline, its dialog's, or its wider-terminal line.
19 *
20 * The line only where the session is fullscreen (or not known not to be)
21 * and the terminal too narrow to dock, as the built-in shows no panel
22 * there; without the fullscreen layout the dialog draws at any width.
23 *
24 * @param kit the elements, the handlers, the width
25 * @param model the pane's state
26 * @param seat where the surface seated the pane, and the terminal's width
27 * @returns the tree
28 */
29export function paneView(
30 kit: Kit,
31 model: PaneState.PaneModel,
32 seat: PaneSeat,
33): RenderElement {
34 const { Box } = kit.ui
35 const isDocked = seat.placement === 'dock'
36
37 const isNarrow =
38 model.isFullscreen !== false &&
39 seat.terminalColumns !== null &&
40 seat.terminalColumns < Limits.OPEN_MIN_COLUMNS
41
42 return isDocked ? (
43 <Box
44 flexDirection="column"
45 paddingTop={Limits.PANE_TOP_PAD_ROWS}
46 paddingRight={Limits.PANE_RIGHT_PAD_COLUMNS}
47 >
48 {sidebarPane(insetOf(kit), model)}
49 </Box>
50 ) : isNarrow ? (
51 <Box>{Sections.dimNote(kit, Names.RESIZE_TERMINAL_TEXT)}</Box>
52 ) : (
53 dialogPane(kit, model)
54 )
55}