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 / tests / fixtures / pane-view / draws-pane.ts
39 lines · 1.2 KBRaw
1import type { On, RenderElement } from 'claude-code'
2
3import { isOnPaneSurface } from '../../../hooks/is-on-pane-surface'
4import type Views from '../../../hooks/views'
5import { BODY_ROWS } from './body-rows.js'
6import { COLUMNS } from './columns.js'
7import { noopActionsOf } from './noop-actions-of.js'
8
9/**
10 * Draws a pane beneath the plugin with a view of the test's, handed the kit
11 * every view takes.
12 *
13 * The hook resolves the surface's elements; the body size is the view
14 * fixtures' and the actions do nothing, unless overridden.
15 *
16 * @param on the test's `on`
17 * @param view draws the tree from the kit
18 * @param overrides kit members that differ from the ordinary ones
19 */
20export const drawsPane = (
21 on: On,
22 view: (kit: Views.Kit) => RenderElement,
23 overrides: Partial<Omit<Views.Kit, 'ui'>> = {},
24) =>
25 on('ui.render', { component: 'Pane' }, async ($, e, next) => {
26 if (!isOnPaneSurface(e)) {
27 return next(e)
28 }
29
30 const { Box, Text, Button, Select, Code } = await $.ui.resolve(e)
31
32 return view({
33 ui: { Box, Text, Button, Select, Code },
34 actions: noopActionsOf(),
35 columns: COLUMNS,
36 rows: BODY_ROWS,
37 ...overrides,
38 })
39 })