Revert "fix(settings): keep the Coach entry for a managed record"

This reverts commit 5b8543f471.
This commit is contained in:
Marc-André Bombeck committed 2026-11-12 13:48:08 +01:00
1 parent 9b4b5a1255
commit 6004b0c98d
2 files changed
+3 -40

No files matched your search

@@ -15,10 +15,7 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
const h = vi.hoisted(() => ({
coachAvailable: true,
active: null as Record<string, unknown> | null,
}));
const h = vi.hoisted(() => ({ coachAvailable: true }));
vi.mock("next/navigation", () => ({
usePathname: () => "/settings/ai",
@@ -27,12 +24,7 @@ vi.mock("next/navigation", () => ({
vi.mock("@/hooks/use-mounted", () => ({ useMounted: () => true }));
vi.mock("@/hooks/use-auth", () => ({
useAuth: () => ({
user: {
id: "u1",
role: "USER",
modules: { coach: true },
accountAccess: { active: h.active },
},
user: { id: "u1", role: "USER", modules: { coach: true } },
isAuthenticated: true,
isLoading: false,
refetch: vi.fn(),
@@ -76,7 +68,6 @@ function render(node: React.ReactNode) {
describe("the Coach entry in Settings", () => {
beforeEach(() => {
h.coachAvailable = true;
h.active = null;
});
it("is listed while the Coach can answer, and the memory lives there", () => {
@@ -95,18 +86,4 @@ describe("the Coach entry in Settings", () => {
).not.toContain('href="/settings/coach"');
expect(render(<AiSection />)).toContain('data-slot="stored-coach-memory"');
});
it("stays for a managed record whose Coach cannot answer yet", () => {
// A record has no Settings, AI: the guardian reaches the record's Coach
// data scope and switch through this entry only.
h.coachAvailable = false;
h.active = {
recordKind: "managed",
level: "manage",
manageableDomains: [],
};
expect(
render(<SettingsShell active="coach">body</SettingsShell>),
).toContain('href="/settings/coach"');
});
});
+1 -15
View File
@@ -356,20 +356,6 @@ function deriveActiveSlug(
return isSettingsSectionSlug(candidate) ? candidate : "account";
}
/**
* The module map the section list reads, the sidebar's. A managed record has
* no Settings, AI to list its Coach settings (its data scope, its switch), so
* there the Coach entry follows the module switch alone, not whether the
* record's Coach can answer yet.
*/
function useSectionModules() {
const { user } = useAuth();
const navModules = useNavModules();
return user?.accountAccess?.active?.recordKind === "managed"
? user.modules
: navModules;
}
export function SettingsShell({
active,
heading,
@@ -405,7 +391,7 @@ export function SettingsShell({
// effect (which the lint rule flags as a cascading render), and no risk of
// the two passes disagreeing.
const hydrated = useMounted();
const modules = useSectionModules();
const modules = useNavModules();
const activeRecord = user?.accountAccess?.active ?? null;
const allVisibleSections = SETTINGS_SECTIONS.filter(
(section) =>