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
43 lines · 1.2 KBRaw
1import type Git from '../git'
2import { modeLabelOf } from './mode-label-of'
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 requested the mode the person picked
13 * @param data the last good fetch
14 * @param filesCount the header's session file count
15 * @returns the line, or null
16 */
17export function baseLabelOf(
18 requested: Git.BaseMode,
19 data: Git.DiffData | null,
20 filesCount: number,
21): string | null {
22 if (!data) {
23 return null
24 }
25
26 if (data.isUnborn) {
27 const hasRows = filesCount > 0
28
29 return hasRows ? 'no commits yet — showing staged and new files' : null
30 }
31
32 const isPending = requested !== data.mode
33 const isSettledSession = !isPending && requested === 'session'
34
35 if (isSettledSession) {
36 return null
37 }
38
39 const phase = isPending ? 'pending' : 'settled'
40 const label = modeLabelOf(requested, data.source, phase)
41
42 return isPending ? `${label}…` : label
43}