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

mods/diff: a close ✕ at the header's right edge closes the pane as /diff doesBrowse files
poteat authored on Sep 10, 2026 parent 23e30f0 · commit 8b41514793d8
6 changed files+58 -4compared with 23e30f0
Mmods/diff/hooks/register.ts
Mmods/diff/hooks/views/pane-actions/pane-actions.ts
Amods/diff/hooks/views/sections/close-button/close-button.tsx
Amods/diff/hooks/views/sections/close-button/index.ts
Mmods/diff/hooks/views/sections/header-view.tsx
Mmods/diff/hooks/views/sections/index.ts
@@ -400,6 +400,11 @@
400400
401401 arm(engine, path)
402402 },
403+ close: () => {
404+ void closePane(engine)
405+ .then(() => engine.storeSet(Names.STORE_OPEN_KEY, false))
406+ .catch(() => undefined)
407+ },
403408 })
404409
405410 function arm(engine: Host, path: string) {
@@ -33,4 +33,10 @@
3333 * Arms this file's diff for the next prompt, or disarms it.
3434 */
3535 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
3642 }
@@ -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 @@
66 import type PaneState from '../../pane-state'
77 import type { Kit } from '../kit'
88 import Layout from '../layout'
9+import { closeButton } from './close-button'
910 import { diffStat } from './diff-stat'
1011
1112 /**
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.
1416 *
1517 * The headline may name a branch the repository chose, so it is drawn as
1618 * a name: no control or format character survives.
@@ -25,7 +27,7 @@
2527 headline: string | null,
2628 totals: PaneState.HeaderTotals,
2729 ): RenderElement {
28- const { Text } = kit.ui
30+ const { Box, Text } = kit.ui
2931 const empty = (
3032 <Text dimColor wrap="truncate-end">
3133 {Layout.sanitizeName(headline ?? '')}
@@ -39,5 +41,9 @@
3941 </Text>
4042 )
4143
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+ )
4349 }
@@ -1,3 +1,4 @@
1+export * from './close-button'
12 export * from './controls-view.jsx'
23 export * from './diff-stat'
34 export * from './dim-note'