fix(tui): fall back to local cwd when editor spawns in attach mode#30583
Open
pcadena-lila wants to merge 1 commit into
Open
fix(tui): fall back to local cwd when editor spawns in attach mode#30583pcadena-lila wants to merge 1 commit into
pcadena-lila wants to merge 1 commit into
Conversation
In attach mode the server's project directory does not exist on the local machine, so Process.spawn fails with an invalid cwd. Check that the resolved cwd exists before using it; fall back to process.cwd() otherwise. Closes anomalyco#30582
|
I can confirm that the fix works for me (with a relatively similar setup). Thank you 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #30582
Type of change
What does this PR do?
In
opencode attachmode, the/editorcommand (ctrl+x e) fails silently because the server's project directory (e.g./home/user/project) does not exist on the local machine where the TUI client runs.Editor.open()passes the server-reportedproject.instance.path().worktreeascwdtoProcess.spawn(). When that path doesn't exist locally, the spawn fails and the editor never opens.This fix checks whether the resolved
cwdexists on the local filesystem before using it. If it doesn't (as is always the case in remote attach mode), it falls back toprocess.cwd().How did you verify your code works?
opencode serve --port 4096on a remote Linux machinessh -L 4096:127.0.0.1:4096 <remote>opencode attach http://localhost:4096locally (macOS, iTerm2)ctrl+x e— editor ($EDITOR=nvim) now opens correctlyopencodedirectly) still works as beforeScreenshots / recordings
N/A
Checklist