anomalyco / anomalyco/opencode
tool/edit: stale-content error mentions "permission approval" though any concurrent write triggers it
@kitlangton is already working on this.
Since Sep 12, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
edit reports File changed after permission approval. Read it again before editing. whenever FileMutation.StaleContentError fires, but that error is raised whenever the file's bytes differ from what the tool read — for example when another session or process writes the file during the edit's read→write window. The message misattributes the cause to the permission flow, which is confusing when debugging concurrent edits.
Environment
- opencode version: 2.0.2
- OS: Windows 11 (10.0.26220.9343, win32 x64)
- Terminal: Unavailable: reproduced against the background service
- Shell: cmd.exe
- Install/channel: latest (2.0.2)
- Active plugins: 4 local entries auto-discovered from
~/.config/opencode/plugins/
Reproduction
- Start an
editon a file whose content another writer changes concurrently (same path, any session or process). - The store's compare-and-swap detects the mismatch and
editfails with:File changed after permission approval. Read it again before editing. - No permission approval was involved in the failing mutation.
Expected Behavior
A message that names the actual condition, e.g. File changed since it was read. Read it again before editing.
Actual Behavior
File changed after permission approval. Read it again before editing.
Additional Context
- Source:
packages/core/src/tool/edit.tsmapsFileMutation.StaleContentErrorto this message;packages/core/src/file-mutation.tsraises it when the expected bytes differ from the current bytes under the per-path lock. - Impact is low — the message still tells the reader to re-read — but the stated reason is misleading in the common concurrent-write case.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.