Skip to content

Commit 14ec6b0

Browse files
committed
Merge Commit '098e5c2': fix(resume): allow passing a prompt via stdin while resuming using --resume (google-gemini#13520)
2 parents 45d22f3 + 098e5c2 commit 14ec6b0

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
@@ -283,11 +283,6 @@ export async function parseArguments(settings: Settings): Promise<CliArgs> {
283283
if (argv['prompt'] && argv['promptInteractive']) {
284284
return 'Cannot use both --prompt (-p) and --prompt-interactive (-i) together';
285285
}
286-
if (argv['resume'] && !argv['prompt'] && !process.stdin.isTTY) {
287-
throw new Error(
288-
'When resuming a session, you must provide a message via --prompt (-p) or stdin',
289-
);
290-
}
291286
if (argv['yolo'] && argv['approvalMode']) {
292287
return 'Cannot use both --yolo (-y) and --approval-mode together. Use --approval-mode=yolo instead.';
293288
}

0 commit comments

Comments
 (0)