File size: 1,673 Bytes
00080b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* @jsxRuntime classic */
/* @jsx h */
/* @jsxFrag Fragment */
import type { RenderElement } from 'claude-code'

import Limits from '../limits'
import Names from '../names'
import type PaneState from '../pane-state'
import { dialogPane } from './dialog-pane'
import { insetOf } from './inset-of'
import type { Kit } from './kit'
import type { PaneSeat } from './pane-seat'
import Sections from './sections'
import { sidebarPane } from './sidebar-pane'

/**
 * The diff pane's body for one `ui.render`: docked, the built-in panel's
 * layout (sidebarPane); inline, its dialog's, or its wider-terminal line.
 *
 * The line only where the session is fullscreen (or not known not to be)
 * and the terminal too narrow to dock, as the built-in shows no panel
 * there; without the fullscreen layout the dialog draws at any width.
 *
 * @param kit the elements, the handlers, the width
 * @param model the pane's state
 * @param seat where the surface seated the pane, and the terminal's width
 * @returns the tree
 */
export function paneView(
  kit: Kit,
  model: PaneState.PaneModel,
  seat: PaneSeat,
): RenderElement {
  const { Box } = kit.ui
  const isDocked = seat.placement === 'dock'

  const isNarrow =
    model.isFullscreen !== false &&
    seat.terminalColumns !== null &&
    seat.terminalColumns < Limits.OPEN_MIN_COLUMNS

  return isDocked ? (
    <Box
      flexDirection="column"
      paddingTop={Limits.PANE_TOP_PAD_ROWS}
      paddingRight={Limits.PANE_RIGHT_PAD_COLUMNS}
    >
      {sidebarPane(insetOf(kit), model)}
    </Box>
  ) : isNarrow ? (
    <Box>{Sections.dimNote(kit, Names.RESIZE_TERMINAL_TEXT)}</Box>
  ) : (
    dialogPane(kit, model)
  )
}