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
| 1 | import type Git from '../../git' |
| 2 | import type { PaneModel } from '../pane-model' |
| 3 | |
| 4 | /** |
| 5 | * A requested mode's name for the base line. |
| 6 | * |
| 7 | * Branch mode names its base branch from the data, or says what stands in |
| 8 | * while none is known. A working-tree diff names its own base (`HEAD`, a |
| 9 | * short sha); anything else falls back to the backend's word for it. |
| 10 | * |
| 11 | * @param model the mode the person picked, and the backend's words |
| 12 | * @param source what the data on screen compares |
| 13 | * @param phase `pending` while the requested mode's fetch has not landed |
| 14 | * @returns the label without its pending ellipsis |
| 15 | */ |
| 16 | export function modeLabelOf( |
| 17 | model: Pick<PaneModel, 'requestedMode' | 'words'>, |
| 18 | source: Git.DiffSource, |
| 19 | phase: 'pending' | 'settled', |
| 20 | ) { |
| 21 | const base = source.kind === 'working-tree' ? source.base : model.words.base |
| 22 | |
| 23 | switch (model.requestedMode) { |
| 24 | case 'session': |
| 25 | return 'this session' |
| 26 | case 'uncommitted': |
| 27 | return `uncommitted (vs ${base})` |
| 28 | case 'branch': |
| 29 | if (source.kind === 'branch') { |
| 30 | return `branch vs ${source.baseBranch}` |
| 31 | } |
| 32 | |
| 33 | return phase === 'pending' ? 'branch diff' : `vs ${base} (no base branch)` |
| 34 | } |
| 35 | } |