-
Notifications
You must be signed in to change notification settings - Fork 5
feat(tui): state-tinted tool cards, session status bar, mode borders, cosine shimmer #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
646aa39
feat(tui): state-tinted tool cards, session status bar, mode borders,…
elkaix 5b3b9ff
fix(tui): guard codePointAt result in session accent hash
elkaix 65150bd
fix: address review feedback on TUI signature design
elkaix 72c030e
feat(tui): render the status bar below the editor as the single statu…
elkaix d439110
fix(tui): clamp light accent contrast, neutral truncated cards, foote…
elkaix 307424d
test: follow the status line move and calm loader in suite assertions
elkaix f833012
feat(tui): default context gauge, short cwd chip, braille orchestrati…
elkaix 345c24c
fix(tui): honor status_line toggles and calm the shimmer sweep
elkaix 431c896
fix(tui): neutral prompt border and token speed on the model chip
elkaix ebfb674
test: follow the token speed move and rate-independent shimmer checks
elkaix 66d0076
test: make TUI render assertions fail on an empty render
elkaix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@pythoughts/pythinker-code": minor | ||
| --- | ||
|
|
||
| Redesign core TUI surfaces: tool cards get state-tinted backgrounds with three new theme tokens, a status bar with a per-session accent color appears between the input box and footer, and the prompt box uses a neutral border while permission mode appears in the status bar. The working-label shimmer uses a calmer constant-velocity sweep with alternating mission-control highlights. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
apps/pythinker-code/src/tui/components/chrome/status-bar.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| import { sep } from 'node:path'; | ||
|
|
||
| import { truncateToWidth, visibleWidth, type Component } from '@earendil-works/pi-tui'; | ||
| import chalk from 'chalk'; | ||
|
|
||
| import type { StatusLineConfig } from '#/tui/config'; | ||
| import { | ||
| formatTokenSpeed, | ||
| type FooterStatus, | ||
| } from '#/tui/runtime/footer/footer-model'; | ||
| import { currentTheme } from '#/tui/theme'; | ||
| import { themeFromHexChannels } from '#/tui/theme/terminal-background'; | ||
| import { effortColorToken, shortEffortLabel } from '#/tui/utils/thinking-levels'; | ||
| import { sessionAccentHex } from '#/tui/utils/session-accent'; | ||
|
|
||
| export type StatusBarStatus = Pick< | ||
| FooterStatus, | ||
| | 'model' | ||
| | 'thinkingLevel' | ||
| | 'cwd' | ||
| | 'homeDir' | ||
| | 'permissionMode' | ||
| | 'planMode' | ||
| | 'fastMode' | ||
| | 'dynamicWorkflowMode' | ||
| | 'tokenSpeed' | ||
| | 'tokenSpeedEstimated' | ||
| > & { | ||
| readonly extras: readonly string[]; | ||
| readonly sessionKey: string; | ||
| readonly statusLine: StatusLineConfig; | ||
| }; | ||
|
|
||
| export class StatusBarComponent implements Component { | ||
| private status: StatusBarStatus | undefined; | ||
|
|
||
| update(status: StatusBarStatus): void { | ||
| this.status = status; | ||
| } | ||
|
|
||
| render(width: number): string[] { | ||
| const status = this.status; | ||
| if (status === undefined) return []; | ||
|
|
||
| const effortSuffix = status.statusLine.showEffort && status.thinkingLevel !== 'off' | ||
| ? `${currentTheme.fg('textDim', ' · ')}${currentTheme.fg( | ||
| effortColorToken(status.thinkingLevel), | ||
| shortEffortLabel(status.thinkingLevel), | ||
| )}` | ||
| : ''; | ||
| const fastSuffix = status.statusLine.showModes && status.fastMode | ||
| ? `${currentTheme.fg('textDim', ' · ')}${currentTheme.fg('modeFast', '↯ fast')}` | ||
| : ''; | ||
| const speed = status.statusLine.showTokenSpeed ? formatTokenSpeed(status) : null; | ||
| const modelChip = status.statusLine.showModel | ||
| ? chip( | ||
| `${currentTheme.fg('text', status.model)}${effortSuffix}${fastSuffix}${ | ||
| speed === null ? '' : currentTheme.fg('textDim', ` · ${speed}`) | ||
| }`, | ||
| ) | ||
| : undefined; | ||
| let modesChip = status.statusLine.showModes ? renderModesChip(status) : undefined; | ||
| const extraChips = status.extras.map((extra) => | ||
| chip(currentTheme.fg('textDim', extra)), | ||
| ); | ||
| let cwdChip: string | undefined = chip( | ||
| currentTheme.fg('textDim', shortenCwd(status.cwd, status.homeDir)), | ||
| ); | ||
| const left = (): string => | ||
| [modelChip, modesChip, ...extraChips] | ||
| .filter((item): item is string => item !== undefined) | ||
| .join(' '); | ||
| const fullGapWidth = | ||
| width - visibleWidth(left()) - (cwdChip === undefined ? 1 : visibleWidth(cwdChip) + 2); | ||
|
|
||
| let line: string; | ||
| if (fullGapWidth > 0) { | ||
| const background = currentTheme.color('background'); | ||
| const mode = themeFromHexChannels( | ||
| background.slice(1, 3), | ||
| background.slice(3, 5), | ||
| background.slice(5, 7), | ||
| ); | ||
| const gap = chalk.hex(sessionAccentHex(status.sessionKey, mode))('─'.repeat(fullGapWidth)); | ||
| line = cwdChip === undefined ? `${left()} ${gap}` : `${left()} ${gap} ${cwdChip}`; | ||
| } else { | ||
| line = `${left()}${cwdChip === undefined ? '' : ` ${cwdChip}`}`; | ||
| while (visibleWidth(line) > width && extraChips.length > 0) { | ||
| extraChips.pop(); | ||
| line = `${left()}${cwdChip === undefined ? '' : ` ${cwdChip}`}`; | ||
| } | ||
| if (visibleWidth(line) > width && modesChip !== undefined) { | ||
| modesChip = undefined; | ||
| line = `${left()}${cwdChip === undefined ? '' : ` ${cwdChip}`}`; | ||
| } | ||
| if (visibleWidth(line) > width && cwdChip !== undefined) { | ||
| cwdChip = undefined; | ||
| line = left(); | ||
| } | ||
| } | ||
|
|
||
| return [truncateToWidth(line, Math.max(0, width))]; | ||
| } | ||
|
|
||
| invalidate(): void {} | ||
| } | ||
|
|
||
| function chip(content: string): string { | ||
| return currentTheme.bg('surfaceHighlight', ` ${content} `); | ||
| } | ||
|
|
||
| function renderModesChip(status: StatusBarStatus): string | undefined { | ||
| const modes: string[] = []; | ||
| if (status.planMode) modes.push(currentTheme.fg('modePlan', 'plan')); | ||
| if (status.permissionMode === 'auto') modes.push(currentTheme.fg('modePermission', 'auto')); | ||
| if (status.permissionMode === 'yolo') modes.push(currentTheme.fg('error', 'yolo')); | ||
| if (status.dynamicWorkflowMode) modes.push(currentTheme.fg('accent', 'workflow')); | ||
| return modes.length === 0 ? undefined : chip(modes.join(' ')); | ||
| } | ||
|
|
||
| function shortenCwd(cwd: string, homeDir: string | null): string { | ||
| const path = homeDir !== null && homeDir.length > 0 | ||
| ? cwd === homeDir | ||
| ? '~' | ||
| : cwd.startsWith(`${homeDir}${sep}`) | ||
| ? `~${cwd.slice(homeDir.length)}` | ||
| : cwd | ||
| : cwd; | ||
| const segments = path.startsWith(`~${sep}`) | ||
| ? path.slice(2).split(sep) | ||
| : path.startsWith(sep) | ||
| ? path.slice(1).split(sep) | ||
| : []; | ||
| return segments.length > 2 ? `…${sep}${segments.slice(-2).join(sep)}` : path; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.