fix(cli): don't delete connect file when --connect is omitted#2060
Draft
fix(cli): don't delete connect file when --connect is omitted#2060
--connect is omitted#2060Conversation
Every command that goes through the generic dispatcher unlinks the
connect file when --connect isn't on the current invocation. That
breaks the intended flow:
$ browse env remote --connect <id> # writes connect file, spawns daemon
$ browse open <url> # no --connect → unlinks connect file
# daemon then initializes lazily,
# finds no connect file, creates a
# brand-new companion session
The connect file should only be managed when the user explicitly
opts in or out of --connect on the current command. Switching modes
(`browse env local`) is the right place to clean up stale connect
state, not every navigation.
Drop the unconditional `else { unlink }` branch. The file lifecycle
is now: created when --connect is set on `env remote` or any command,
removed when switching to local mode (handled in PR for env handler),
or left alone otherwise.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
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.
Summary
The generic command dispatcher unconditionally unlinks the connect file whenever
--connectis not present on the current invocation. This breaks the expectedbrowse env remote --connect <id>→browse open <url>flow:browse env remote --connect <id>writes the connect file and spawns the daemonbrowse open <url>arrives →opts.connectis undefined → the dispatcher unlinks the connect filebrowse_cli: trueNet effect: the user's session is never resumed. Logs and recordings end up on the companion session, not the one the user passed in.
Fix
Remove the
else { unlink }branch in the dispatcher. The connect file's lifecycle should be managed only when the user explicitly opts in or out via--connect, not as a side effect of unrelated commands.This pairs naturally with the env handler change in #2059, which writes the connect file when
--connectis passed toenv remoteand removes it when switching toenv local.Reproduction (before)
After
The connect file persists through subsequent commands. The daemon resumes
abc-123instead of creating a companion.Test plan
browse env remote --connect <id>, runningbrowse open <url>does not delete the connect filebrowse open <url> --connect <other-id>still updates the connect file (existing behavior preserved)browse env localcleans up the connect file (handled in fix(cli): honor--connectonbrowse env remote#2059)🤖 Generated with Claude Code