fix: symlink path resolution causing duplicate instances (#15482)#15483
fix: symlink path resolution causing duplicate instances (#15482)#15483snowstorm0182 wants to merge 1 commit intoanomalyco:devfrom
Conversation
) - Add canonical() function to resolve symlinks before caching instances - Prevents TUI freeze when working with symlinked directories - Add comprehensive tests for symlink path handling - Fixes anomalyco#15482
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on the search results, here are potentially related PRs: Related PRs:
These PRs share the theme of symlink handling and deduplication/caching logic. PR #10366 in particular appears to be the closest match as it also deals with resolving symlinks in the project handling code. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Description
Issue for this PR
Closes #15482
Type of change
What does this PR do?
When OpenCode was opened from a directory that was a symlink (e.g.,
~/ssd→/media/user/ssd_storage), it would create two separate server instances - one for the symlink path and one for the resolved real path. This caused the TUI to freeze when sending prompts because the UI was connected to one instance while operations were executing on a different instance.The fix adds a
canonical()function that resolves symlinks usingfs.realpath()before using the directory as a cache key inInstance.provide(). This ensures symlink paths and their real paths always map to the same instance.How did you verify your code works?
test/project/instance-symlink.test.ts:Checklist