fix: notebook

This commit is contained in:
tao.chen
2026-08-25 11:35:51 +08:00
parent 799f4e2a09
commit 76aa2dcb27
@@ -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;