Skip to content

CLI: stream remote-session activity to stdout while the REPL is blocked - #3282

Merged
gcsecsey merged 4 commits into
trunkfrom
gcsecsey/cli-remote-stream-logs
Apr 30, 2026
Merged

CLI: stream remote-session activity to stdout while the REPL is blocked#3282
gcsecsey merged 4 commits into
trunkfrom
gcsecsey/cli-remote-stream-logs

Conversation

@gcsecsey

@gcsecsey gcsecsey commented Apr 29, 2026

Copy link
Copy Markdown
Member

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.

  • RemoteSessionLogger now takes an options object ({ logPath?, mirrorToStdout? }). When mirrorToStdout is 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.
  • runRemoteSession constructs the logger with { mirrorToStdout: true }. Debug-level lines stay suppressed unless STUDIO_REMOTE_DEBUG=1, matching the file behavior.
  • The structured ~/.studio/remote-session.log file continues to receive the full NDJSON record. No format change there.

Testing Instructions

  • npm run cli:build
  • STUDIO_ENABLE_REMOTE_SESSION=true node apps/cli/dist/cli/main.mjs code --remote-session
  • Send a message from Telegram and check that you see the log streaming to stdout
  • tail -f ~/.studio/remote-session.log should still receive the full entries
  • Without --remote-session, the regular interactive studio code REPL should produce no extra log lines on stdout.
Telegram Before After
CleanShot 2026-04-29 at 16 49 21@2x CleanShot 2026-04-29 at 16 49 04@2x CleanShot 2026-04-29 at 16 47 58@2x

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@wpmobilebot

wpmobilebot commented Apr 29, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 29f1a2b vs trunk

app-size

Metric trunk 29f1a2b Diff Change
App Size (Mac) 1454.75 MB 1454.75 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk 29f1a2b Diff Change
load 1768 ms 1818 ms +50 ms 🔴 2.8%

site-startup

Metric trunk 29f1a2b Diff Change
siteCreation 8073 ms 8105 ms +32 ms ⚪ 0.0%
siteStartup 4956 ms 4945 ms 11 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RemoteSessionLogger to accept { logPath?, mirrorToStdout? }, mirror non-suppressed logs to stdout, and add an event() 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.

Comment thread apps/cli/remote-session/tests/logger.test.ts Outdated
Comment thread apps/cli/remote-session/logger.ts
Comment thread apps/cli/remote-session/poll-loop.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RemoteSessionLogger to accept an options object and optionally mirror non-suppressed log lines to stdout, plus a new event() 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.

Comment thread apps/cli/remote-session/tests/logger.test.ts Outdated
@gcsecsey
gcsecsey requested a review from epeicher April 29, 2026 16:06

@epeicher epeicher left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great @gcsecsey! That works perfectly, LGTM!

Telegram Local terminal
Image Image
@gcsecsey
gcsecsey merged commit 4ef07bb into trunk Apr 30, 2026
12 checks passed
@gcsecsey
gcsecsey deleted the gcsecsey/cli-remote-stream-logs branch April 30, 2026 14:27
gcsecsey added a commit that referenced this pull request May 1, 2026
- `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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants