fix(ai): close the notes' windows on a fresh Codex sign-in

A save of a person's provider settings and of the operator's admin AI
settings forget the health ledger's record and close the status notes'
negative windows. The two Codex sign-ins, the operator's central one and a
person's own, forgot the ledger record only, so a fixed connection still
had every note wait out the window the refused one earned, up to two hours.

The central sign-in now closes every record's windows, since every account
may fall back on that connection, and a person's own sign-in closes theirs.
Proven against the real rows in the Codex sign-in integration suite.

Refs #1279
This commit is contained in:
Marc-André Bombeck committed 2026-10-25 01:03:50 +02:00
1 parent 8b47d033e7
commit a172e377c1
3 files changed
+121 -3

No files matched your search

@@ -9,6 +9,7 @@ import { auditLog } from "@/lib/auth/audit";
import { getClientIp, apiSuccess, apiError } from "@/lib/api-response";
import { annotate } from "@/lib/logging/context";
import { forgetProviderHealth } from "@/lib/ai/provider-health-ledger";
import { clearStatusNegativeWindows } from "@/lib/insights/status-negative-window";
/**
* Operator-shared central Codex — device-code poll (admin only).
@@ -94,7 +95,12 @@ export const POST = apiHandler(async (request: NextRequest) => {
cookieStore.delete("central_codex_device");
// A new central sign-in: every account's ledger rows describe the refused
// one, and the central connection is one credential shared by all of them.
await forgetProviderHealth({ providerType: "admin-codex" });
// #1279 — and every record's note windows close, as on the admin AI
// settings save, so no note sits out a window the broken one earned.
await Promise.all([
forgetProviderHealth({ providerType: "admin-codex" }),
clearStatusNegativeWindows(),
]);
await auditLog("admin.central-codex.connected", {
userId: user.id,