Skip to content

Commit e7ad109

Browse files
committed
fix(tui): let only the dot carry background-task status
The started line rendered dot and wording in periwinkle and the completed line rendered both in green, so an ambient background task drew as much attention as the work the user asked for. Keep the wording dim on every phase and colour the bullet alone: dim while running, green on completion, red on failure.
1 parent c6a0b06 commit e7ad109

2 files changed

Lines changed: 51 additions & 4 deletions

File tree

apps/pythinker-code/src/tui/components/messages/background-agent-status.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,22 @@ export class BackgroundAgentStatusComponent implements Component {
1515
const safeWidth = Math.max(0, width);
1616
if (safeWidth <= 0) return [''];
1717

18-
const tone: keyof ColorPalette =
18+
// Only the bullet carries the status. A background task is ambient — it is
19+
// not what the user asked for — so the wording stays dim and the eye picks
20+
// the line out by colour of the dot alone, never by a fully coloured line.
21+
const bulletTone: keyof ColorPalette =
1922
this.data.phase === 'started'
20-
? 'primary'
23+
? 'textDim'
2124
: this.data.phase === 'completed'
2225
? 'success'
2326
: 'error';
2427

2528
const bullet =
26-
this.data.phase === 'failed' ? currentTheme.fg(tone, FAILURE_MARK) : currentTheme.fg(tone, STATUS_BULLET);
29+
this.data.phase === 'failed'
30+
? currentTheme.fg(bulletTone, FAILURE_MARK)
31+
: currentTheme.fg(bulletTone, STATUS_BULLET);
2732
const text =
28-
currentTheme.fg(tone, this.data.headline) +
33+
currentTheme.fg('textDim', this.data.headline) +
2934
(this.data.detail !== undefined && this.data.detail.length > 0
3035
? currentTheme.fg('textDim', ` (${this.data.detail})`)
3136
: '');

apps/pythinker-code/test/tui/components/messages/background-agent-status.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { visibleWidth } from '@earendil-works/pi-tui';
2+
import chalk from 'chalk';
23
import { describe, expect, it } from 'vitest';
34

45
import { BackgroundAgentStatusComponent } from '#/tui/components/messages/background-agent-status';
56
import { STATUS_BULLET } from '#/tui/constant/symbols';
7+
import { currentTheme } from '#/tui/theme';
68

79
function strip(text: string): string {
810
return text.replaceAll(/\u001B\[[0-9;]*m/g, '');
@@ -45,6 +47,46 @@ describe('BackgroundAgentStatusComponent', () => {
4547
);
4648
});
4749

50+
it('colours only the bullet by phase and keeps the wording dim', () => {
51+
const started = new BackgroundAgentStatusComponent({
52+
phase: 'started',
53+
headline: 'bash task started in background',
54+
detail: 'E2E: contained brand mark',
55+
});
56+
const completed = new BackgroundAgentStatusComponent({
57+
phase: 'completed',
58+
headline: 'bash task completed in background',
59+
detail: 'E2E: contained brand mark · exit 0',
60+
});
61+
62+
// Colours are off by default under vitest, which would make every
63+
// assertion below compare bare strings and pass for the wrong reason.
64+
const previousLevel = chalk.level;
65+
chalk.level = 3;
66+
try {
67+
const startedLine = started.render(120)[1] ?? '';
68+
const completedLine = completed.render(120)[1] ?? '';
69+
70+
// A running task is ambient: dim dot, dim wording, no accent colour.
71+
expect(startedLine).toContain(currentTheme.fg('textDim', STATUS_BULLET));
72+
expect(startedLine).toContain(currentTheme.fg('textDim', 'bash task started in background'));
73+
expect(startedLine).not.toContain(
74+
currentTheme.fg('primary', 'bash task started in background'),
75+
);
76+
77+
// Completion turns the dot green — and only the dot.
78+
expect(completedLine).toContain(currentTheme.fg('success', STATUS_BULLET));
79+
expect(completedLine).toContain(
80+
currentTheme.fg('textDim', 'bash task completed in background'),
81+
);
82+
expect(completedLine).not.toContain(
83+
currentTheme.fg('success', 'bash task completed in background'),
84+
);
85+
} finally {
86+
chalk.level = previousLevel;
87+
}
88+
});
89+
4890
it('keeps status lines within very narrow widths', () => {
4991
const component = new BackgroundAgentStatusComponent({
5092
phase: 'started',

0 commit comments

Comments
 (0)