fix(cli): restore resume for legacy sessions (#26577)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
Kuroda Kayn
2026-05-12 08:28:47 +08:00
committed by GitHub
parent 24b98ade86
commit 11a9edc808
4 changed files with 177 additions and 11 deletions
+33
View File
@@ -1189,6 +1189,39 @@ describe('resolveSessionId', () => {
expect(sessionId).toBe('new-id');
expect(resumedSessionData).toBeUndefined();
});
it('should exit with FATAL_INPUT_ERROR when explicit resume session is missing', async () => {
vi.mocked(SessionSelector).mockImplementation(
() =>
({
resolveSession: vi
.fn()
.mockRejectedValue(SessionError.noSessionsFound()),
}) as unknown as InstanceType<typeof SessionSelector>,
);
const emitFeedbackSpy = vi.spyOn(coreEvents, 'emitFeedback');
const processExitSpy = vi
.spyOn(process, 'exit')
.mockImplementation((code) => {
throw new MockProcessExitError(code);
});
try {
await resolveSessionId('explicit-session-id');
} catch (e) {
if (!(e instanceof MockProcessExitError)) throw e;
}
expect(emitFeedbackSpy).toHaveBeenCalledWith(
'error',
expect.stringContaining('Error resuming session:'),
);
expect(processExitSpy).toHaveBeenCalledWith(ExitCodes.FATAL_INPUT_ERROR);
emitFeedbackSpy.mockRestore();
processExitSpy.mockRestore();
});
});
describe('gemini.tsx main function exit codes', () => {