fix(sync): 恢复双击断线 + 同步不再用「更旧的磁盘画板」覆盖本地连线
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 4m22s

用户确认:双击连线断开是他正常的操作设定,必须保留(撤回上一版的删除)。

_boot.log 实证(2026-11-27 16:12:20,带端点的版本):
  board-sync-apply ws=ws1791793128523_269487 edges 14→14 gone=1 added=1
  goneE=n1795689443288_469543>n1795788899243_541047   ← 老参考图 → 配置节点
  addE =n1795790112627_199074>n1795788899243_541047   ← 新参考图 → 配置节点
即:内存里是新连线,磁盘上是旧连线,同步把磁盘版本整块应用回来 ⇒ 「出完图连回老图」。
gen-run-start / gen-run-end 都是 edges=14,生成流程本身没动边。

改动:
- src/ui-canvas-view.js:恢复 EdgePath 的 onDoubleClick 断线(并注明是用户要保留的习惯)
- src/runtime-workbench-logic.js:applyLatestSync 增加时间戳守卫 —— 边 id 形如 e<毫秒>_<随机>,
  本地最大边时间戳比磁盘新 1 秒以上就跳过本次应用,并写 board-sync-skip 到 _boot.log;
  同时 session 标脏时记 editedAt,便于后续做更精细的新旧判断
This commit is contained in:
qiqi committed 2026-11-28 00:16:52 +08:00
1 parent bdd975cac0
commit ab3833ade7
3 files changed
+19 -7

No files matched your search

+14
View File
@@ -982,6 +982,19 @@
refreshSessionsFromList(syncedList) // 非激活 session 合并(标脏的保留本地并记 sync-conflict)
const curWs = syncedList.find((w) => w.id === activeWsIdRef.current) || syncedList[0]
setActiveWsId(curWs.id)
// v3.26.109 修:磁盘上的画板可能比内存旧(网络卷写入慢 / 同步盘被旧副本覆盖 / flush 未落地)。
// 边的 id 形如 e<毫秒时间戳>_<随机>,直接比最大时间戳就能判断谁更新:本地更新就不覆盖,
// 否则会把用户刚连好的新参考图整块换回老图(2026-11-27 实测:goneE=老ref>gen addE=新ref>gen)。
try {
const tsOf = (id) => { const m = /^[ne](\d{10,})_/.exec(String(id || '')); return m ? Number(m[1]) : 0 }
const maxTs = (es) => (es || []).reduce((a, e) => Math.max(a, tsOf(e && e.id)), 0)
const localTs = maxTs(refs.edges)
const diskTs = maxTs(curWs.edges)
if (localTs > diskTs + 1000) {
try { const st = (typeof window !== 'undefined') ? window.IWBStorageFile : null; if (st && st.logLine) st.logLine('board-sync-skip ws=' + curWs.id + ' localTs=' + localTs + ' diskTs=' + diskTs + '(本地更新,不覆盖)') } catch (e2) { /* ignore */ }
return true
}
} catch (e) { /* 诊断失败按原逻辑走 */ }
// 活动 session 标脏(本地有未保存修改)→ 保留本地,不用同步数据覆盖(下次保存赢)
const activeSess = sessionsStore.get(curWs.id)
if (activeSess && activeSess.dirty) {
@@ -2277,6 +2290,7 @@
// S6/D2:数据引用变化 = 本地编辑 → 标脏(loadWsInto 会在装载后清脏,避免误标)
if (s.nodes !== refs.nodes || s.edges !== refs.edges || s.groups !== refs.groups) {
s.dirty = true
s.editedAt = Date.now()
s.nodes = refs.nodes
s.edges = refs.edges
s.groups = refs.groups
+4 -6
View File
@@ -189,18 +189,16 @@ function ToolbarBottom(props) {
}
function EdgePath(props) {
const { ed, src, dst, graph, nodeMap, measuredH, pathCache, focusNodeId, selEdge, edgeHover, onSelect } = props
const { ed, src, dst, graph, nodeMap, measuredH, pathCache, focusNodeId, selEdge, edgeHover, onSelect, onDelete } = props
const d = React.useMemo(() => computeEdgePath(ed, graph, nodeMap, measuredH, pathCache), [ed, src, dst, graph, nodeMap, measuredH])
if (!d) return null
const relation = focusNodeId ? (ed.to === focusNodeId ? ' iwb-edge-upstream' : (ed.from === focusNodeId ? ' iwb-edge-downstream' : '')) : ''
const cls = 'iwb-edge' + (selEdge === ed.id ? ' iwb-edge-sel' : '') + relation + ((edgeHover && edgeHover.mode === 'insert' && edgeHover.edgeId === ed.id) ? ' iwb-edge-hot' : '') + ((edgeHover && edgeHover.mode === 'detach' && edgeHover.edgeIds.indexOf(ed.id) >= 0) ? ' iwb-edge-detach' : '')
// v3.26.109:去掉「双击连线直接断开」——线和节点的热区都是细长一条,双击很容易误中,
// 日志里用户 5 次丢失同一条参考连线全来自这里(edge-drop 栈指向 edge onDoubleClick)。
// 断线保留:单击选中后按 Delete、右键菜单、或拖到空白处。
const hnd = { onPointerDown: (e) => { e.stopPropagation(); onSelect(ed.id) } }
// 双击连线 = 断开连线:这是用户明确要保留的操作习惯(2026-11-28 确认),不要删。
const hnd = { onPointerDown: (e) => { e.stopPropagation(); onSelect(ed.id) }, onDoubleClick: (e) => { e.stopPropagation(); onDelete(ed.id) } }
return el('g', { 'data-edge-id': ed.id },
el('path', { key: ed.id + '_hit', className: 'iwb-edge-hit', d, fill: 'none', ...hnd }),
el('path', { key: ed.id, className: cls, d, fill: 'none', title: '点击选中(Delete 断开)', ...hnd }),
el('path', { key: ed.id, className: cls, d, fill: 'none', title: '点击选中(Delete 断开)· 双击直接断开', ...hnd }),
)
}