AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).
feat(ui): give the settings page a section nav and grouped tools (#260)
Rufusf89656265e9f
diff --git a/packages/core/openexecutive/architecture/prebuilt/user_guide.json b/packages/core/openexecutive/architecture/prebuilt/user_guide.jsonindex d7013bc2..b83f1361 100644--- a/packages/core/openexecutive/architecture/prebuilt/user_guide.json+++ b/packages/core/openexecutive/architecture/prebuilt/user_guide.json@@ -1,7 +1,7 @@{"section_id": "user_guide","title": "User Guide Surface",- "markdown": "The `/guide` page is a **plain-language overview of every user-facing feature** — \"what it is, what it does, how to use it\" — aimed at non-engineers. It is deliberately kept separate from this technical reference: Architecture explains how the system is built; the User Guide explains what each feature does for you.\n\nIt is reached from a **tile on the Settings hub** (`ADVANCED_ITEMS` in `navConfig.ts`), not the day-to-day nav.\n\n**Served exactly like this page.** Each section is static, hand-authored JSON shipped in the image — `packages/core/openexecutive/guide/prebuilt/<id>.json`, one file per entry in `guide/sections.py` → `GUIDE_SECTIONS`. The route `api/routes/guide.py` exposes `GET /guide/sections` and `GET /guide/sections/{id}`, mirroring the architecture routes. **Nothing on the serving path calls an LLM.**\n\n**Shared loader.** Both surfaces load their files through one class — `openexecutive.utils.prebuilt_store.PrebuiltDocStore` — pointed at each module's own `prebuilt/` directory. The same fields apply (`section_id`, `title`, `markdown`, `mermaid`, `generated_at`), and the same path-traversal guard rejects any id containing a separator or dot segment.\n\n**Shared renderer.** The UI reuses the architecture page's `DynamicSection` component via a `basePath` prop (`\"architecture\"` by default, `\"guide\"` for the guide), so deep links, lazy loading, and Markdown sanitization behave identically. The guide is intentionally diagram-free — its sections carry `mermaid: null`.\n\n**Keeping it current:** when a user-facing feature is added or materially changed, add or update the matching `guide/prebuilt/<id>.json` (and its registry entry in `guide/sections.py` + the mirror list in `app/guide/page.tsx`), the same way technical sections are maintained here. Every section must include a `**How to use:**` walkthrough (and an `**Example:**` where one helps) — `tests/unit/test_guide_prebuilt.py` enforces it. Because Ask OE inlines the current page's section into its user turn, those steps also ground its \"how do I…\" answers.",+ "markdown": "The `/guide` page is a **plain-language overview of every user-facing feature** — \"what it is, what it does, how to use it\" — aimed at non-engineers. It is deliberately kept separate from this technical reference: Architecture explains how the system is built; the User Guide explains what each feature does for you.\n\nIt is reached from the **Tools** section of the Settings page (`ADVANCED_ITEMS` in `navConfig.ts`), not the day-to-day nav.\n\n**Served exactly like this page.** Each section is static, hand-authored JSON shipped in the image — `packages/core/openexecutive/guide/prebuilt/<id>.json`, one file per entry in `guide/sections.py` → `GUIDE_SECTIONS`. The route `api/routes/guide.py` exposes `GET /guide/sections` and `GET /guide/sections/{id}`, mirroring the architecture routes. **Nothing on the serving path calls an LLM.**\n\n**Shared loader.** Both surfaces load their files through one class — `openexecutive.utils.prebuilt_store.PrebuiltDocStore` — pointed at each module's own `prebuilt/` directory. The same fields apply (`section_id`, `title`, `markdown`, `mermaid`, `generated_at`), and the same path-traversal guard rejects any id containing a separator or dot segment.\n\n**Shared renderer.** The UI reuses the architecture page's `DynamicSection` component via a `basePath` prop (`\"architecture\"` by default, `\"guide\"` for the guide), so deep links, lazy loading, and Markdown sanitization behave identically. The guide is intentionally diagram-free — its sections carry `mermaid: null`.\n\n**Keeping it current:** when a user-facing feature is added or materially changed, add or update the matching `guide/prebuilt/<id>.json` (and its registry entry in `guide/sections.py` + the mirror list in `app/guide/page.tsx`), the same way technical sections are maintained here. Every section must include a `**How to use:**` walkthrough (and an `**Example:**` where one helps) — `tests/unit/test_guide_prebuilt.py` enforces it. Because Ask OE inlines the current page's section into its user turn, those steps also ground its \"how do I…\" answers.","mermaid": "flowchart LR\n Settings([\"Settings hub tile\"]) --> Guide[\"/guide page\"]\n Guide --> Route[\"api/routes/guide.py\"]\n Route --> Store{\"PrebuiltDocStore\"}\n Store --> Files[(\"guide/prebuilt/*.json\")]\n ArchRoute[\"api/routes/architecture.py\"] --> Store\n Store --> ArchFiles[(\"architecture/prebuilt/*.json\")]\n class Settings entry\n class Guide entry\n class Route compute\n class ArchRoute compute\n class Store compute\n class Files storage\n class ArchFiles storage","generated_at": "2026-09-23T00:00:00+00:00"}diff --git a/packages/core/openexecutive/guide/prebuilt/settings.json b/packages/core/openexecutive/guide/prebuilt/settings.jsonindex 0d3dc8ac..5defdda8 100644--- a/packages/core/openexecutive/guide/prebuilt/settings.json+++ b/packages/core/openexecutive/guide/prebuilt/settings.json@@ -1,7 +1,7 @@{"section_id": "settings","title": "Settings & Advanced",- "markdown": "**What it is:** The hub for power-user and admin tools that were pulled out of the day-to-day nav to keep it focused.\n\n**What it does:**\n\n- Links to Setup status, the Agent Council, Audit Log, Token Usage, this User Guide, the Architecture reference, Company Simulator, and Client Companies.\n- Acts as a directory — each tile opens a dedicated screen.\n- Keeps advanced configuration one click away without cluttering the main workspace.\n- Shows whether the Executive is **running** or **paused**, with a switch to pause or resume it.\n- Holds the **Workspace** card: whether you use Open Executive just for yourself or with your team, your role when it's just you, your time zone, and whether the Executive books meetings without asking.\n- Holds the **Act as me** card, where the owner can let the Executive write email drafts as them, in their own voice, from their own Gmail.\n\n**How to use:**\n\n1. Click **Settings** at the bottom of the sidebar.\n2. Click the tile for what you want to do:\n - **Setup status** — check that every part of your setup is working, and see what to do about anything that isn't.\n - **Agent Council** — change a specialist's model or prompt, or the Executive's voice.\n - **Audit log** — find out what the Executive did, and why.\n - **Token usage** — see what you're spending and where.\n - **User Guide** — this guide.\n - **Architecture** — the technical reference for how the system is built.\n - **Company Simulator** — try the Executive on a test company.\n - **Client Companies** — switch between clients if you do fractional work.\n\n**Checking your setup:**\n\n- Open **Settings → Setup status**. Each part of your setup gets a light: green is working, amber needs attention, red isn't working, grey isn't set up (and is optional).\n- It tests things for real: the AI key, and each chat app's token, with a quick call that sends nothing. It also checks the Executive's email address, the company setup, the daily schedule, when and where your daily brief goes, and whether anyone on your team list can reach each chat app.\n- Anything that isn't green says what to do in plain words, with a button when the fix is on another page. After you change a setting and restart the app, click **Check again**.\n\n**Workspace:**\n\n- **Using Open Executive** — **Just me** or **With your team**. You pick this when you first set up; change it here. Switching asks you to confirm and says what changes:\n - **Just me** pauses department check-ins and shows **Goals** (grouped by area) in the sidebar instead of Departments. Nothing is deleted — your departments stay, as the areas your goals are grouped by.\n - **With your team** brings back Departments and their daily check-ins, and the People and department cards on the Briefing.\n- **Your role** (just you) — which describes you best (**Owner / founder**, **Executive inside an organisation**, **Independent or fractional**, or **Other**), your title, who you report to, what you're responsible for and what you're measured on. Every field is optional; click **Save role** after editing. The Executive uses it to fit its advice to your job — a VP gets help making the case to their boss, an owner gets help with a call that's theirs alone to make. It stays saved if you switch to your team.\n- **Time zone** — when your morning brief, end-of-day digest and reflection arrive, and how the Executive reads \"tomorrow at 9\". It suggests the zone your browser is in; **Follow server default** uses the server's setting.\n- **Book meetings without asking** — when on, the Executive books meetings on your calendar on its own; when off, each booking waits for your approval on the Briefing. (Shown only when your install supports it.)\n- Only the principal can change the mode, role and time zone. A persona you customised in Council stays in place in either mode.\n\n**Act as me:**\n\n- Normally the Executive writes only as itself, from its own email account. **Act as me** lets it write an email *as you*: ask in chat — \"reply to Dana as me: yes to the 5th\" — and it saves a draft in **your own Gmail Drafts** for you to read, change and send. It never sends anything itself, and everything else it writes stays in its own name.\n- For now only the owner (the principal) sees this card. It works when you ask in the web app, in a direct message to the Executive on Slack or Discord, or in a verified private Telegram chat — never in a shared channel or thread, from an email, a scheduled job or anyone else's conversation.\n- **Your Gmail** — connect your own Gmail first. The card shows the command to run on a computer with a browser; sign in as yourself, put the file it writes where your install reads it, then click **Check again**. It won't connect the Executive's own address as yours.\n- **Write drafts as me** — the switch. It stays off until your Gmail is connected, and turning it off applies from your next message.\n- **How I write** — click **Learn from my sent mail** and it reads your recent sent emails once and describes how you write: your usual **Length** and **Tone**, a **Greeting** for your team, your contacts and anyone else ({first} stands for their first name), your **Sign-off**, your **Habits**, what you **Never** do, and a few **Examples of your writing** that set the tone. Change any of them and click **Save changes**; **Lock** stops it being relearned from your mail (you can still edit it); **Reset** starts over; **Remove examples** drops the examples. Your Gmail signature is added to every draft: **Refresh from Gmail** picks up a change you made to it in Gmail, **Don't add my signature** stops adding it, and **Add my Gmail signature** brings it back.\n- In chat you get a card, \"Drafted an email as you to …\", that opens the draft in Gmail. If the Executive isn't sure about something, it asks you instead of guessing.\n\n**Setting up just for yourself:**\n\n- The first time you set up, Open Executive asks who it is for — **Just me** or **Me and my team** — before anything else, and saves your time zone from the browser. Re-running setup later skips this; change the mode here instead.\n- **Just me** is for anyone who uses Open Executive just for themselves, whatever their role: your own business, a team you lead inside an organisation, or clients you advise as an independent or fractional executive.\n- Choosing **Just me** then asks **What's your role?** — the same fields as **Your role** above. Fill in what you like, or click **Skip for now**.\n- Just for yourself, the setup conversation asks about your work rather than your team, following the role you gave: an owner about what you offer, your customers, pricing, cash and runway; an executive inside an organisation about that organisation (it becomes your company profile), what you're responsible for, who you report to and what you're measured on; an independent about your practice and clients. Everyone is asked about their goals. On **Here's what I understood** there is a single **You** card (your name and role) next to **Your sign-in email**, instead of the team and department lists.\n- The step-by-step form skips the team size, team members and fractional executives steps.\n- In the sidebar, **You** holds **Goals**, **People** and your profile: **Business profile** if you own the business, **Your work** for any other role (or none). The profile page follows the same choice: for any other role it is worded around the organisation you work in (**Where You Work** in place of Company Basics). Either way departments are listed there as **Areas**, and your title, who you report to and what you're responsible for stay under **Your role** above.\n\n**Pausing the Executive:**\n\n- Click **Executive running** at the bottom of the sidebar (or use the card at the top of Settings), add a reason if you like, and click **Pause Executive**.\n- While paused, the Executive starts nothing on its own: no briefs, nudges, monitoring, inbox processing or workflow timers. An amber banner appears on every page.\n- Chat and direct messages (Slack, Telegram, Discord, Google Chat) still get answers.\n- Nothing is lost. Work that falls due during the pause waits, and runs when you click **Resume**. The switch shows how many actions are waiting.\n- Anyone who can sign in can pause the Executive, but only the principal can resume it.\n\n*Tip: if you're looking for a feature that isn't in the sidebar, it's probably here. This guide is also pinned next to Settings at the bottom of the nav.*",+ "markdown": "**What it is:** The one page for the settings that live outside the day-to-day nav: whether the Executive is running, who Open Executive is for, letting it write email as you, and the admin and power-user tools.\n\n**What it does:**\n\n- Lays the settings out as four sections down one page — **Executive**, **Workspace**, **Act as me** (the owner only) and **Tools** — with a section list beside them (a row of chips on a phone) that follows as you scroll and jumps to a section when you click it. A link can land on a section directly, such as **Settings → Workspace** on your profile page.\n- **Executive** shows whether the Executive is **running** or **paused**. While it runs, the pause form stays folded behind **Pause…**; while it is paused, the section stays open so the held count and **Resume** are in view.\n- **Workspace** holds, one row each: whether you use Open Executive just for yourself or with your team, your role when it's just you, your time zone, and whether the Executive books meetings without asking.\n- **Act as me** lets the owner have the Executive write email drafts as them, in their own voice, from their own Gmail. The fields of your writing profile sit behind **Edit how I write** until you want them.\n- **Tools** lists the pages that open their own screen, grouped by what you'd use them for: **Check & diagnose** (Setup status, Audit log, Token usage), **Configure** (Agent Council, Company Simulator, Client Companies) and **Learn** (User Guide, Architecture).\n\n**How to use:**\n\n1. Click **Settings** at the bottom of the sidebar.\n2. Click a section in the list beside the page (a chip above it on a phone) to jump there, or scroll — the list highlights where you are.\n3. Under **Tools**, click a row to open that page:\n - **Setup status** — check that every part of your setup is working, and see what to do about anything that isn't.\n - **Agent Council** — change a specialist's model or prompt, or the Executive's voice.\n - **Audit log** — find out what the Executive did, and why.\n - **Token usage** — see what you're spending and where.\n - **User Guide** — this guide.\n - **Architecture** — the technical reference for how the system is built.\n - **Company Simulator** — try the Executive on a test company.\n - **Client Companies** — switch between clients if you do fractional work.\n\n**Checking your setup:**\n\n- Open **Settings → Setup status**. Each part of your setup gets a light: green is working, amber needs attention, red isn't working, grey isn't set up (and is optional).\n- It tests things for real: the AI key, and each chat app's token, with a quick call that sends nothing. It also checks the Executive's email address, the company setup, the daily schedule, when and where your daily brief goes, and whether anyone on your team list can reach each chat app.\n- Anything that isn't green says what to do in plain words, with a button when the fix is on another page. After you change a setting and restart the app, click **Check again**.\n\n**Workspace:**\n\n- **Using Open Executive** — **Just me** or **With your team**. You pick this when you first set up; change it here. Switching asks you to confirm and says what changes:\n - **Just me** pauses department check-ins and shows **Goals** (grouped by area) in the sidebar instead of Departments. Nothing is deleted — your departments stay, as the areas your goals are grouped by.\n - **With your team** brings back Departments and their daily check-ins, and the People and department cards on the Briefing.\n- **Your role** (just you) — which describes you best (**Owner / founder**, **Executive inside an organisation**, **Independent or fractional**, or **Other**), your title, who you report to, what you're responsible for and what you're measured on. Every field is optional; click **Save role** after editing. The Executive uses it to fit its advice to your job — a VP gets help making the case to their boss, an owner gets help with a call that's theirs alone to make. It stays saved if you switch to your team.\n- **Time zone** — when your morning brief, end-of-day digest and reflection arrive, and how the Executive reads \"tomorrow at 9\". It suggests the zone your browser is in; **Follow server default** uses the server's setting.\n- **Book meetings without asking** — when on, the Executive books meetings on your calendar on its own; when off, each booking waits for your approval on the Briefing. (Shown only when your install supports it.)\n- Only the principal can change the mode, role and time zone. A persona you customised in Council stays in place in either mode.\n\n**Act as me:**\n\n- Normally the Executive writes only as itself, from its own email account. **Act as me** lets it write an email *as you*: ask in chat — \"reply to Dana as me: yes to the 5th\" — and it saves a draft in **your own Gmail Drafts** for you to read, change and send. It never sends anything itself, and everything else it writes stays in its own name.\n- For now only the owner (the principal) sees this card. It works when you ask in the web app, in a direct message to the Executive on Slack or Discord, or in a verified private Telegram chat — never in a shared channel or thread, from an email, a scheduled job or anyone else's conversation.\n- **Your Gmail** — connect your own Gmail first. The card shows the command to run on a computer with a browser; sign in as yourself, put the file it writes where your install reads it, then click **Check again**. It won't connect the Executive's own address as yours.\n- **Write drafts as me** — the switch. It stays off until your Gmail is connected, and turning it off applies from your next message.\n- **How I write** — click **Learn from my sent mail** and it reads your recent sent emails once and describes how you write (click **Edit how I write** to open the fields): your usual **Length** and **Tone**, a **Greeting** for your team, your contacts and anyone else ({first} stands for their first name), your **Sign-off**, your **Habits**, what you **Never** do, and a few **Examples of your writing** that set the tone. Change any of them and click **Save changes**; **Lock** stops it being relearned from your mail (you can still edit it); **Reset** starts over; **Remove examples** drops the examples. Your Gmail signature is added to every draft: **Refresh from Gmail** picks up a change you made to it in Gmail, **Don't add my signature** stops adding it, and **Add my Gmail signature** brings it back.\n- In chat you get a card, \"Drafted an email as you to …\", that opens the draft in Gmail. If the Executive isn't sure about something, it asks you instead of guessing.\n\n**Setting up just for yourself:**\n\n- The first time you set up, Open Executive asks who it is for — **Just me** or **Me and my team** — before anything else, and saves your time zone from the browser. Re-running setup later skips this; change the mode here instead.\n- **Just me** is for anyone who uses Open Executive just for themselves, whatever their role: your own business, a team you lead inside an organisation, or clients you advise as an independent or fractional executive.\n- Choosing **Just me** then asks **What's your role?** — the same fields as **Your role** above. Fill in what you like, or click **Skip for now**.\n- Just for yourself, the setup conversation asks about your work rather than your team, following the role you gave: an owner about what you offer, your customers, pricing, cash and runway; an executive inside an organisation about that organisation (it becomes your company profile), what you're responsible for, who you report to and what you're measured on; an independent about your practice and clients. Everyone is asked about their goals. On **Here's what I understood** there is a single **You** card (your name and role) next to **Your sign-in email**, instead of the team and department lists.\n- The step-by-step form skips the team size, team members and fractional executives steps.\n- In the sidebar, **You** holds **Goals**, **People** and your profile: **Business profile** if you own the business, **Your work** for any other role (or none). The profile page follows the same choice: for any other role it is worded around the organisation you work in (**Where You Work** in place of Company Basics). Either way departments are listed there as **Areas**, and your title, who you report to and what you're responsible for stay under **Your role** above.\n\n**Pausing the Executive:**\n\n- Click **Executive running** at the bottom of the sidebar (or **Pause…** in the Executive section at the top of Settings), add a reason if you like, and click **Pause Executive**.\n- While paused, the Executive starts nothing on its own: no briefs, nudges, monitoring, inbox processing or workflow timers. An amber banner appears on every page.\n- Chat and direct messages (Slack, Telegram, Discord, Google Chat) still get answers.\n- Nothing is lost. Work that falls due during the pause waits, and runs when you click **Resume**. The switch shows how many actions are waiting.\n- Anyone who can sign in can pause the Executive, but only the principal can resume it.\n\n*Tip: if you're looking for a feature that isn't in the sidebar, it's probably under Tools here. This guide is also pinned next to Settings at the bottom of the nav.*","mermaid": null,- "generated_at": "2026-09-26T16:58:25Z"+ "generated_at": "2026-09-28T14:08:12Z"}diff --git a/packages/ui/scripts/navConfig.test.mjs b/packages/ui/scripts/navConfig.test.mjsindex 90e1d69c..f8b150f0 100644--- a/packages/ui/scripts/navConfig.test.mjs+++ b/packages/ui/scripts/navConfig.test.mjs@@ -1,7 +1,11 @@import assert from "node:assert/strict";import test from "node:test";import {+ ADVANCED_GROUPS,+ ADVANCED_ITEMS,PROFILE_NAV,+ SETTINGS_SECTIONS,+ advancedItemsByGroup,buildMobilePrimary,buildPrimaryNav,profileWording,@@ -115,3 +119,43 @@ test("every destination explains itself", () => {}}});++test("every Settings tool is in exactly one group, and no group is empty", () => {+ const keys = ADVANCED_GROUPS.map((g) => g.key);+ for (const item of ADVANCED_ITEMS) {+ assert.ok(keys.includes(item.group), `${item.href} has group ${item.group}`);+ assert.ok(item.description.trim(), `${item.href} needs a description`);+ }+ assert.equal(new Set(ADVANCED_ITEMS.map((i) => i.href)).size, ADVANCED_ITEMS.length);+ for (const group of advancedItemsByGroup()) assert.ok(group.items.length > 0, group.key);+});++test("the Settings tools are grouped by what you'd use them for", () => {+ const grouped = advancedItemsByGroup().map((g) => ({+ key: g.key,+ label: g.label,+ items: g.items.map((i) => `${i.label} → ${i.href}`),+ }));+ assert.deepEqual(grouped, [+ {+ key: "diagnose",+ label: "Check & diagnose",+ items: ["Setup status → /settings/status", "Audit log → /audit", "Token usage → /audit/usage"],+ },+ {+ key: "configure",+ label: "Configure",+ items: ["Agent Council → /council", "Company Simulator → /demo", "Client Companies → /clients"],+ },+ { key: "learn", label: "Learn", items: ["User Guide → /guide", "Architecture → /architecture"] },+ ]);+ // Grouping reorders nothing and drops nothing.+ assert.equal(grouped.flatMap((g) => g.items).length, ADVANCED_ITEMS.length);+});++test("the Settings sections have unique ids and a label each", () => {+ const ids = SETTINGS_SECTIONS.map((s) => s.id);+ assert.deepEqual(ids, ["executive", "workspace", "act-as-me", "tools"]);+ assert.equal(new Set(ids).size, ids.length);+ for (const s of SETTINGS_SECTIONS) assert.ok(s.label.trim(), s.id);+});diff --git a/packages/ui/src/app/company-profile/page.tsx b/packages/ui/src/app/company-profile/page.tsxindex 637d6417..336c91de 100644--- a/packages/ui/src/app/company-profile/page.tsx+++ b/packages/ui/src/app/company-profile/page.tsx@@ -163,7 +163,7 @@ export default function CompanyProfilePage() {<>{" "}{copy.roleNote}{" "}- <Link href="/settings" className="whitespace-nowrap text-indigo-400 hover:text-indigo-300 transition-colors">+ <Link href="/settings#workspace" className="whitespace-nowrap text-indigo-400 hover:text-indigo-300 transition-colors">Settings → Workspace</Link>.diff --git a/packages/ui/src/app/settings/page.tsx b/packages/ui/src/app/settings/page.tsxindex 5ea9bc67..2b07640f 100644--- a/packages/ui/src/app/settings/page.tsx+++ b/packages/ui/src/app/settings/page.tsx@@ -1,55 +1,123 @@"use client";import Link from "next/link";+import { useEffect, useMemo, useRef, useState } from "react";import ExecutiveRunSwitch from "@/components/executive/ExecutiveRunSwitch";import Icon from "@/components/Icon";import ActAsMeCard from "@/components/settings/ActAsMeCard";+import SettingsNav from "@/components/settings/SettingsNav";+import SettingsSection from "@/components/settings/SettingsSection";import WorkspaceCard from "@/components/settings/WorkspaceCard";-import { ADVANCED_ITEMS } from "@/components/shell/navConfig";+import { advancedItemsByGroup, SETTINGS_SECTIONS } from "@/components/shell/navConfig";+import { useActiveSection } from "@/lib/useActiveSection";-// Settings hub — home for admin / power-user tools that were pulled out-// of the primary nav to keep day-to-day navigation focused. Each tool is-// a full route; this page is just the directory that points to them.+// Settings — the configuration that lives outside the day-to-day nav, as+// one page of sections (Executive, Workspace, Act as me, Tools) with an+// in-page nav to jump between them. Each section id is a hash a link can+// land on; the Tools section points at the admin / power-user pages+// (ADVANCED_ITEMS), grouped by what you'd use them for.export default function SettingsPage() {+ const mainRef = useRef<HTMLElement>(null);+ // Act as me decides for itself whether it is on the page (owner only).+ const [actAsMe, setActAsMe] = useState(false);+ const sections = useMemo(+ () => SETTINGS_SECTIONS.filter((s) => s.id !== "act-as-me" || actAsMe),+ [actAsMe],+ );+ const ids = useMemo(() => sections.map((s) => s.id), [sections]);+ const { active, jumpTo } = useActiveSection(ids, mainRef);++ // A link with a hash lands on its section. The browser does this itself+ // for a section present at first paint; Act as me mounts after its fetch,+ // so scroll to the hash once its section exists.+ const scrolledToHash = useRef(false);+ useEffect(() => {+ if (scrolledToHash.current) return;+ const id = window.location.hash.slice(1);+ if (!id || !ids.includes(id as (typeof ids)[number])) return;+ const el = document.getElementById(id);+ if (!el) return;+ scrolledToHash.current = true;+ el.scrollIntoView({ block: "start" });+ }, [ids]);+return (- <main className="flex-1 min-h-0 overflow-y-auto">- <div className="max-w-3xl mx-auto px-4 sm:px-6 py-8">+ <main ref={mainRef} className="flex-1 min-h-0 overflow-y-auto">+ <div className="max-w-3xl lg:max-w-4xl mx-auto px-4 sm:px-6 pt-8 pb-16"><h1 className="text-xl font-semibold text-fg">Settings & advanced</h1><p className="mt-1 text-sm text-fg-muted">- Configuration, diagnostics, and power-user tools. These sit outside the+ How the Executive runs, who it runs for, and the tools that sit outside theday-to-day workspace nav.</p>- <div className="mt-6">- <ExecutiveRunSwitch variant="card" />- </div>+ <div className="mt-6 lg:grid lg:grid-cols-[176px_minmax(0,1fr)] lg:gap-10">+ <SettingsNav sections={sections} active={active} onJump={jumpTo} />- <div className="mt-3">- <WorkspaceCard />- </div>+ <div className="mt-4 lg:mt-0 space-y-8 min-w-0">+ <SettingsSection+ id="executive"+ title="Executive"+ description="Whether the Executive is doing its own work — briefs, nudges, monitoring, inbox, workflow timers — or holding it."+ >+ <ExecutiveRunSwitch variant="card" />+ </SettingsSection>++ <SettingsSection+ id="workspace"+ title="Workspace"+ description="Who Open Executive is for, and the time zone your briefs run in."+ >+ <WorkspaceCard />+ </SettingsSection>- {/* Renders nothing for anyone who can't have Act as me (only the owner can). */}- <ActAsMeCard />+ {/* Renders nothing for anyone who can't have Act as me (only the owner can). */}+ <ActAsMeCard onVisible={setActAsMe} />- <div className="mt-6 grid gap-3 sm:grid-cols-2">- {ADVANCED_ITEMS.map((item) => (- <Link- key={item.href}- href={item.href}- className="group rounded-xl border border-line bg-surface-elevated p-4 hover:border-line-strong hover:bg-surface-overlay transition-colors"+ <SettingsSection+ id="tools"+ title="Tools"+ description="Diagnostics, configuration and reference pages. Each opens its own screen.">- <div className="flex items-center gap-2.5">- <span className="text-fg-muted group-hover:text-fg transition-colors">- <Icon name={item.icon} size="w-5 h-5" />- </span>- <h2 className="text-sm font-medium text-fg">{item.label}</h2>+ <div className="space-y-5">+ {advancedItemsByGroup().map((group) => (+ <div key={group.key}>+ <h3+ id={`tools-${group.key}`}+ className="text-[10px] font-semibold uppercase tracking-widest text-fg-subtle"+ >+ {group.label}+ </h3>+ <ul className="mt-1 divide-y divide-line">+ {group.items.map((item) => (+ <li key={item.href}>+ <Link+ href={item.href}+ className="group flex items-center gap-3 py-2.5 -mx-2 px-2 rounded-lg hover:bg-surface-overlay transition-colors"+ >+ <span className="text-fg-muted group-hover:text-fg transition-colors">+ <Icon name={item.icon} size="w-4 h-4" />+ </span>+ <span className="min-w-0 flex-1">+ <span className="block text-sm text-fg">{item.label}</span>+ <span className="block text-xs text-fg-muted">+ {item.description}+ </span>+ </span>+ <Icon+ name="chevron-right"+ size="w-3.5 h-3.5"+ className="text-fg-subtle group-hover:text-fg transition-colors"+ />+ </Link>+ </li>+ ))}+ </ul>+ </div>+ ))}</div>- <p className="mt-2 text-xs text-fg-muted leading-relaxed">- {item.description}- </p>- </Link>- ))}+ </SettingsSection>+ </div></div></div></main>diff --git a/packages/ui/src/components/Switch.tsx b/packages/ui/src/components/Switch.tsxnew file mode 100644index 00000000..3dfe8c6c--- /dev/null+++ b/packages/ui/src/components/Switch.tsx@@ -0,0 +1,36 @@+"use client";++// An on/off switch. The caller labels it with `labelledBy`, the id of the+// text that says what it switches, so a screen reader reads that text.+export default function Switch({+ checked,+ onChange,+ disabled = false,+ labelledBy,+}: {+ checked: boolean;+ onChange: (checked: boolean) => void;+ disabled?: boolean;+ labelledBy: string;+}) {+ return (+ <button+ type="button"+ role="switch"+ aria-checked={checked}+ aria-labelledby={labelledBy}+ disabled={disabled}+ onClick={() => onChange(!checked)}+ className={`relative mt-0.5 inline-flex h-5 w-9 flex-shrink-0 items-center rounded-full transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${+ checked ? "bg-indigo-500" : "bg-surface-overlay border border-line"+ }`}+ >+ <span+ aria-hidden="true"+ className={`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${+ checked ? "translate-x-4" : "translate-x-0.5"+ }`}+ />+ </button>+ );+}diff --git a/packages/ui/src/components/executive/ExecutiveRunSwitch.tsx b/packages/ui/src/components/executive/ExecutiveRunSwitch.tsxindex 721fc1b3..0c27eb34 100644--- a/packages/ui/src/components/executive/ExecutiveRunSwitch.tsx+++ b/packages/ui/src/components/executive/ExecutiveRunSwitch.tsx@@ -20,7 +20,9 @@ function heldLabel(n: number): string {** - `sidebar`: a one-line status row in the shared sidebar footer that* expands into the pause/resume panel.- * - `card`: the always-expanded panel, for the Settings page.+ * - `card`: the body of the Settings page's Executive section — a status+ * row that opens into the pause form on request, and stays open while+ * paused so the held count and Resume are always in view.*/export default function ExecutiveRunSwitch({ variant }: { variant: "sidebar" | "card" }) {const { status, unknown, busy, error, pause, resume } = useExecutiveStatus();@@ -32,11 +34,10 @@ export default function ExecutiveRunSwitch({ variant }: { variant: "sidebar" | "// The last status read failed: say so rather than show a stale state,// and offer no action whose effect we can't confirm.return (- <div- className={variant === "card" ? "rounded-xl border border-line bg-surface-elevated p-4" : "pb-1"}- title="Couldn't reach the backend — retrying"- >- <div className="flex items-center gap-2.5 px-3 py-2 text-sm text-fg-muted">+ <div className={variant === "card" ? "" : "pb-1"} title="Couldn't reach the backend — retrying">+ <div+ className={`flex items-center gap-2.5 text-sm text-fg-muted ${variant === "card" ? "" : "px-3 py-2"}`}+ ><span className="inline-block w-2 h-2 rounded-full flex-shrink-0 bg-fg-subtle" aria-hidden="true" /><span className="truncate">Executive status unknown</span></div>@@ -44,7 +45,8 @@ export default function ExecutiveRunSwitch({ variant }: { variant: "sidebar" | ");}const paused = status.paused;- const open = variant === "card" || expanded;+ // The card opens on request while running and always while paused.+ const open = variant === "card" ? paused || expanded : expanded;// Collapse only on success so a failure's error stays visible.const onPause = async () => {@@ -129,13 +131,35 @@ export default function ExecutiveRunSwitch({ variant }: { variant: "sidebar" | "if (variant === "card") {return (- <section className="rounded-xl border border-line bg-surface-elevated p-4">- <div className="flex items-center gap-2.5">- {dot}- <h2 className="text-sm font-medium text-fg">{label}</h2>+ <div className="max-w-md">+ <div className="flex items-center justify-between gap-3">+ <div className="flex items-center gap-2.5 text-sm font-medium text-fg">+ {dot}+ <span>{label}</span>+ </div>+ {!paused && (+ <button+ type="button"+ onClick={() => setExpanded((v) => !v)}+ aria-expanded={open}+ aria-controls="executive-pause-panel"+ className="flex items-center gap-1 text-xs text-fg-muted hover:text-fg transition-colors cursor-pointer"+ >+ Pause…+ <Icon+ name="chevron-right"+ size="w-3.5 h-3.5"+ className={`transition-transform ${open ? "rotate-90" : ""}`}+ />+ </button>+ )}</div>- <div className="mt-3 max-w-md">{panel}</div>- </section>+ {open && (+ <div id="executive-pause-panel" className="mt-3">+ {panel}+ </div>+ )}+ </div>);}diff --git a/packages/ui/src/components/settings/ActAsMeCard.tsx b/packages/ui/src/components/settings/ActAsMeCard.tsxindex 728bf060..1c0a3bec 100644--- a/packages/ui/src/components/settings/ActAsMeCard.tsx+++ b/packages/ui/src/components/settings/ActAsMeCard.tsx@@ -2,6 +2,9 @@import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";+import Icon from "@/components/Icon";+import SettingsSection from "@/components/settings/SettingsSection";+import Switch from "@/components/Switch";import {getDelegation,getVoiceProfile,@@ -17,7 +20,12 @@ import {// Settings → Act as me: let the Executive draft email AS you, in your own// Gmail Drafts, when you ask it to — it never sends. Backed by GET/PUT// /delegation and /delegation/voice. Hidden for anyone who can't have it yet-// (only the owner can) and on a backend without it.+// (only the owner can) and on a backend without it — so, unlike the other+// sections, this one renders its own heading and tells the page (via+// `onVisible`) whether it is on the page at all.++const INTRO =+ "Let the Executive write email as you, in your own voice. When you ask it to reply to or write an email as you, it saves a draft in your own Gmail for you to review and send — it never sends anything. Everything else it writes stays in its own name.";const LENGTHS = ["short", "medium", "long"] as const;const FORMALITIES = ["casual", "neutral", "formal"] as const;@@ -43,7 +51,7 @@ function greetingFields(p: VoiceProfile): Record<string, string> {return Object.fromEntries(AUDIENCES.map((a) => [a, p.greetings[a] ?? ""]));}-export default function ActAsMeCard() {+export default function ActAsMeCard({ onVisible }: { onVisible?: (visible: boolean) => void }) {const [settings, setSettings] = useState<DelegationSettings | null>(null);const [state, setState] = useState<"loading" | "hidden" | "ready" | "error">("loading");const [busy, setBusy] = useState(false);@@ -70,13 +78,18 @@ export default function ActAsMeCard() {return () => controller.abort();}, [load]);+ // The page lists the section in its nav only while it is on the page, and+ // scrolls a `#act-as-me` link here once it is.+ useEffect(() => {+ onVisible?.(state === "ready" || state === "error");+ }, [state, onVisible]);+if (state === "hidden" || state === "loading") return null;if (state === "error" || !settings) {return (- <section className="mt-3 rounded-xl border border-line bg-surface-elevated p-4">- <h2 className="text-sm font-medium text-fg">Act as me</h2>- <p className="mt-1 text-xs text-fg-subtle">Couldn't load this setting.</p>- </section>+ <SettingsSection id="act-as-me" title="Act as me" description={INTRO}>+ <p className="text-xs text-fg-subtle">Couldn't load this setting.</p>+ </SettingsSection>);}@@ -103,17 +116,10 @@ export default function ActAsMeCard() {};return (- <section className="mt-3 rounded-xl border border-line bg-surface-elevated p-4">- <h2 className="text-sm font-medium text-fg">Act as me</h2>- <p className="mt-1 text-xs text-fg-muted leading-relaxed">- Let the Executive write email as you, in your own voice. When you ask it to reply to or- write an email as you, it saves a draft in your own Gmail for you to review and send — it- never sends anything. Everything else it writes stays in its own name.- </p>-- <div className="mt-4 space-y-5 max-w-md">+ <SettingsSection id="act-as-me" title="Act as me" description={INTRO}>+ <div className="max-w-md divide-y divide-line">{/* Your Gmail */}- <div>+ <div className="py-4 first:pt-0 last:pb-0"><div className="text-xs font-medium text-fg">Your Gmail</div><p className="text-xs text-fg-muted mt-0.5 leading-relaxed">{connected ? `Connected to ${settings.gmail.email}.` : settings.gmail.message}@@ -143,7 +149,7 @@ export default function ActAsMeCard() {</div>{/* The switch */}- <div>+ <div className="py-4 first:pt-0 last:pb-0"><div className="flex items-start justify-between gap-3"><div><div className="text-xs font-medium text-fg" id="act-as-me-label">@@ -157,36 +163,27 @@ export default function ActAsMeCard() {: "Connect your Gmail first."}</p></div>- <button- type="button"- role="switch"- aria-checked={on}- aria-labelledby="act-as-me-label"+ <Switch+ checked={on}+ onChange={() => void toggle()}disabled={busy || (!on && !connected)}- onClick={() => void toggle()}- className={`relative mt-0.5 inline-flex h-5 w-9 flex-shrink-0 items-center rounded-full transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${- on ? "bg-indigo-500" : "bg-surface-overlay border border-line"- }`}- >- <span- aria-hidden="true"- className={`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${- on ? "translate-x-4" : "translate-x-0.5"- }`}- />- </button>+ labelledBy="act-as-me-label"+ /></div>{error && <p className="mt-1 text-xs text-red-400">{error}</p>}</div><VoiceSection connected={connected} /></div>- </section>+ </SettingsSection>);}-// "How I write": learned from your sent mail, editable, lockable.+// "How I write": learned from your sent mail, editable, lockable. The+// summary line and the Learn button are always in view; the fields sit+// behind "Edit how I write", and stay open while an edit is unsaved.function VoiceSection({ connected }: { connected: boolean }) {+ const [editing, setEditing] = useState(false);const [profile, setProfile] = useState<VoiceProfile | null>(null);const [greetings, setGreetings] = useState<Record<string, string>>({});const [habits, setHabits] = useState("");@@ -280,9 +277,10 @@ function VoiceSection({ connected }: { connected: boolean }) {length !== profile.length ||formality !== profile.formality;const linkButton = "text-xs text-indigo-400 hover:text-indigo-300 disabled:opacity-50";+ const showForm = editing || dirty;return (- <div>+ <div className="py-4 first:pt-0 last:pb-0"><div className="text-xs font-medium text-fg">How I write</div><p className="text-xs text-fg-muted mt-0.5 leading-relaxed">{learned@@ -290,19 +288,37 @@ function VoiceSection({ connected }: { connected: boolean }) {: "Not learned yet. It reads your recent sent mail once, keeps only what you wrote, and describes your style — you can edit or lock it."}</p>- {!profile.locked && (- <button- type="button"- disabled={busy || !connected}- onClick={() => void run(learnVoiceProfile)}- className="mt-2 rounded-md border border-line px-2.5 py-1 text-xs text-fg hover:bg-surface-overlay disabled:opacity-50"- >- {busy ? "Working…" : learned ? "Learn again from my sent mail" : "Learn from my sent mail"}- </button>- )}+ <div className="mt-2 flex flex-wrap items-center gap-2">+ {!profile.locked && (+ <button+ type="button"+ disabled={busy || !connected}+ onClick={() => void run(learnVoiceProfile)}+ className="rounded-md border border-line px-2.5 py-1 text-xs text-fg hover:bg-surface-overlay disabled:opacity-50"+ >+ {busy ? "Working…" : learned ? "Learn again from my sent mail" : "Learn from my sent mail"}+ </button>+ )}+ {learned && !dirty && (+ <button+ type="button"+ onClick={() => setEditing((v) => !v)}+ aria-expanded={showForm}+ aria-controls="voice-editor"+ className="flex items-center gap-1 rounded-md px-2 py-1 text-xs text-fg-muted hover:text-fg disabled:opacity-50"+ >+ {showForm ? "Done editing" : "Edit how I write"}+ <Icon+ name="chevron-right"+ size="w-3.5 h-3.5"+ className={`transition-transform ${showForm ? "rotate-90" : ""}`}+ />+ </button>+ )}+ </div>- {learned && (- <div className="mt-3 space-y-4">+ {learned && showForm && (+ <div id="voice-editor" className="mt-3 space-y-4"><div className="flex gap-3"><label className="text-xs text-fg-muted">Lengthdiff --git a/packages/ui/src/components/settings/SettingsNav.tsx b/packages/ui/src/components/settings/SettingsNav.tsxnew file mode 100644index 00000000..7c397ac2--- /dev/null+++ b/packages/ui/src/components/settings/SettingsNav.tsx@@ -0,0 +1,53 @@+"use client";++import type { SettingsSectionDef } from "@/components/shell/navConfig";++// The Settings page's section nav: a sticky list beside the sections on+// `lg` and up, a sticky row of chips under the heading below that. Links+// are real `#id` anchors, so they work without JavaScript; with it, the+// page scrolls smoothly and keeps the hash in the address bar.+export default function SettingsNav({+ sections,+ active,+ onJump,+}: {+ sections: SettingsSectionDef[];+ active: string | null;+ onJump: (id: string) => void;+}) {+ const link = (section: SettingsSectionDef, className: string) => {+ const current = active === section.id;+ return (+ <a+ key={section.id}+ href={`#${section.id}`}+ aria-current={current ? "location" : undefined}+ onClick={(e) => {+ e.preventDefault();+ onJump(section.id);+ }}+ className={`${className} transition-colors ${+ current ? "bg-indigo-500/10 text-indigo-400" : "text-fg-muted hover:text-fg hover:bg-surface-overlay/60"+ }`}+ >+ {section.label}+ </a>+ );+ };++ return (+ <>+ <aside className="hidden lg:block lg:sticky lg:top-6 lg:self-start">+ <nav aria-label="Settings sections" className="space-y-0.5">+ {sections.map((s) => link(s, "block px-2.5 py-1.5 rounded-lg text-xs"))}+ </nav>+ </aside>+ <nav+ aria-label="Settings sections"+ className="lg:hidden sticky top-0 z-10 -mx-4 sm:-mx-6 px-4 sm:px-6 py-2 bg-surface border-b border-line flex gap-1.5 overflow-x-auto"+ >+ {sections.map((s) => link(s, "flex-shrink-0 px-3 py-1.5 rounded-md text-xs whitespace-nowrap"))}+ </nav>+ </>+ );+}diff --git a/packages/ui/src/components/settings/SettingsSection.tsx b/packages/ui/src/components/settings/SettingsSection.tsxnew file mode 100644index 00000000..23382945--- /dev/null+++ b/packages/ui/src/components/settings/SettingsSection.tsx@@ -0,0 +1,28 @@+import type { ReactNode } from "react";++// One section of the Settings page: a heading the in-page nav can land on+// (`id` is the hash), an optional one-line description, and a card body.+// `scroll-mt` keeps the heading clear of the sticky chip row that sits at+// the top of the scroller below `lg`; on `lg` nothing overlaps it.+export default function SettingsSection({+ id,+ title,+ description,+ children,+}: {+ id: string;+ title: string;+ description?: ReactNode;+ children: ReactNode;+}) {+ const titleId = `${id}-title`;+ return (+ <section id={id} aria-labelledby={titleId} className="scroll-mt-16 lg:scroll-mt-6">+ <h2 id={titleId} className="text-sm font-medium text-fg">+ {title}+ </h2>+ {description && <p className="mt-1 text-xs text-fg-muted leading-relaxed">{description}</p>}+ <div className="mt-3 rounded-xl border border-line bg-surface-elevated p-4">{children}</div>+ </section>+ );+}diff --git a/packages/ui/src/components/settings/WorkspaceCard.tsx b/packages/ui/src/components/settings/WorkspaceCard.tsxindex 173e14db..e55f03ca 100644--- a/packages/ui/src/components/settings/WorkspaceCard.tsx+++ b/packages/ui/src/components/settings/WorkspaceCard.tsx@@ -2,6 +2,7 @@import { useEffect, useMemo, useState } from "react";+import Switch from "@/components/Switch";import RoleFields from "@/components/workspace/RoleFields";import { useWorkspace } from "@/components/workspace/WorkspaceContext";import {@@ -16,9 +17,10 @@ import { roleFormErrors, roleFormFrom, roleUpdate, type RoleForm } from "@/lib/p// Settings → Workspace: who Open Executive is for (just you, or you and your// team), your role when it's just you, the time zone its briefs run in, and-// whether it books meetings without asking. Mode, role and zone go through-// PUT /workspace and then the app-wide WorkspaceProvider is refreshed so the-// nav and pages follow.+// whether it books meetings without asking, as one row each. Mode, role and+// zone go through PUT /workspace and then the app-wide WorkspaceProvider is+// refreshed so the nav and pages follow. The page supplies the section+// heading; this is the body.const MODE_LABEL: Record<WorkspaceMode, string> = {solo: "Just me",@@ -80,15 +82,10 @@ export default function WorkspaceCard() {}return (- <section className="rounded-xl border border-line bg-surface-elevated p-4">- <h2 className="text-sm font-medium text-fg">Workspace</h2>- <p className="mt-1 text-xs text-fg-muted leading-relaxed">- Who Open Executive is for, and the time zone your briefs run in.- </p>-- <div className="mt-4 space-y-5 max-w-md">+ <div className="max-w-md">+ <div className="divide-y divide-line">{/* Mode */}- <div>+ <div className="py-4 first:pt-0 last:pb-0"><div className="text-xs font-medium text-fg mb-1.5" id="ws-mode-label">Using Open Executive</div>@@ -149,7 +146,7 @@ export default function WorkspaceCard() {{mode === "solo" && <RoleSection />}{/* Time zone */}- <div>+ <div className="py-4 first:pt-0 last:pb-0"><label htmlFor="ws-timezone" className="text-xs font-medium text-fg">Time zone</label>@@ -192,14 +189,13 @@ export default function WorkspaceCard() {</div><MeetingAutonomySwitch />-- {error && <p className="text-xs text-red-400">{error}</p>}</div>+ {error && <p className="mt-3 text-xs text-red-400">{error}</p>}<p className="mt-4 text-xs text-fg-subtle">A persona you customised in Council stays in place in either mode.</p>- </section>+ </div>);}@@ -240,7 +236,7 @@ function RoleSection() {}return (- <div>+ <div className="py-4 first:pt-0 last:pb-0"><div className="text-xs font-medium text-fg">Your role</div><p className="text-xs text-fg-muted mt-0.5 mb-2 leading-relaxed">So the Executive's advice fits your job, whatever your role: your own business, a@@ -314,7 +310,11 @@ function MeetingAutonomySwitch() {if (state === "absent" || state === "loading") return null;if (state === "error") {- return <p className="text-xs text-fg-subtle">Couldn't load the meeting-booking setting.</p>;+ return (+ <div className="py-4 first:pt-0 last:pb-0">+ <p className="text-xs text-fg-subtle">Couldn't load the meeting-booking setting.</p>+ </div>+ );}const on = mode === "auto_execute";@@ -332,7 +332,7 @@ function MeetingAutonomySwitch() {};return (- <div>+ <div className="py-4 first:pt-0 last:pb-0"><div className="flex items-start justify-between gap-3"><div><div className="text-xs font-medium text-fg" id="ws-meetings-label">@@ -344,24 +344,7 @@ function MeetingAutonomySwitch() {: "Each meeting the Executive wants to book waits for your approval in the briefing."}</p></div>- <button- type="button"- role="switch"- aria-checked={on}- aria-labelledby="ws-meetings-label"- disabled={busy}- onClick={() => void toggle()}- className={`relative mt-0.5 inline-flex h-5 w-9 flex-shrink-0 items-center rounded-full transition-colors cursor-pointer disabled:opacity-50 ${- on ? "bg-indigo-500" : "bg-surface-overlay border border-line"- }`}- >- <span- aria-hidden="true"- className={`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${- on ? "translate-x-4" : "translate-x-0.5"- }`}- />- </button>+ <Switch checked={on} onChange={() => void toggle()} disabled={busy} labelledBy="ws-meetings-label" /></div>{error && <p className="mt-1 text-xs text-red-400">{error}</p>}</div>diff --git a/packages/ui/src/components/shell/navConfig.ts b/packages/ui/src/components/shell/navConfig.tsindex 62090aae..8a7748de 100644--- a/packages/ui/src/components/shell/navConfig.ts+++ b/packages/ui/src/components/shell/navConfig.ts@@ -157,8 +157,8 @@ function youGroup(isOnboarded: boolean, roleKind: RoleKind | null): NavGroup {};}-// Day-to-day navigation only. Power/admin tools live in the Settings-// area (see ADVANCED_ITEMS) so this list stays focused.+// Day-to-day navigation only. Power/admin tools live on the Settings+// page (see ADVANCED_ITEMS) so this list stays focused.export function buildPrimaryNav({isOnboarded = true,reviewBadge = 0,@@ -244,13 +244,28 @@ export const NEW_CHAT_DESCRIPTION = "Start a fresh conversation with the Executiexport const BRIEFING_DESCRIPTION ="Land on a daily brief of what's happened and what needs you.";-// Admin / power-user tools surfaced on the Settings hub page rather than+// Where a Settings tool sits on that page: what you open to check on the+// install, to change how it runs, or to learn how it works.+export type AdvancedGroupKey = "diagnose" | "configure" | "learn";++export interface AdvancedItem extends NavItem {+ group: AdvancedGroupKey;+}++export const ADVANCED_GROUPS: { key: AdvancedGroupKey; label: string }[] = [+ { key: "diagnose", label: "Check & diagnose" },+ { key: "configure", label: "Configure" },+ { key: "learn", label: "Learn" },+];++// Admin / power-user tools surfaced on the Settings page rather than// in the primary nav — they aren't part of the day-to-day loop.-export const ADVANCED_ITEMS: NavItem[] = [+export const ADVANCED_ITEMS: AdvancedItem[] = [{href: "/settings/status",label: "Setup status",icon: "check-circle",+ group: "diagnose",description:"A light for each part of your setup — AI key, sign-in, channels, schedule — and what to do about anything that isn't working.",},@@ -258,6 +273,7 @@ export const ADVANCED_ITEMS: NavItem[] = [href: "/council",label: "Agent Council",icon: "users",+ group: "configure",description:"Configure the agents — models, system prompts, deep-reasoning, and the Executive voice persona.",},@@ -265,6 +281,7 @@ export const ADVANCED_ITEMS: NavItem[] = [href: "/audit",label: "Audit log",icon: "doc-search",+ group: "diagnose",description:"Searchable event log of every chat turn, specialist consult, tool call, and scheduled action.",},@@ -272,6 +289,7 @@ export const ADVANCED_ITEMS: NavItem[] = [href: "/audit/usage",label: "Token usage",icon: "activity",+ group: "diagnose",description:"Aggregate token usage and cost across all sessions — totals, by day, and by model.",},@@ -279,6 +297,7 @@ export const ADVANCED_ITEMS: NavItem[] = [href: "/guide",label: "User Guide",icon: "info",+ group: "learn",description:"Plain-language overviews of every feature — what each one is and what it does.",},@@ -286,12 +305,14 @@ export const ADVANCED_ITEMS: NavItem[] = [href: "/architecture",label: "Architecture",icon: "grid",+ group: "learn",description: "Interactive reference docs explaining how the system is built.",},{href: "/demo",label: "Company Simulator",icon: "cog",+ group: "configure",description:"Load prebuilt company fixtures, snapshot your current data, or generate a new scenario with AI.",},@@ -299,11 +320,43 @@ export const ADVANCED_ITEMS: NavItem[] = [href: "/clients",label: "Client Companies",icon: "building",+ group: "configure",description:"Multi-client mode for fractional work — switch the live company between named client slots.",},];+// The tools as the Settings page lists them: by group, in ADVANCED_GROUPS+// order, each keeping its ADVANCED_ITEMS order within the group.+export function advancedItemsByGroup(): {+ key: AdvancedGroupKey;+ label: string;+ items: AdvancedItem[];+}[] {+ return ADVANCED_GROUPS.map((group) => ({+ ...group,+ items: ADVANCED_ITEMS.filter((item) => item.group === group.key),+ }));+}++// The Settings page's sections in page order. Its in-page nav and the page+// itself both read this list, so the two can't drift; the ids are the+// hashes a link can land on (`/settings#workspace`). "act-as-me" is only+// on the page for the owner — the page drops it when the card is hidden.+export type SettingsSectionId = "executive" | "workspace" | "act-as-me" | "tools";++export interface SettingsSectionDef {+ id: SettingsSectionId;+ label: string;+}++export const SETTINGS_SECTIONS: SettingsSectionDef[] = [+ { id: "executive", label: "Executive" },+ { id: "workspace", label: "Workspace" },+ { id: "act-as-me", label: "Act as me" },+ { id: "tools", label: "Tools" },+];+// Anchors the mobile bottom nav. ≤5 per Material guidance; "More" opens// the drawer with the full menu. `/` lands on the briefing surface. Solo// swaps People for Goals — the page a team of one visits most.diff --git a/packages/ui/src/lib/useActiveSection.ts b/packages/ui/src/lib/useActiveSection.tsnew file mode 100644index 00000000..d214cfca--- /dev/null+++ b/packages/ui/src/lib/useActiveSection.ts@@ -0,0 +1,62 @@+"use client";++import { useCallback, useEffect, useState, type RefObject } from "react";++// Which of the sections `ids` is in view inside the scroller `root`, for an+// in-page nav to highlight, plus `jumpTo` for its links. Same observer band+// as the Architecture and User Guide pages (a section is "active" while it+// crosses the 20-30% mark from the top), but with the page's own scroller as+// the root so the band is measured against it, not the whole viewport.+export function useActiveSection(+ ids: readonly string[],+ root: RefObject<HTMLElement | null>,+): { active: string | null; jumpTo: (id: string) => void } {+ const [active, setActive] = useState<string | null>(ids[0] ?? null);+ // A section that mounts late (Act as me, after its fetch) must be+ // observed too, so re-run whenever the list changes.+ const key = ids.join("|");++ useEffect(() => {+ const list = key ? key.split("|") : [];+ const scroller = root.current;+ // Several short sections can sit in the band at once (the top of the+ // page, say): the first in page order is the one in view.+ const inBand = new Set<string>();+ const observer = new IntersectionObserver(+ (entries) => {+ for (const e of entries) {+ if (e.isIntersecting) inBand.add(e.target.id);+ else inBand.delete(e.target.id);+ }+ const first = list.find((id) => inBand.has(id));+ if (first) setActive(first);+ },+ { root: scroller, rootMargin: "-20% 0px -70% 0px", threshold: 0 },+ );+ for (const id of list) {+ const el = document.getElementById(id);+ if (el) observer.observe(el);+ }+ // A short last section never reaches the band, so at the very bottom+ // the last section is the one in view.+ const onScroll = () => {+ if (!scroller) return;+ if (scroller.scrollTop + scroller.clientHeight >= scroller.scrollHeight - 2) {+ setActive(list[list.length - 1] ?? null);+ }+ };+ scroller?.addEventListener("scroll", onScroll, { passive: true });+ return () => {+ observer.disconnect();+ scroller?.removeEventListener("scroll", onScroll);+ };+ }, [key, root]);++ const jumpTo = useCallback((id: string) => {+ setActive(id);+ document.getElementById(id)?.scrollIntoView({ behavior: "smooth", block: "start" });+ window.history.replaceState(null, "", `#${id}`);+ }, []);++ return { active, jumpTo };+}