Skip to content

feat(onboarding): ask "What do you work on?" once, at sign-up and on joining (menu access, part 6) - #1707

Merged
gkhngyk merged 28 commits into
ansvisor:mainfrom
cihan-gyk:feature/menu-access-welcome
Oct 28, 2026
Merged

gkhngyk merged 28 commits into
ansvisor:mainfrom
cihan-gyk:feature/menu-access-welcome

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Menu access, part 6: "What do you work on?", asked once. Stacked on part 5 (#1706).

  • Sign-up (cloud): a new step after competitors and before the plan, components/onboarding/work-areas-step.tsx: the nine areas as cards with a live menu preview, Continue and Skip: show me everything (both save through setMyWorkAreas, which also sets work_areas_asked_at). onboarding/page.tsx names its steps (WORK_AREAS_STEP, PLAN_STEP) instead of numbers; resuming lands on the right one. Self-host keeps its 5 steps; the layout asks instead.
  • People joining from an invite (and self-hosted sign-ups): the dashboard layout sends anyone not asked yet to /dashboard/welcome (in the onboarding group, so it can't redirect to itself), after the subscription check. "Welcome to {brand} Workspace, {first name}" / "You've joined as {role}."; the organization's name when it has several brands; admins get "What do you work on?".
  • Everyone already here counts as asked (00374, feat(settings): store who sees which menu sections, by role, person and work area (menu access, part 1) #1702), so existing people aren't stopped; they can pick in Settings › Account.
  • Copy in en.json (welcome namespace).

Related issue

None.

Type of change

  • feat — New feature

How to test

Same setup as part 2.

  1. update profiles set work_areas_asked_at = null where id = '1111…'; then open the dashboard: it goes to /dashboard/welcome. Pick Brand & PR, Continue: back on the dashboard, the sidebar follows Brand & PR. Reloading doesn't ask again.
  2. Skip: show me everything also sets it, with every section.
  3. Cloud sign-up (NEXT_PUBLIC_IS_CLOUD=true, a new account): after competitors comes "What do you work on?", then the plan step.
  4. Light and dark themes.
  5. Put it back: update profiles set work_areas = '{}', work_areas_asked_at = now() where id = '1111…';

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • yarn lint / yarn typecheck / yarn format pass
  • Changes are focused — one concern per PR
  • yarn test and yarn build pass, on this PR's tip: 465 files, 4,561 tests; build OK (on part 6's tip 8c2e172).
  • Tests added (work-areas-step.test.tsx)
  • npm run version:check (fails on main too: docker-compose images 0.2.0)

🤖 Generated with Claude Code

cihan-gyk and others added 27 commits October 28, 2026 14:02
… 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]>
…enu 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]>
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]>
…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 ansvisor#1599
lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ions (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]>
…t (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]>
…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]>
"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]>
… 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]>
…ettings

# Conflicts:
#	web/src/app/[locale]/(dashboard)/layout.tsx
…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]>
…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]>
…rk-areas

# Conflicts:
#	web/src/components/layout/sidebar.test.tsx
#	web/src/lib/actions/menu-access.ts
…ss, 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]>
…s-welcome

# Conflicts:
#	web/src/lib/menu-access.test.ts
#	web/src/lib/menu-access.ts
…menu access, part 3 review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 28, 2026

@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.

What I checked:

  • Own change. The diff against part 5 (4b89f5d..8c2e172): one feature commit (9e6ac7c) and two merges of part 5. Part 5's head is the last merge's parent, so nothing else is hidden in the merges. It doesn't touch 00374 or supabase/ at all. On today's main the branch conflicts only in supabase/schema.sql, which comes from part 1. This part's own files merge clean.
  • Asked once. The layout sends someone to /dashboard/welcome only when work_areas_asked_at is null. The welcome page sends anyone already asked back to the dashboard. Continue and Skip both go through setMyWorkAreas, which sets work_areas_asked_at. After that, a full page load (window.location.assign) means the layout reads the new value, so there's no redirect loop. 00374 marks everyone already here as asked, so existing people aren't stopped. A failed save shows a toast and keeps the step open (tested).
  • Doesn't block sign-up or joining. The welcome page is in the onboarding group, so the dashboard layout's redirect can't send it to itself. The redirect comes after the subscription check, so a blocked member still sees the notice and an admin who needs to pay still goes to the plan. On the cloud the step comes after competitors (when onboarding_completed is already set) and before the plan. Resuming lands on the work areas or the plan depending on work_areas_asked_at. Self-host keeps 5 steps and asks on the dashboard instead.
  • No organization. Someone without one (onboarding, or removed) is sent to onboarding by the layout before the menu is worked out, and the welcome page does the same. Its getMyMenu() call has a .catch, so a failed read gives an empty "hidden by admin" list instead of an error page.
  • Hide only. hiddenWithWorkAreas gives the same result as menuOfProfile. It's what the role and exceptions hide, plus what the work areas narrow. Action Center always stays, and a section no work area names isn't hidden. The Settings card now uses the same helper.
  • Copy. The welcome namespace in en.json is used by every key, and settings.team_role_* covers every TeamRole.
  • Tests. On the PR's tree, work-areas-step.test.tsx, menu-access.test.ts, the actions tests, and the settings, layout and onboarding component tests all pass: 25 files, 222 tests. tsc --noEmit on the web package reports nothing in this PR's files. The only errors are missing modules and types in my local test setup (@ai-sdk/*, sanitize-html) in files this PR doesn't change.

Follow-ups (none block):

  1. Analytics step numbers. onboarding_step_completed used to send step: 6 for the plan. It now sends step: 7, and step: 6 means work_areas. Any funnel or insight that filters on the step number rather than step_name will mix the two from the day this ships. Either check the funnels before merging, or note the cut-over date.
  2. Invited admins. Anyone joining with the admin role gets the sign-up copy: "What do you work on?" and "...your team can pick their own when they join." The docs say an invitation shows "Welcome to {brand} Workspace". Either welcome invited admins too (invited could come from the page, not from role !== 'admin'), or say in the docs that admins get the plain question.
  3. Empty workspace name. When the organization has no brand and no name, the title reads "Welcome to Workspace". Fall back to invitedTitleNoName's wording without the workspace, or to the organization's name only.
  4. People who already had an account. Someone with an existing profile who accepts an invitation keeps their work_areas_asked_at and isn't asked. That's fine, but acceptInvitation is where it would be reset if you want joining a new organization to ask again. Either way, the docs should match (see part 7).
  5. Continue with nothing picked does the same as Skip. You could disable Continue until something is picked, so the two buttons don't mean the same thing.

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