Skip to content

refactor(site/src): split Agent Settings Behavior into focused destinations#24574

Merged
ibetitsmike merged 23 commits into
mainfrom
mike/split-agent-settings-behavior
Apr 22, 2026
Merged

refactor(site/src): split Agent Settings Behavior into focused destinations#24574
ibetitsmike merged 23 commits into
mainfrom
mike/split-agent-settings-behavior

Conversation

@ibetitsmike
Copy link
Copy Markdown
Collaborator

@ibetitsmike ibetitsmike commented Apr 21, 2026

Reorganizes Agents Settings navigation. Previously a flat sidebar with admin items gated by a role check; now a two-level drill-down with user settings at the top and admin destinations nested under a "Manage Agents" sub-panel.

Top Settings panel (all users, sidebar title "Settings"):

Destination Route
General /agents/settings/general
Compaction /agents/settings/compaction
Secrets (API keys) /agents/settings/api-keys
Manage Agents › (admin only) drills into the admin sub-panel

Manage Agents sub-panel (admin only, sidebar title "Manage Agents"):

Destination Route
Agents /agents/settings/agents
Providers /agents/settings/providers
Models /agents/settings/models
MCP Servers /agents/settings/mcp-servers
Templates /agents/settings/templates
Spend /agents/settings/spend
Instructions /agents/settings/instructions
Experiments /agents/settings/experiments
Lifecycle /agents/settings/lifecycle
Insights /agents/settings/insights

On mobile, tapping "Manage Agents" lands on /agents/settings/admin, an admin sub-panel index URL that shows the admin nav in the sidebar (so admins can still reach every admin destination without desktop-width viewports).

Key changes:

  • Split the monolithic Behavior page into five focused destinations (General, Compaction, Instructions, Experiments, Lifecycle) so non-admin users no longer trigger deployment-scoped queries like chatSystemPrompt, chatDesktopEnabled, or chatWorkspaceTTL. Admin-only pages gate both route (via RequirePermission) and query enabled flags.
  • Split chat debug logging into audience-specific components so no admin-gated controls remain in user-facing pages. AdminChatDebugLoggingSettings (admin "Let users record chat debug logs") now lives in the Experiments tab; UserChatDebugLoggingSettings ("Record debug logs for my chats") stays in General and only renders when the admin has allowed user-level toggling.
  • Nested admin sub-panel in the sidebar. SidebarView gains a "settings-admin" panel; sidebarViewFromPath routes admin sections into it. The slide animation and back button behavior extend cleanly. A small isSettingsView helper was extracted alongside to avoid duplicating the panel-membership check.
  • Renamed /agents/settings/system-instructions to /agents/settings/instructions. Sidebar label is "Instructions". Page files renamed to AgentSettingsInstructionsPage(View) to match the route slug (the other split pages all do).
  • Renamed "API Keys" to "Secrets (API keys)" in the sidebar and page header.
  • Added MCP Servers entry to the sidebar (route already existed).
  • Added "Manage Coder Agents" link at the bottom of the Deployment settings sidebar (gated by editDeploymentConfig, matches the existing Groups ↗ external-link style).
  • Updated icons across the sidebar: General uses UserIcon, Compaction ShrinkIcon, Secrets KeyIcon, Manage Agents Settings2Icon, Providers PlugIcon, MCP Servers ServerIcon, Spend CoinsIcon, Instructions ReceiptTextIcon, Lifecycle RefreshCwIcon, Insights SparklesIcon.
  • Storybook interaction coverage restored and extended for the split views: user-prompt save flow, invisible-Unicode warning detection, system-prompt default toggle, workspace-TTL validation, virtual-desktop toggle, compaction threshold save/reset/validation, retention toggle/save-error/load-error parity, plan-mode instructions save, and a mobile story verifying the admin sub-panel remains reachable after the "Manage Agents" tap.
  • Unit tests added for sidebarViewFromPath and isSettingsView (17 cases covering chats, analytics, user sections, admin sections, the new /admin index, non-admin fallthrough, and defaults).

Mux opened this PR on behalf of Mike.

@ibetitsmike ibetitsmike changed the title refactor(site/src/pages/AgentsPage): split Behavior settings into focused destinations refactor(site/src): split Agent Settings Behavior into focused destinations Apr 21, 2026
@ibetitsmike ibetitsmike force-pushed the mike/split-agent-settings-behavior branch from 308ee27 to 2e2c852 Compare April 21, 2026 18:31
Comment thread site/src/router.tsx Outdated
Comment thread site/src/pages/AgentsPage/types.ts Outdated
Comment thread site/src/pages/AgentsPage/AgentSettingsLifecyclePageView.stories.tsx Outdated
Comment thread site/src/pages/AgentsPage/AgentSettingsGeneralPageView.tsx Outdated
Comment thread site/src/pages/AgentsPage/AgentSettingsGeneralPageView.stories.tsx Outdated
Comment thread site/src/pages/AgentsPage/AgentSettingsCompactionPageView.stories.tsx Outdated
Comment thread site/src/pages/AgentsPage/AgentSettingsBehaviorPage.tsx Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the Agents Settings UX by splitting the former monolithic “Behavior” settings into dedicated routes and introducing a nested admin-only settings sub-panel, reducing unnecessary admin-scoped queries for non-admin users.

Changes:

  • Split Behavior into dedicated destinations (General, Compaction, Instructions, Experiments, Lifecycle) and added backward-compatible redirects.
  • Reworked Agents sidebar navigation into a two-level settings drill-down with an admin sub-panel.
  • Updated Storybook interaction coverage and renamed “API Keys” UI copy to “Secrets (API keys)”.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
site/src/router.tsx Adds new settings routes and backward-compat redirects for legacy paths.
site/src/pages/AgentsPage/types.ts Extracts a shared MutationCallbacks type for the new page views.
site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx Introduces the nested settings-admin panel and updates settings navigation items/icons.
site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.stories.tsx Updates interactions to reflect sidebar copy changes and input edit behavior.
site/src/pages/AgentsPage/components/AgentPageHeader.tsx Keeps Settings button active state in sync with the new settings-admin panel.
site/src/pages/AgentsPage/AgentsPageView.tsx Updates mobile layout logic to treat settings-admin as part of the settings flow.
site/src/pages/AgentsPage/AgentsPageView.stories.tsx Updates routing and API mocks for the new split settings pages and navigation flows.
site/src/pages/AgentsPage/AgentSettingsSystemInstructionsPageView.tsx Adds the new admin-only “Instructions” settings view composition.
site/src/pages/AgentsPage/AgentSettingsSystemInstructionsPageView.stories.tsx Adds interaction coverage for the new Instructions page view.
site/src/pages/AgentsPage/AgentSettingsSystemInstructionsPage.tsx Adds the new admin-gated container with queries/mutations for Instructions settings.
site/src/pages/AgentsPage/AgentSettingsLifecyclePageView.tsx Adds the new admin-only “Lifecycle” settings view composition.
site/src/pages/AgentsPage/AgentSettingsLifecyclePageView.stories.tsx Adds interaction coverage for lifecycle settings validation and error states.
site/src/pages/AgentsPage/AgentSettingsLifecyclePage.tsx Adds the new admin-gated container with queries/mutations for lifecycle settings.
site/src/pages/AgentsPage/AgentSettingsGeneralPageView.tsx Adds the new “General” settings view composition (personal instructions + UI prefs).
site/src/pages/AgentsPage/AgentSettingsGeneralPageView.stories.tsx Adds interaction coverage for personal-instructions warnings and save behavior.
site/src/pages/AgentsPage/AgentSettingsGeneralPage.tsx Adds the new container for General settings data + mutation.
site/src/pages/AgentsPage/AgentSettingsExperimentsPageView.tsx Adds the new admin-only “Experiments” settings view composition.
site/src/pages/AgentsPage/AgentSettingsExperimentsPageView.stories.tsx Adds interaction coverage for toggling the virtual desktop setting.
site/src/pages/AgentsPage/AgentSettingsExperimentsPage.tsx Adds the new admin-gated container for Experiments settings.
site/src/pages/AgentsPage/AgentSettingsCompactionPageView.tsx Adds the new “Compaction” settings view composition.
site/src/pages/AgentsPage/AgentSettingsCompactionPageView.stories.tsx Adds a page-level story wrapper for the Compaction destination.
site/src/pages/AgentsPage/AgentSettingsCompactionPage.tsx Adds the new container for compaction thresholds/configs queries and mutations.
site/src/pages/AgentsPage/AgentSettingsBehaviorPageView.tsx Removes the old combined Behavior page view.
site/src/pages/AgentsPage/AgentSettingsBehaviorPageView.stories.tsx Removes the old combined Behavior page view stories (replaced by split pages).
site/src/pages/AgentsPage/AgentSettingsBehaviorPage.tsx Converts the legacy Behavior route into a permanent redirect to General.
site/src/pages/AgentsPage/AgentSettingsAPIKeysPageView.tsx Renames page header label to “Secrets (API keys)”.
site/src/modules/management/DeploymentSidebarView.tsx Adds a deployment sidebar entry linking to Agents admin settings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx
Comment thread site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx
Comment thread site/src/pages/AgentsPage/AgentSettingsLifecyclePageView.tsx Outdated
@ibetitsmike
Copy link
Copy Markdown
Collaborator Author

Mux working on behalf of Mike.

Good call. Replaced the local MutationCallbacks interface with React Query's UseMutateFunction in the four new view files (AgentSettingsLifecyclePageView, AgentSettingsGeneralPageView, AgentSettingsExperimentsPageView, AgentSettingsSystemInstructionsPageView). Pushed in 8b464c0 on the branch.

Scoped to the views introduced in this PR, left the pre-existing components/*Settings.tsx and AgentSettingsTemplatesPageView.tsx alone; happy to roll those in a follow-up if you want the whole file tree converted.

@ibetitsmike
Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@ibetitsmike
Copy link
Copy Markdown
Collaborator Author

@coder-agents-review review

@ibetitsmike ibetitsmike marked this pull request as ready for review April 22, 2026 11:21
Copy link
Copy Markdown
Contributor

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

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

Clean refactor that breaks a monolithic settings page into focused destinations with proper permission gating. The drill-down sidebar and RequirePermission wrappers look well-structured.

This is a first-pass review only: these are mechanical findings from Netero. The full review panel has not yet reviewed this PR. The panel will review after these findings are addressed.

1 P2, 2 P3.

"Existing bookmarks, shared links, and browser history entries pointing to /agents/settings/behavior will render a blank settings outlet with no active sidebar item." (Netero)

🤖 This review was automatically generated with Coder Agents.

Comment thread site/src/router.tsx
Comment thread site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8a7527a51d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread site/src/pages/AgentsPage/AgentsPageView.tsx Outdated
Comment thread site/src/router.tsx
@ibetitsmike
Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@ibetitsmike
Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

Copy link
Copy Markdown
Contributor

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

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

The split from a monolithic Behavior page into five focused destinations is well-motivated: non-admins no longer fire deployment-scoped queries, and the authorization boundary moved from component-level conditional rendering to route-level RequirePermission wrappers. The sidebar drill-down is clean on desktop. Story migration was systematic; every old story was accounted for, and new coverage (compaction threshold stories, user prompt save flow) was added beyond what was asked.

DEREM-1 (redirect for removed /behavior route): the panel unanimously closed this (18/18 accept). The maintainer explicitly accepted this breakage for an unstable feature.

2 P2, 7 P3, 1 P4, 3 Nit.

The two P2s are the mobile admin navigation regression (the drill-down sidebar architecture makes admin pages unreachable on mobile viewports) and the Lifecycle stories testing only half the page (RetentionPeriodSettings has zero play-function coverage).

"Before this PR, all admin items were flat siblings in the settings nav. Mobile admins could reach any admin page by tapping it from the settings index. After this PR, the only admin page reachable on mobile via the UI is the one 'Manage Agents' hardcodes." (Hisoka)


site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx:136

P3 [DEREM-11] sidebarViewFromPath is a pure function that now drives panel selection for three consumers. It has a Set.has() check, a nullable coalescing fallback, and a regex, but no unit tests. The project convention reserves vitest for pure logic. The existing test file (AgentsSidebar.test.tsx) does not cover it.

The function is exercised through the SettingsViewResets integration story, which provides adequate end-to-end coverage. Dedicated unit tests would be faster to run and protect against regressions in the classification logic if the set of admin sections grows.

(Meruem P3, Mafuuu, Bisky)

🤖

site/src/pages/AgentsPage/AgentsPageView.stories.tsx:664

P3 [DEREM-14] OpensSettingsForNonAdmins verifies the General page renders for non-admins but never asserts that admin-only sidebar items are absent. If the {isAdmin && ...} guard on the "Manage Agents" nav item were accidentally removed, this test would still pass. Adding expect(screen.queryByRole("link", { name: "Manage Agents" })).not.toBeInTheDocument() would guard the admin/non-admin boundary.

(Kite)

🤖

🤖 This review was automatically generated with Coder Agents.

Comment thread site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx
Comment thread site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx Outdated
Comment thread site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx
Comment thread site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx
Comment thread site/src/pages/AgentsPage/AgentSettingsGeneralPageView.stories.tsx
Comment thread site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx Outdated
Comment thread site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx Outdated
Comment thread site/src/pages/AgentsPage/AgentSettingsSystemInstructionsPage.tsx Outdated
Comment thread site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx Outdated
Copy link
Copy Markdown
Contributor

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

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

DEREM-4 (mobile admin navigation) was addressed in 7743b8c, nice fix with the dedicated /agents/settings/admin index URL.

Further review is blocked until the remaining 12 open findings receive a response (fix, acknowledgment, or contest). The panel cannot re-review while prior findings are silent.

Open findings awaiting response:

  • DEREM-5 (P2) RetentionPeriodSettings has zero play-function coverage in Lifecycle stories
  • DEREM-6 (P3) isSettingsPanel check duplicated in three files
  • DEREM-7 (P3) ADMIN_SETTINGS_SECTIONS is a second source of truth
  • DEREM-8 (P3) Non-admin on admin URL sees misleading sidebar state
  • DEREM-9 (P3) Plan mode instructions save flow untested
  • DEREM-10 (P3) ChatFullWidthSettings untested in General page
  • DEREM-11 (P3) sidebarViewFromPath has no unit tests
  • DEREM-12 (Nit) "MCP servers" title-case inconsistency
  • DEREM-14 (P3) Non-admin story missing negative assertion
  • DEREM-15 (P4) "Manage Agents" active prop is dead code
  • DEREM-16 (Nit) File name SystemInstructions doesn't match route slug
  • DEREM-17 (Nit) UsersIcon for personal-settings page

A reply on each thread (even "acknowledged, won't fix" or "deferred to follow-up with ticket") unblocks the next round.

🤖 This review was automatically generated with Coder Agents.

@ibetitsmike
Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

Copy link
Copy Markdown
Contributor

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

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

Great progress. 10 of 12 open findings addressed or acknowledged across 5175fa0 and 9961e42. The isSettingsView helper, retention stories, plan-mode story, non-admin fallback fix, file renames, and icon/label corrections all look clean.

DEREM-7 (ADMIN_SETTINGS_SECTIONS coupling): author acknowledged, bounded risk, follow-up offered. Accepted.

Two findings remain without a response. These were folded into the review body (not inline threads) because they fell outside the diff hunks, so they may have been easy to miss:

  • DEREM-11 (P3) sidebarViewFromPath has new branching logic with no unit tests. The function now handles "admin" as a special section, user/admin panel classification via ADMIN_SETTINGS_SECTIONS, and the isSettingsView guard. A vitest file covering the key cases would be fast to add.
  • DEREM-14 (P3) OpensSettingsForNonAdmins story is missing a negative assertion for admin sidebar items. Adding expect(screen.queryByRole("link", { name: "Manage Agents" })).not.toBeInTheDocument() guards the admin/non-admin boundary.

A reply on each (fix, acknowledge, or contest) unblocks the next round.

🤖 This review was automatically generated with Coder Agents.

@ibetitsmike
Copy link
Copy Markdown
Collaborator Author

Mux working on behalf of Mike.

Addressing the two body-level findings from the 3rd review:

  • DEREM-11: Added site/src/pages/AgentsPage/components/Sidebar/sidebarViewFromPath.test.ts in bfc4caa. 17 cases covering sidebarViewFromPath() (chats, analytics, settings index, user sections, admin sections, the new /admin index, non-admin fallthrough) and isSettingsView(). Runs in ~8ms.
  • DEREM-14: Added the queryByRole("link", { name: "Manage Agents" })).not.toBeInTheDocument() negative assertion to OpensSettingsForNonAdmins in bfc4caa.

Re-requesting:

/coder-agents-review

@ibetitsmike
Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

Copy link
Copy Markdown
Contributor

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

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

All prior findings addressed or acknowledged. The fix commits are clean: isSettingsView type guard extracted, retention and plan-mode stories added, sidebarViewFromPath unit-tested with 17 cases, non-admin fallback fixed, file renames applied, icon and label corrections landed. Mafu-san noted that the correction arc across rounds shows systematic, non-regressing work.

2 P3.

"Pure-logic unit test for sidebarViewFromPath and isSettingsView. 17 cases, all passing, no mocks, no DOM, no fragility." (Bisky)


site/src/pages/AgentsPage/AgentSettingsPage.tsx:17

P3 [DEREM-19] mobileBack always targets /agents/settings regardless of whether the current section is user-level or admin-level. On mobile, an admin on /agents/settings/providers who taps the "Settings" back link lands on the user settings sidebar (General, Compaction, Secrets, Manage Agents), not the admin sidebar they came from. Returning to the admin context requires two extra taps.

Fix: detect admin sections and route to /agents/settings/admin:

const sidebarView = sidebarViewFromPath(location.pathname);
const mobileBack = section
    ? sidebarView.panel === "settings-admin"
        ? { to: "/agents/settings/admin", label: "Manage Agents" }
        : { to: "/agents/settings", label: "Settings" }
    : undefined;

(Meruem)

🤖

🤖 This review was automatically generated with Coder Agents.

Copy link
Copy Markdown
Contributor

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

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

No new commits since R5. Both open findings are still awaiting a response:

  • DEREM-18 (P3) Retention toggle-off, save-error, and load-error story coverage. Inline thread on AgentSettingsLifecyclePageView.stories.tsx:236.
  • DEREM-19 (P3) Mobile back navigation from admin content pages skips admin sidebar. In the R5 review body (AgentSettingsPage.tsx:17).

A reply on each (fix, acknowledge, or contest) unblocks the next round.

🤖 This review was automatically generated with Coder Agents.

@ibetitsmike
Copy link
Copy Markdown
Collaborator Author

Mux working on behalf of Mike.

Addressing the two P3 body-level findings from the 4th review:

  • DEREM-19 (mobile back to admin sub-panel): Fixed in 24620b1. AgentSettingsPage now derives sidebarView from the pathname; on admin sections the mobile back-link targets /agents/settings/admin with label "Manage Agents" (one tap back into the admin sub-panel), while user sections still target /agents/settings with label "Settings".
  • DEREM-18 (retention parity): Fixed in 24620b1. Added three parity stories to AgentSettingsLifecyclePageView.stories.tsx mirroring the autostop coverage: RetentionToggleOffSavesDisabled, RetentionSaveError, and RetentionLoadError.

Re-requesting:

/coder-agents-review

@ibetitsmike
Copy link
Copy Markdown
Collaborator Author

Mux working on behalf of Mike.

Timing race: the 5th review fired 12s before the fix commit 24620b1 landed on origin. HEAD is now 24620b1, which addresses both DEREM-18 (retention parity stories added) and DEREM-19 (mobileBack now routes to /agents/settings/admin for admin sections). Please re-review from that commit.

/coder-agents-review

Copy link
Copy Markdown
Contributor

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

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

All 19 findings across 7 rounds are closed: 15 fixed in code, 1 acknowledged with bounded-risk defense (DEREM-7, follow-up offered), 1 panel-closed (DEREM-1, 18/18 accept), 1 dropped by orchestrator (DEREM-13, pre-existing gap). Netero R7 and the R7 panel (Bisky, Mafu-san, Mafuuu) found no new issues.

The 24620b1 fix correctly addresses both R5 findings: mobile back navigation now routes to /agents/settings/admin for admin sections, and retention stories have full parity with autostop coverage.

PS. The PR description icon table still says General uses UsersIcon; the code now uses UserIcon (fixed in DEREM-17). Worth updating the description before merge. (Mafu-san)

🤖 This review was automatically generated with Coder Agents.

# Conflicts:
#	site/src/pages/AgentsPage/AgentSettingsBehaviorPage.tsx
#	site/src/pages/AgentsPage/AgentSettingsBehaviorPageView.stories.tsx
#	site/src/pages/AgentsPage/AgentSettingsBehaviorPageView.tsx
#	site/src/pages/AgentsPage/AgentsPageView.stories.tsx
@ibetitsmike ibetitsmike force-pushed the mike/split-agent-settings-behavior branch from 3dc5fec to 578c3a0 Compare April 22, 2026 14:54
@ibetitsmike ibetitsmike merged commit 60186b2 into main Apr 22, 2026
27 checks passed
@ibetitsmike ibetitsmike deleted the mike/split-agent-settings-behavior branch April 22, 2026 15:45
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants