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 { DialogTitle } from './dialog-title' |
| 2 | import type { PaneModel } from './pane-model' |
| 3 | import { pickedTurnOf } from './picked-turn-of' |
| 4 | import { turnTitleOf } from './turn-title-of' |
| 5 | |
| 6 | /** |
| 7 | * The inline pane's heading (DiffDialog's title): the picked turn and its |
| 8 | * prompt's opening words, or what the working tree is compared with. |
| 9 | * |
| 10 | * An unborn HEAD lists staged and new files; a branch diff names its base; |
| 11 | * anything else is the uncommitted changes against HEAD. |
| 12 | * |
| 13 | * @param model the pane's state |
| 14 | * @returns the title and its dim subtitle |
| 15 | */ |
| 16 | export function dialogTitleOf(model: PaneModel): DialogTitle { |
| 17 | const turn = pickedTurnOf(model) |
| 18 | const source = model.data?.source |
| 19 | const isUnborn = model.data?.isUnborn === true |
| 20 | const isBranch = source?.kind === 'branch' |
| 21 | |
| 22 | function currentOf(): DialogTitle { |
| 23 | switch (true) { |
| 24 | case isUnborn: |
| 25 | return { title: 'Staged and new files', subtitle: '(no commits yet)' } |
| 26 | case isBranch && source?.kind === 'branch': |
| 27 | return { |
| 28 | title: 'Branch changes', |
| 29 | subtitle: `(vs ${source.baseBranch})`, |
| 30 | } |
| 31 | default: |
| 32 | return { title: 'Uncommitted changes', subtitle: '(git diff HEAD)' } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | return turn ? turnTitleOf(turn) : currentOf() |
| 37 | } |