Skip to content

Commit 391df5a

Browse files
committed
fix(auth): tighten onboarding backup refresh
1 parent 2dc73dd commit 391df5a

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

lib/codex-manager.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4403,20 +4403,22 @@ async function runAuthLogin(): Promise<number> {
44034403
return 0;
44044404
}
44054405
if (signInMode === "restore-backup") {
4406-
namedBackups = await loadNamedBackupsForOnboarding();
44074406
const latestAvailableBackup = namedBackups[0] ?? null;
44084407
if (!latestAvailableBackup) {
4408+
namedBackups = await loadNamedBackupsForOnboarding();
44094409
continue;
44104410
}
44114411
const restoreMode = await promptBackupRestoreMode(latestAvailableBackup);
44124412
if (restoreMode === "back") {
4413+
namedBackups = await loadNamedBackupsForOnboarding();
44134414
continue;
44144415
}
44154416

44164417
const selectedBackup = restoreMode === "manual"
44174418
? await promptManualBackupSelection(namedBackups)
44184419
: latestAvailableBackup;
44194420
if (!selectedBackup) {
4421+
namedBackups = await loadNamedBackupsForOnboarding();
44204422
continue;
44214423
}
44224424

@@ -4427,6 +4429,7 @@ async function runAuthLogin(): Promise<number> {
44274429
),
44284430
);
44294431
if (!confirmed) {
4432+
namedBackups = await loadNamedBackupsForOnboarding();
44304433
continue;
44314434
}
44324435

@@ -4472,6 +4475,7 @@ async function runAuthLogin(): Promise<number> {
44724475
if ((storageAfterRestoreAttempt?.accounts.length ?? 0) > 0) {
44734476
continue loginFlow;
44744477
}
4478+
namedBackups = await loadNamedBackupsForOnboarding();
44754479
continue;
44764480
}
44774481
continue loginFlow;

test/codex-manager-cli.test.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3220,16 +3220,10 @@ describe("codex manager cli commands", () => {
32203220
])
32213221
.mockResolvedValueOnce([
32223222
{
3223-
path: "/mock/backups/latest.json",
3224-
fileName: "latest.json",
3225-
accountCount: 4,
3226-
mtimeMs: now,
3227-
},
3228-
{
3229-
path: "/mock/backups/old-manual.json",
3230-
fileName: "old-manual.json",
3231-
accountCount: 1,
3232-
mtimeMs: now - 60_000,
3223+
path: "/mock/backups/replacement.json",
3224+
fileName: "replacement.json",
3225+
accountCount: 2,
3226+
mtimeMs: now + 60_000,
32333227
},
32343228
])
32353229
.mockResolvedValueOnce([
@@ -3810,7 +3804,7 @@ describe("codex manager cli commands", () => {
38103804
const exitCode = await runCodexMultiAuthCli(["auth", "login"]);
38113805

38123806
expect(exitCode).toBe(0);
3813-
expect(getNamedBackupsMock).toHaveBeenCalledTimes(2);
3807+
expect(getNamedBackupsMock).toHaveBeenCalledTimes(1);
38143808
expect(restoreAccountsFromBackupMock).toHaveBeenCalledWith(
38153809
"/mock/backups/manual-choice.json",
38163810
{ persist: false },

0 commit comments

Comments
 (0)