Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions src/utils/__tests__/default-colors.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import chalk from 'chalk';
import {
afterAll,
beforeAll,
describe,
expect,
it
} from 'vitest';

import {
DEFAULT_SETTINGS,
type Settings
} from '../../types/Settings';
import type { WidgetItem } from '../../types/Widget';
import {
COLOR_MAP,
updateColorMap
} from '../colors';
import { renderStatusLine } from '../renderer';
import { WIDGET_MANIFEST } from '../widget-manifest';

const BRIGHT_BLACK_FG = '\x1b[90m';

describe('default colors resolve through COLOR_MAP', () => {
it('every widget default color is a COLOR_MAP name', () => {
const known = new Set(COLOR_MAP.map(entry => entry.name));
for (const entry of WIDGET_MANIFEST) {
const color = entry.create().getDefaultColor();
expect(known.has(color), `${entry.type} -> '${color}'`).toBe(true);
}
});
});

describe('uncolored separator default', () => {
const previousLevel = chalk.level;

beforeAll(() => {
chalk.level = 1;
updateColorMap();
});

afterAll(() => {
chalk.level = previousLevel;
updateColorMap();
});

it('paints a separator with no explicit color as bright black', () => {
const widgets: WidgetItem[] = [
{ id: 'a', type: 'custom-text' },
{ id: 'sep', type: 'separator' },
{ id: 'b', type: 'custom-text' }
];
const settings: Settings = {
...DEFAULT_SETTINGS,
colorLevel: 1,
inheritSeparatorColors: false
};
const preRendered = widgets.map(widget => ({
content: widget.type === 'separator' ? '' : widget.id.toUpperCase(),
plainLength: widget.type === 'separator' ? 0 : 1,
widget
}));

const out = renderStatusLine(widgets, settings, { isPreview: false, terminalWidth: 200 }, preRendered, []);

expect(out).toContain(`${BRIGHT_BLACK_FG} | `);
});
});
2 changes: 1 addition & 1 deletion src/utils/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ export function renderStatusLine(
const formattedSep = formatSeparator(sepChar);

// Check if we should inherit colors from the previous widget
let separatorColor = widget.color ?? 'gray';
let separatorColor = widget.color ?? 'brightBlack';
let separatorBg = widget.backgroundColor;
let separatorBold = widget.bold;
let separatorDim = widget.dim;
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/GitSha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from './shared/hideable';

export class GitShaWidget implements Widget {
getDefaultColor(): string { return 'gray'; }
getDefaultColor(): string { return 'brightBlack'; }
getDescription(): string { return 'Shows short commit hash (SHA)'; }
getDisplayName(): string { return 'Git SHA'; }
getCategory(): string { return 'Git'; }
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/TerminalWidth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
import { getTerminalWidth } from '../utils/terminal';

export class TerminalWidthWidget implements Widget {
getDefaultColor(): string { return 'gray'; }
getDefaultColor(): string { return 'brightBlack'; }
getDescription(): string { return 'Shows current terminal width in columns'; }
getDisplayName(): string { return 'Terminal Width'; }
getCategory(): string { return 'Environment'; }
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/Version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
} from '../types/Widget';

export class VersionWidget implements Widget {
getDefaultColor(): string { return 'gray'; }
getDefaultColor(): string { return 'brightBlack'; }
getDescription(): string { return 'Shows Claude Code CLI version number'; }
getDisplayName(): string { return 'Version'; }
getCategory(): string { return 'Core'; }
Expand Down