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 / pane-toggle / pane-toggle-of.ts
21 lines · 700 BRaw
1import Limits from '../limits'
2import type { PaneBelief } from './pane-belief'
3
4/**
5 * What `/diff` does, the one place its toggle is decided: close the open
6 * pane; otherwise open it, unless the terminal is too narrow.
7 *
8 * Narrower than the built-in panel shows on, it answers the resize line
9 * (`too-narrow`); a width not drawn yet opens.
10 *
11 * @param pane whether the pane is open, and the width
12 * @returns `close`, `open` or `too-narrow`
13 */
14export function paneToggleOf(
15 pane: PaneBelief,
16): 'open' | 'close' | 'too-narrow' {
17 const isTooNarrow =
18 pane.columns !== null && pane.columns < Limits.OPEN_MIN_COLUMNS
19
20 return pane.isOpen ? 'close' : isTooNarrow ? 'too-narrow' : 'open'
21}