Skip to content

.watchman-cookie-* files in git worktrees cause periodic /vcs/diff requests #24357

@jasonyork

Description

@jasonyork

Description

When using secondary workspaces (git worktrees), .watchman-cookie-* files created by Watchman at the worktree root trigger the file watcher. This leads to frequent refreshVcs() calls and periodic requests to /vcs/diff.

This can be annoying when attempting to comment on the code because the file will refresh, losing anything typed in the comment.

Root cause(s)

  1. .watchman-cookie-* files are not ignored by default (they likely should be).
  2. The watcher.ignore config option is only applied to the project directory subscription, not to the .git directory subscription used for worktrees.

Proposed Fix

Update packages/opencode/src/file/watcher.ts to apply config ignores to the VCS directory subscription:

// Currently:
yield* subscribe(vcsDir, ignore)

// Should be:
yield* subscribe(vcsDir, [...ignore, ...cfgIgnores])
Additionally, add .watchman-cookie-* to the default ignore patterns in src/file/ignore.ts.

Workaround

Disabling the watcher with OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER=true

Plugins

obra/superpowers

OpenCode version

1.14.23

Steps to reproduce

  1. Use a project with "workspaces" enabled (secondary git worktree).
  2. Let Watchman run (creates .watchman-cookie-* files in the secondary worktree root).
  3. Observe periodic /vcs/diff requests in network tab or server logs.

Screenshot and/or share link

No response

Operating System

macOS Tahoe 26.4.1

Terminal

iTerm2

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)perfIndicates a performance issue or need for optimization

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions