fix(agent): 抽屉开着时路由变化,新对话的上下文跟着页面换

浏览器前进后退或会话里的链接换了页面,抽屉里新对话仍挂着上一页的对象。
按路由推断的上下文随页面更新;页面按钮带进来的上下文、正在看的会话不动。

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-10-06 18:08:19 +08:00
1 parent a87c2c19c4
commit bbd7459935
3 files changed
+57 -1

No files matched your search

@@ -28,6 +28,7 @@ import {
setAgentDrawerOpen,
shortGoalTitle,
showAgentRunInDrawer,
syncAgentContextToPath,
takeReturnFocus,
toggleAgentDrawer,
useAgentDrawer,
@@ -104,6 +105,7 @@ export function AgentDrawer() {
const content = useRef<HTMLDivElement>(null);
// 记下最近的非智能体页面:会话页「在侧边打开」回到这里
useEffect(() => noteAgentReturnPath(pathname, search), [pathname, search]);
useEffect(() => syncAgentContextToPath(pathname), [pathname]);
const name = useContextName(context);
const mock = agentMockEnabled();
// 目标前缀带名称和 ID:名称给人看,ID 给模型用