diff --git a/packages/cli/src/ui/components/ColorsDisplay.test.tsx b/packages/cli/src/ui/components/ColorsDisplay.test.tsx index 38b2ce8f62..1cb9515896 100644 --- a/packages/cli/src/ui/components/ColorsDisplay.test.tsx +++ b/packages/cli/src/ui/components/ColorsDisplay.test.tsx @@ -70,9 +70,6 @@ describe('ColorsDisplay', () => { expect(output).toContain('/colors - Theme Colors Demo'); expect(output).toContain('visualize how colors are used'); - // Check for Background section - expect(output).toContain('Background Colors'); - // Check for active theme name expect(output).toContain('Test Theme'); @@ -87,7 +84,7 @@ describe('ColorsDisplay', () => { // Check for some descriptions expect(output).toContain('Primary text color'); expect(output).toContain('Standard border color'); - + expect(output).toContain('Main terminal background color'); unmount(); }); }); diff --git a/packages/cli/src/ui/components/ColorsDisplay.tsx b/packages/cli/src/ui/components/ColorsDisplay.tsx index 49d5d4a76b..08a36f56a7 100644 --- a/packages/cli/src/ui/components/ColorsDisplay.tsx +++ b/packages/cli/src/ui/components/ColorsDisplay.tsx @@ -6,15 +6,17 @@ import type React from 'react'; import { Box, Text } from 'ink'; +import Gradient from 'ink-gradient'; import { themeManager } from '../themes/theme-manager.js'; import { theme } from '../semantic-colors.js'; const COLOR_DESCRIPTIONS: Record = { - 'text.primary': 'Primary text color', + 'text.primary': 'Primary text color (uses terminal default if blank)', 'text.secondary': 'Secondary/dimmed text color', 'text.link': 'Hyperlink and highlighting color', 'text.accent': 'Accent color for emphasis', - 'text.response': 'Color for model response text', + 'text.response': + 'Color for model response text (uses terminal default if blank)', 'background.primary': 'Main terminal background color', 'background.message': 'Subtle background for message blocks', 'background.input': 'Background for the input prompt', @@ -49,12 +51,13 @@ interface BackgroundColorRow { value: string; } +type ColorRow = StandardColorRow | GradientColorRow | BackgroundColorRow; + export const ColorsDisplay: React.FC = () => { const semanticColors = themeManager.getSemanticColors(); const activeTheme = themeManager.getActiveTheme(); - const standardRows: StandardColorRow[] = []; - const backgroundRows: BackgroundColorRow[] = []; + const allRows: ColorRow[] = []; const gradientRow: GradientColorRow | null = semanticColors.ui.gradient && semanticColors.ui.gradient.length > 0 ? { @@ -67,7 +70,7 @@ export const ColorsDisplay: React.FC = () => { // Flatten and categorize the SemanticColors object for (const [category, subColors] of Object.entries(semanticColors)) { if (category === 'ui' && 'gradient' in subColors) { - // Handled separately + // Handled separately or later continue; } @@ -82,13 +85,13 @@ export const ColorsDisplay: React.FC = () => { for (const [diffName, diffValue] of Object.entries(value)) { if (typeof diffValue === 'string') { if (category === 'background') { - backgroundRows.push({ + allRows.push({ type: 'background', name: `${fullName}.${diffName}`, value: diffValue, }); } else { - standardRows.push({ + allRows.push({ type: 'standard', name: `${fullName}.${diffName}`, value: diffValue, @@ -98,13 +101,13 @@ export const ColorsDisplay: React.FC = () => { } } else if (typeof value === 'string') { if (category === 'background') { - backgroundRows.push({ + allRows.push({ type: 'background', name: fullName, value, }); } else { - standardRows.push({ + allRows.push({ type: 'standard', name: fullName, value, @@ -114,6 +117,11 @@ export const ColorsDisplay: React.FC = () => { } } + // Add gradient row if it exists + if (gradientRow) { + allRows.push(gradientRow); + } + return ( @@ -162,26 +170,14 @@ export const ColorsDisplay: React.FC = () => { - {/* Standard Section */} - - {standardRows.map((row) => renderStandardRow(row))} - - - {/* Gradient Section */} - {gradientRow && ( - - {renderGradientRow(gradientRow)} - - )} - - {/* Background Section */} - - - - Background Colors - - - {backgroundRows.map((row) => renderBackgroundRow(row))} + {/* All Rows */} + + {allRows.map((row) => { + if (row.type === 'standard') return renderStandardRow(row); + if (row.type === 'gradient') return renderGradientRow(row); + if (row.type === 'background') return renderBackgroundRow(row); + return null; + })} ); @@ -190,14 +186,15 @@ export const ColorsDisplay: React.FC = () => { function renderStandardRow({ name, value }: StandardColorRow) { const description = COLOR_DESCRIPTIONS[name] || ''; const isHex = value.startsWith('#'); + const displayColor = isHex ? value : theme.text.primary; return ( - {value} + {value || '(blank)'} - {name} + {name} {description} @@ -211,16 +208,17 @@ function renderGradientRow({ name, value }: GradientColorRow) { return ( - + {value.map((c, i) => ( {c} - {i < value.length - 1 ? ', ' : ''} ))} - {name} + + {name} + {description} @@ -233,7 +231,7 @@ function renderBackgroundRow({ name, value }: BackgroundColorRow) { const description = COLOR_DESCRIPTIONS[name] || ''; return ( - + - {name} + {name} {description}