perf: 优化智能体与工作流幕布渲染性能

- 分阶段加载智能体配置并按需缓存 MCP 工具

- 合并画布状态更新与节点尺寸监听,启用大图可视区域渲染和静态连线

- 隔离 Tinyflow Store 实例并补充数据同步与回归测试
This commit is contained in:
2026-07-27 18:27:01 +08:00
parent dc7e46260b
commit aedefe6b5e
39 changed files with 1349 additions and 408 deletions

View File

@@ -1,9 +1,11 @@
import { type Edge, type Node, type Viewport } from '@xyflow/svelte';
import { getContext, setContext } from 'svelte';
import type { TinyflowNodeNormalizer } from '../utils/nodeInteraction';
const DEFAULT_VIEWPORT: Viewport = { x: 250, y: 100, zoom: 1 };
const TINYFLOW_STORE_CONTEXT = Symbol('tinyflow_store');
const createStore = () => {
export const createStore = () => {
let nodesInternal = $state.raw([] as Node[]);
let edgesInternal = $state.raw([] as Edge[]);
let viewport = $state.raw({ ...DEFAULT_VIEWPORT } as Viewport);
@@ -86,4 +88,18 @@ const createStore = () => {
};
};
export const store = createStore();
export type TinyflowStore = ReturnType<typeof createStore>;
export const createTinyflowStoreContext = () => {
const store = createStore();
setContext(TINYFLOW_STORE_CONTEXT, store);
return store;
};
export const useTinyflowStore = () => {
const store = getContext<TinyflowStore | undefined>(TINYFLOW_STORE_CONTEXT);
if (!store) {
throw new Error('Tinyflow store context is not initialized');
}
return store;
};