Preserve active tab when switching agents in sidebar

When clicking a different agent in the sidebar, the current tab (prompts,
skills, configuration, budget, runs) is now preserved in the navigation
URL instead of always defaulting to dashboard. Falls back to default
agent URL for non-tab paths (e.g. specific run detail pages).

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
dotta
2026-03-18 06:31:42 -05:00
parent 8954512dad
commit f98d821213

View File

@@ -74,8 +74,12 @@ export function SidebarAgents() {
return sortByHierarchy(filtered);
}, [agents]);
const agentMatch = location.pathname.match(/^\/(?:[^/]+\/)?agents\/([^/]+)/);
const agentMatch = location.pathname.match(/^\/(?:[^/]+\/)?agents\/([^/]+)(?:\/([^/]+))?/);
const activeAgentId = agentMatch?.[1] ?? null;
const activeTab = agentMatch?.[2] ?? null;
// Valid agent detail tabs — preserve across agent switches
const validTabs = new Set(["dashboard", "prompts", "skills", "configuration", "configure", "budget", "runs"]);
return (
<Collapsible open={open} onOpenChange={setOpen}>
@@ -112,7 +116,7 @@ export function SidebarAgents() {
return (
<NavLink
key={agent.id}
to={agentUrl(agent)}
to={activeTab && validTabs.has(activeTab) ? `${agentUrl(agent)}/${activeTab}` : agentUrl(agent)}
onClick={() => {
if (isMobile) setSidebarOpen(false);
}}