Repository navigation
feat(settings): leave a person's hidden sections off the left menu (menu access, part 2) - #1703
Merged
Merged
Conversation
… 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]>
…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]>
… 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]>
10 of 11 tasks
7 of 8 tasks
gkhngyk
approved these changes
Oct 28, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good, with follow-ups. 00374 is now on the production database, so the order in 1 is met.
What I checked:
- Own change. The diff from part 1's head (d44c81f) to c323a26: 49755f6 (feature), c323a26 (the layout reads the menu with its own profile read), and two merges of part 1. It touches no migration, so 00374 is the same as in part 1. On today's main, only part 1's
supabase/schema.sqlconflicts. None of this part's files changed on main since the stack's base apart fromen.json, and that merges on its own. - Layout. The profile read now also selects the menu columns, and the role's row is read in the same
Promise.allas the organization and brands. Someone without an organization, or who hasn't finished onboarding (a removed member, or someone signing up), is still sent to onboarding before any menu read, so the layout can't crash for them.readRoleHiddenskips the read for admins. When the row can't be read, it logs and shows the whole menu instead of throwing. This also covers part 1's follow-up 3: the layout no longer callsgetMyMenu, which throws without an organization. - Hide only.
shouldShowDashboardNavItemdrops an item by its section and changes nothing else, so pages still open from a link. The mobile menu's brand Prompts link goes with Prompts. The sidebar drops a group whose items are all hidden, and stops reading the tracked-prompt count while Prompts is hidden. Admins get no role row, and only their own work areas can narrow their menu (part 1's rule). - Refactor.
canManageMenus,workAreasOf,menuOfProfileandMyMenumoved from the action file tolib/menu-access.tsand behave the same.getMyMenugives the same result, built on the shared helpers. - Tests. I ran mobile-nav, sidebar, dashboard-navigation, menu-access and actions/menu-access on the PR's tree: 66 tests pass.
menu-access.test.tsreadssupabase/migrations, so I laid that folder out next toweb.tscshows no errors in the changed files. It does report 13 errors elsewhere, from packages missing in my test setup (@ai-sdk/*, thesanitize-htmltypes); those are the same without this change.
Follow-ups:
- Deploy order. The layout's profile read now names
work_areas,work_areas_asked_at,menu_shown,menu_hiddenandcan_manage_menus. Before 00374 adds those columns, the read fails andprofileis null. The layout then sends every signed-in user to onboarding, and onboarding sends someone who has finished it back to/dashboard, so they loop. The web goes out on merge, so 00374 has to be applied first. The same would happen to a self-hosted install that pulls this change without running the migration. I'd also make the layout safe on its own: read the menu columns in a separate query, and fall back to the whole menu when that read fails, asreadRoleHiddenalready does. Then a missing column only costs the menu filter, not the dashboard. - Nothing tests the layout's wiring: that it passes
menu.hiddento the provider and that the onboarding redirect still comes before the menu read. A small test ofDashboardLayoutwith a mocked client would cover both, and also 1's fallback once it's in.
Merged
7 of 12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Menu access, part 2: the left menu follows the data from part 1. Stacked on #1702; review that first.
(dashboard)/layout.tsxreads the menu columns in its ownprofilesselect, and the role's row (readRoleHidden, skipped for admins) in the samePromise.allas the organization and brands; the puremenuOfProfilebuilds the menu and a newMenuAccessProviderhands it down. No extra round trip for admins, one parallel read for everyone else. If the role's row can't be read, it's logged and the whole menu shows.shouldShowDashboardNavItemtakes the hidden sections. A section is the route segment under/dashboard, e.g.contentoraudit.Related issue
None.
Type of change
feat— New featureHow to test
Needs migration 00374 from #1702 on your dev database. Demo user
11111111-1111-1111-1111-111111111111, demo org22222222-2222-2222-2222-222222222222. Run the SQL as the database owner (psql or the SQL editor).cd web && yarn dev, then sign in as[email protected]/demo123(admin). The menu is unchanged.update profiles set work_areas = '{brand}' where id = '11111111-1111-1111-1111-111111111111';Reload. The sidebar shows Action Center, Chat, Brand Visibility, Mentions, Citations and Reports; Content, Audit, Prompts and AI Referral Traffic are gone. Open/dashboard/contentby its address: the page still opens.update profiles set role = 'manager', work_areas = '{}' where id = '1111…';theninsert into organization_menu_roles (organization_id, role, hidden_sections) values ('2222…', 'manager', '{insights,prompts,mentions,citations,shopping,traffic}');Reload. The whole Analytics group, heading included, is gone; Execution and Reports stay.update profiles set role = 'admin', work_areas = '{}' where id = '1111…'; delete from organization_menu_roles where organization_id = '2222…';Checklist
yarn lintpasses (0 errors; 7 warnings in files this PR doesn't touch)yarn typecheckpassesyarn formatleaves no changesyarn testandyarn buildpass, run on part 6's tip, which includes this PR: 465 files, 4,561 tests; build OK (on part 6's tip 8c2e172).dashboard-navigation.test.ts,sidebar.test.tsx,mobile-nav.test.tsx,menu-access.test.ts)npm run version:check(fails on main too: docker-compose images 0.2.0)🤖 Generated with Claude Code