Studio Code: detach remote-session by default and add attach subcommand#3347
Merged
gcsecsey merged 3 commits intoMay 6, 2026
Merged
Conversation
…mand `studio code remote-session start` now daemonizes by default — pass `--no-detach` to keep running attached in the foreground. The new `attach` subcommand connects to a running daemon and streams its log file to stdout in the same human-readable format used by foreground mode; Ctrl-C detaches the terminal without stopping the daemon.
The child spawned by startDaemon parses its own argv. With `--detach` defaulting to true, the child was re-entering the daemon-spawn branch instead of running the bridge, so the PID file was never written and startup timed out. Append `--no-detach` to the spawn args so the child always runs in foreground mode.
gcsecsey
reviewed
May 5, 2026
Contributor
There was a problem hiding this comment.
Thanks @epeicher for tackling this! 🙌 In my testing the updated commands are working well, and I could attach-detach to the same session multiple times as described. 👍
| command | output |
|---|---|
start |
![]() |
status |
![]() |
attach |
![]() |
| detaching | ![]() |
status (after detaching) |
![]() |
stop |
![]() |
start --no-detach |
![]() |
gcsecsey
approved these changes
May 5, 2026
…e-detatch-mode-by-default-and-allow-to-attach-to-an
Collaborator
📊 Performance Test ResultsComparing 20fd75c vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
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.







Related issues
How AI was used in this PR
Implementation written by Claude under direction. I reviewed the diff and verified behavior end-to-end against a live daemon (attach connects, formats logs, detaches on Ctrl-C without killing the daemon). Test design and edge cases (rotation, dead-PID, daemon-exit detection) were iterated on with the assistant.
Proposed Changes
studio code remote-session startdefault from foreground to detached. The new behavior is "background daemon" by default; pass--no-detachto keep running attached in the foreground (same code path as before).studio code remote-session attach: connects to a running daemon, replays a 16 KB tail of~/.studio/remote-session.log, then streams new entries in the same human-readable format used when running foreground. Errors with exit 1 if no daemon is running. Ctrl-C / SIGTERM detach the terminal without stopping the daemon. Recovers from log rotation (size shrinks → reset offset) and reports daemon exit when the PID stops being live.formatLogLineForStdout()fromremote-session/logger.tsso attach can reuse the existing JSON-to-human formatter and stay consistent with foreground output.Testing Instructions
CLI:
npm run cli:buildSTUDIO_REMOTE_SESSION_ENABLED=1 node apps/cli/dist/cli/main.mjs code remote-session start— should printRemote-session daemon started (PID …)and return immediately.studio code remote-session status— confirms the daemon is running.studio code remote-session attach— should print the attach banner, replay the last bit of log, and stream new entries live. Press Ctrl-C: should printDetached. Daemon is still running.studio code remote-session status— daemon should still be running after detaching.studio code remote-session stop— terminates the daemon. Re-runningattachshould now error withRemote-session daemon is not running.studio code remote-session start --no-detach— should still run attached and print activity to stdout as before.Tests:
npm test -- apps/cli/remote-session/tests apps/cli/commands/ai/tests(150 passing)npm run typecheckPre-merge Checklist