Skip to content

feat(web): let a workspace whose plan ended browse read-only, with one "Choose a plan" dialog - #1599

Merged
gkhngyk merged 6 commits into
ansvisor:mainfrom
cihan-gyk:feature/read-only-upgrade-dialog
Oct 28, 2026
Merged

gkhngyk merged 6 commits into
ansvisor:mainfrom
cihan-gyk:feature/read-only-upgrade-dialog

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Read-only once the plan has ended: the web. On the cloud, a workspace whose 14-day trial ended, or whose plan was cancelled (during the trial or after a payment), can now sign in and look around. Before, it got a full-screen "subscription expired" notice that only signed out. Ansvisor wants these members back in, so a campaign can bring them to the product.

Nothing may change or cost anything until the workspace buys a plan. Every action opens one "Choose a plan to keep going" dialog; the X closes it and browsing goes on.

The API's part is #1589 (402 subscription_inactive on writes). This PR stands on its own from main. Self-hosted is unchanged.

Who's affected:

  • Onboarding is unchanged. An admin who never started a trial (no stripe_subscription_id) still goes to the plan step. A trial in progress works as today.
  • A cancel is cancel_at_period_end, so a paying customer, or one in the trial, keeps everything until that period ends.
  • A refused card (past_due, unpaid) is read-only too, with Update payment method (Stripe's portal). invoice.payment_succeeded unlocks it.

The layout and the dialog:

  • (dashboard)/layout.tsx lets these workspaces in. (onboarding)/layout.tsx sends a finished-onboarding, ended workspace to /dashboard.
  • The banner (ReadOnlyBanner): "Your workspace is read-only. You can look around; adding, running and AI need a plan." with See plans. It's hidden on Billing, and on a failed payment it says so.
  • UpgradeDialogProvider and useUpgradeGate() (providers/upgrade-gate.ts) give { guard, isLocked, openUpgrade }.
    • guard(fn, { action }) runs fn on an active plan, and otherwise opens the dialog with the action as a small label ("Adding prompts needs a plan").
    • The action buttons get guard() in the next PRs (C1–C3). This PR is the base.
    • The dialog here is simple: admins go to Billing, members are told to ask their admin. The plans themselves come in the next PR (B2), stacked on this one.
  • A 402 subscription_inactive from the API opens the dialog, not a toast. This goes through use-failure-toast, api-failure.ts's new subscription class, and the Webflow, catalog, publish and Send to CMS clients.
  • Automatic calls aren't sent while locked, so browsing shows saved data with no error toast:
    • Library's Webflow status;
    • the editor's link, source-class, claim and page reads;
    • Improve's saved read.

Billing:

  • An ended subscription starts a new Stripe Checkout ("Choose {plan}", monthly or annual) instead of a plan change Stripe would refuse. A cancelled Checkout returns to Billing.
  • /api/stripe/checkout:
    • admins only (403 admin_only);
    • 409 subscription_exists while a live subscription exists, so there's never a second one;
    • its body is checked with Zod (planId, interval, returnTo: 'billing').
  • Billing reads again after a buy, a change or a reactivation (router.refresh()).

MCP and chat:

  • lib/mcp/subscription-gate.ts: list_ and get_ tools stay open. Every other tool answers subscription_inactive, by default for any tool added later; server.tool(...) now throws, so nothing can skip the gate.
  • mcp-auth.ts: REST writes answer 402.
  • POST /api/agent/chat and POST /api/agent/conversations answer 402. A refused message goes back to the input.
  • runSiteAuditFor, generateBriefFor and createImproveActionFor check too (assertSubscriptionActive), so no caller skips it. Their REST routes answer 402 (failedCallResponse).

The old subscription-expired-notice.tsx is removed. Strings are in en.json (readOnly.*, apiFailure.subscription).

Related issue

None. Product decision (Ansvisor, 2026-10-27): an ended trial or plan browses read-only until it buys.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. cd web && yarn vitest run src/components/providers src/components/billing "src/app/[locale]/(dashboard)/layout.test.tsx" "src/app/[locale]/(onboarding)/layout.test.tsx" src/app/api/stripe src/app/api/agent src/lib/mcp src/lib/mcp-auth.test.ts src/lib/api-failure.test.ts src/config/plans.test.ts
  2. On a cloud set-up (NEXT_PUBLIC_IS_CLOUD=true, with feat(server): keep a workspace read-only once its plan has ended #1589's API and IS_CLOUD=true), give an organization subscription_status = canceled and a stripe_subscription_id. Then:
    • the dashboard opens with the banner;
    • See plans opens the dialog, and X or Escape closes it;
    • an action the API refuses opens the dialog.

Checked in the browser at 1024 px, light and dark, against the dev DB, with #1589's API and this web, both in cloud mode. The demo organization was set to a cancelled Growth plan for the check, then put back.

  • Tracked Prompts opened read-only with the banner.
  • See plans opened "Choose a plan to keep going" with the shared text. Escape closed it.
  • No sideways scroll.

Two things the check found, both in the next PR (C1, the Prompts area's buttons):

  • Analyze N prompts reaches the API, which refuses it with 402, and then shows "Volume analysis is not part of your current plan." C1 guards the button and maps the 402 to the dialog.
  • On load, "Volume data is temporarily unavailable" shows, since the volume read is refused. C1 skips that read while locked.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run in web/:

  • yarn format, yarn lint (0 errors), yarn typecheck;
  • yarn test (4,214 tests);
  • yarn build.

The pre-push review's findings are folded in:

  • a test it broke (isSubscriptionActive kept as on main);
  • the checkout's role, live-subscription check and Zod body;
  • the failed-payment path;
  • the MCP gate tested through each tool's handler;
  • Billing reading again;
  • the clients' 402s;
  • the chat message put back;
  • the org read failing closed.

For you, @gkhngyk:

  • Direct Supabase writes. About 26 server actions and a few Next routes write to Supabase without the API, so feat(server): keep a workspace read-only once its plan has ended #1589's 402 doesn't cover them. The C PRs guard their buttons. A server-side check (a shared assert in those actions, or RLS) would be its own PR, if you want it.
  • Trial vs paid cancel. A cancel during the trial and a cancel after a payment can't be told apart: no trial trace is stored. The text is written to fit both.
  • Plan in the client. The client gets org.plan while the API gives an ended org Starter's limits. The only difference is shopping_analytics, whose reads get 403 while browsing.
  • MCP skills. The skills/*/SKILL.md docs should say that write tools answer subscription_inactive. That's a separate docs PR.

🤖 Generated with Claude Code

…e "Choose a plan" dialog

On the cloud, an ended trial, a cancel during the trial and a cancel
after the first payment can now sign in and look around. They used to
see a full-screen "subscription expired" notice that only signed out.
Onboarding is unchanged: an admin who never started a trial still goes
to the plan step.

- The dashboard layout lets these workspaces in, read-only. A thin
  banner says so, with "See plans".
- UpgradeDialogProvider and useUpgradeGate ({ guard, isLocked,
  openUpgrade }) open one "Choose a plan to keep going" dialog, with the
  action that was clicked as a label.
  - Admins go to Billing; members are told to ask their admin.
  - A failed payment (past_due, unpaid) says so and opens Stripe's
    portal.
  - A 402 subscription_inactive from the API opens the dialog
    (use-failure-toast, api-failure's subscription class, and the
    Webflow, catalog, publish and Send to CMS clients).
- Automatic calls (Library's Webflow status, the editor's link, source,
  claim and page reads, Improve's read) aren't sent while locked.
- Billing: an ended subscription starts a new Checkout ("Choose
  {plan}", monthly or annual). The checkout route takes admins only,
  refuses a second live subscription (409), and validates its body.
  Billing reads again after a change.
- MCP: list_ and get_ tools stay open; every other tool, and REST
  writes, answer subscription_inactive. Chat and new conversations
  answer 402, and runSiteAuditFor, generateBriefFor and
  createImproveActionFor check too. A chat message refused by a 402
  goes back to the input.

Self-hosted is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with follow-ups. Merge it only once #1589's API is live (see "Before and after the API deploy").

What I checked:

  • Merge state. One commit (22fdd46) on 55b49e7. git merge-tree with main (15b5b5f) is clean. Main's changes since then that touch the same files are #1567 (Library's send filter), #1593 (Webflow card) and the billing/plan config. All three auto-merge, and the merged tree's tests pass (below).
  • Who's affected.
    • evaluateSubscriptionAccess keeps active and trialing as the only open statuses, the same pair isSubscriptionActive uses on the server (#1589). Paying and trialing workspaces get ok and nothing changes for them: subscriptionActive stays true, the banner renders nothing, guard() runs the handler, and useFailureToast only opens the dialog on subscription_inactive or on a plan refusal while already locked.
    • Self-hosted: the layouts skip the check (isCloud()), and PlanProvider forces subscriptionActive: true when NEXT_PUBLIC_IS_CLOUD isn't set. subscriptionActiveFor returns true off the cloud, so the MCP and agent gates never fire there.
    • An admin with no stripe_subscription_id keeps the plan step (choose_plan). The webhook never clears the id on subscription.deleted, so a cancelled workspace doesn't fall back into onboarding. The onboarding layout sends an ended, onboarded workspace to /dashboard, and there's no loop between the two layouts.
  • Checkout.
    • The admin check, the Zod body and the 409 on a live subscription are right. subscriptionEnded and LIVE_STATUSES agree with the layout: past_due/unpaid go to the portal, canceled/incomplete_expired/none start a new Checkout.
    • Onboarding's call ({ planId, organizationId }) still parses. A new account's creator is admin by the column default, so the new role check doesn't block the first purchase.
  • Server-side gates on the web.
    • The MCP tools are wrapped in registerTool; tool() throws. All 50 tools on the stack's head follow the prefix rule: the 36 list_/get_ tools only read, and the 14 others (accept/dismiss, update status, brief, audit, improve action, sentiment override, draft create/source/suggest/ready) are gated. The plan is read once per request, and a failed read refuses the call.
    • authenticateMcpRequest refuses POST/PUT/PATCH/DELETE on the /api/mcp/* REST routes. /api/mcp itself opts out and gates per tool.
    • generateBriefFor, runSiteAuditFor and createImproveActionFor assert after the ownership check, so any caller is covered.
    • POST /api/agent/chat and POST /api/agent/conversations answer 402 before any model call. Reading and deleting conversations stay open.
    • /api/aeo/* forwards to the API, which #1589 gates. /api/keys, /api/settings/pulse and /api/settings/ai-providers still write while locked; none of them costs anything (follow-up 1).
  • Tests.
    • On main merged with this PR, the whole web suite passes apart from failures that main shows on its own in the same run (export and server/-path tests that need files outside web/). tsc --noEmit on the merged tree adds no errors to main's.
    • With this PR's source files put back to 55b49e7 and its tests kept, 24 of its 25 test files fail (38 tests, plus the files that no longer load).

Before and after the API deploy:

  • With today's API (no #1589), this PR shouldn't go out. It's the first change that lets an ended workspace into the dashboard. This PR guards almost no buttons itself; #1606 and #1609 add those.
    • Today's API leaves several model and page-reading routes to #1589's middleware: the report summary, fan-out intents, competitor and topic suggestions, and the content page reads. An ended workspace could run them from the dashboard.
    • The routes already behind plan-guard answer its 402 without a code. The web reads that as plan and, while locked, opens the dialog. So those are fine.
  • With #1589 live, every route that costs answers 402 subscription_inactive, and this PR turns that into the dialog.
    • What still goes through is the writes that go straight to the database from server actions and RLS. That's adding or editing prompts, topics, competitors, brands, notes and drafts' fields, for pages #1606/#1609 don't cover yet.
    • None of those costs anything: tracking and the other sweeps skip an ended organization.
  • Merge #1599, #1606 and #1609 together, or close together. On #1599 alone, every button outside the dialog's own paths runs and lands on a 402 or a plain toast.

Follow-ups:

  1. Writes that skip the API. "Read-only" holds only in the UI for the direct server-action and RLS writes (the ~26 actions in the description), and for /api/keys and /api/settings/*. A shared assertSubscriptionActive(orgId) in those actions would make the rule hold server-side the way the MCP surface already does. An RLS-level check on the main tables would also work. Neither costs today, so it can be its own PR, but it belongs before C3 is called done.
  2. An org read that fails opens the dashboard unlocked (isCloud() && !orgError). That's fine once #1589 is live, because the API still refuses. It's worth a comment that this leans on the API.
  3. Re-subscribing goes through /api/stripe/success. That route triggers tracking and volume analysis for the first brand, as for a new account. For a returning customer that's a full run at once on the day they pay. It's probably wanted, but it's worth confirming.
  4. The plan step for an ended trial vs. an ended paid plan. As the description says, there's no stored trace to tell them apart. If that copy matters later, a trial_ended_at set by the webhook would do it.

cihan-gyk and others added 2 commits October 27, 2026 23:48
…essage test

main's catalog-client test (ansvisor#1583) asks for words for every StoreError
code; 'subscription' opens the upgrade dialog instead of saying one, so
the test leaves it out, as ansvisor#1613 does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Merged main forward (through #1611) so the read-only chain applies on today's main. One fix, 9616d2e: main's catalog-client.test.ts (#1582/#1583) asks every StoreError code for a message, and this PR's 'subscription' opens the plan dialog instead, so the test leaves it out (Exclude<StoreError, 'subscription'>, with a comment). Checks on the chain's tops: typecheck on every branch; at #1614, yarn test (4,576 tests) and yarn build; at #1613, its tests and yarn build (the editor page's test file timed out under load in the full run and passes alone, 323 tests with the Library's).

gkhngyk pushed a commit that referenced this pull request Oct 28, 2026
…lan & usage, not Starter's (#1671)

* fix(prompts): show an organization whose plan ended its own plan in Plan & usage, not Starter's

Follow-up from the read-only browser check. /api/prompts/usage read the
plan with planFromOrgRow, which gives an organization without an active
subscription Starter's limits, so an ended Growth workspace's Plan &
usage fold said "Starter plan · 25 of 50 on Starter · Upgrade to Growth".

- plan-guard.ts: usagePlanFromOrgRow is the plan to show usage against.
  While the subscription is active or trialing it's planFromOrgRow's; once
  it has ended (cloud), the plan the row names, Enterprise overrides
  merged, marked ended. planFromOrgRow is unchanged for every other caller.
- The summary's plan gets `ended: true` and the new cta `choose_plan`
  then (ended is left out otherwise, so other answers are as before).
- The cards say "Growth plan · ended", 0 slots left, and "Your Growth plan
  has ended · Choose a plan", linking to the plan page as the other
  upgrades do.
- The MCP's prompt usage read (getPromptUsageFor) reads it the same way.

Only seen once an ended workspace can open the dashboard (the read-only
web part, #1599). The coach skills list plan.cta's values; they'll need
choose_plan in their own docs PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(prompts): leave an ended plan no slots in the Add Prompt dialog and bulk import, and say so in get_prompt_usage

Review follow-up.

- locationQuotaFromUsage read only locationLimit, so with the plan ended
  the cards said 0 slots left while the Add Prompt dialog and bulk import
  still let 154 more in. An ended plan's quota now reads as full.
- get_prompt_usage's description told the agent "Slots left =
  locationLimit − locationsUsed" with no word of plan.ended, so it would
  say an ended Growth plan had 154 left. It now names `ended` and the
  choose_plan cta, and says no slot is left until a plan is chosen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 28, 2026
…access, part 3) (#1704)

* feat(settings): store who sees which left-menu sections (menu access, part 1)

Menu access, part 1 of 7: the data and the rule, with no UI yet.

- 00374 adds organization_menu_roles, the sections a role (not admin)
  doesn't see. Members of the organization read it and the server
  writes it.
- On profiles it adds menu_shown, menu_hidden and can_manage_menus,
  which only the server sets (00228's guard is extended), and
  work_areas and work_areas_asked_at, which the person sets.
- lib/menu-access.ts holds the rule: the role's sections, then the
  person's exceptions, narrowed to their work areas.
  - Action Center is always on.
  - Nobody takes a section off an admin's menu; only their own work
    areas narrow it.
  - A section is named by its route, so a new one shows by default.
- lib/actions/menu-access.ts covers getMyMenu, the Settings data, the
  role table, per-person exceptions and menu managers (admin only).
  It also writes the person's own work areas.

Hide only: pages still open from a link, roles and data access don't
change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): leave a person's hidden sections off the left menu (menu access, part 2)

The dashboard layout reads the viewer's menu once (getMyMenu, part 1) and
hands the sections it leaves out to a MenuAccessProvider. Both menus filter
by them through shouldShowDashboardNavItem:

- the sidebar drops a group whose sections are all off the menu, title and
  all;
- the mobile menu drops the active brand's Prompts link with the Prompts
  section.

If the menu can't be read, the whole menu shows. Hide only: an address
still opens its page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): clear a person's menu access when they move organization

A removed member keeps their profile and an invitation moves it to the
next organization, so a menu manager of one organization arrived in
another still able to change its menus, with their old exceptions. A
trigger now clears menu_shown, menu_hidden and can_manage_menus on a new
organization and can_manage_menus on a new role, unless the same update
sets them; it fires after the guard, so the guard still checks what the
person asked for.

Also reloads PostgREST's schema at the end of 00374, validates
setMenuManager's flag with Zod, and tests that the work-area check in
the database lists exactly the app's work areas.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): choose which left-menu sections each role sees (menu access, part 3)

A new Settings section, Menu access, for admins and the managers they let
change menus. Others don't see it in Settings, and its address tells them
who can.

- A table of the menu's sections by its groups, with a column per role:
  - each box saves at once, and is put back with a toast if the save
    fails;
  - Admin is always Everything, and Action Center can't be turned off;
  - "Use a set…" fills a role from a work area's ready-made set, or
    Everything.
- Fixed column shares keep the table inside Settings' column at 1024 px.
- en.json carries the copy and the nine work areas' names and lines, so
  the Account and welcome-step parts can use them too.
- MenuAccessProvider also carries whether the viewer can change menus.

The plan dialog for a workspace whose plan has ended follows once #1599
lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): count everyone already here as asked about their work areas

"What do you work on?" is for new sign-ups and people joining from an
invite, once. Without this, every existing person would get the step at
their next sign-in. They can still pick work areas in Settings › Account.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): read the menu with the layout's own profile read (menu access, part 2 review)

The dashboard layout read the viewer's menu through getMyMenu, a second
user check and profile read after its own: two or three requests in a row
on every render. The menu columns now come with the profile the layout
already reads. The role's row (none for admins) is read alongside the
organization and the brands. menuOfProfile builds the menu from both,
and getMyMenu uses the same.

- A role row that can't be read is logged (console.error) and the menu
  shows whole, rather than the failure passing silently.
- The sidebar no longer reads the tracked prompts' count while Prompts is
  off the menu.
- Tests cover a group dropped with its title when all its sections are
  hidden, the whole menu without a menu to go by, the count not read, the
  mobile menu leaving hidden sections off (the brand's Prompts link with
  Prompts), and readRoleHidden.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): keep a save that went through when another fails, and let "Use a set…" fit (menu access, part 3 review)

- A failed save on Menu access reads the role table again, instead of
  putting back the state from before it, which also undid a later save
  that had gone through.
- No router.refresh after a save: setRoleMenu's revalidatePath already
  brings the menu up to date, so each click no longer renders twice.
- The role columns get a little more of the table, and the select's
  chevron is smaller, so "Use a set…" isn't cut at 1024 px with the
  sidebar open.
- Tests: picking a ready-made set saves it; a failed save next to a
  successful one keeps the successful one; Settings lists Menu access
  only for someone who can change menus.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): keep Everything inside the admins' column at 1024 px (menu access, part 3 review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 28, 2026
…ions (menu access, part 4) (#1705)

* feat(settings): store who sees which left-menu sections (menu access, part 1)

Menu access, part 1 of 7: the data and the rule, with no UI yet.

- 00374 adds organization_menu_roles, the sections a role (not admin)
  doesn't see. Members of the organization read it and the server
  writes it.
- On profiles it adds menu_shown, menu_hidden and can_manage_menus,
  which only the server sets (00228's guard is extended), and
  work_areas and work_areas_asked_at, which the person sets.
- lib/menu-access.ts holds the rule: the role's sections, then the
  person's exceptions, narrowed to their work areas.
  - Action Center is always on.
  - Nobody takes a section off an admin's menu; only their own work
    areas narrow it.
  - A section is named by its route, so a new one shows by default.
- lib/actions/menu-access.ts covers getMyMenu, the Settings data, the
  role table, per-person exceptions and menu managers (admin only).
  It also writes the person's own work areas.

Hide only: pages still open from a link, roles and data access don't
change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): leave a person's hidden sections off the left menu (menu access, part 2)

The dashboard layout reads the viewer's menu once (getMyMenu, part 1) and
hands the sections it leaves out to a MenuAccessProvider. Both menus filter
by them through shouldShowDashboardNavItem:

- the sidebar drops a group whose sections are all off the menu, title and
  all;
- the mobile menu drops the active brand's Prompts link with the Prompts
  section.

If the menu can't be read, the whole menu shows. Hide only: an address
still opens its page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): clear a person's menu access when they move organization

A removed member keeps their profile and an invitation moves it to the
next organization, so a menu manager of one organization arrived in
another still able to change its menus, with their old exceptions. A
trigger now clears menu_shown, menu_hidden and can_manage_menus on a new
organization and can_manage_menus on a new role, unless the same update
sets them; it fires after the guard, so the guard still checks what the
person asked for.

Also reloads PostgREST's schema at the end of 00374, validates
setMenuManager's flag with Zod, and tests that the work-area check in
the database lists exactly the app's work areas.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): choose which left-menu sections each role sees (menu access, part 3)

A new Settings section, Menu access, for admins and the managers they let
change menus. Others don't see it in Settings, and its address tells them
who can.

- A table of the menu's sections by its groups, with a column per role:
  - each box saves at once, and is put back with a toast if the save
    fails;
  - Admin is always Everything, and Action Center can't be turned off;
  - "Use a set…" fills a role from a work area's ready-made set, or
    Everything.
- Fixed column shares keep the table inside Settings' column at 1024 px.
- en.json carries the copy and the nine work areas' names and lines, so
  the Account and welcome-step parts can use them too.
- MenuAccessProvider also carries whether the viewer can change menus.

The plan dialog for a workspace whose plan has ended follows once #1599
lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): let managers change menus and set a person's own sections (menu access, part 4)

Two more cards on Settings › Menu access.

Who can change menus:
- lists the managers;
- an admin switches one on (setMenuManager) to let them use this page;
- a manager who changes menus sees the switches but can't flip them.

People: every non-admin with their role, work areas, menu ("{role}'s
menu", or "Custom: +Prompts, −Content") and how many sections it keeps.
Customize opens their sections:
- ticked as their role has them;
- a change from the role marked "shown for them" or "hidden for them";
- Action Center always on;
- each box saved at once (setMemberMenu);
- "Use {role}'s menu" goes back to the role's.

A failed save puts the switch or box back, with a toast. A row lays out on
one line when the card is wide, and on two when it's narrow (1024 px).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): count everyone already here as asked about their work areas

"What do you work on?" is for new sign-ups and people joining from an
invite, once. Without this, every existing person would get the step at
their next sign-in. They can still pick work areas in Settings › Account.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): read the menu with the layout's own profile read (menu access, part 2 review)

The dashboard layout read the viewer's menu through getMyMenu, a second
user check and profile read after its own: two or three requests in a row
on every render. The menu columns now come with the profile the layout
already reads. The role's row (none for admins) is read alongside the
organization and the brands. menuOfProfile builds the menu from both,
and getMyMenu uses the same.

- A role row that can't be read is logged (console.error) and the menu
  shows whole, rather than the failure passing silently.
- The sidebar no longer reads the tracked prompts' count while Prompts is
  off the menu.
- Tests cover a group dropped with its title when all its sections are
  hidden, the whole menu without a menu to go by, the count not read, the
  mobile menu leaving hidden sections off (the brand's Prompts link with
  Prompts), and readRoleHidden.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): keep a save that went through when another fails, and let "Use a set…" fit (menu access, part 3 review)

- A failed save on Menu access reads the role table again, instead of
  putting back the state from before it, which also undid a later save
  that had gone through.
- No router.refresh after a save: setRoleMenu's revalidatePath already
  brings the menu up to date, so each click no longer renders twice.
- The role columns get a little more of the table, and the select's
  chevron is smaller, so "Use a set…" isn't cut at 1024 px with the
  sidebar open.
- Tests: picking a ready-made set saves it; a failed save next to a
  successful one keeps the successful one; Settings lists Menu access
  only for someone who can change menus.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): read the people's menus again when a save fails (menu access, part 4 review)

As with the role table: a failed save on Who can change menus or People
reads the settings again (onFailed), instead of putting back the state
from before it, which could undo a later save that had gone through. No
router.refresh after a save: setMenuManager and setMemberMenu revalidate
already.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): keep Everything inside the admins' column at 1024 px (menu access, part 3 review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 28, 2026
…t (menu access, part 5) (#1706)

* feat(settings): store who sees which left-menu sections (menu access, part 1)

Menu access, part 1 of 7: the data and the rule, with no UI yet.

- 00374 adds organization_menu_roles, the sections a role (not admin)
  doesn't see. Members of the organization read it and the server
  writes it.
- On profiles it adds menu_shown, menu_hidden and can_manage_menus,
  which only the server sets (00228's guard is extended), and
  work_areas and work_areas_asked_at, which the person sets.
- lib/menu-access.ts holds the rule: the role's sections, then the
  person's exceptions, narrowed to their work areas.
  - Action Center is always on.
  - Nobody takes a section off an admin's menu; only their own work
    areas narrow it.
  - A section is named by its route, so a new one shows by default.
- lib/actions/menu-access.ts covers getMyMenu, the Settings data, the
  role table, per-person exceptions and menu managers (admin only).
  It also writes the person's own work areas.

Hide only: pages still open from a link, roles and data access don't
change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): leave a person's hidden sections off the left menu (menu access, part 2)

The dashboard layout reads the viewer's menu once (getMyMenu, part 1) and
hands the sections it leaves out to a MenuAccessProvider. Both menus filter
by them through shouldShowDashboardNavItem:

- the sidebar drops a group whose sections are all off the menu, title and
  all;
- the mobile menu drops the active brand's Prompts link with the Prompts
  section.

If the menu can't be read, the whole menu shows. Hide only: an address
still opens its page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): clear a person's menu access when they move organization

A removed member keeps their profile and an invitation moves it to the
next organization, so a menu manager of one organization arrived in
another still able to change its menus, with their old exceptions. A
trigger now clears menu_shown, menu_hidden and can_manage_menus on a new
organization and can_manage_menus on a new role, unless the same update
sets them; it fires after the guard, so the guard still checks what the
person asked for.

Also reloads PostgREST's schema at the end of 00374, validates
setMenuManager's flag with Zod, and tests that the work-area check in
the database lists exactly the app's work areas.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): choose which left-menu sections each role sees (menu access, part 3)

A new Settings section, Menu access, for admins and the managers they let
change menus. Others don't see it in Settings, and its address tells them
who can.

- A table of the menu's sections by its groups, with a column per role:
  - each box saves at once, and is put back with a toast if the save
    fails;
  - Admin is always Everything, and Action Center can't be turned off;
  - "Use a set…" fills a role from a work area's ready-made set, or
    Everything.
- Fixed column shares keep the table inside Settings' column at 1024 px.
- en.json carries the copy and the nine work areas' names and lines, so
  the Account and welcome-step parts can use them too.
- MenuAccessProvider also carries whether the viewer can change menus.

The plan dialog for a workspace whose plan has ended follows once #1599
lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): let managers change menus and set a person's own sections (menu access, part 4)

Two more cards on Settings › Menu access.

Who can change menus:
- lists the managers;
- an admin switches one on (setMenuManager) to let them use this page;
- a manager who changes menus sees the switches but can't flip them.

People: every non-admin with their role, work areas, menu ("{role}'s
menu", or "Custom: +Prompts, −Content") and how many sections it keeps.
Customize opens their sections:
- ticked as their role has them;
- a change from the role marked "shown for them" or "hidden for them";
- Action Center always on;
- each box saved at once (setMemberMenu);
- "Use {role}'s menu" goes back to the role's.

A failed save puts the switch or box back, with a toast. A row lays out on
one line when the card is wide, and on two when it's narrow (1024 px).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): let people pick their work areas in Settings › Account (menu access, part 5)

Settings › Account gets "Your work areas": the nine areas as chips plus
Everything.
- Picking one narrows the person's own left menu; admins can pick too,
  since nobody else narrows an admin's menu.
- Each change is saved at once (setMyWorkAreas) and the menu refreshes; a
  failed save puts the chips back, with a toast.
- "Your menu" lists the sections. One that's off says why: "Hidden by your
  admin" (role or exception) or "Not in your work areas". A note says how
  many the admin took off.
- getMyMenu now also returns hiddenByAdmin.

The sidebar says "N sections off your menu. Change" above Send feedback
when something is off, with Change linking to Account.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): count everyone already here as asked about their work areas

"What do you work on?" is for new sign-ups and people joining from an
invite, once. Without this, every existing person would get the step at
their next sign-in. They can still pick work areas in Settings › Account.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): read the menu with the layout's own profile read (menu access, part 2 review)

The dashboard layout read the viewer's menu through getMyMenu, a second
user check and profile read after its own: two or three requests in a row
on every render. The menu columns now come with the profile the layout
already reads. The role's row (none for admins) is read alongside the
organization and the brands. menuOfProfile builds the menu from both,
and getMyMenu uses the same.

- A role row that can't be read is logged (console.error) and the menu
  shows whole, rather than the failure passing silently.
- The sidebar no longer reads the tracked prompts' count while Prompts is
  off the menu.
- Tests cover a group dropped with its title when all its sections are
  hidden, the whole menu without a menu to go by, the count not read, the
  mobile menu leaving hidden sections off (the brand's Prompts link with
  Prompts), and readRoleHidden.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): keep a save that went through when another fails, and let "Use a set…" fit (menu access, part 3 review)

- A failed save on Menu access reads the role table again, instead of
  putting back the state from before it, which also undid a later save
  that had gone through.
- No router.refresh after a save: setRoleMenu's revalidatePath already
  brings the menu up to date, so each click no longer renders twice.
- The role columns get a little more of the table, and the select's
  chevron is smaller, so "Use a set…" isn't cut at 1024 px with the
  sidebar open.
- Tests: picking a ready-made set saves it; a failed save next to a
  successful one keeps the successful one; Settings lists Menu access
  only for someone who can change menus.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): read the people's menus again when a save fails (menu access, part 4 review)

As with the role table: a failed save on Who can change menus or People
reads the settings again (onFailed), instead of putting back the state
from before it, which could undo a later save that had gone through. No
router.refresh after a save: setMenuManager and setMemberMenu revalidate
already.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): read the work areas again when a save fails (menu access, part 5 review)

As on Menu access: Settings › Account's work areas read the menu again when
a save fails, instead of putting back the state from before it. No
router.refresh after a save: setMyWorkAreas revalidates the layout
already. The Settings list test mocks the Account card too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): keep Everything inside the admins' column at 1024 px (menu access, part 3 review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 28, 2026
…joining (menu access, part 6) (#1707)

* feat(settings): store who sees which left-menu sections (menu access, part 1)

Menu access, part 1 of 7: the data and the rule, with no UI yet.

- 00374 adds organization_menu_roles, the sections a role (not admin)
  doesn't see. Members of the organization read it and the server
  writes it.
- On profiles it adds menu_shown, menu_hidden and can_manage_menus,
  which only the server sets (00228's guard is extended), and
  work_areas and work_areas_asked_at, which the person sets.
- lib/menu-access.ts holds the rule: the role's sections, then the
  person's exceptions, narrowed to their work areas.
  - Action Center is always on.
  - Nobody takes a section off an admin's menu; only their own work
    areas narrow it.
  - A section is named by its route, so a new one shows by default.
- lib/actions/menu-access.ts covers getMyMenu, the Settings data, the
  role table, per-person exceptions and menu managers (admin only).
  It also writes the person's own work areas.

Hide only: pages still open from a link, roles and data access don't
change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): leave a person's hidden sections off the left menu (menu access, part 2)

The dashboard layout reads the viewer's menu once (getMyMenu, part 1) and
hands the sections it leaves out to a MenuAccessProvider. Both menus filter
by them through shouldShowDashboardNavItem:

- the sidebar drops a group whose sections are all off the menu, title and
  all;
- the mobile menu drops the active brand's Prompts link with the Prompts
  section.

If the menu can't be read, the whole menu shows. Hide only: an address
still opens its page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): clear a person's menu access when they move organization

A removed member keeps their profile and an invitation moves it to the
next organization, so a menu manager of one organization arrived in
another still able to change its menus, with their old exceptions. A
trigger now clears menu_shown, menu_hidden and can_manage_menus on a new
organization and can_manage_menus on a new role, unless the same update
sets them; it fires after the guard, so the guard still checks what the
person asked for.

Also reloads PostgREST's schema at the end of 00374, validates
setMenuManager's flag with Zod, and tests that the work-area check in
the database lists exactly the app's work areas.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): choose which left-menu sections each role sees (menu access, part 3)

A new Settings section, Menu access, for admins and the managers they let
change menus. Others don't see it in Settings, and its address tells them
who can.

- A table of the menu's sections by its groups, with a column per role:
  - each box saves at once, and is put back with a toast if the save
    fails;
  - Admin is always Everything, and Action Center can't be turned off;
  - "Use a set…" fills a role from a work area's ready-made set, or
    Everything.
- Fixed column shares keep the table inside Settings' column at 1024 px.
- en.json carries the copy and the nine work areas' names and lines, so
  the Account and welcome-step parts can use them too.
- MenuAccessProvider also carries whether the viewer can change menus.

The plan dialog for a workspace whose plan has ended follows once #1599
lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): let managers change menus and set a person's own sections (menu access, part 4)

Two more cards on Settings › Menu access.

Who can change menus:
- lists the managers;
- an admin switches one on (setMenuManager) to let them use this page;
- a manager who changes menus sees the switches but can't flip them.

People: every non-admin with their role, work areas, menu ("{role}'s
menu", or "Custom: +Prompts, −Content") and how many sections it keeps.
Customize opens their sections:
- ticked as their role has them;
- a change from the role marked "shown for them" or "hidden for them";
- Action Center always on;
- each box saved at once (setMemberMenu);
- "Use {role}'s menu" goes back to the role's.

A failed save puts the switch or box back, with a toast. A row lays out on
one line when the card is wide, and on two when it's narrow (1024 px).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): let people pick their work areas in Settings › Account (menu access, part 5)

Settings › Account gets "Your work areas": the nine areas as chips plus
Everything.
- Picking one narrows the person's own left menu; admins can pick too,
  since nobody else narrows an admin's menu.
- Each change is saved at once (setMyWorkAreas) and the menu refreshes; a
  failed save puts the chips back, with a toast.
- "Your menu" lists the sections. One that's off says why: "Hidden by your
  admin" (role or exception) or "Not in your work areas". A note says how
  many the admin took off.
- getMyMenu now also returns hiddenByAdmin.

The sidebar says "N sections off your menu. Change" above Send feedback
when something is off, with Change linking to Account.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): count everyone already here as asked about their work areas

"What do you work on?" is for new sign-ups and people joining from an
invite, once. Without this, every existing person would get the step at
their next sign-in. They can still pick work areas in Settings › Account.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(onboarding): ask what people work on, once (menu access, part 6)

"What do you work on?" is a step of its own (components/onboarding/
work-areas-step.tsx). It shows:
- the nine work areas as cards, with each area's line and sections;
- the menu they give as they're picked, with the count the admin took off.

Continue or "Skip: show me everything" saves (setMyWorkAreas), so it's
asked once; it changes later in Settings › Account.

- Cloud sign-up: it comes after the competitors and before the plan.
  WORK_AREAS_STEP and PLAN_STEP name the two steps, so the plan step and
  anything added to it move together. Resuming a finished sign-up opens
  whichever of the two is still owed.
- Anyone not asked in onboarding (an invited person, or a self-hosted
  admin with no plan step) is sent by the dashboard layout, once, to
  /dashboard/welcome. It sits in the onboarding group, so the layout can't
  send it to itself.
  - An invited person reads "Welcome to {brand} Workspace, {first name}"
    and "You've joined as {role}." (the organization's name when it has
    several brands).
  - An admin is asked "What do you work on?".
- lib/menu-access.ts gets hiddenWithWorkAreas, which the Account card now
  uses too.

People already here were counted as asked by 00374.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): read the menu with the layout's own profile read (menu access, part 2 review)

The dashboard layout read the viewer's menu through getMyMenu, a second
user check and profile read after its own: two or three requests in a row
on every render. The menu columns now come with the profile the layout
already reads. The role's row (none for admins) is read alongside the
organization and the brands. menuOfProfile builds the menu from both,
and getMyMenu uses the same.

- A role row that can't be read is logged (console.error) and the menu
  shows whole, rather than the failure passing silently.
- The sidebar no longer reads the tracked prompts' count while Prompts is
  off the menu.
- Tests cover a group dropped with its title when all its sections are
  hidden, the whole menu without a menu to go by, the count not read, the
  mobile menu leaving hidden sections off (the brand's Prompts link with
  Prompts), and readRoleHidden.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): keep a save that went through when another fails, and let "Use a set…" fit (menu access, part 3 review)

- A failed save on Menu access reads the role table again, instead of
  putting back the state from before it, which also undid a later save
  that had gone through.
- No router.refresh after a save: setRoleMenu's revalidatePath already
  brings the menu up to date, so each click no longer renders twice.
- The role columns get a little more of the table, and the select's
  chevron is smaller, so "Use a set…" isn't cut at 1024 px with the
  sidebar open.
- Tests: picking a ready-made set saves it; a failed save next to a
  successful one keeps the successful one; Settings lists Menu access
  only for someone who can change menus.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): read the people's menus again when a save fails (menu access, part 4 review)

As with the role table: a failed save on Who can change menus or People
reads the settings again (onFailed), instead of putting back the state
from before it, which could undo a later save that had gone through. No
router.refresh after a save: setMenuManager and setMemberMenu revalidate
already.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): read the work areas again when a save fails (menu access, part 5 review)

As on Menu access: Settings › Account's work areas read the menu again when
a save fails, instead of putting back the state from before it. No
router.refresh after a save: setMyWorkAreas revalidates the layout
already. The Settings list test mocks the Account card too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): keep Everything inside the admins' column at 1024 px (menu access, part 3 review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 28, 2026
* feat(settings): store who sees which left-menu sections (menu access, part 1)

Menu access, part 1 of 7: the data and the rule, with no UI yet.

- 00374 adds organization_menu_roles, the sections a role (not admin)
  doesn't see. Members of the organization read it and the server
  writes it.
- On profiles it adds menu_shown, menu_hidden and can_manage_menus,
  which only the server sets (00228's guard is extended), and
  work_areas and work_areas_asked_at, which the person sets.
- lib/menu-access.ts holds the rule: the role's sections, then the
  person's exceptions, narrowed to their work areas.
  - Action Center is always on.
  - Nobody takes a section off an admin's menu; only their own work
    areas narrow it.
  - A section is named by its route, so a new one shows by default.
- lib/actions/menu-access.ts covers getMyMenu, the Settings data, the
  role table, per-person exceptions and menu managers (admin only).
  It also writes the person's own work areas.

Hide only: pages still open from a link, roles and data access don't
change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): leave a person's hidden sections off the left menu (menu access, part 2)

The dashboard layout reads the viewer's menu once (getMyMenu, part 1) and
hands the sections it leaves out to a MenuAccessProvider. Both menus filter
by them through shouldShowDashboardNavItem:

- the sidebar drops a group whose sections are all off the menu, title and
  all;
- the mobile menu drops the active brand's Prompts link with the Prompts
  section.

If the menu can't be read, the whole menu shows. Hide only: an address
still opens its page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): clear a person's menu access when they move organization

A removed member keeps their profile and an invitation moves it to the
next organization, so a menu manager of one organization arrived in
another still able to change its menus, with their old exceptions. A
trigger now clears menu_shown, menu_hidden and can_manage_menus on a new
organization and can_manage_menus on a new role, unless the same update
sets them; it fires after the guard, so the guard still checks what the
person asked for.

Also reloads PostgREST's schema at the end of 00374, validates
setMenuManager's flag with Zod, and tests that the work-area check in
the database lists exactly the app's work areas.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): choose which left-menu sections each role sees (menu access, part 3)

A new Settings section, Menu access, for admins and the managers they let
change menus. Others don't see it in Settings, and its address tells them
who can.

- A table of the menu's sections by its groups, with a column per role:
  - each box saves at once, and is put back with a toast if the save
    fails;
  - Admin is always Everything, and Action Center can't be turned off;
  - "Use a set…" fills a role from a work area's ready-made set, or
    Everything.
- Fixed column shares keep the table inside Settings' column at 1024 px.
- en.json carries the copy and the nine work areas' names and lines, so
  the Account and welcome-step parts can use them too.
- MenuAccessProvider also carries whether the viewer can change menus.

The plan dialog for a workspace whose plan has ended follows once #1599
lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): let managers change menus and set a person's own sections (menu access, part 4)

Two more cards on Settings › Menu access.

Who can change menus:
- lists the managers;
- an admin switches one on (setMenuManager) to let them use this page;
- a manager who changes menus sees the switches but can't flip them.

People: every non-admin with their role, work areas, menu ("{role}'s
menu", or "Custom: +Prompts, −Content") and how many sections it keeps.
Customize opens their sections:
- ticked as their role has them;
- a change from the role marked "shown for them" or "hidden for them";
- Action Center always on;
- each box saved at once (setMemberMenu);
- "Use {role}'s menu" goes back to the role's.

A failed save puts the switch or box back, with a toast. A row lays out on
one line when the card is wide, and on two when it's narrow (1024 px).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(settings): let people pick their work areas in Settings › Account (menu access, part 5)

Settings › Account gets "Your work areas": the nine areas as chips plus
Everything.
- Picking one narrows the person's own left menu; admins can pick too,
  since nobody else narrows an admin's menu.
- Each change is saved at once (setMyWorkAreas) and the menu refreshes; a
  failed save puts the chips back, with a toast.
- "Your menu" lists the sections. One that's off says why: "Hidden by your
  admin" (role or exception) or "Not in your work areas". A note says how
  many the admin took off.
- getMyMenu now also returns hiddenByAdmin.

The sidebar says "N sections off your menu. Change" above Send feedback
when something is off, with Change linking to Account.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): count everyone already here as asked about their work areas

"What do you work on?" is for new sign-ups and people joining from an
invite, once. Without this, every existing person would get the step at
their next sign-in. They can still pick work areas in Settings › Account.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(onboarding): ask what people work on, once (menu access, part 6)

"What do you work on?" is a step of its own (components/onboarding/
work-areas-step.tsx). It shows:
- the nine work areas as cards, with each area's line and sections;
- the menu they give as they're picked, with the count the admin took off.

Continue or "Skip: show me everything" saves (setMyWorkAreas), so it's
asked once; it changes later in Settings › Account.

- Cloud sign-up: it comes after the competitors and before the plan.
  WORK_AREAS_STEP and PLAN_STEP name the two steps, so the plan step and
  anything added to it move together. Resuming a finished sign-up opens
  whichever of the two is still owed.
- Anyone not asked in onboarding (an invited person, or a self-hosted
  admin with no plan step) is sent by the dashboard layout, once, to
  /dashboard/welcome. It sits in the onboarding group, so the layout can't
  send it to itself.
  - An invited person reads "Welcome to {brand} Workspace, {first name}"
    and "You've joined as {role}." (the organization's name when it has
    several brands).
  - An admin is asked "What do you work on?".
- lib/menu-access.ts gets hiddenWithWorkAreas, which the Account card now
  uses too.

People already here were counted as asked by 00374.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): read the menu with the layout's own profile read (menu access, part 2 review)

The dashboard layout read the viewer's menu through getMyMenu, a second
user check and profile read after its own: two or three requests in a row
on every render. The menu columns now come with the profile the layout
already reads. The role's row (none for admins) is read alongside the
organization and the brands. menuOfProfile builds the menu from both,
and getMyMenu uses the same.

- A role row that can't be read is logged (console.error) and the menu
  shows whole, rather than the failure passing silently.
- The sidebar no longer reads the tracked prompts' count while Prompts is
  off the menu.
- Tests cover a group dropped with its title when all its sections are
  hidden, the whole menu without a menu to go by, the count not read, the
  mobile menu leaving hidden sections off (the brand's Prompts link with
  Prompts), and readRoleHidden.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): keep a save that went through when another fails, and let "Use a set…" fit (menu access, part 3 review)

- A failed save on Menu access reads the role table again, instead of
  putting back the state from before it, which also undid a later save
  that had gone through.
- No router.refresh after a save: setRoleMenu's revalidatePath already
  brings the menu up to date, so each click no longer renders twice.
- The role columns get a little more of the table, and the select's
  chevron is smaller, so "Use a set…" isn't cut at 1024 px with the
  sidebar open.
- Tests: picking a ready-made set saves it; a failed save next to a
  successful one keeps the successful one; Settings lists Menu access
  only for someone who can change menus.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): read the people's menus again when a save fails (menu access, part 4 review)

As with the role table: a failed save on Who can change menus or People
reads the settings again (onFailed), instead of putting back the state
from before it, which could undo a later save that had gone through. No
router.refresh after a save: setMenuManager and setMemberMenu revalidate
already.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): read the work areas again when a save fails (menu access, part 5 review)

As on Menu access: Settings › Account's work areas read the menu again when
a save fails, instead of putting back the state from before it. No
router.refresh after a save: setMyWorkAreas revalidates the layout
already. The Settings list test mocks the Account card too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(settings): keep Everything inside the admins' column at 1024 px (menu access, part 3 review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(settings): explain menu access (menu access, part 7)

A new guide, Menu access, covers:
- who changes menus, and letting a manager do it;
- choosing what each role sees, with "Use a set…";
- changing one person's menu (People → Customize);
- the nine work areas and their sections;
- when "What do you work on?" is asked, and changing the answer in
  Settings → Account;
- how a menu is worked out, and what "hide only" means;
- a self-host note on migration 00374.

Add your first brand now lists the cloud's step 6 (What do you work on?)
before the plan step, which becomes step 7.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(settings): write the menu access examples without braces, which MDX reads as code

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
# Conflicts:
#	web/src/app/[locale]/(dashboard)/layout.tsx
#	web/src/lib/mcp/data.ts
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Merged main forward (8356ba3): resolved (dashboard)/layout.tsx (UpgradeDialogProvider wraps main's MenuAccessProvider, ReadOnlyBanner kept) and lib/mcp/data.ts imports (kept both). Typecheck and layout/MCP tests pass.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with follow-ups. Your merge of main resolved the two conflicts. At merge time the whole read-only stack on today's main passes the web and server suites, typecheck, lint and format.

Since my last review (22fdd46), the branch merged main at 3f6a4d4 (9865d8a) and added 9616d2e. The PR's own change is the same apart from 9616d2e: catalog-client.test.ts now leaves 'subscription' out of its "every code has a message" check, since that code opens the plan dialog instead of saying something. That's right.

The one thing I asked to wait for, #1589's API in production, is done, so this can go out.

What I checked:

  • Merge state on main (8356ba3). It conflicts in two files, both from main's newer PRs, not this PR's own logic:
    • web/src/app/[locale]/(dashboard)/layout.tsx (menu access, #1703/#1704/#1707). Keep main's roleHidden read and add error: orgError to the same destructure: const [{ data: org, error: orgError }, brands, roleHidden] = …. Nest the providers: MenuAccessProvider outside, UpgradeDialogProvider inside it (or the other way round, both work), and keep <ReadOnlyBanner /> where this PR put it. Keep main's "What do you work on?" redirect after the subscription check.
    • web/src/lib/mcp/data.ts (#1671). Keep both imports: usagePlanFromOrgRow from main and assertSubscriptionActive from this PR.
  • The new tools on main. Since 3f6a4d4, main changed list_action_history and get_prompt_usage's output and added no tool. Both are list_/get_ and only read, so gateWriteTools still leaves the right ones open.
  • Paying and self-hosted workspaces, Checkout, the MCP gate and the agent routes: unchanged since my last review, and still as I described there.
  • Tests on this head. The PR's 25 test files: 24 pass. The editor page's test timed out under load in that run and passes on its own (a known slow file). tsc --noEmit: no errors.

Follow-ups (unchanged from last time, none blocking):

  1. Writes that skip the API. #1613 now covers the server actions and Next routes. Direct table writes with a person's own session (RLS) are still open; that's #1613's note for later.
  2. An org read that fails opens the dashboard unlocked (isCloud() && !orgError). Fine with #1589 live; worth a comment that it leans on the API.
  3. The MCP message names only "its free trial ended or it was canceled", but past_due is refused too. #1613 moved the text to subscription-guard.ts; if it changes, update the quote in docs/guides/mcp-server.mdx (#1631) in the same change.
  4. Re-subscribing goes through /api/stripe/success, which runs tracking and volumes for the first brand as for a new account. Probably wanted; worth confirming.

Merge order: #1599 first, then #1604, #1606 → #1609 → #1612 → #1614, and #1613 (each after its parent), then #1631 last.

@gkhngyk
gkhngyk merged commit 7e64892 into ansvisor:main Oct 28, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants