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 | /* @jsxRuntime classic */ |
| 2 | /* @jsx h */ |
| 3 | /* @jsxFrag Fragment */ |
| 4 | import type { RenderElement } from 'claude-code' |
| 5 | |
| 6 | import Limits from '../../limits' |
| 7 | import type PaneState from '../../pane-state' |
| 8 | import type { Kit } from '../kit' |
| 9 | |
| 10 | /** |
| 11 | * The session's todo progress as a bar and `done/total`, drawn only while |
| 12 | * a todo list exists (ReplDiffSidebar's ProgressBar row). |
| 13 | * |
| 14 | * @param kit the elements and the width |
| 15 | * @param model the pane's state, holding its todos' completed over total |
| 16 | * @returns the row, or null without todos |
| 17 | */ |
| 18 | export function todoBar( |
| 19 | kit: Kit, |
| 20 | model: Pick<PaneState.PaneModel, 'todos'>, |
| 21 | ): RenderElement | null { |
| 22 | const { todos } = model |
| 23 | |
| 24 | if (todos.total === 0) { |
| 25 | return null |
| 26 | } |
| 27 | |
| 28 | const { Box, Text } = kit.ui |
| 29 | |
| 30 | const cells = Math.max( |
| 31 | 1, |
| 32 | Math.min(Limits.TODO_BAR_CELLS, kit.columns - Limits.TODO_BAR_RESERVE), |
| 33 | ) |
| 34 | |
| 35 | const filled = Math.round((todos.done / todos.total) * cells) |
| 36 | |
| 37 | return ( |
| 38 | <Box flexDirection="row" gap={1} marginTop={1}> |
| 39 | <Text> |
| 40 | <Text color="success">{'█'.repeat(filled)}</Text> |
| 41 | <Text color="inactive">{'░'.repeat(Math.max(0, cells - filled))}</Text> |
| 42 | </Text> |
| 43 | <Text dimColor>{`${todos.done}/${todos.total}`}</Text> |
| 44 | </Box> |
| 45 | ) |
| 46 | } |