Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
feat(onboarding): ask "What do you work on?" once, at sign-up and on joining (menu access, part 6) (#1707)
Cihanb34b3ea8c8ac
diff --git a/web/messages/en.json b/web/messages/en.jsonindex a1809a4c8..ab9a59a5a 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -7992,6 +7992,19 @@"citationEvidence": "Citation Evidence","citationEvidenceDescription": "The URLs AI answers cited most in this period, and which tracked prompts surfaced them."},+ "welcome": {+ "title": "What do you work on?",+ "invitedTitle": "Welcome to {workspace} Workspace, {name}",+ "invitedTitleNoName": "Welcome to {workspace} Workspace",+ "lede": "Pick what you work on or lead, one or more. We'll set up your menu around it; your team can pick their own when they join.",+ "invitedLede": "You've joined as {role}. What do you work on or lead? We'll set up your menu around it.",+ "yourMenu": "Your menu",+ "hiddenByAdmin": "{count} hidden by your admin",+ "changeLater": "You can change this any time in Settings › Account.",+ "skip": "Skip: show me everything",+ "continue": "Continue",+ "saveFailed": "Couldn't save your work areas. Try again."+ },"settings": {"title": "Settings","description": "Manage your project and account settings.",diff --git a/web/src/app/[locale]/(dashboard)/layout.tsx b/web/src/app/[locale]/(dashboard)/layout.tsxindex cbf8dc396..c838a36bb 100644--- a/web/src/app/[locale]/(dashboard)/layout.tsx+++ b/web/src/app/[locale]/(dashboard)/layout.tsx@@ -74,6 +74,12 @@ export default async function DashboardLayout({ children }: { children: React.Re}}+ // "What do you work on?", asked once (menu access): an invited person on+ // their first visit, a self-hosted admin after onboarding.+ if (!menu.workAreasAsked) {+ redirect('/dashboard/welcome');+ }+const planId = (org?.plan ?? 'starter') as PlanId;// Effective API-model allowlist for the client (null = all allowed).diff --git a/web/src/app/[locale]/(onboarding)/dashboard/onboarding/page.tsx b/web/src/app/[locale]/(onboarding)/dashboard/onboarding/page.tsxindex 1ff70a53b..d982e32de 100644--- a/web/src/app/[locale]/(onboarding)/dashboard/onboarding/page.tsx+++ b/web/src/app/[locale]/(onboarding)/dashboard/onboarding/page.tsx@@ -1,6 +1,7 @@'use client';import { useState, useEffect, useRef } from 'react';+import { useTranslations } from 'next-intl';import { useRouter } from '@/i18n/navigation';import { createClient } from '@/lib/supabase/client';import { createBrand, markBrandAsEcommerce } from '@/lib/actions/brand';@@ -26,13 +27,19 @@ import { ALL_MODELS, ALL_SCRAPERS } from '@/config/prompt-options';import { isCloud, PLANS, SUBSCRIBABLE_PLANS, getPlan, type PlanId } from '@/config/plans';import { setPersonProperties, track } from '@/lib/analytics';+/** "What do you work on?" (menu access): once the brand is set up, before the plan. */+const WORK_AREAS_STEP = 6;+/** Choose a plan (cloud only): the last step. */+const PLAN_STEP = 7;+const ONBOARDING_STEP_NAMES: Record<number, string> = {1: 'brand_setup',2: 'brand_details',3: 'topics',4: 'prompts',5: 'competitors',- 6: 'plan',+ [WORK_AREAS_STEP]: 'work_areas',+ [PLAN_STEP]: 'plan',};import type { Brand } from '@/types';import { Badge } from '@/components/ui/badge';@@ -76,6 +83,7 @@ import {} from '@/lib/ai-brand-setup';import { DashboardPreview } from '@/components/onboarding/dashboard-preview';import { OnboardingFrame } from '@/components/onboarding/onboarding-frame';+import { WorkAreasStep } from '@/components/onboarding/work-areas-step';import { DASHBOARD_HOME } from '@/config/home';// ── Step indicator ─────────────────────────────────────────────────────────────@@ -246,7 +254,12 @@ const PLAN_STEP_COPY: Partial<const TRIAL_ASSURANCES = ['Zero risk', 'No charge today', 'Cancel anytime'];// Card width per step, matched to each step's content column; unlisted steps are forms.-const STEP_FRAME_WIDTH: Record<number, 'medium' | 'wide'> = { 3: 'wide', 4: 'wide', 6: 'medium' };+const STEP_FRAME_WIDTH: Record<number, 'medium' | 'wide'> = {+ 3: 'wide',+ 4: 'wide',+ [WORK_AREAS_STEP]: 'wide',+ [PLAN_STEP]: 'medium',+};const TOPIC_LOADING_MESSAGES = ['Researching topics for your brand...',@@ -269,6 +282,7 @@ const COMPETITOR_LOADING_MESSAGES = [export default function OnboardingPage() {const router = useRouter();+ const tWelcome = useTranslations('welcome');const { addBrand, setActiveBrand, updateBrand: updateBrandInStore } = useBrandStore();const [step, setStep] = useState(1);@@ -343,7 +357,7 @@ export default function OnboardingPage() {const [competitorLoadingMsg, setCompetitorLoadingMsg] = useState('');const competitorMsgIdx = useRef(0);- // Step 6 (cloud only)+ // Plan step (cloud only)const [checkoutLoading, setCheckoutLoading] = useState<PlanId | null>(null);const [organizationId, setOrganizationId] = useState<string | null>(null);// Trial length when the plan step is reached; null once the organization has@@ -355,7 +369,7 @@ export default function OnboardingPage() {const [trialConfirmed, setTrialConfirmed] = useState(false);useEffect(() => {- if (step !== 6) return;+ if (step !== PLAN_STEP) return;let cancelled = false;fetch('/api/stripe/trial').then((res) => (res.ok ? res.json() : null))@@ -383,7 +397,9 @@ export default function OnboardingPage() {competitors: { name: string; domain: string }[];} | null>(null);- const totalSteps = isCloud() ? 6 : 5;+ // Self-host has no plan step, and asks "What do you work on?" on the+ // dashboard's first visit instead (/dashboard/welcome).+ const totalSteps = isCloud() ? PLAN_STEP : 5;// Determine which scrapers/models are available based on the planconst currentPlan = getPlan(currentPlanId);@@ -450,7 +466,7 @@ export default function OnboardingPage() {const { data: profile } = await supabase.from('profiles')- .select('organization_id, onboarding_completed')+ .select('organization_id, onboarding_completed, work_areas_asked_at').eq('id', user.id).single();@@ -467,7 +483,7 @@ export default function OnboardingPage() {if (subStatus !== 'active' && subStatus !== 'trialing') {setOrganizationId(profile.organization_id);void loadResumedPreview(profile.organization_id);- setStep(6);+ setStep(profile.work_areas_asked_at ? PLAN_STEP : WORK_AREAS_STEP);setInitialLoading(false);return;}@@ -949,11 +965,11 @@ export default function OnboardingPage() {onboarding_completed: true,});- // Cloud mode → proceed to subscription step (tracking triggered after payment)+ // Cloud mode → what they work on, then the subscription step (tracking+ // triggered after payment)if (isCloud()) {- toast.success('Almost done! Choose a plan to get started.');setSavingCompetitors(false);- setStep(6);+ setStep(WORK_AREAS_STEP);return;}@@ -990,13 +1006,13 @@ export default function OnboardingPage() {}};- // ── Step 6: Stripe checkout ──+ // ── Plan step: Stripe checkout ──const handleCheckout = async (planId: PlanId) => {if (!organizationId) return;setCheckoutLoading(planId);track('onboarding_step_completed', {- step: 6,+ step: PLAN_STEP,step_name: 'plan',plan_id: planId,});@@ -1722,9 +1738,41 @@ export default function OnboardingPage() {);}- // ── Step 6: Choose Plan (cloud only) ──+ // ── What do you work on? (menu access) ──++ if (step === WORK_AREAS_STEP) {+ return (+ <WorkAreasStep+ title={tWelcome('title')}+ lede={tWelcome('lede')}+ onDone={() => {+ track('onboarding_step_completed', {+ step: WORK_AREAS_STEP,+ step_name: 'work_areas',+ });+ toast.success('Almost done! Choose a plan to get started.');+ setStep(PLAN_STEP);+ }}+ footer={+ <div className="flex mx-auto w-full max-w-4xl items-center justify-between mt-8">+ <button+ onClick={() => setStep(5)}+ className="flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground"+ >+ <ArrowLeft className="h-3.5 w-3.5" />+ Back+ </button>+ <StepDots current={WORK_AREAS_STEP} total={totalSteps} />+ <div className="w-12" />+ </div>+ }+ />+ );+ }++ // ── Choose Plan (cloud only) ──- if (step !== 6) return null;+ if (step !== PLAN_STEP) return null;return (<div className="flex flex-col p-6 md:p-10">@@ -1846,13 +1894,13 @@ export default function OnboardingPage() {<div className="flex mx-auto w-full max-w-2xl items-center justify-between mt-8"><button- onClick={() => setStep(5)}+ onClick={() => setStep(WORK_AREAS_STEP)}className="flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground"><ArrowLeft className="h-3.5 w-3.5" />Back</button>- <StepDots current={6} total={totalSteps} />+ <StepDots current={PLAN_STEP} total={totalSteps} /><div className="w-12" /></div></div>diff --git a/web/src/app/[locale]/(onboarding)/dashboard/welcome/_welcome-view.tsx b/web/src/app/[locale]/(onboarding)/dashboard/welcome/_welcome-view.tsxnew file mode 100644index 000000000..b07c1e453--- /dev/null+++ b/web/src/app/[locale]/(onboarding)/dashboard/welcome/_welcome-view.tsx@@ -0,0 +1,44 @@+'use client';++import { useTranslations } from 'next-intl';+import { WorkAreasStep } from '@/components/onboarding/work-areas-step';+import { DASHBOARD_HOME } from '@/config/home';+import type { TeamRole } from '@/components/providers/role-provider';++/**+ * The welcome step's copy: an invited person is welcomed to the workspace by+ * name; an admin is asked what they work on.+ */+export function WelcomeView({+ role,+ workspace,+ firstName,+ hiddenByAdmin,+}: {+ role: TeamRole;+ workspace: string;+ firstName: string;+ hiddenByAdmin: string[];+}) {+ const t = useTranslations('welcome');+ const tSettings = useTranslations('settings');+ const invited = role !== 'admin';+ const title = !invited+ ? t('title')+ : firstName+ ? t('invitedTitle', { workspace, name: firstName })+ : t('invitedTitleNoName', { workspace });+ const lede = invited+ ? t('invitedLede', { role: tSettings(`team_role_${role}`).toLowerCase() })+ : t('lede');++ return (+ <WorkAreasStep+ title={title}+ lede={lede}+ hiddenByAdmin={hiddenByAdmin}+ // A full load, so the dashboard reads the answer and doesn't send them back.+ onDone={() => window.location.assign(DASHBOARD_HOME)}+ />+ );+}diff --git a/web/src/app/[locale]/(onboarding)/dashboard/welcome/page.tsx b/web/src/app/[locale]/(onboarding)/dashboard/welcome/page.tsxnew file mode 100644index 000000000..2b42aa863--- /dev/null+++ b/web/src/app/[locale]/(onboarding)/dashboard/welcome/page.tsx@@ -0,0 +1,50 @@+import { redirect } from 'next/navigation';+import { createClient } from '@/lib/supabase/server';+import { getMyMenu } from '@/lib/actions/menu-access';+import { OnboardingFrame } from '@/components/onboarding/onboarding-frame';+import { DASHBOARD_HOME } from '@/config/home';+import type { TeamRole } from '@/components/providers/role-provider';+import { WelcomeView } from './_welcome-view';++/**+ * "What do you work on?" for someone who wasn't asked in onboarding: an+ * invited person on their first sign-in, or a self-hosted admin (no plan+ * step to ask before). The dashboard sends them here once (menu access);+ * anyone already asked goes on to the dashboard.+ */+export default async function WelcomePage() {+ const supabase = await createClient();+ const {+ data: { user },+ } = await supabase.auth.getUser();+ if (!user) redirect('/sign-in');++ const { data: profile } = await supabase+ .from('profiles')+ .select('full_name, role, organization_id, onboarding_completed, work_areas_asked_at')+ .eq('id', user.id)+ .single();+ if (!profile?.organization_id || !profile.onboarding_completed) redirect('/dashboard/onboarding');+ if (profile.work_areas_asked_at) redirect(DASHBOARD_HOME);++ const [menu, { data: brands }, { data: org }] = await Promise.all([+ getMyMenu().catch(() => null),+ supabase.from('brands').select('name').eq('organization_id', profile.organization_id).limit(2),+ supabase.from('organizations').select('name').eq('id', profile.organization_id).single(),+ ]);+ // The brand's name, or the organization's when it has several brands.+ const workspace =+ (brands?.length === 1 ? brands[0].name : (org?.name ?? brands?.[0]?.name)) ?? '';+ const fullName = profile.full_name || (user.user_metadata?.full_name as string | undefined) || '';++ return (+ <OnboardingFrame width="wide" preview={null}>+ <WelcomeView+ role={profile.role as TeamRole}+ workspace={workspace}+ firstName={fullName.trim().split(/\s+/)[0] ?? ''}+ hiddenByAdmin={menu?.hiddenByAdmin ?? []}+ />+ </OnboardingFrame>+ );+}diff --git a/web/src/components/onboarding/work-areas-step.test.tsx b/web/src/components/onboarding/work-areas-step.test.tsxnew file mode 100644index 000000000..7191296b5--- /dev/null+++ b/web/src/components/onboarding/work-areas-step.test.tsx@@ -0,0 +1,131 @@+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { NextIntlClientProvider } from 'next-intl';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import messages from '../../../messages/en.json';++/**+ * "What do you work on?": the person picks their work areas and sees the menu+ * they give; Continue or Skip saves (so it isn't asked again) and moves on.+ */++const toast = vi.hoisted(() => ({ error: vi.fn(), success: vi.fn() }));+vi.mock('sonner', () => ({ toast }));++const actions = vi.hoisted(() => ({ setMyWorkAreas: vi.fn() }));+vi.mock('@/lib/actions/menu-access', () => actions);++const { WorkAreasStep } = await import('./work-areas-step');+const { WelcomeView } = await import('@/app/[locale]/(onboarding)/dashboard/welcome/_welcome-view');++(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT =+ true;++let container: HTMLDivElement;+let root: Root;+const onDone = vi.fn();++beforeEach(() => {+ vi.clearAllMocks();+ actions.setMyWorkAreas.mockResolvedValue(undefined);+ container = document.createElement('div');+ document.body.appendChild(container);+ root = createRoot(container);+});++afterEach(() => {+ act(() => root.unmount());+ container.remove();+});++async function render(node: React.ReactNode) {+ await act(async () => {+ root.render(+ <NextIntlClientProvider locale="en" messages={messages}>+ {node}+ </NextIntlClientProvider>,+ );+ });+}++const button = (text: string) =>+ [...container.querySelectorAll('button')].find((b) =>+ b.textContent?.startsWith(text),+ ) as HTMLButtonElement;+const menu = () => [...container.querySelectorAll('[data-section]')].map((li) => li.textContent);++describe('WorkAreasStep', () => {+ it('shows every area with its sections, and the whole menu before a pick', async () => {+ await render(<WorkAreasStep title="What do you work on?" lede="Pick." onDone={onDone} />);+ expect(container.querySelectorAll('button[aria-pressed]')).toHaveLength(9);+ expect(button('Founders & leaders').textContent).toContain(+ 'Action Center · Chat · Brand Visibility · Mentions · AI Referral Traffic · Reports',+ );+ expect(container.textContent).toContain('11 of 11 sections');+ });++ it('narrows the menu as areas are picked, and saves them on Continue', async () => {+ await render(<WorkAreasStep title="t" lede="l" onDone={onDone} />);+ act(() => button('Brand & PR').click());+ act(() => button('Developers').click());+ expect(button('Brand & PR').getAttribute('aria-pressed')).toBe('true');+ expect(container.textContent).toContain('9 of 11 sections');+ expect(menu()).not.toContain('Content');+ expect(menu()).not.toContain('Product Visibility');++ await act(async () => button('Continue').click());+ expect(actions.setMyWorkAreas).toHaveBeenCalledWith(['brand', 'developers']);+ expect(onDone).toHaveBeenCalled();+ });++ it('saves no areas on Skip: every section', async () => {+ await render(<WorkAreasStep title="t" lede="l" onDone={onDone} />);+ act(() => button('Growth').click());+ await act(async () => button('Skip: show me everything').click());+ expect(actions.setMyWorkAreas).toHaveBeenCalledWith([]);+ expect(onDone).toHaveBeenCalled();+ });++ it('stays when the save fails', async () => {+ actions.setMyWorkAreas.mockRejectedValueOnce(new Error('nope'));+ await render(<WorkAreasStep title="t" lede="l" onDone={onDone} />);+ await act(async () => button('Continue').click());+ expect(onDone).not.toHaveBeenCalled();+ expect(toast.error).toHaveBeenCalledWith("Couldn't save your work areas. Try again.");+ expect(button('Continue').disabled).toBe(false);+ });++ it('keeps what the admin took off out of the menu, and says so', async () => {+ await render(+ <WorkAreasStep title="t" lede="l" hiddenByAdmin={['content', 'audit']} onDone={onDone} />,+ );+ expect(container.textContent).toContain('9 of 11 sections');+ expect(container.textContent).toContain('2 hidden by your admin');+ });+});++describe('WelcomeView', () => {+ it('welcomes an invited person to the workspace by name', async () => {+ await render(+ <WelcomeView role="analyst" workspace="Acme Coffee" firstName="Mert" hiddenByAdmin={[]} />,+ );+ expect(container.querySelector('h1')?.textContent).toBe(+ 'Welcome to Acme Coffee Workspace, Mert',+ );+ expect(container.textContent).toContain("You've joined as analyst.");+ });++ it('does without a name it doesn’t have', async () => {+ await render(+ <WelcomeView role="manager" workspace="Acme Coffee" firstName="" hiddenByAdmin={[]} />,+ );+ expect(container.querySelector('h1')?.textContent).toBe('Welcome to Acme Coffee Workspace');+ });++ it('asks an admin what they work on', async () => {+ await render(+ <WelcomeView role="admin" workspace="Acme" firstName="Cihan" hiddenByAdmin={[]} />,+ );+ expect(container.querySelector('h1')?.textContent).toBe('What do you work on?');+ });+});diff --git a/web/src/components/onboarding/work-areas-step.tsx b/web/src/components/onboarding/work-areas-step.tsxnew file mode 100644index 000000000..a40f3347c--- /dev/null+++ b/web/src/components/onboarding/work-areas-step.tsx@@ -0,0 +1,193 @@+'use client';++import { useState, type ReactNode } from 'react';+import { useTranslations } from 'next-intl';+import { toast } from 'sonner';+import {+ BarChart3,+ Briefcase,+ Check,+ Code,+ Crown,+ Loader2,+ MessageCircle,+ Package,+ PenLine,+ Search,+ TrendingUp,+ type LucideIcon,+} from 'lucide-react';+import { Button } from '@/components/ui/button';+import { cn } from '@/lib/utils';+import { dashboardNav } from '@/config/dashboard';+import { getDashboardNavLabel } from '@/lib/dashboard-navigation';+import {+ MENU_SECTIONS,+ WORK_AREAS,+ WORK_AREA_IDS,+ hiddenWithWorkAreas,+ menuSectionOf,+ type WorkAreaId,+} from '@/lib/menu-access';+import { setMyWorkAreas } from '@/lib/actions/menu-access';++const AREA_ICONS: Record<WorkAreaId, LucideIcon> = {+ leaders: Crown,+ aeo: Search,+ content: PenLine,+ brand: MessageCircle,+ growth: TrendingUp,+ product: Package,+ bizdev: Briefcase,+ developers: Code,+ analytics: BarChart3,+};++/** The menu's sections with their icons and nav titles, in its order. */+const SECTIONS = dashboardNav+ .flatMap((group) => group.items)+ .flatMap((item) => {+ const section = menuSectionOf(item.href);+ return section ? [{ section, title: item.title, icon: item.icon }] : [];+ });++/**+ * "What do you work on?" (menu access): the person picks what they work on or+ * lead, and sees the menu it gives them. Asked once, after the brand is set up+ * in onboarding, or on an invited person's first sign-in; saved on Continue or+ * Skip, so it isn't asked again. Changed later in Settings › Account.+ */+export function WorkAreasStep({+ title,+ lede,+ hiddenByAdmin = [],+ footer,+ onDone,+}: {+ title: string;+ lede: string;+ /** Sections the person's role or an exception takes off, whatever they pick. */+ hiddenByAdmin?: readonly string[];+ /** The wizard's own row under the step (Back, step dots). */+ footer?: ReactNode;+ onDone: () => void;+}) {+ const t = useTranslations('welcome');+ const tAreas = useTranslations('settings.menuAccess');+ const tNav = useTranslations('nav');+ const [picked, setPicked] = useState<WorkAreaId[]>([]);+ const [saving, setSaving] = useState<'continue' | 'skip' | null>(null);+ const hidden = hiddenWithWorkAreas(hiddenByAdmin, picked);+ const label = (title: string) => getDashboardNavLabel(title, tNav);++ const toggle = (area: WorkAreaId) =>+ setPicked((current) =>+ WORK_AREA_IDS.filter((a) => (a === area ? !current.includes(a) : current.includes(a))),+ );++ const save = async (areas: WorkAreaId[], which: 'continue' | 'skip') => {+ setSaving(which);+ try {+ await setMyWorkAreas(areas);+ onDone();+ } catch {+ toast.error(t('saveFailed'));+ setSaving(null);+ }+ };++ return (+ <div className="flex flex-col p-6 md:p-10">+ <div className="mx-auto w-full max-w-4xl flex-1">+ <div className="mb-6 text-center">+ <h1 className="text-2xl font-bold tracking-tight">{title}</h1>+ <p className="mt-1 text-sm text-muted-foreground">{lede}</p>+ </div>++ <div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">+ {WORK_AREAS.map((area) => {+ const Icon = AREA_ICONS[area.id];+ const on = picked.includes(area.id);+ return (+ <button+ key={area.id}+ type="button"+ aria-pressed={on}+ onClick={() => toggle(area.id)}+ className={cn(+ 'flex flex-col gap-1.5 rounded-xl border bg-card p-4 text-left transition-colors hover:border-foreground/40',+ on && 'border-foreground ring-1 ring-foreground',+ )}+ >+ <span className="flex items-center gap-2 text-sm font-semibold">+ <Icon className="h-4 w-4 shrink-0" />+ {tAreas(`areas.${area.id}.title`)}+ <span+ className={cn(+ 'ml-auto flex h-4 w-4 shrink-0 items-center justify-center rounded-full border',+ on && 'border-foreground bg-foreground text-background',+ )}+ >+ {on && <Check className="h-3 w-3" />}+ </span>+ </span>+ <span className="text-xs text-muted-foreground">+ {tAreas(`areas.${area.id}.text`)}+ </span>+ <span className="text-[11px] text-muted-foreground/80">+ {area.sections+ .map((section) => label(SECTIONS.find((s) => s.section === section)!.title))+ .join(' · ')}+ </span>+ </button>+ );+ })}+ </div>++ <div className="mt-4 rounded-xl border border-dashed p-4">+ <p className="mb-2 flex items-baseline gap-2 text-sm font-medium">+ {t('yourMenu')}+ <span className="text-xs font-normal text-muted-foreground">+ {tAreas('sectionCount', {+ count: MENU_SECTIONS.length - hidden.length,+ total: MENU_SECTIONS.length,+ })}+ </span>+ </p>+ <ul className="grid grid-cols-2 gap-x-4 gap-y-1.5 sm:grid-cols-3 lg:grid-cols-4">+ {SECTIONS.filter(({ section }) => !hidden.includes(section)).map(+ ({ section, title, icon: Icon }) => (+ <li+ key={section}+ data-section={section}+ className="flex items-center gap-2 text-sm"+ >+ <Icon className="h-4 w-4 shrink-0 text-muted-foreground" />+ <span className="truncate">{label(title)}</span>+ </li>+ ),+ )}+ </ul>+ {hiddenByAdmin.length > 0 && (+ <p className="mt-2 text-xs text-muted-foreground">+ {t('hiddenByAdmin', { count: hiddenByAdmin.length })}+ </p>+ )}+ </div>++ <div className="mt-6 flex flex-col-reverse gap-3 sm:flex-row sm:items-center">+ <p className="text-xs text-muted-foreground sm:flex-1">{t('changeLater')}</p>+ <Button variant="ghost" disabled={saving !== null} onClick={() => void save([], 'skip')}>+ {saving === 'skip' && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}+ {t('skip')}+ </Button>+ <Button disabled={saving !== null} onClick={() => void save(picked, 'continue')}>+ {saving === 'continue' && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}+ {t('continue')}+ </Button>+ </div>+ </div>+ {footer}+ </div>+ );+}diff --git a/web/src/components/settings/work-areas-card.tsx b/web/src/components/settings/work-areas-card.tsxindex c430076fb..d59736630 100644--- a/web/src/components/settings/work-areas-card.tsx+++ b/web/src/components/settings/work-areas-card.tsx@@ -14,7 +14,7 @@ import { getDashboardNavLabel } from '@/lib/dashboard-navigation';import {MENU_SECTIONS,WORK_AREA_IDS,- hiddenMenuSections,+ hiddenWithWorkAreas,menuSectionOf,type WorkAreaId,} from '@/lib/menu-access';@@ -33,18 +33,7 @@ const SECTIONS = dashboardNav* areas narrow the rest (as for anyone, admins included).*/export function menuWithWorkAreas(menu: MyMenu, workAreas: WorkAreaId[]): MyMenu {- const byAreas = hiddenMenuSections({- role: 'admin',- roleHidden: [],- shown: [],- hidden: [],- workAreas,- });- return {- ...menu,- workAreas,- hidden: MENU_SECTIONS.filter((s) => menu.hiddenByAdmin.includes(s) || byAreas.has(s)),- };+ return { ...menu, workAreas, hidden: hiddenWithWorkAreas(menu.hiddenByAdmin, workAreas) };}/**diff --git a/web/src/lib/menu-access.test.ts b/web/src/lib/menu-access.test.tsindex 362af0a02..949ffabe6 100644--- a/web/src/lib/menu-access.test.ts+++ b/web/src/lib/menu-access.test.ts@@ -8,6 +8,7 @@ import {WORK_AREA_IDS,cleanMenuSections,hiddenMenuSections,+ hiddenWithWorkAreas,menuOfProfile,menuSectionOf,readRoleHidden,@@ -116,6 +117,20 @@ describe('workAreaSections', () => {});});+describe('hiddenWithWorkAreas', () => {+ it('keeps what the admin takes off and narrows the rest to the areas', () => {+ expect(hiddenWithWorkAreas(['mentions'], ['brand'])).toEqual([+ 'content',+ 'audit',+ 'prompts',+ 'mentions',+ 'shopping',+ 'traffic',+ ]);+ expect(hiddenWithWorkAreas(['mentions'], [])).toEqual(['mentions']);+ });+});+describe('menuOfProfile', () => {const profile = {role: 'manager' as const,diff --git a/web/src/lib/menu-access.ts b/web/src/lib/menu-access.tsindex 9a6ba9d92..3aae32188 100644--- a/web/src/lib/menu-access.ts+++ b/web/src/lib/menu-access.ts@@ -136,6 +136,25 @@ export function hiddenMenuSections(return left;}+/**+ * The sections off a menu with these work areas, given those the person's+ * role and exceptions take off whatever they work on: as they pick, before+ * it's saved.+ */+export function hiddenWithWorkAreas(+ hiddenByAdmin: readonly string[],+ workAreas: readonly string[],+): string[] {+ const byAreas = hiddenMenuSections({+ role: 'admin',+ roleHidden: [],+ shown: [],+ hidden: [],+ workAreas,+ });+ return MENU_SECTIONS.filter((section) => hiddenByAdmin.includes(section) || byAreas.has(section));+}+/** A person's menu, as the dashboard and Settings read it. */export interface MyMenu {/** Sections off this person's left menu. */