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 Names from '../names' |
| 2 | import type { EmptyState } from './empty-state' |
| 3 | import type { PaneModel } from './pane-model' |
| 4 | |
| 5 | /** |
| 6 | * The headline that replaces the count when nothing is listed, worded as |
| 7 | * ReplDiffSidebar words it, keyed on the mode the data was FETCHED in. |
| 8 | * |
| 9 | * Null while there are files to count. No data after a settled fetch is |
| 10 | * "Diff unavailable"; no tracked rows while the untracked listing was |
| 11 | * withheld claims nothing about new files. |
| 12 | * |
| 13 | * @param model the last good fetch (null when none ever settled), the words |
| 14 | * @param filesCount the header's session file count |
| 15 | * @returns the empty state, or null |
| 16 | */ |
| 17 | export function emptyStateOf( |
| 18 | model: Pick<PaneModel, 'data' | 'words'>, |
| 19 | filesCount: number, |
| 20 | ): EmptyState | null { |
| 21 | const { data, words } = model |
| 22 | |
| 23 | if (!data) { |
| 24 | return { |
| 25 | headline: 'Diff unavailable', |
| 26 | hint: |
| 27 | `Couldn't read the ${words.diffCommand} — it will retry on the ` + |
| 28 | 'next change', |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | if (filesCount > 0) { |
| 33 | return null |
| 34 | } |
| 35 | |
| 36 | if (data.isUntrackedWithheld) { |
| 37 | return { |
| 38 | headline: 'No tracked changes', |
| 39 | hint: Names.untrackedWithheldTextOf(model), |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | if (data.isUnborn) { |
| 44 | return { |
| 45 | headline: 'No commits yet', |
| 46 | hint: "Nothing to diff against until the repo's first commit", |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | switch (data.mode) { |
| 51 | case 'uncommitted': |
| 52 | return { headline: 'No uncommitted changes', hint: null } |
| 53 | case 'branch': |
| 54 | if (data.source.kind === 'branch') { |
| 55 | return { |
| 56 | headline: `No changes vs ${data.source.baseBranch}`, |
| 57 | hint: null, |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | return { |
| 62 | headline: `No changes vs ${data.source.base}`, |
| 63 | hint: |
| 64 | 'No base branch to compare against — showing changes vs ' + |
| 65 | data.source.base, |
| 66 | } |
| 67 | case 'session': |
| 68 | return { headline: 'No changes this session', hint: null } |
| 69 | } |
| 70 | } |