mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 21:03:05 -07:00
fix(core): detect kmscon terminal as supporting true color (#25282)
Co-authored-by: Adib234 <30782825+Adib234@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -195,6 +195,7 @@ describe('compatibility', () => {
|
|||||||
desc: '256 colors are not supported',
|
desc: '256 colors are not supported',
|
||||||
},
|
},
|
||||||
])('should return $expected when $desc', ({ depth, term, expected }) => {
|
])('should return $expected when $desc', ({ depth, term, expected }) => {
|
||||||
|
vi.stubEnv('COLORTERM', '');
|
||||||
process.stdout.getColorDepth = vi.fn().mockReturnValue(depth);
|
process.stdout.getColorDepth = vi.fn().mockReturnValue(depth);
|
||||||
if (term !== undefined) {
|
if (term !== undefined) {
|
||||||
vi.stubEnv('TERM', term);
|
vi.stubEnv('TERM', term);
|
||||||
@@ -203,6 +204,13 @@ describe('compatibility', () => {
|
|||||||
}
|
}
|
||||||
expect(supports256Colors()).toBe(expected);
|
expect(supports256Colors()).toBe(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return true when COLORTERM is kmscon', () => {
|
||||||
|
process.stdout.getColorDepth = vi.fn().mockReturnValue(4);
|
||||||
|
vi.stubEnv('TERM', 'linux');
|
||||||
|
vi.stubEnv('COLORTERM', 'kmscon');
|
||||||
|
expect(supports256Colors()).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('supportsTrueColor', () => {
|
describe('supportsTrueColor', () => {
|
||||||
@@ -230,6 +238,12 @@ describe('compatibility', () => {
|
|||||||
expected: true,
|
expected: true,
|
||||||
desc: 'getColorDepth returns >= 24',
|
desc: 'getColorDepth returns >= 24',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
colorterm: 'kmscon',
|
||||||
|
depth: 4,
|
||||||
|
expected: true,
|
||||||
|
desc: 'COLORTERM is kmscon',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
colorterm: '',
|
colorterm: '',
|
||||||
depth: 8,
|
depth: 8,
|
||||||
@@ -409,6 +423,18 @@ describe('compatibility', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return no color warnings for kmscon terminal', () => {
|
||||||
|
vi.mocked(os.platform).mockReturnValue('linux');
|
||||||
|
vi.stubEnv('TERMINAL_EMULATOR', '');
|
||||||
|
vi.stubEnv('TERM', 'linux');
|
||||||
|
vi.stubEnv('COLORTERM', 'kmscon');
|
||||||
|
process.stdout.getColorDepth = vi.fn().mockReturnValue(4);
|
||||||
|
|
||||||
|
const warnings = getCompatibilityWarnings();
|
||||||
|
expect(warnings.find((w) => w.id === '256-color')).toBeUndefined();
|
||||||
|
expect(warnings.find((w) => w.id === 'true-color')).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
it('should return no warnings in a standard environment with true color', () => {
|
it('should return no warnings in a standard environment with true color', () => {
|
||||||
vi.mocked(os.platform).mockReturnValue('darwin');
|
vi.mocked(os.platform).mockReturnValue('darwin');
|
||||||
vi.stubEnv('TERMINAL_EMULATOR', '');
|
vi.stubEnv('TERMINAL_EMULATOR', '');
|
||||||
|
|||||||
@@ -85,6 +85,11 @@ export function supports256Colors(): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Terminals supporting true color (like kmscon) also support 256 colors
|
||||||
|
if (supportsTrueColor()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +100,8 @@ export function supportsTrueColor(): boolean {
|
|||||||
// Check COLORTERM environment variable
|
// Check COLORTERM environment variable
|
||||||
if (
|
if (
|
||||||
process.env['COLORTERM'] === 'truecolor' ||
|
process.env['COLORTERM'] === 'truecolor' ||
|
||||||
process.env['COLORTERM'] === '24bit'
|
process.env['COLORTERM'] === '24bit' ||
|
||||||
|
process.env['COLORTERM'] === 'kmscon'
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user