Skip to content

Commit 71d5355

Browse files
committed
fix(ui): require exact archive identity
1 parent 61988fc commit 71d5355

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

‎ui/src/lib/sessions/list-options.test.ts‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,31 +298,46 @@ describe("session list replacement options", () => {
298298
}
299299
listCallCount += 1;
300300
if (listCallCount === 1) {
301-
return sessionsResult([{ key, kind: "direct", updatedAt: 10 }], listCallCount);
301+
return sessionsResult(
302+
[{ key, kind: "direct", sessionId: "archived-session", updatedAt: 10 }],
303+
listCallCount,
304+
);
302305
}
303306
if (listCallCount === 2) {
307+
return sessionsResult(
308+
[{ key, kind: "direct", updatedAt: 30, archived: false }],
309+
listCallCount,
310+
);
311+
}
312+
if (listCallCount === 3) {
304313
return sessionsResult(
305314
[
306315
{
307316
key,
308317
kind: "direct",
309318
sessionId: "replacement-session",
310-
updatedAt: 30,
319+
updatedAt: 40,
311320
archived: false,
312321
},
313322
],
314323
listCallCount,
315324
);
316325
}
317326
return sessionsResult(
318-
[{ key, kind: "direct", updatedAt: 40, archived: false }],
327+
[{ key, kind: "direct", updatedAt: 50, archived: false }],
319328
listCallCount,
320329
);
321330
});
322331
const sessions = createSessions({ request } as unknown as GatewayBrowserClient, key);
323332

324333
await sessions.refresh({ agentId: "main", force: true });
325334
await sessions.patch(key, { archived: true }, { agentId: "main" });
335+
expect(sessions.state.result?.sessions[0]).toMatchObject({
336+
archived: false,
337+
});
338+
expect(sessions.state.result?.sessions[0]?.sessionId).toBeUndefined();
339+
340+
await sessions.refresh({ agentId: "main", force: true });
326341
expect(sessions.state.result?.sessions[0]).toMatchObject({
327342
sessionId: "replacement-session",
328343
archived: false,

‎ui/src/lib/sessions/session-mutations.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,12 @@ export function createSessionMutations(host: SessionMutationsHost) {
501501
if (!archive) {
502502
return row;
503503
}
504-
if (archive.sessionId && row.sessionId && archive.sessionId !== row.sessionId) {
505-
confirmedArchives.delete(row.key);
504+
if (archive.sessionId && archive.sessionId !== row.sessionId) {
505+
// An id-less row may be a same-key replacement whose identity has not arrived.
506+
// Do not transfer archive state; retire it only after a different identity appears.
507+
if (row.sessionId) {
508+
confirmedArchives.delete(row.key);
509+
}
506510
return row;
507511
}
508512
if (row.archived === true) {

0 commit comments

Comments
 (0)