fix(insights): wait as long as the response timeout allows in the browser

The regenerate button aborted its inline POST after a fixed 45 s, so on a
slow local model every regenerate was cut while the server still had
minutes left on the person's setting. It now uses clientAbortMs over the
route's sequential model calls, never less per call than the briefing's
own 180 s default, because the published value cannot say whether the
person set it.

A save of the about-me self-context derives the clarifying questions
inline and ran under the 15 s request default, which reported a failed
save while the server went on to commit it. All six save sites now take
their abort from the same setting. Every other browser request that waits
on a model either has no client timeout or only queues the work.

Refs #1267
This commit is contained in:
Marc-André Bombeck committed 2026-10-22 13:01:20 +02:00
1 parent 221960af88
commit 6d250d092d
17 files changed
+289 -27

No files matched your search

+16 -1
View File
@@ -8,7 +8,10 @@ import type {
AiConsentState,
AiProviderState,
} from "@/lib/ai/capabilities/types";
import { PROVIDER_DEFAULT_TIMEOUT_MS } from "@/lib/ai/effective-timeout";
import {
clientAbortMs,
PROVIDER_DEFAULT_TIMEOUT_MS,
} from "@/lib/ai/effective-timeout";
import type { CoachReasoningState } from "@/lib/ai/reasoning/resolve";
import type { AiUsageState } from "@/lib/ai/usage-level";
@@ -69,6 +72,18 @@ function useAiProviderStateInner(): AiProviderState {
return user?.ai?.provider ?? NO_PROVIDER_STATE;
}
/**
* #1267 — the timeout for a save of `PUT /api/coach/about-me`. A save that
* changes the text or the shared sections waits on one model call (the
* clarifying questions) before it answers, so the fixed 15 s request default
* reported a failed save while a slow model was still within the person's
* response timeout, and the server went on to commit it.
*/
export function useAboutMeSaveTimeoutMs(): number {
const { responseTimeoutMs } = useAiProviderState();
return clientAbortMs(responseTimeoutMs, 1);
}
/**
* v1.41 — the Coach's thinking depth, resolved on the server (`coachReasoning`
* on `GET /api/auth/me`), or `null` while it is not known: `/me` loading, no