Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

test(desktop): cover restoring deleted Codex imports (#1985)

许君山 Junshan8c9d05e686a2
diff --git a/apps/desktop/src/main/__tests__/codexLocalSessions.test.ts b/apps/desktop/src/main/__tests__/codexLocalSessions.test.ts
index 2ce79ec8a4..8d534c6272 100644
--- a/apps/desktop/src/main/__tests__/codexLocalSessions.test.ts
+++ b/apps/desktop/src/main/__tests__/codexLocalSessions.test.ts
@@ -392,6 +392,39 @@ describe('Codex local session import', () => {
expect(rows).toEqual([{ id: `codex-${threadId}`, title: 'Import Me' }]);
});
+ it('restores a soft-deleted imported Codex session without creating a duplicate', async () => {
+ const dbPath = createStateDb(externalHome);
+ const rolloutPath = path.join(externalHome, 'sessions', `rollout-2026-05-13-${threadId}.jsonl`);
+ fs.mkdirSync(path.dirname(rolloutPath), { recursive: true });
+ fs.writeFileSync(rolloutPath, '');
+ insertThread(dbPath, threadId, rolloutPath, { updatedAt: 2_000, title: 'Restored from Codex' });
+
+ const localId = `codex-${threadId}`;
+ insertImportedCodexSession(currentTestDb(), localId, threadId);
+ currentTestDb().prepare('UPDATE sessions SET status = ? WHERE id = ?').run('deleted', localId);
+
+ const result = await importExternalCodexSessions([threadId]);
+
+ expect(result).toMatchObject({ scanned: 1, inserted: 0, updated: 1 });
+ const sessions = currentTestDb()
+ .prepare(
+ `
+ SELECT id, title, status, sdk_session_id AS sdkSessionId
+ FROM sessions
+ WHERE sdk_session_id = ?
+ `,
+ )
+ .all(threadId);
+ expect(sessions).toEqual([
+ {
+ id: localId,
+ title: 'Restored from Codex',
+ status: 'active',
+ sdkSessionId: threadId,
+ },
+ ]);
+ });
+
it('normalizes Windows backslash cwd to storage form on import (#537)', async () => {
const dbPath = createStateDb(externalHome);
const rolloutPath = path.join(externalHome, 'sessions', `rollout-2026-05-13-${threadId}.jsonl`);