Skip to content

Commit cba1f84

Browse files
nieaoclaude
andcommitted
fix(yjsSync): promoteOntologyToTask 拆成两个 set 避免 immer 单 set 多数组引用 stable
bug: 单个 set callback 内同时 state.nodes.push + state.edges.push 时, yjsSync 的 store.subscribe 拿到的 state.nodes === lastNodes (引用相等), 被 short-circuit return, 新创建的 TaskNode 永远不 push 到 yjs. Conductor 看不到 pending+auto 的 task, ResultNode 永远不涌现. 实测: yjs LevelDB 只有老 task, 新 task 在 zustand 里 (DOM 渲染了) 但 yjs 0 同步. 其他 add 方法 (addConceptNode 等) 都是单数组 set, 没踩到这个雷. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7df13de commit cba1f84

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/stores/useCanvasStore.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,13 +1896,13 @@ const useCanvasStore = create(
18961896
data: { relationType: '派单' },
18971897
style: { stroke: '#c8a882', strokeWidth: 2 },
18981898
}
1899-
set((state) => {
1900-
state.nodes.push(taskNode)
1901-
state.edges.push(newEdge)
1902-
})
1899+
// 拆成两个 set — 单 set 同时改 nodes+edges 在 immer 下被观察过引用 stable
1900+
// 导致 yjsSync subscribe 的 (nodes === lastNodes) 短路, 永远不 push 到 yjs
1901+
set((state) => { state.nodes.push(taskNode) })
1902+
set((state) => { state.edges.push(newEdge) })
19031903

19041904
// 不调 dispatchTaskNode (那是 manual 流) — orchestra dispatcher 看到
1905-
// agentMode='auto' + status='draft' 会自动推 pending → hermes worker 抢锁
1905+
// agentMode='auto' + status='pending' 会自动接管 → hermes worker 抢锁
19061906
return taskId
19071907
},
19081908

0 commit comments

Comments
 (0)