feat(agent): update agent connection behavior to start with a blank conversation and allow user-initiated session restoration

This commit is contained in:
HouYunFei
2026-07-29 14:16:35 +08:00
parent 0526290c8f
commit eda3481533
16 changed files with 2016 additions and 1910 deletions
+6
View File
@@ -157,6 +157,7 @@ function InfiniteCanvasPage() {
const agentPanelOpen = useAgentStore((state) => state.panelOpen);
const toggleAgentPanel = useAgentStore((state) => state.togglePanel);
const openAgentPanel = useAgentStore((state) => state.openPanel);
const setAgentState = useAgentStore((state) => state.setAgentState);
const containerRef = useRef<HTMLDivElement>(null);
const imageInputRef = useRef<HTMLInputElement>(null);
const uploadTargetRef = useRef<{ nodeId?: string; position?: Position } | null>(null);
@@ -352,6 +353,11 @@ function InfiniteCanvasPage() {
void restore();
}, [hydrated, navigate, openProject, projectId]);
useEffect(() => {
if (!projectLoaded) return;
setAgentState({ activeThreadId: "", messages: [], tokenUsage: null, pendingTool: null });
}, [projectId, projectLoaded, setAgentState]);
useEffect(() => {
if (!projectLoaded || !["new", "recent", "choose"].includes(searchParams.get("mode") || "")) return;
if (!searchParams.has("agentUrl")) openAgentPanel();