mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 00:12:18 +00:00
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:
1 parent
adb4cd5c40
commit
df0689ffbe
10 files changed
+554
-3
No files matched your search
@@ -12,7 +12,11 @@ vi.mock("@/hooks/use-auth", () => ({
|
||||
useAuth: () => ({ user: authUser }),
|
||||
}));
|
||||
|
||||
import { useAiCapability, useAiProviderState } from "../use-ai-capability";
|
||||
import {
|
||||
useAiCapability,
|
||||
useAiProviderState,
|
||||
useCoachReasoning,
|
||||
} from "../use-ai-capability";
|
||||
import type { AiCapabilityKey } from "@/lib/ai/capabilities/types";
|
||||
|
||||
function Probe({ capability }: { capability: AiCapabilityKey }) {
|
||||
@@ -107,3 +111,47 @@ describe("useAiCapability", () => {
|
||||
expect(render("briefing", false).state).toEqual(UNKNOWN);
|
||||
});
|
||||
});
|
||||
|
||||
function ReasoningProbe() {
|
||||
return <span>{JSON.stringify(useCoachReasoning())}</span>;
|
||||
}
|
||||
|
||||
function renderReasoning(withClient = true): unknown {
|
||||
const html = renderToStaticMarkup(
|
||||
withClient ? (
|
||||
<QueryClientProvider client={new QueryClient()}>
|
||||
<ReasoningProbe />
|
||||
</QueryClientProvider>
|
||||
) : (
|
||||
<ReasoningProbe />
|
||||
),
|
||||
);
|
||||
return JSON.parse(
|
||||
html.replace(/^<span>|<\/span>$/g, "").replace(/"/g, '"'),
|
||||
);
|
||||
}
|
||||
|
||||
describe("useCoachReasoning", () => {
|
||||
const STATE = {
|
||||
level: "low",
|
||||
preference: "high",
|
||||
maxLevel: "low",
|
||||
available: true,
|
||||
offIsReal: true,
|
||||
source: "admin_cap",
|
||||
};
|
||||
|
||||
it("hands over the server's resolved block untouched", () => {
|
||||
authUser = { coachReasoning: STATE };
|
||||
expect(renderReasoning()).toEqual(STATE);
|
||||
});
|
||||
|
||||
it("is null while the payload is not there or carries no block", () => {
|
||||
authUser = null;
|
||||
expect(renderReasoning()).toBeNull();
|
||||
authUser = { coachReasoning: null };
|
||||
expect(renderReasoning()).toBeNull();
|
||||
authUser = { coachReasoning: STATE };
|
||||
expect(renderReasoning(false)).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user