feat(settings): explain operator switches and keep the Coach memory reachable

Settings, AI says which AI features the server's operator switched off and
shows the one setup hint while no provider is configured. The consent
withdrawal says what it deletes and what stays, and a document-reading
consent on file gets its own withdrawal. Regenerate follows the briefing
capability and the connection test names an operator refusal.

The Coach memory (facts and stored conversations) is never gated on the
Coach: Settings, Coach always shows it, and Settings, AI shows it while
the Coach page is out of reach, whenever rows exist.

Onboarding offers AI only where it can be set up here: the done-screen
panel and the getting-started row go away while the operator has AI off
or inside somebody else's record.
This commit is contained in:
Marc-André Bombeck committed 2026-09-24 11:05:54 +02:00
1 parent 4449b34ac7
commit 3d85445e50
24 files changed
+913 -232

No files matched your search

@@ -63,21 +63,18 @@ vi.mock("@/hooks/use-auth", async () => {
return { ...actual, useAuth: () => authSpy() };
});
// The hub now renders a live coach switch, so it reads the operator assistant
// flag matrix (`flags.coach`) to decide whether the operator killed Coach
// server-wide. Mock the hook directly so the SSR pass doesn't need a
// `<QueryClientProvider>`; default all-on.
import type { AssistantFlagSet } from "@/hooks/use-feature-flags";
const ALL_ON_FLAGS: AssistantFlagSet = {
enabled: true,
coach: true,
briefing: true,
insightStatus: true,
documentAi: true,
// The hub renders a live coach switch and reads the `coach` AI capability to
// decide whether the operator switched the Coach off server-wide. Mock the
// hook directly so the SSR pass doesn't need a `<QueryClientProvider>`.
import type { AiCapabilityState } from "@/lib/ai/capabilities/types";
const COACH_AVAILABLE: AiCapabilityState = {
available: true,
reason: null,
onDeviceAllowed: true,
};
const flagsSpy = vi.fn<() => AssistantFlagSet>(() => ALL_ON_FLAGS);
vi.mock("@/hooks/use-feature-flags", () => ({
useFeatureFlags: () => flagsSpy(),
const coachSpy = vi.fn<() => AiCapabilityState>(() => COACH_AVAILABLE);
vi.mock("@/hooks/use-ai-capability", () => ({
useAiCapability: () => coachSpy(),
}));
function buildUser(
@@ -133,7 +130,7 @@ beforeEach(() => {
user: buildUser({}),
isAuthenticated: true,
}));
flagsSpy.mockImplementation(() => ALL_ON_FLAGS);
coachSpy.mockImplementation(() => COACH_AVAILABLE);
});
afterEach(() => {
@@ -295,7 +292,11 @@ describe("<ModulesSection>", () => {
it("disables the switch + shows a hint when the operator killed Coach", () => {
// Operator assistant master flag off → coach is unavailable server-wide.
flagsSpy.mockImplementation(() => ({ ...ALL_ON_FLAGS, coach: false }));
coachSpy.mockImplementation(() => ({
available: false,
reason: "operator_disabled",
onDeviceAllowed: false,
}));
const html = render();
const coachTag = html.match(
/<button[^>]*id="module-toggle-coach"[^>]*>/,