mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 05:42:19 +00:00
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:
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,
|
||||
|
||||
@@ -10,6 +10,7 @@ import { getClientIp, apiSuccess, apiError } from "@/lib/api-response";
|
||||
import { annotate } from "@/lib/logging/context";
|
||||
import { INSIGHTS_CACHE_CLEARED } from "@/lib/insights/cached-text-cipher";
|
||||
import { forgetProviderHealth } from "@/lib/ai/provider-health-ledger";
|
||||
import { clearStatusNegativeWindows } from "@/lib/insights/status-negative-window";
|
||||
|
||||
/**
|
||||
* v1.4.7.1: Device-code flow polling endpoint.
|
||||
@@ -90,8 +91,12 @@ export const POST = apiHandler(async (request: NextRequest) => {
|
||||
|
||||
cookieStore.delete("codex_device");
|
||||
// A new sign-in: whatever the ledger held against the old one no longer
|
||||
// describes this credential.
|
||||
await forgetProviderHealth({ userId: user.id, providerType: "codex" });
|
||||
// describes this credential, and (#1279) the person's notes stop waiting
|
||||
// out windows it earned, as on a save of their provider settings.
|
||||
await Promise.all([
|
||||
forgetProviderHealth({ userId: user.id, providerType: "codex" }),
|
||||
clearStatusNegativeWindows(user.id),
|
||||
]);
|
||||
|
||||
await auditLog("codex.oauth.connected", {
|
||||
userId: user.id,
|
||||
|
||||
Reference in new issue
Block a user