[cli-ui] Keep header ASCII art colored on non-gradient terminals (#13373) (#13374)

Co-authored-by: Niladri Das <bniladridas@users.noreply.github.com>
This commit is contained in:
niladri das
2025-11-20 03:34:58 +05:30
committed by GitHub
parent 25f8452127
commit f8a862738d
2 changed files with 34 additions and 4 deletions

View File

@@ -116,13 +116,38 @@ describe('<Header />', () => {
it('renders with no gradient when theme.ui.gradient is undefined', async () => {
vi.spyOn(semanticColors, 'theme', 'get').mockReturnValue({
ui: { gradient: undefined },
} as typeof semanticColors.theme);
text: {
primary: '',
secondary: '',
link: '',
accent: '#123456',
response: '',
},
background: {
primary: '',
diff: { added: '', removed: '' },
},
border: {
default: '',
focused: '',
},
ui: {
comment: '',
symbol: '',
dark: '',
gradient: undefined,
},
status: {
error: '',
success: '',
warning: '',
},
});
const Gradient = await import('ink-gradient');
render(<Header version="1.0.0" nightly={false} />);
expect(Gradient.default).not.toHaveBeenCalled();
const textCalls = (Text as Mock).mock.calls;
expect(textCalls[0][0]).not.toHaveProperty('color');
expect(textCalls[0][0]).toHaveProperty('color', '#123456');
});
it('renders with a single color when theme.ui.gradient has one color', async () => {

View File

@@ -28,5 +28,10 @@ export const ThemedGradient: React.FC<TextProps> = ({ children, ...props }) => {
);
}
return <Text {...props}>{children}</Text>;
// Fallback to accent color if no gradient
return (
<Text color={theme.text.accent} {...props}>
{children}
</Text>
);
};