Skip to content

fix: preserve annotation saves with frozen VS Code API - #36

Merged
AliceJump merged 2 commits into
mainfrom
fix/annotation-save-frozen-vscode-api
Oct 8, 2026
Merged

AliceJump merged 2 commits into
mainfrom
fix/annotation-save-frozen-vscode-api

Conversation

@AliceJump

@AliceJump AliceJump commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fix the annotation-save regression introduced with the v1.22 external-sync timing guard (#31).

VS Code returns a frozen object from acquireVsCodeApi(). The annotation panel's shared API shim cached that native object directly, while externalSync.js attempted to replace vscode.postMessage. In a real VS Code Webview that assignment does not take effect, so save / saveMode messages leave app.js without imagePath and editorVersion; the host then drops them in processEditorSave().

Changes

  • wrap the native VS Code Webview API in a mutable shared facade instead of exposing the frozen native object
  • keep externalSync.js's save interception and versioning protocol unchanged
  • extend the existing annotation mode-cycle test with a frozen native API regression case that verifies saves are enriched with imagePath and editorVersion

Scope

Only the VS Code annotation panel shim and its regression test are changed. No JetBrains code, persistence format, or merge protocol changes.

Validation

  • reproduced the old behavior with an Object.freeze() native API: save reaches the host without imagePath / editorVersion
  • verified the facade behavior with the same frozen API: save reaches the native API with imagePath: x/frozen.png and editorVersion: 1
  • GitHub Actions / repository test suite to validate the checked-in integration test

Summary by CodeRabbit

  • Bug Fixes
    • 修复原生 VS Code API 对象被冻结时的兼容问题;图像加载后,保存消息仍可正常发送,并包含图像路径和版本信息。

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1acc9410-d95a-4ea8-9526-69414d4e2493
📥 Commits

Reviewing files that changed from the base of the PR and between 8888265 and d37058a.

📒 Files selected for processing (2)
  • media/annotationPanel/index.html
  • scripts/test_annotation_mode_cycle.js
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

acquireVsCodeApi 现在返回缓存的共享包装对象,并将 API 调用转发给原生 VS Code API。新增集成测试验证冻结的原生 API 对象可接收包含图像路径和版本号的保存消息。

Changes

API 包装对象与保存消息

层 / 文件 摘要
包装对象转发与保存消息验证
media/annotationPanel/index.html, scripts/test_annotation_mode_cycle.js
shim 缓存包装对象,并转发 postMessage、getState 和 setState。新增测试通过 externalSync.js 加载图像,并验证保存消息到达冻结的原生 API,且包含 imagePath 和 editorVersion: 1。

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to d3705

The shared API wrapper and frozen-API save test present no identified merge-blocking issue. Normal checks remain appropriate.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:修复冻结的 VS Code API 导致的标注保存问题。标题简洁、具体,并与代码和测试变更一致。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@AliceJump
AliceJump merged commit 7b39a8a into main Oct 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant