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:
@@ -74,8 +74,12 @@ export function SidebarAgents() {
|
|||||||
return sortByHierarchy(filtered);
|
return sortByHierarchy(filtered);
|
||||||
}, [agents]);
|
}, [agents]);
|
||||||
|
|
||||||
const agentMatch = location.pathname.match(/^\/(?:[^/]+\/)?agents\/([^/]+)/);
|
const agentMatch = location.pathname.match(/^\/(?:[^/]+\/)?agents\/([^/]+)(?:\/([^/]+))?/);
|
||||||
const activeAgentId = agentMatch?.[1] ?? null;
|
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 (
|
return (
|
||||||
<Collapsible open={open} onOpenChange={setOpen}>
|
<Collapsible open={open} onOpenChange={setOpen}>
|
||||||
@@ -112,7 +116,7 @@ export function SidebarAgents() {
|
|||||||
return (
|
return (
|
||||||
<NavLink
|
<NavLink
|
||||||
key={agent.id}
|
key={agent.id}
|
||||||
to={agentUrl(agent)}
|
to={activeTab && validTabs.has(activeTab) ? `${agentUrl(agent)}/${activeTab}` : agentUrl(agent)}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (isMobile) setSidebarOpen(false);
|
if (isMobile) setSidebarOpen(false);
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user