feat: add record subcommand for session recording#2
Merged
Conversation
Move output.ts, session.ts, ui.ts, websocket.ts, and worker.ts into src/replay/ to cleanly separate replay concerns from the upcoming record feature. Update all import paths in source and test files.
Add events module with discriminated union types for recording events (REQ_HOME, REQ_SINF, WS_OPEN, WS_RECV, WS_SEND, WS_CLOSE), token replacement for session-specific values, and a RecordingWriter that streams events to .log files in the shinycannon recording format.
Implement RecordingProxy that sits between the browser and a Shiny app, intercepting HTTP and WebSocket traffic. HTTP requests are forwarded to the target app with REQ_HOME captured on initial GET. WebSocket messages are relayed bidirectionally, recording WS_OPEN/RECV/SEND/CLOSE events with relative timestamps. Includes token discovery for session IDs, worker IDs, and Shiny tokens, plus graceful shutdown with active connection tracking and a 500ms grace period.
Add record orchestrator that coordinates the recording lifecycle: starts the reverse proxy, waits for the first browser connection, handles Ctrl+C for graceful shutdown, and writes the final recording file. Add RecordTerminalUI with ora spinners showing live event count, connection status, timestamps, and a quit hint.
Wire up the record orchestrator as 'shinyloadtest record <app-url>' with options for output file, port, and open-browser. Update main.ts to route to replay-specific modules under src/replay/.
Add comprehensive tests for the recording feature: - record-events: event creation and serialization - record-tokens: token discovery and replacement - record-writer: file writing and event counting - record-proxy: HTTP reverse proxy behavior - record-ws-proxy: WebSocket relay and message recording - record-e2e: full lifecycle integration test - cli: record subcommand argument parsing
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
Adds a
shinyloadtest recordsubcommand that captures a user's interaction with a Shiny app into a recording file for later replay withshinyloadtest replay.The recording system works as a reverse proxy that sits between the browser and the Shiny app, intercepting HTTP and WebSocket traffic. Key components:
REQ_HOMEWS_OPEN,WS_RECV,WS_SEND, andWS_CLOSEevents with relative timestamps.logfile in the existing shinycannon recording formatoraspinnersAlso refactors replay-specific modules (
output.ts,session.ts,ui.ts,websocket.ts,worker.ts) intosrc/replay/to cleanly separate concerns.Verification
Tests: 6 new test files with ~1450 lines covering events, tokens, writer, HTTP proxy, WS proxy, and E2E lifecycle.