Skip to content

fix(core): reload symlinked config targets - #53932

Open
ykai55 wants to merge 2 commits into
anomalyco:devfrom
ykai55:symlink-config-reload
Open

ykai55 wants to merge 2 commits into
anomalyco:devfrom
ykai55:symlink-config-reload

Conversation

@ykai55

@ykai55 ykai55 commented Oct 8, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #53920

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Config watches cover the directory containing a symlink, but miss edits to its target outside that directory. Resolve file symlink targets when building the watch plan and include them in the existing parent-entry watches. Keep the original paths watched so retargeting the link reconciles the target watch, and retain the original document paths for relative config references.

Reading the link before resolving its target also keeps a watch when the target file is temporarily absent, allowing deletion/recreation and atomic saves to reload.

How did you verify your code works?

  • One real-watcher regression test checks two successive in-place edits to a symlinked global config, with no settle sleep. Removing target watches makes this test time out.
  • Watch-plan unit tests cover global, direct project, .opencode, and explicit config symlinks, including dangling targets and retargeting, without starting filesystem watchers.
  • bun test test/config/config.test.ts test/config/watch.test.ts test/filesystem/watcher.test.ts from packages/core: 63 passed.
  • bun run check from the repository root: passed, including all 36 typecheck tasks.
  • Tested on macOS arm64 with Bun 1.4.2.

Screenshots / recordings

Not applicable (filesystem/config change).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reproduced #53920 on the base: with ~/.config/opencode/opencode.json symlinked to a dotfiles file and serve running, edits to the target after the first one were ignored (1111/1111/1111). With this PR each edit is picked up (1111/2222/3333). The new test times out on the base and passes here. The core and watch tests pass and packages/core type-checks.

The approach looks right. The watch plan resolves each config symlink's target and adds a watch on the target's parent directory, alongside the existing directory watches. If the target is missing it is still watched, because resolve falls back to the plain path when the file isn't found. Retargeting the link triggers a reload, which rebuilds the plan with the new target.

My one request is about the new integration test (see inline comment): it is large and timing-sensitive for what it checks.

Comment thread packages/core/test/config/config.test.ts Outdated
@thdxr
thdxr changed the base branch from v2 to dev October 10, 2026 19:37

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config: edits to symlinked global config target do not trigger hot reload

1 participant