fix: notebook

This commit is contained in:
tao.chen
2026-09-02 10:10:41 +08:00
committed by tao.chen
parent c3947d6066
commit ce7adce89c
@@ -50,10 +50,9 @@ export const createEditSessionSlice: StateCreator<
if (getEditorOpening()) return;
setEditorOpening(true);
const api = requireApi();
const requestId = getEditorOpenRequest() + 1;
// 记录本次请求的 id (供 requestIsCurrent 校验)。
// 原版用模块级 _editorOpenRequest 配合闭包变量;现在 requestIsCurrent
// 通过 helpers 读取最新的模块级值 + getSelectedId()。
// bump 模块级 _editorOpenRequest,捕获本次请求 id 用于 stale 检测
// (如果后续 openScriptEditor / endEditing 又 bump 了,本请求就算过期)。
const requestId = bumpEditorOpenRequest();
const requestIsCurrent = () =>
getEditorOpenRequest() === requestId &&
getSelectedId() === script.script_id;