Skip to content

write/edit freezes when writing long content ("Preparing write..." hangs) #20477

Closed as not planned

Description

@FindTea

Description

When writing or editing files with a large number of lines, the TUI freezes on "Preparing write..." / "Preparing patch..." for several seconds before the permission prompt appears.
Root cause: createTwoFilesPatch (Myers diff, O(N²) in line count) runs synchronously on the main thread before ctx.ask(), blocking the Node.js event loop when content has many lines.
Also observed on Windows: apply_patch throws EEXIST from fs.mkdir when the target directory already exists (Bun 1.3.x bug with recursive:true).

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. added
    perfIndicates a performance issue or need for optimization
    on Apr 1, 2026
  2. github-actions commented on Apr 1, 2026

    @github-actions
    Contributor

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

    If your issue is the same as one of these, please comment there instead so efforts can be consolidated.

  3. removed
    bugSomething isn't working
    perfIndicates a performance issue or need for optimization
    on May 3, 2026
  4. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions