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-state / base-label-of.ts
44 lines · 1.2 KBRaw
1import { modeLabelOf } from './mode-label-of'
2import type { PaneModel } from './pane-model'
3
4/**
5 * The dim line under the header naming what the diff compares against
6 * (ReplDiffSidebar diffBaseLabel), or null for none.
7 *
8 * Hidden in settled session mode and before any fetch; the requested mode
9 * with an ellipsis while its fetch is pending; on an unborn HEAD with
10 * rows, what the rows are instead.
11 *
12 * @param model the mode the person picked, the last good fetch, and the
13 * backend's words
14 * @param filesCount the header's session file count
15 * @returns the line, or null
16 */
17export function baseLabelOf(
18 model: Pick<PaneModel, 'requestedMode' | 'data' | 'words'>,
19 filesCount: number,
20): string | null {
21 const { requestedMode, data } = model
22
23 if (!data) {
24 return null
25 }
26
27 if (data.isUnborn) {
28 const hasRows = filesCount > 0
29
30 return hasRows ? 'no commits yet — showing staged and new files' : null
31 }
32
33 const isPending = requestedMode !== data.mode
34 const isSettledSession = !isPending && requestedMode === 'session'
35
36 if (isSettledSession) {
37 return null
38 }
39
40 const phase = isPending ? 'pending' : 'settled'
41 const label = modeLabelOf(model, data.source, phase)
42
43 return isPending ? `${label}…` : label
44}