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
| @@ -400,6 +400,11 @@ | ||
| 400 | 400 | |
| 401 | 401 | arm(engine, path) |
| 402 | 402 | }, |
| 403 | + close: () => { | |
| 404 | + void closePane(engine) | |
| 405 | + .then(() => engine.storeSet(Names.STORE_OPEN_KEY, false)) | |
| 406 | + .catch(() => undefined) | |
| 407 | + }, | |
| 403 | 408 | }) |
| 404 | 409 | |
| 405 | 410 | function arm(engine: Host, path: string) { |
| @@ -33,4 +33,10 @@ | ||
| 33 | 33 | * Arms this file's diff for the next prompt, or disarms it. |
| 34 | 34 | */ |
| 35 | 35 | toggleAsk: (path: string) => void |
| 36 | + | |
| 37 | + /** | |
| 38 | + * Closes the pane as `/diff` closes it, the choice kept for the next | |
| 39 | + * first edit. | |
| 40 | + */ | |
| 41 | + close: () => void | |
| 36 | 42 | } |
| @@ -1,0 +1,33 @@ | ||
| 1 | +/* @jsxRuntime classic */ | |
| 2 | +/* @jsx h */ | |
| 3 | +/* @jsxFrag Fragment */ | |
| 4 | +import type { RenderElement } from 'claude-code' | |
| 5 | + | |
| 6 | +import type { Kit } from '../../kit' | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * The pane's close control (ReplDiffSidebar's PanelCloseButton): a `✕` at | |
| 10 | + * the header's right edge that closes the pane as `/diff` does. | |
| 11 | + * | |
| 12 | + * Bold under the pointer, as the built-in's is. The built-in's rest style, | |
| 13 | + * dim, is not a Button's to take: its label's only style is `hover`. | |
| 14 | + * | |
| 15 | + * @param kit the drawing's kit; its handlers close the pane | |
| 16 | + * @returns the control, in the keyed Box its hover needs | |
| 17 | + */ | |
| 18 | +export function closeButton(kit: Kit): RenderElement { | |
| 19 | + const { Box, Button } = kit.ui | |
| 20 | + | |
| 21 | + return ( | |
| 22 | + <Box key="close"> | |
| 23 | + <Button | |
| 24 | + key="close" | |
| 25 | + plain | |
| 26 | + hover={{ bold: true }} | |
| 27 | + onPress={kit.actions.close} | |
| 28 | + > | |
| 29 | + {'✕'} | |
| 30 | + </Button> | |
| 31 | + </Box> | |
| 32 | + ) | |
| 33 | +} |
| @@ -1,0 +1,3 @@ | ||
| 1 | +export * from './close-button.jsx' | |
| 2 | + | |
| 3 | +export * as default from '.' |
| @@ -6,11 +6,13 @@ | ||
| 6 | 6 | import type PaneState from '../../pane-state' |
| 7 | 7 | import type { Kit } from '../kit' |
| 8 | 8 | import Layout from '../layout' |
| 9 | +import { closeButton } from './close-button' | |
| 9 | 10 | import { diffStat } from './diff-stat' |
| 10 | 11 | |
| 11 | 12 | /** |
| 12 | - * The pane's first line: `N files changed +A -R`, or the empty headline in | |
| 13 | - * its place when there is nothing to count (ReplDiffSidebar's header). | |
| 13 | + * The pane's first line (ReplDiffSidebar's header row): `N files changed | |
| 14 | + * +A -R`, or the empty headline in its place when there is nothing to | |
| 15 | + * count, and the close `✕` at the right edge either way. | |
| 14 | 16 | * |
| 15 | 17 | * The headline may name a branch the repository chose, so it is drawn as |
| 16 | 18 | * a name: no control or format character survives. |
| @@ -25,7 +27,7 @@ | ||
| 25 | 27 | headline: string | null, |
| 26 | 28 | totals: PaneState.HeaderTotals, |
| 27 | 29 | ): RenderElement { |
| 28 | - const { Text } = kit.ui | |
| 30 | + const { Box, Text } = kit.ui | |
| 29 | 31 | const empty = ( |
| 30 | 32 | <Text dimColor wrap="truncate-end"> |
| 31 | 33 | {Layout.sanitizeName(headline ?? '')} |
| @@ -39,5 +41,9 @@ | ||
| 39 | 41 | </Text> |
| 40 | 42 | ) |
| 41 | 43 | |
| 42 | - return headline === null ? counts : empty | |
| 44 | + return ( | |
| 45 | + <Box flexDirection="row"> | |
| 46 | + {[headline === null ? counts : empty, <Box flexGrow={1} />, closeButton(kit)]} | |
| 47 | + </Box> | |
| 48 | + ) | |
| 43 | 49 | } |
| @@ -1,3 +1,4 @@ | ||
| 1 | +export * from './close-button' | |
| 1 | 2 | export * from './controls-view.jsx' |
| 2 | 3 | export * from './diff-stat' |
| 3 | 4 | export * from './dim-note' |