perf: add dirty persist and hydrate/layout optimizations

This commit is contained in:
Youzini-afk
2026-04-22 22:27:22 +08:00
parent 0b71a35a93
commit fb4dabeaf1
11 changed files with 1297 additions and 184 deletions

View File

@@ -2,7 +2,10 @@
// 不依赖 index.js 模块级可变状态currentGraph / graphPersistenceState 等)
import { deserializeGraph, getGraphStats, serializeGraph } from "./graph.js";
import { normalizeGraphRuntimeState } from "../runtime/runtime-state.js";
import {
cloneGraphPersistDirtyState,
normalizeGraphRuntimeState,
} from "../runtime/runtime-state.js";
// ═══════════════════════════════════════════════════════════
// 常量
@@ -1594,10 +1597,12 @@ export function removeGraphShadowSnapshot(chatId = "") {
// ═══════════════════════════════════════════════════════════
export function cloneGraphForPersistence(graph, chatId = "") {
return normalizeGraphRuntimeState(
const clonedGraph = normalizeGraphRuntimeState(
deserializeGraph(serializeGraph(graph)),
chatId,
);
cloneGraphPersistDirtyState(graph, clonedGraph);
return clonedGraph;
}
export function shouldPreferShadowSnapshotOverOfficial(