fix(resume): allow passing a prompt via stdin while resuming using --resume (#13520)

This commit is contained in:
bl-ue
2025-11-25 10:53:17 -07:00
committed by GitHub
parent f2c52f777c
commit 098e5c281c
2 changed files with 3 additions and 30 deletions
+3 -25
View File
@@ -435,37 +435,15 @@ describe('parseArguments', () => {
debugErrorSpy.mockRestore();
});
it('should throw an error when resuming a session without prompt in non-interactive mode', async () => {
it('should allow resuming a session without prompt argument in non-interactive mode (expecting stdin)', async () => {
const originalIsTTY = process.stdin.isTTY;
process.stdin.isTTY = false;
process.argv = ['node', 'script.js', '--resume', 'session-id'];
const mockExit = vi.spyOn(process, 'exit').mockImplementation(() => {
throw new Error('process.exit called');
});
const mockConsoleError = vi
.spyOn(console, 'error')
.mockImplementation(() => {});
const debugErrorSpy = vi
.spyOn(debugLogger, 'error')
.mockImplementation(() => {});
try {
await expect(parseArguments({} as Settings)).rejects.toThrow(
'process.exit called',
);
expect(debugErrorSpy).toHaveBeenCalledWith(
expect.stringContaining(
'When resuming a session, you must provide a message via --prompt (-p) or stdin',
),
);
expect(mockConsoleError).toHaveBeenCalled();
const argv = await parseArguments({} as Settings);
expect(argv.resume).toBe('session-id');
} finally {
mockExit.mockRestore();
mockConsoleError.mockRestore();
debugErrorSpy.mockRestore();
process.stdin.isTTY = originalIsTTY;
}
});