feat(auth): publish the resolved Coach reasoning on the account payload

GET /api/auth/me gains coachReasoning: the level a turn runs at, the
person's own pick, the highest level the settings may offer, whether
reasoning can run at all, whether the lowest option is a real off, and
the layer that decided. Resolved on the server so the web settings and
the native client read the same answer.

The web reads it through useCoachReasoning. The Coach preferences route
names the stored level on its wide event, and a unit test round-trips
the level through the account-settings backup section.
This commit is contained in:
Marc-André Bombeck committed 2026-10-06 19:44:52 +02:00
1 parent adb4cd5c40
commit df0689ffbe
10 files changed
+554 -3

No files matched your search

@@ -20,6 +20,10 @@ import {
} from "@/lib/export/account-settings-backup";
import { UNREADABLE_EXPORT_MARKER } from "@/lib/export/unreadable-marker";
import { reasoningEffortFor } from "@/lib/ai/reasoning-effort";
import {
coachReasoningLevel,
parseCoachPrefs,
} from "@/lib/validations/coach-prefs";
/** A 1x1 PNG, the smallest image the avatar upload accepts. */
const PNG_1X1 =
@@ -223,6 +227,28 @@ describe("admitAccountSettings", () => {
expect(reasoningEffortFor(restored, "openai-compatible")).toBe("high");
});
it("carries the Coach's thinking depth through a round trip", async () => {
const prefs = {
tone: "warm",
verbosity: "default",
excludeMetrics: [],
showEvidenceByDefault: false,
defaultWindow: "allTime",
reasoning: "high",
};
const { accountSettings } = await buildAccountSettingsBackupSection(
prismaReturning(rowWith({ coachPrefsJson: prefs })),
"u1",
{ purpose: "portable-export" },
);
const restored = admitAccountSettings(
JSON.parse(JSON.stringify(accountSettings)),
ctx,
).data.coachPrefsJson;
expect(restored).toEqual(prefs);
expect(coachReasoningLevel(parseCoachPrefs(restored))).toBe("high");
});
it("writes a database null for a JSON setting the file clears", () => {
expect(
admitAccountSettings({ dashboardWidgetsJson: null }, ctx).data