Skip to content

[Bug]: The OpenCode status plugin is written in place, so a reload can see it missing or truncated #24121

Closed

Description

@jutaz

Operating system: Linux (also applies to macOS, Windows and SSH/WSL hosts)
Orca version: checkout at d68a5be13a (1.4.214+)


Orca writes its OpenCode status plugin in place, so the plugin file can be missing or truncated for a moment while it is being replaced. OpenCode 2 reloads a plugin whenever the file's mtime changes (see src/shared/opencode-installed-plugin.ts), so a reload that lands in that window can load nothing or a partial file. I haven't caught that happening; what I confirmed is that the write is not atomic.

Where

  • OpenCodeHookService.writePluginToConfigDir and writePluginIntoOverlay in src/main/opencode/hook-service.ts: a plain writeFileSync, and the overlay path unlinks first.
  • installOpenCodePluginInCanonicalConfig in src/relay/opencode-canonical-config.ts and writeOpenCodePlugin in src/relay/plugin-overlay.ts: unlinkSync then writeFileSync, so the file does not exist between the two calls.

The Claude and Codex hook installers already write via a temp file and rename (writeHooksJson and writeManagedScript in src/main/agent-hooks/installer-utils.ts, writeFileAtomically for Codex's real-home hooks JSON). The OpenCode plugin is the outlier, and it is the one where a bad read costs the whole session's status rather than one hook run.

How to reproduce

Mock writeFileSync and record its paths, install over a stale plugin, and assert the plugin's own path was never written. It fails today at all of the sites above.

Fix

Write to a temp file in the same directory and rename it over the target. A dotfile-manager symlink at the canonical path should stay a symlink (write to its target); a mirrored user entry in an overlay should still be replaced, not written through.

Activity

  1. added a commit that references this issue on Oct 3, 2026
    fee8143
  2. added a commit that references this issue on Oct 5, 2026
    fb5f504
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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