Skip to content

Commit 2dfd2db

Browse files
committed
feat(cli): paint the update notice in the status bar in the warning color
1 parent a7074c9 commit 2dfd2db

4 files changed

Lines changed: 40 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pymodel/pythinker-code": patch
3+
---
4+
5+
Highlight the update notice in the terminal status bar with the warning color.

apps/pythinker-code/src/tui/components/chrome/status-bar.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export type StatusBarStatus = Pick<
2727
| 'tokenSpeedEstimated'
2828
> & {
2929
readonly extras: readonly string[];
30+
/** The `extras` entry that carries the update notice, painted in `warning`. */
31+
readonly updateExtra?: string;
3032
readonly sessionKey: string;
3133
readonly statusLine: StatusLineConfig;
3234
};
@@ -61,7 +63,7 @@ export class StatusBarComponent implements Component {
6163
: undefined;
6264
let modesChip = status.statusLine.showModes ? renderModesChip(status) : undefined;
6365
const extraChips = status.extras.map((extra) =>
64-
chip(currentTheme.fg('textDim', extra)),
66+
chip(currentTheme.fg(extra === status.updateExtra ? 'warning' : 'textDim', extra)),
6567
);
6668
let cwdChip: string | undefined = chip(
6769
currentTheme.fg('textDim', shortenCwd(status.cwd, status.homeDir)),

apps/pythinker-code/src/tui/pythinker-tui.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ import {
141141
foldFooterEvents,
142142
selectFooterViewModel,
143143
selectStatusBarExtras,
144+
selectStatusItemParts,
144145
type FooterActivity,
145146
type FooterEvent,
146147
type FooterGoal,
@@ -1400,13 +1401,19 @@ export class PythinkerTUI {
14001401
this.state.appState.statusLine,
14011402
),
14021403
);
1404+
const statusParts = selectStatusItemParts(
1405+
this.state.footerState,
1406+
Date.now(),
1407+
this.state.appState.statusLine,
1408+
);
14031409
this.state.statusBar.update({
14041410
...this.state.footerState.status,
14051411
extras: selectStatusBarExtras(
14061412
this.state.footerState,
14071413
Date.now(),
14081414
this.state.appState.statusLine,
14091415
),
1416+
updateExtra: statusParts.update ?? undefined,
14101417
sessionKey:
14111418
this.state.appState.sessionTitle?.trim() ||
14121419
this.state.appState.sessionId ||

apps/pythinker-code/test/tui/components/status-bar.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,31 @@ describe('StatusBarComponent', () => {
108108
}
109109
});
110110

111+
it('paints the update extra in warning and leaves other extras dim', () => {
112+
const previousLevel = chalk.level;
113+
const previousPalette = currentTheme.palette;
114+
chalk.level = 3;
115+
currentTheme.setPalette(darkColors);
116+
117+
try {
118+
const component = new StatusBarComponent();
119+
component.update(
120+
status({
121+
extras: ['6% · 55.6k/1M', '↑ v0.18.0 restart to apply'],
122+
updateExtra: '↑ v0.18.0 restart to apply',
123+
}),
124+
);
125+
126+
const line = renderRow(component, 160);
127+
128+
expect(line).toContain(chalk.hex(darkColors.warning)('↑ v0.18.0 restart to apply'));
129+
expect(line).toContain(chalk.hex(darkColors.textDim)('6% · 55.6k/1M'));
130+
} finally {
131+
chalk.level = previousLevel;
132+
currentTheme.setPalette(previousPalette);
133+
}
134+
});
135+
111136
it('drops the gap, modes, and cwd in that order as width shrinks', () => {
112137
const component = new StatusBarComponent();
113138
component.update(status());

0 commit comments

Comments
 (0)