fix(tui): attach auth token when editor port comes from env#32481
Open
timbit123 wants to merge 1 commit into
Open
fix(tui): attach auth token when editor port comes from env#32481timbit123 wants to merge 1 commit into
timbit123 wants to merge 1 commit into
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
dad47d8 to
ad32734
Compare
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
CLAUDE_CODE_SSE_PORT connections were opened without the lock file's auth token, so the IDE server rejected them with 1008 in integrated terminals. And when that port was stale, opencode never fell back to lock discovery. Read the token from ~/.claude/ide/<port>.lock, and fall back to scanning ~/.claude/ide for the live server when the configured port has no lock.
ad32734 to
1430727
Compare
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 #29570
Closes #26852
Type of change
What does this PR do?
Fixes the editor file/selection context not syncing when opencode runs in a VSCode / Cursor integrated terminal.
The Claude Code extension injects
CLAUDE_CODE_SSE_PORTinto integrated terminals and writes a matching~/.claude/ide/<port>.lockwhoseauthTokenits WebSocket server requires. External terminals don't get the env var, so they already worked via lock-file discovery. Two bugs on the configured-port path:1008 Unauthorizedand noselection_changedevents ever arrived.Now, for a configured port we read its
~/.claude/ide/<port>.lockand attach the token; if that lock is missing we fall back to scanning~/.claude/idefor the live server matching the working directory. This runs on every (re)connect, so if the server dies mid-session it recovers on its own. A locklessOPENCODE_EDITOR_SSE_PORToverride still connects directly. Also extracted a smallreadEditorLockhelper so the by-directory and by-port lookups don't duplicate the parse/validate logic.How did you verify your code works?
1008 Unauthorized; with the lock token → handshake OK +selection_changed. A deadCLAUDE_CODE_SSE_PORTfalls back to the live server.bun test test/cli/tui/editor-context.test.tsxpasses (7);tsgo --noEmitpasses forpackages/tuiandpackages/opencode.Screenshots / recordings
N/A — not a visual change.
Checklist