opencode icon indicating copy to clipboard operation
opencode copied to clipboard

race condition when applying changes immediatly after each other on same file

Open chenxin-yan opened this issue 1 month ago • 1 comments

Description

When multiple changes are proposed for user to accept on the same file and user press "enter" to accept them one by one immediately after each other, the last change on the file will override all previous changes, resulting the previous changes not being applied correctly on that file and only the last change is applied correctly.

OpenCode version

0.15.29

Steps to reproduce

  1. send a prompt that results in multiple changes that need to be accepted sequentially on one file
  2. accept all of them by pressing "enter" multiple times quickly
  3. only the last change is applied correctly

Screenshot and/or share link

No response

Operating System

macOS 14.7.1

Terminal

Ghostty

chenxin-yan avatar Nov 03 '25 22:11 chenxin-yan

This issue might be a duplicate of existing issues. Please check:

  • #2882: Describes parallel edit tool calls on same file causing errors, which appears to be the same race condition where multiple rapid changes to a file interfere with each other
  • #196: Mentions a race condition with streamed operations, potentially related to the same timing issues with sequential operations

Feel free to ignore if none of these address your specific case.

github-actions[bot] avatar Nov 03 '25 22:11 github-actions[bot]

Found workaround: set permission "write": true. OpenCode rejects writes out of the working directory, and has functionality to undo the last edit. So I think this permission must be safe for most cases

sr-tream avatar Nov 06 '25 18:11 sr-tream

Found workaround: set permission "write": true. OpenCode rejects writes out of the working directory, and has functionality to undo the last edit. So I think this permission must be safe for most cases

I think write tool is being enabled by default. Also, to reproduce this error, the file do not have to be outside of cwd.

chenxin-yan avatar Nov 07 '25 23:11 chenxin-yan