Skip to content

Commit d02232a

Browse files
fix(web): keep selected tab when flipping dev/live agent toggle (#4448)
The Develop/Live toggle hand-rolled its navigate with only ?virtualmcpid, wiping ?main/?chat. Route it through navigateToTask, which preserves the selected tab (and drops thread-scoped tabs like file previews). Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 6f79b67 commit d02232a

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

apps/mesh/src/web/components/dev-agent/dev-agent-control.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
* agent settings (see DevAgentSetup), not here.
77
*/
88

9-
import { useNavigate } from "@tanstack/react-router";
109
import { cn } from "@deco/ui/lib/utils.ts";
11-
import { useProjectContext, useVirtualMCPs } from "@decocms/mesh-sdk";
10+
import { useVirtualMCPs } from "@decocms/mesh-sdk";
1211
import type { VirtualMCPEntity } from "@decocms/mesh-sdk/types";
12+
import { useChatNavigation } from "@/web/components/chat/hooks/use-chat-navigation";
1313
import { useThreadActions } from "@/web/components/chat/store/hooks";
1414
import { findDevPartner } from "@/web/lib/agent-capabilities";
1515

@@ -19,16 +19,16 @@ export function DevAgentControl({
1919
virtualMcp: VirtualMCPEntity;
2020
}) {
2121
const allAgents = useVirtualMCPs();
22-
const { org } = useProjectContext();
23-
const navigate = useNavigate();
22+
const { navigateToTask } = useChatNavigation();
2423
const { create } = useThreadActions();
2524

2625
const partner = findDevPartner(virtualMcp, allAgents);
2726
if (!partner) return null;
2827

2928
const isDev = partner.mode === "dev";
3029

31-
/** Open a fresh task on the paired counterpart. */
30+
/** Open a fresh task on the paired counterpart. `navigateToTask` carries
31+
* `?main`/`?chat`, so a same-id tab stays selected across the flip. */
3232
const goToAgent = async (agentId: string) => {
3333
const taskId = crypto.randomUUID();
3434
try {
@@ -37,11 +37,7 @@ export function DevAgentControl({
3737
// The action already toasted; navigate anyway so the route loader's
3838
// ensure-fallback retries the thread create.
3939
}
40-
navigate({
41-
to: "/$org/$taskId",
42-
params: { org: org.slug, taskId },
43-
search: { virtualmcpid: agentId },
44-
});
40+
navigateToTask(taskId, { virtualMcpId: agentId });
4541
};
4642

4743
const segment = (label: string, active: boolean) => (

0 commit comments

Comments
 (0)