Skip to content

fix(extensions): keep Windows settings saves atomic while a reader is active - #995

Open
mouzhi wants to merge 1 commit into
mainfrom
fix/windows-extension-settings-replace
Open

mouzhi wants to merge 1 commit into
mainfrom
fix/windows-extension-settings-replace

Conversation

@mouzhi

@mouzhi mouzhi commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Saving Desktop extension settings can fail on Windows while a reader still has settings.json open. Keep the complete replacement file beside its destination and retry the atomic rename on Windows sharing errors. Five bounded delays allow 560 ms for a reader to finish. A persistent failure reaches the caller and the temporary file is cleaned up.

Related issues

Observed in the Windows check on #948 after the Desktop extensions merge in #992. The same failure reproduced locally against main with a real open file handle.

Test plan

  • Added a Windows regression test that holds the old settings file open, releases it during save, and checks the persisted revision and directory contents. It failed with EPERM before the change and passed after it.
  • Ran the harness-plugin-files Vitest suite on Windows x64. 76 passed and one was skipped.
  • Package TypeScript build, ESLint for both changed files, and git diff --check passed.

The change is confined to saving Desktop extension settings and can be reverted without a data migration.

The branch inherits the nine TypeScript errors on main tracked in #994. As an integration check, I combined #994, this change, and the heads of #948, #978, and #990 in a disposable worktree. npm run typecheck, npm run lint, and npm run format:check all passed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T12:00:11.749012Z 6651d81 PR opened
🔒 Security Review ✅ Completed 2026-11-20T12:02:08.946205Z 6651d81 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • 修复
    • 在 Windows 上,设置文件因权限或占用问题无法重命名时,会按间隔短暂等待并重试;其他错误仍会直接报告。
    • 改善文件被读取时更新设置的可靠性。

设置文件替换现在会在 Windows 上遇到指定错误时按配置间隔重试。新增的 Windows 专用测试覆盖读取器打开设置文件期间写入新 revision 的场景。

Changes: 设置文件替换

Layer / File(s) Summary
替换重试与写入接入
packages/harness-plugin-files/src/desktop-extension-data.ts
新增 Windows 重命名重试。仅当平台为 win32、错误码为 EPERM、EACCES 或 EBUSY,且仍有等待间隔时重试;其他失败会抛出。设置文件写入改用该替换逻辑。
Windows 替换测试
packages/harness-plugin-files/test/desktop-extension-data.test.ts
新增 Windows 专用测试:读取器打开旧设置文件期间写入新 revision;随后验证新设置内容,并确认目录中仅有 settings.json。

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

Change: Bug fix

Possibly related PRs

Suggested reviewers: bytepioneer-ai

Merge Risk: Minimal · up to 6651d

This change makes saving Desktop extension settings on Windows tolerate a reader briefly holding the old settings file open. The retries are bounded, so a persistent failure still reaches the caller. Rollback is simple and needs no data migration. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“fix(extensions): keep Windows settings saves atomic while a reader is active”描述了主要变更:当读取器仍打开设置文件时,Windows 上的设置保存保持原子替换。变更集中在 desktop-extension-data.ts 中为设置文件重命名增加 Windows 共享冲突重试,并新增对应的 Windows 回归测试…
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.
Description check Passed PR 描述与变更集直接相关。描述说明了问题:Windows 上读取器仍打开 settings.json 时保存 Desktop 扩展设置会失败。描述还说明了修复方式:保留完整替换文件、对 Windows 共享错误重试原子重命名、使用五个有界延迟(共 560 ms),并在持续失败时把错误抛给调用方并清理临时文件。测试计划也与 desktop-extension-data.test.ts 中新增的 W…
Full details: Title check

Explanation

标题“fix(extensions): keep Windows settings saves atomic while a reader is active”描述了主要变更:当读取器仍打开设置文件时,Windows 上的设置保存保持原子替换。变更集中在 desktop-extension-data.ts 中为设置文件重命名增加 Windows 共享冲突重试,并新增对应的 Windows 回归测试,二者与标题一致。标题清晰、具体,可判定为通过。

Full details: Description check

Explanation

PR 描述与变更集直接相关。描述说明了问题:Windows 上读取器仍打开 settings.json 时保存 Desktop 扩展设置会失败。描述还说明了修复方式:保留完整替换文件、对 Windows 共享错误重试原子重命名、使用五个有界延迟(共 560 ms),并在持续失败时把错误抛给调用方并清理临时文件。测试计划也与 desktop-extension-data.test.ts 中新增的 Windows 回归测试相符。

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · 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

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