mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-05 02:40:55 -07:00
Fix mixed input crash by adding proper error handling 8304 (#8430)
This commit is contained in:
@@ -174,6 +174,15 @@ describe('gemini.tsx main function kitty protocol', () => {
|
||||
(process.stdin as any).setRawMode = vi.fn();
|
||||
}
|
||||
setRawModeSpy = vi.spyOn(process.stdin, 'setRawMode');
|
||||
|
||||
Object.defineProperty(process.stdin, 'isTTY', {
|
||||
value: true,
|
||||
configurable: true,
|
||||
});
|
||||
Object.defineProperty(process.stdin, 'isRaw', {
|
||||
value: false,
|
||||
configurable: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('should call setRawMode and detectAndEnableKittyProtocol when isInteractive is true', async () => {
|
||||
|
||||
@@ -209,9 +209,17 @@ export async function main() {
|
||||
argv,
|
||||
);
|
||||
|
||||
// Check for invalid input combinations early to prevent crashes
|
||||
if (argv.promptInteractive && !process.stdin.isTTY) {
|
||||
console.error(
|
||||
'Error: The --prompt-interactive flag cannot be used when input is piped from stdin.',
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const wasRaw = process.stdin.isRaw;
|
||||
let kittyProtocolDetectionComplete: Promise<boolean> | undefined;
|
||||
if (config.isInteractive() && !wasRaw) {
|
||||
if (config.isInteractive() && !wasRaw && process.stdin.isTTY) {
|
||||
// Set this as early as possible to avoid spurious characters from
|
||||
// input showing up in the output.
|
||||
process.stdin.setRawMode(true);
|
||||
@@ -248,13 +256,6 @@ export async function main() {
|
||||
validateDnsResolutionOrder(settings.merged.advanced?.dnsResolutionOrder),
|
||||
);
|
||||
|
||||
if (argv.promptInteractive && !process.stdin.isTTY) {
|
||||
console.error(
|
||||
'Error: The --prompt-interactive flag is not supported when piping input from stdin.',
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (config.getListExtensions()) {
|
||||
console.log('Installed extensions:');
|
||||
for (const extension of extensions) {
|
||||
|
||||
Reference in New Issue
Block a user