Repository navigation
feat(frontend): add a staged switch for developer views in /m - #7985
Conversation
A registry of rebuilt developer views with three stages (hidden, preview, on), a per-user preview switch in Preferences, a runtime env override (AGENTA_DEVELOPER_VIEWS), a Developer rail section whose links never prefetch, and a route gate that shows the not-found page. Ships no view.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Registry and access state docs/design/m-developer-views/registry.md, web/entrypoint.sh, web/mobile/src/features/developer/developerViews.ts, web/mobile/src/features/developer/developerViewAccess.ts, web/mobile/src/lib/env.ts, web/mobile/tests/unit/developerViewFixtures.ts, web/mobile/tests/unit/developerViewAccess.test.ts |
Defines view stages and navigation metadata, parses deployment-forced view IDs, and applies stage and per-user preview access rules. Runtime configuration exposes the deployment setting. Tests cover stage access, forced IDs, and user-specific preferences. |
Mobile navigation and route access web/packages/agenta-navigation/src/types.ts, web/packages/agenta-navigation-ui/src/NavMenu.tsx, web/mobile/src/components/PageNotFound.tsx, web/mobile/src/features/developer/DeveloperViewGate.tsx, web/mobile/src/features/developer/developerNavItems.ts, web/mobile/src/features/nav/useMobileNavItems.tsx, web/mobile/src/pages/404.tsx, web/mobile/tests/unit/developerViews.render.test.tsx |
Adds optional link prefetch configuration and uses it for developer navigation links. The route gate renders nothing while access is unknown, renders children when enabled, and otherwise renders the not-found component. Tests cover navigation and gate states. |
Preview controls in Preferences web/packages/agenta-settings-ui/src/PreferencesPage.tsx, web/packages/agenta-settings-ui/src/index.ts, web/mobile/src/features/settings/PreferencesTab.tsx, web/mobile/tests/unit/preferencesTabDeveloperViews.render.test.tsx |
Adds host-provided preference rows and exports their type. The mobile Preferences tab maps preview views to Feature Flags switches. Tests cover switch display and opt-in behavior. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Sequence Diagram(s)
sequenceDiagram
actor User
participant PreferencesTab
participant developerViewPreviewSwitchesAtom
participant developerViewPreviewAtomFamily
participant enabledDeveloperViewsAtom
participant useMobileNavItems
User->>PreferencesTab: Toggle a preview switch
PreferencesTab->>developerViewPreviewSwitchesAtom: Set opted-in state for the view
developerViewPreviewSwitchesAtom->>developerViewPreviewAtomFamily: Update the user's view preference
developerViewPreviewAtomFamily-->>enabledDeveloperViewsAtom: Supply preview preference
enabledDeveloperViewsAtom-->>useMobileNavItems: Return enabled views
Merge Risk: 
Minimal · up to f70ab
-
No developer views ship in this change, and no concrete issue remains that should block merging after normal checks.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 18 files. (1 skipped: 1 unsupported.)
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
📘 Docs preview
This comment updates in place on every push. |
Website previewPreview URL: https://pr-7985-agenta-website-preview.mahmoud-637.workers.dev Built from |
Railway Preview Environment
Preview use finished or expired. Environment absence verified; retained storage requires separate provider accounting. Post |
|
🤖 The AI agent says: Review loop result, 2 rounds, base
Fixed: a stale comment in
Contract: unchanged (entry shape, Checks run: the three developer view test files (17 tests pass), eslint on the changed files, Base branch test: |
Context
We will rebuild about ten developer views from the old app (
/w) in/m, one at a time. Each view must merge hidden, then move to preview, then to on, so that every PR is safe to merge. This PR adds that switch. It ships no view, so users see no change.Changes
Registry. One file lists every view:
web/mobile/src/features/developer/developerViews.ts. The list is empty.A view with no
routesis a gate for part of a shared screen (for example a filter by app on traces and sessions). It has no nav link, and the screen only asks the helper below. The registry imports no view code.Stages.
hiddenpreviewonDeployment override. Set
AGENTA_DEVELOPER_VIEWS=testsets,endpointson the web container.web/entrypoint.shwrites it to__env.jsasNEXT_PUBLIC_AGENTA_DEVELOPER_VIEWS, so a change needs a restart, not a rebuild. A listed view is on for everyone on that deployment, whatever its stage. Note: the brief pointed atNEXT_PUBLIC_SETTINGS_NESTED_NAVas the model, but that flag is not inentrypoint.shand is build-time only. This one follows the runtime pattern ofAGENTA_WALLETS_ENABLED.Helpers (
features/developer/developerViewAccess.ts):useDeveloperViewEnabled(viewId):true,false, ornulluntil the signed-in user is known. The first render is alwaysnull, so it never differs from the prerendered HTML. It reads only atoms and the list, so a shared screen can call it.useEnabledDeveloperViews(): the views the nav shows.isDeveloperViewEnabled(view, {previewOptedIn, forcedIds}): the pure rule.developerViewPreviewSwitchesAtom: the Preferences switches. The preview choice is auserScopedFlagAtomper view, stored asagenta:settings:<user id>:developer-view:<view id>.<DeveloperViewGate viewId="...">(features/developer/DeveloperViewGate.tsx): wraps a view's route page. It renders the view, the app's "not found" page, or nothing while the user is unknown.Nav.
useMobileNavItemsadds a "Developer" section after Sessions with one link per enabled view that has a route and a nav entry. With no enabled view, it adds nothing. The links useprefetch={false}. To do this,SidebarConfiggets an optionalprefetchfield, andNavMenupasses it to its three nav<Link>s. Unset keeps the Next default, so/wdoes not change.Preferences.
PreferencesPage(@agenta/settings-ui) takes optionalhostItems: rows that only one app shows, added after the shared rows of a section./mpasses one Feature Flags row per view in preview./wpasses none. The shared structure test (preferencesTab.render.test.tsx) is unchanged and passes.Not-found page. The body of
pages/404.tsxmoved tocomponents/PageNotFound.tsx, so the gate shows the same page.How a view PR uses this
stage: "hidden".src/pages/w/[workspace_id]/p/[project_id]/and wrap the screen in<DeveloperViewGate viewId="...">. Do not import the view anywhere else.routesandnav, and show the part only whenuseDeveloperViewEnabled(id)istrue.stagein its own small PR.Left for the flip milestone: sending /w pages to /m
/wsends a page to/mthroughmobileRouteForin@agenta/shared/utils/mobileGate. The/wmiddleware anduseClassicModeRedirectboth call it. The/wmiddleware cannot read the/mregistry or the/mruntime env. So the PR that moves a view toonalso adds its paths tomobileRouteFor(and the inverse todesktopRouteFor), with a test in@agenta/shared. That is a few lines in the shared package and touches no/wfile. No view is on yet, so this PR does not change it. A view in preview, or one forced on by the env, does not redirect from/w. The design notedocs/design/m-developer-views/registry.mdhas the full contract.Tests
developerViewAccess.test.ts(each stage, the preference switch per user, the env override, a gate with no route),developerViews.render.test.tsx(the nav section renders links withprefetch=false, adds nothing without enabled views or for a gate; the route gate for each stage, an unknown id, and an unknown user),preferencesTabDeveloperViews.render.test.tsx(preview views appear under Feature Flags, and the switch turns the view on).pnpm --filter @agenta/mobile types:check,lint(0 errors), pass. The fullpnpm --filter @agenta/mobile testpasses except one test:agentPermissions.render.test.tsx> "keeps permission editors out of the real Advanced drawer". It fails the same way onrelease/v0.128.2without this change, so it is not caused here.lintalso passes for@agenta/navigation,@agenta/navigation-uiand@agenta/settings-ui.