CLI: stream remote-session activity to stdout while the REPL is blocked - #3282
Conversation
📊 Performance Test ResultsComparing 29f1a2b 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) |
There was a problem hiding this comment.
Pull request overview
Adds stdout mirroring for remote-session activity so studio code --remote-session shows live progress in the same terminal while the REPL is blocked, without changing the existing NDJSON log file behavior.
Changes:
- Extend
RemoteSessionLoggerto accept{ logPath?, mirrorToStdout? }, mirror non-suppressed logs to stdout, and add anevent()API for stdout-only “conversation content” lines. - Emit streamed
event()lines for polled Telegram messages, turn progress/info/errors, replies, and paused questions while attached. - Update/expand tests to cover stdout mirroring, redaction, and
event()behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/cli/remote-session/logger.ts | Adds options-based constructor, stdout mirroring, and event() streaming API. |
| apps/cli/remote-session/index.ts | Enables stdout mirroring for --remote-session runs. |
| apps/cli/remote-session/poll-loop.ts | Streams full inbound message text to stdout via logger.event(). |
| apps/cli/remote-session/turn-runner.ts | Streams subprocess progress/info/errors, replies, and questions to stdout via logger.event(). |
| apps/cli/remote-session/tests/logger.test.ts | Adds coverage for stdout mirroring + event() behavior and redaction. |
| apps/cli/remote-session/tests/poll-loop.test.ts | Updates logger construction for new options signature. |
| apps/cli/remote-session/tests/progress-streamer.test.ts | Updates logger construction for new options signature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Adds stdout streaming for studio code --remote-session so users can see live session activity while the interactive REPL is blocked, while preserving the existing structured NDJSON file log.
Changes:
- Extend
RemoteSessionLoggerto accept an options object and optionally mirror non-suppressed log lines to stdout, plus a newevent()API for stdout-only “activity” lines. - Emit
logger.event(...)for polled Telegram messages and key subprocess/turn events (progress/info/error, replies, paused questions). - Add/adjust Vitest coverage for stdout mirroring, terminal-control stripping, and updated logger constructor usage.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| apps/cli/remote-session/logger.ts | Adds stdout mirroring + event() streaming and terminal-control sanitization/redaction for stdout output. |
| apps/cli/remote-session/index.ts | Enables stdout mirroring when running --remote-session. |
| apps/cli/remote-session/poll-loop.ts | Streams the full (trimmed) incoming message body to stdout via logger.event('message', ...). |
| apps/cli/remote-session/turn-runner.ts | Streams subprocess progress/info/error, replies, and paused questions to stdout via logger.event(...). |
| apps/cli/remote-session/tests/logger.test.ts | Adds tests for stripTerminalControls, stdout mirroring, and event() behavior; updates constructor usage. |
| apps/cli/remote-session/tests/poll-loop.test.ts | Updates logger construction to the new options-object API. |
| apps/cli/remote-session/tests/progress-streamer.test.ts | Updates logger construction to the new options-object API. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- `media-streamer.test.ts`: `RemoteSessionLogger`'s constructor signature changed in trunk (#3282) from `(logPath: string)` to `(options: RemoteSessionLoggerOptions)`. Update the five test call sites to use `{ logPath: '/dev/null' }`. - `top-bar.tsx`: drop unused `useEffect`, `useRef`, `useAppDispatch`, and `openWapuuWorld` imports (leftover from #3270).


Related issues
How AI was used in this PR
Claude Code wrote the implementation and tests. I reviewed the logger changes, the stdout line format, and the redaction behavior, then ran typecheck/tests/lint locally to verify.
Proposed Changes
When running
studio code --remote-session, the REPL is blocked while the poll loop runs.This PR mirrors the structured log to stdout while attached, so session activity shows up in the same terminal that is otherwise idle.
RemoteSessionLoggernow takes an options object ({ logPath?, mirrorToStdout? }). WhenmirrorToStdoutis set, every non-suppressed log call also writes a human-readable line to stdout ([HH:MM:SS] level message {meta-as-JSON}) using the same redaction as the file sink. Stdout writes are best-effort and never throw.runRemoteSessionconstructs the logger with{ mirrorToStdout: true }. Debug-level lines stay suppressed unlessSTUDIO_REMOTE_DEBUG=1, matching the file behavior.~/.studio/remote-session.logfile continues to receive the full NDJSON record. No format change there.Testing Instructions
npm run cli:buildSTUDIO_ENABLE_REMOTE_SESSION=true node apps/cli/dist/cli/main.mjs code --remote-sessiontail -f ~/.studio/remote-session.logshould still receive the full entries--remote-session, the regular interactivestudio codeREPL should produce no extra log lines on stdout.Pre-merge Checklist