diff --git a/site/src/pages/AgentsPage/AgentSettingsPage.tsx b/site/src/pages/AgentsPage/AgentSettingsPage.tsx index 016dbff54a..aea8d054f7 100644 --- a/site/src/pages/AgentsPage/AgentSettingsPage.tsx +++ b/site/src/pages/AgentsPage/AgentSettingsPage.tsx @@ -2,17 +2,13 @@ import type { FC } from "react"; import { Outlet, useLocation } from "react-router"; import { ScrollArea } from "#/components/ScrollArea/ScrollArea"; import { AgentPageHeader } from "./components/AgentPageHeader"; -import { sidebarViewFromPath } from "./components/ChatsSidebar/sidebarView"; const AgentSettingsPage: FC = () => { const location = useLocation(); const match = location.pathname.match(/\/agents\/settings\/(.+)/); const section = match?.[1]; - const sidebarView = sidebarViewFromPath(location.pathname); const mobileBack = section - ? sidebarView.panel === "settings-admin" - ? { to: "/agents/settings/admin", label: "Manage agents" } - : { to: "/agents/settings", label: "Settings" } + ? { to: "/agents/settings", label: "Settings" } : undefined; return ( diff --git a/site/src/pages/AgentsPage/AgentsPageView.stories.tsx b/site/src/pages/AgentsPage/AgentsPageView.stories.tsx index 8ced4a1ea9..aa34f6ead4 100644 --- a/site/src/pages/AgentsPage/AgentsPageView.stories.tsx +++ b/site/src/pages/AgentsPage/AgentsPageView.stories.tsx @@ -228,12 +228,15 @@ const agentsRouting = { }, { path: "admin", - element: , + element: , }, - { path: "coder-agents", element: }, { path: "agents", - element: , + element: , + }, + { + path: "coder-agents", + element: , }, { path: "spend", @@ -252,8 +255,11 @@ const agentsRouting = { }; const aiSettingsRouting = { - path: "/ai/settings/spend", - element:
Spend limits and usage
, + path: "/ai/settings", + children: [ + { path: "coder-agents", element: }, + { path: "spend", element:
Spend limits and usage
}, + ], }; const setInnerWidthForStory = (width: number) => { @@ -1160,7 +1166,7 @@ export const OpensSettingsForNonAdmins: Story = { }, }; -export const OpensCoderAgentsFromManageAgentsOnMobile: Story = { +export const OpensAISettingsFromManageAgentsOnMobile: Story = { args: { isAgentsAdmin: true, }, @@ -1172,10 +1178,16 @@ export const OpensCoderAgentsFromManageAgentsOnMobile: Story = { }), }, play: async () => { - await userEvent.click( - await screen.findByRole("link", { name: "Manage agents" }), + const manageAgentsLink = await screen.findByRole("link", { + name: "Manage agents", + }); + expect(manageAgentsLink).toHaveAttribute( + "href", + "/ai/settings/coder-agents", ); + await userEvent.click(manageAgentsLink); + await expect( await screen.findByRole("heading", { name: "Coder Agents" }), ).toBeInTheDocument(); @@ -1196,10 +1208,16 @@ export const SettingsViewCoderAgentsLink: Story = { ).toBeInTheDocument(); }); - await userEvent.click( - await screen.findByRole("link", { name: "Manage agents" }), + const manageAgentsLink = await screen.findByRole("link", { + name: "Manage agents", + }); + expect(manageAgentsLink).toHaveAttribute( + "href", + "/ai/settings/coder-agents", ); + await userEvent.click(manageAgentsLink); + await waitFor(() => { expect( screen.getByText( diff --git a/site/src/pages/AgentsPage/components/ChatsSidebar/ChatsSidebar.stories.tsx b/site/src/pages/AgentsPage/components/ChatsSidebar/ChatsSidebar.stories.tsx index 102b4e98b2..01c6e79b7c 100644 --- a/site/src/pages/AgentsPage/components/ChatsSidebar/ChatsSidebar.stories.tsx +++ b/site/src/pages/AgentsPage/components/ChatsSidebar/ChatsSidebar.stories.tsx @@ -77,6 +77,7 @@ const agentsRouting = [ ]; const settingsRouting = [ + { path: "/ai/settings/coder-agents", useStoryElement: true }, { path: "/agents/settings/:section", useStoryElement: true }, { path: "/agents/settings", useStoryElement: true }, ...agentsRouting, @@ -2271,33 +2272,13 @@ export const SettingsUserAgentsAdmin: Story = { const canvas = within(canvasElement); const agentsLink = canvas.getByRole("link", { name: "Agents" }); await expect(agentsLink).toHaveAttribute("aria-current", "page"); - expect( - canvas.getByRole("link", { name: "Manage agents" }), - ).toBeInTheDocument(); - }, -}; - -export const SettingsAdminCoderAgentsEntryPreserved: Story = { - args: { - chats: [], - isAdmin: true, - }, - parameters: { - reactRouter: reactRouterParameters({ - location: { path: "/agents/settings/agents" }, - routing: settingsRouting, - }), - }, - play: async ({ canvasElement }) => { - const canvas = within(canvasElement); - const coderAgentsLink = canvas.getByRole("link", { - name: "Coder Agents", + const manageAgentsLink = canvas.getByRole("link", { + name: "Manage agents", }); - expect(coderAgentsLink).toHaveAttribute( + expect(manageAgentsLink).toHaveAttribute( "href", "/ai/settings/coder-agents", ); - expect(canvas.getByText("Manage agents")).toBeInTheDocument(); }, }; diff --git a/site/src/pages/AgentsPage/components/ChatsSidebar/ChatsSidebar.tsx b/site/src/pages/AgentsPage/components/ChatsSidebar/ChatsSidebar.tsx index 304f352106..0e65ae1b3e 100644 --- a/site/src/pages/AgentsPage/components/ChatsSidebar/ChatsSidebar.tsx +++ b/site/src/pages/AgentsPage/components/ChatsSidebar/ChatsSidebar.tsx @@ -98,14 +98,7 @@ export const ChatsSidebar: FC = (props) => { const location = useLocation(); const sidebarView = sidebarViewFromPath(location.pathname); const isSettingsPanel = isSettingsView(sidebarView); - const isFallbackToUserPanel = - sidebarView.panel === "settings-admin" && !isAdmin; - const settingsPanel = - sidebarView.panel === "settings-admin" && isAdmin - ? "settings-admin" - : "settings"; - const settingsSection = - isSettingsPanel && !isFallbackToUserPanel ? sidebarView.section : undefined; + const settingsSection = isSettingsPanel ? sidebarView.section : undefined; const providerConfigsQuery = useQuery({ ...userChatProviderConfigs(), enabled: isSettingsPanel && !isAdmin, @@ -164,7 +157,6 @@ export const ChatsSidebar: FC = (props) => { /> = ({ isSettingsPanel, - settingsPanel, settingsSection, showApiKeysItem, isPersonalModelOverridesEnabled, @@ -42,9 +34,6 @@ export const SettingsPanel: FC = ({ location, onCollapse, }) => { - const subNavTitle = - settingsPanel === "settings-admin" ? "Manage agents" : "Settings"; - return (
= ({
- {subNavTitle} + Settings
{onCollapse && ( @@ -100,117 +73,56 @@ export const SettingsPanel: FC = ({ )}
- {settingsPanel === "settings" ? ( - - ) : ( -
); }; diff --git a/site/src/pages/AgentsPage/components/ChatsSidebar/sidebarView.test.ts b/site/src/pages/AgentsPage/components/ChatsSidebar/sidebarView.test.ts index fb7563ff5b..04c9f678ee 100644 --- a/site/src/pages/AgentsPage/components/ChatsSidebar/sidebarView.test.ts +++ b/site/src/pages/AgentsPage/components/ChatsSidebar/sidebarView.test.ts @@ -46,10 +46,10 @@ describe("sidebarViewFromPath", () => { }); }); - it("normalizes the admin index route to an undefined section", () => { + it("keeps legacy admin redirect paths on the settings panel", () => { expect(sidebarViewFromPath("/agents/settings/admin")).toEqual({ - panel: "settings-admin", - section: undefined, + panel: "settings", + section: "admin", }); }); @@ -93,12 +93,6 @@ describe("isSettingsView", () => { ); }); - it("returns true for the admin settings panel", () => { - expect( - isSettingsView({ panel: "settings-admin", section: "providers" }), - ).toBe(true); - }); - it("returns false for chats", () => { expect(isSettingsView({ panel: "chats" })).toBe(false); }); diff --git a/site/src/pages/AgentsPage/components/ChatsSidebar/sidebarView.ts b/site/src/pages/AgentsPage/components/ChatsSidebar/sidebarView.ts index 1dfff5f766..972c48f045 100644 --- a/site/src/pages/AgentsPage/components/ChatsSidebar/sidebarView.ts +++ b/site/src/pages/AgentsPage/components/ChatsSidebar/sidebarView.ts @@ -1,15 +1,8 @@ type SidebarView = | { panel: "chats" } | { panel: "settings"; section: string | undefined } - | { panel: "settings-admin"; section: string | undefined } | { panel: "analytics" }; -const ADMIN_SETTINGS_SECTIONS = new Set([ - "coder-agents", - "mcp-servers", - "spend", -]); - /** * Derive the current sidebar view from the URL pathname. */ @@ -19,22 +12,13 @@ export function sidebarViewFromPath(pathname: string): SidebarView { } const settingsMatch = pathname.match(/^\/agents\/settings(?:\/([^/]+))?/); if (settingsMatch) { - const section = settingsMatch[1]; - if (section === "admin") { - return { panel: "settings-admin", section: undefined }; - } - return { - panel: ADMIN_SETTINGS_SECTIONS.has(section ?? "") - ? "settings-admin" - : "settings", - section, - }; + return { panel: "settings", section: settingsMatch[1] }; } return { panel: "chats" }; } export function isSettingsView( view: SidebarView, -): view is Extract { - return view.panel === "settings" || view.panel === "settings-admin"; +): view is Extract { + return view.panel === "settings"; }