Files
mnote/bugs/07-ai/done/7-55-page-ai-current-page-target-stale-workspace-v1.md
T
lix-2026 1882db7681 收口 MNote P0 P1 P2 审查尾项
- 归档 OnlyOffice live bridge、Page AI、mindmap、design governance 与相关 bug 条目
- 补齐 MinerU OCR 后端 runtime 合同与 smoke/test 基线
- 收口 ChatOnly/Doubao、ObjectIdentity、Page Aggregate compat 与 runtime owner 文档口径

验证:
- cargo test --manifest-path rust/Cargo.toml -p mnote-web local_ocr -- --test-threads=1
- cargo test --manifest-path rust/Cargo.toml -p mnote-web onlyoffice_bridge -- --test-threads=1
- git diff --check
- git diff --cached --check
- codegraph index . --force && codegraph status .
- codegraph sync . && codegraph status .
2026-06-01 09:29:12 +08:00

1.8 KiB
Raw Blame History

7-55 Page AI 当前页目标继承 stale workspacePath

状态

  • 状态:done
  • Owner07-ai / Page AI target runtime
  • 发现时间:2026-06-01
  • 修复时间:2026-06-01

现象

task504-page-ai-history-agent-filter-smoke.js 在模拟 stale OpenEditorsSnapshot 后,用户偏好已将 active_editor contextRef 关闭,只发送当前页上下文;但 sendPageAiMessage() 仍强制把 scopedContext.editorTarget 覆盖为 currentPageAiEditorTarget(),导致当前页请求被旧 active editor 的 workspaceId 拦截,前端显示:

AI target 与当前 workspaceId 不一致,请重新选择当前工作区内的目标。

根因

  • pageAiScopedPageContext() 已按 contextRefs 计算 scoped target,但发送链路又覆盖为 currentPageAiEditorTarget()
  • currentPageAiPageEditorTarget() 从 page editor snapshot 读取 workspacePath 时,没有把当前 workspaceId/sourceKind/rootUri/relativePath/documentId 写回,stale snapshot 会把旧 workspace 信息带进当前页目标。

修复

  • sendPageAiMessage() 改用 currentPageAiScopedEditorTarget(),遵守 contextRefs 对 active editor 的开关。
  • currentPageAiPageEditorTarget() 在复用 page editor snapshot 时显式覆盖当前 workspace path 字段,避免 stale snapshot 污染当前页 target。

验证

  • node --check rust/crates/mnote-web/browser/sidebar-page-ai-target-runtime.js
  • node --check rust/crates/mnote-web/browser/sidebar-page-ai-runtime.js
  • MNOTE_UI_BASE_URL=http://127.0.0.1:3301 MNOTE_WEB_SMOKE_BASE_URL=http://127.0.0.1:3301 node scripts/task504-page-ai-history-agent-filter-smoke.js

验证结果:task504 通过,capturedRuns[0].contextRefs 只包含 current_pagerunTargetSnapshot.editorTarget.workspaceId 为当前 local-ws:mnote-e2e:task504,未继续使用 stale workspaceId。