Uh oh!
There was an error while loading. Please reload this page.
fix(tui): canonicalize cwd after chdir - #16641
Conversation
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Pull request overview
This PR fixes TUI hangs/blank responses when launching OpenCode from symlinked directories by ensuring the TUI main thread and worker use the same canonical working directory (and still resolve relative --project paths from PWD).
Changes:
- Update
TuiThreadCommandtochdirto the requested directory, then re-readprocess.cwd()and use that canonical value forInstance/TUI directory keys. - Add a regression test covering the
PWD-symlink scenario with and without a relative--projectpath.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/opencode/src/cli/cmd/tui/thread.ts | Canonicalizes cwd after chdir so TUI thread and worker share the same directory key. |
| packages/opencode/test/cli/tui/thread.test.ts | Adds regression coverage for symlinked PWD causing mismatched directory keys. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| globalThis.Worker = class extends EventTarget { | ||
| onerror = null | ||
| onmessage = null | ||
| onmessageerror = null | ||
| postMessage() {} | ||
| terminate() {} | ||
| } as unknown as typeof Worker |
There was a problem hiding this comment.
The globalThis.Worker stub extends EventTarget without defining a constructor. Since TuiThreadCommand instantiates new Worker(file, { env: ... }), the default subclass constructor will forward those arguments to EventTarget, which typically throws because it expects no arguments. Add an explicit constructor(..._args: any[]) { super() } (or otherwise accept and ignore args) so the test doesn’t fail during Worker construction.
brndnblck
commented
Mar 8, 2026
This fix completely broke MacOS and POSIX file systems if the working folder is a symlink. This needs to be reverted. |
brndnblck
commented
Mar 8, 2026
(cherry picked from commit e51ed46)
(cherry picked from commit e51ed46)
Fixes#16522
Fixes#16528
Fixes#16596
Use the same canonical cwd for the TUI thread and worker, including relative --project paths resolved from PWD.
Before 1.2.21
In broken 1.2.21
After this fix
For relative --project from a symlinked PWD