Skip to content

Commit 5a0d2ac

Browse files
feat(session): skip directory check for legacy sessions without directory field
1 parent 38fe3ee commit 5a0d2ac

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/cli.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,18 @@ describe('cli', () => {
262262
expect(renderApp).toHaveBeenCalledWith('session-1');
263263
});
264264

265+
it('allows resume when session has no directory field (legacy session)', async () => {
266+
loadSession.mockReturnValueOnce({
267+
metadata: { id: 'session-1', directory: undefined },
268+
messages: [],
269+
});
270+
271+
await commandState.resumeAction?.('session-1');
272+
273+
expect(renderApp).toHaveBeenCalledWith('session-1');
274+
expect(writeError).not.toHaveBeenCalled();
275+
});
276+
265277
it('blocks TUI and errors when resuming a session from a different directory', async () => {
266278
loadSession.mockReturnValueOnce({
267279
metadata: { id: 'session-1', directory: '/other/project' },

src/cli.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ cli
3131
.action(async (sessionId: string) => {
3232
try {
3333
const loaded = session.loadSession(sessionId);
34-
if (loaded.metadata.directory !== process.cwd()) {
34+
if (
35+
loaded.metadata.directory &&
36+
loaded.metadata.directory !== process.cwd()
37+
) {
3538
terminal.writeError(
3639
terminal.color(
3740
`${UI.WARNING} Cannot resume: session belongs to ${loaded.metadata.directory}\n`,

0 commit comments

Comments
 (0)