Skip to content

Commit 098e5c2

Browse files
authored
fix(resume): allow passing a prompt via stdin while resuming using --resume (google-gemini#13520)
1 parent f2c52f7 commit 098e5c2

File tree

2 files changed

+3
-30
lines changed

2 files changed

+3
-30
lines changed

packages/cli/src/config/config.test.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -435,37 +435,15 @@ describe('parseArguments', () => {
435435
debugErrorSpy.mockRestore();
436436
});
437437

438-
it('should throw an error when resuming a session without prompt in non-interactive mode', async () => {
438+
it('should allow resuming a session without prompt argument in non-interactive mode (expecting stdin)', async () => {
439439
const originalIsTTY = process.stdin.isTTY;
440440
process.stdin.isTTY = false;
441441
process.argv = ['node', 'script.js', '--resume', 'session-id'];
442442

443-
const mockExit = vi.spyOn(process, 'exit').mockImplementation(() => {
444-
throw new Error('process.exit called');
445-
});
446-
447-
const mockConsoleError = vi
448-
.spyOn(console, 'error')
449-
.mockImplementation(() => {});
450-
const debugErrorSpy = vi
451-
.spyOn(debugLogger, 'error')
452-
.mockImplementation(() => {});
453-
454443
try {
455-
await expect(parseArguments({} as Settings)).rejects.toThrow(
456-
'process.exit called',
457-
);
458-
459-
expect(debugErrorSpy).toHaveBeenCalledWith(
460-
expect.stringContaining(
461-
'When resuming a session, you must provide a message via --prompt (-p) or stdin',
462-
),
463-
);
464-
expect(mockConsoleError).toHaveBeenCalled();
444+
const argv = await parseArguments({} as Settings);
445+
expect(argv.resume).toBe('session-id');
465446
} finally {
466-
mockExit.mockRestore();
467-
mockConsoleError.mockRestore();
468-
debugErrorSpy.mockRestore();
469447
process.stdin.isTTY = originalIsTTY;
470448
}
471449
});

packages/cli/src/config/config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,6 @@ export async function parseArguments(settings: Settings): Promise<CliArgs> {
262262
if (argv['prompt'] && argv['promptInteractive']) {
263263
return 'Cannot use both --prompt (-p) and --prompt-interactive (-i) together';
264264
}
265-
if (argv['resume'] && !argv['prompt'] && !process.stdin.isTTY) {
266-
throw new Error(
267-
'When resuming a session, you must provide a message via --prompt (-p) or stdin',
268-
);
269-
}
270265
if (argv['yolo'] && argv['approvalMode']) {
271266
return 'Cannot use both --yolo (-y) and --approval-mode together. Use --approval-mode=yolo instead.';
272267
}

0 commit comments

Comments
 (0)