Skip to content

Keep listener state when restarting#1504

Merged
yujonglee merged 3 commits intomainfrom
listener-state-restart
Sep 28, 2025
Merged

Keep listener state when restarting#1504
yujonglee merged 3 commits intomainfrom
listener-state-restart

Conversation

@yujonglee
Copy link
Contributor

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 28, 2025

📝 Walkthrough

Walkthrough

Introduces streaming-based message handling in ListenerActor, restructures session supervision to optionally pass ListenerArgs on respawn, and refactors TranscriptManager to use a generic manager_offset and preloadable partial words via a builder. Public APIs and state fields are updated accordingly across listener, session, and manager components.

Changes

Cohort / File(s) Summary of changes
Listener streaming/message refactor
plugins/listener/src/actors/listener.rs
Added streaming ListenerMsg variants; ListenerState now holds args and TranscriptManager; pre_start builds manager with timestamp/partials; spawn_rx_task sends messages instead of inline processing; handle processes StreamResponse to emit partial/final events and update session; explicit handling for stream lifecycle errors/timeouts.
Session supervision and listener bootstrap
plugins/listener/src/actors/session.rs
Removed SessionState.session_start_ts_ms; start_listener now accepts optional ListenerArgs; supervision extracts prior ListenerState to reconstruct ListenerArgs (including partial_words_by_channel) on respawn; start paths pass None or build ListenerArgs from session_state.
TranscriptManager builder/time offset
plugins/listener/src/manager.rs
Added WordsByChannel type; replaced session_start_timestamp_ms with manager_offset across builder/struct; builder gains with_manager_offset and with_existing_partial_words; build initializes public fields id, partial_words_by_channel, manager_offset; append logic now uses manager_offset for time calculations.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Mic as Audio Source
  participant Stream as Stream Client
  participant RX as RX Task
  participant LA as ListenerActor
  participant TM as TranscriptManager
  participant Sess as SessionActor

  Note over LA,TM: Initialization (pre_start)
  LA->>TM: builder().with_manager_offset(ts?).with_existing_partial_words(...)
  TM-->>LA: TranscriptManager

  Mic->>Stream: Audio frames
  Stream-->>RX: StreamResponse / errors / lifecycle events

  rect rgba(200,230,255,0.3)
    RX->>LA: ListenerMsg::StreamResponse(result)
    LA->>TM: append/process words per channel
    LA-->>Sess: Emit PartialWords / FinalWords
    LA->>Sess: Update session with final words
  end

  alt Stream start failed
    RX->>LA: StreamStartFailed(err)
    LA->>LA: Stop
  else Stream error/timeout/end
    RX->>LA: StreamError/StreamTimeout/StreamEnded
    LA->>LA: Stop
  end
Loading
sequenceDiagram
  autonumber
  participant Sess as SessionActor
  participant LA as ListenerActor
  participant Prev as Previous ListenerState

  Note over Sess: Supervision on ListenerActor termination
  Sess->>Sess: maybe_state.extract(Prev?)
  alt Previous state exists
    Sess->>LA: start_listener(listener_args=Some(reconstructed from Prev: app, session_id, languages, onboarding, partial_words_by_channel))
  else No previous state
    Sess->>LA: start_listener(listener_args=None)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Wrap STT server with actor #1495 — Also refactors ListenerActor startup/shutdown and ListenerState fields; likely touches the same pre_start/spawn_rx_task paths.
  • pro model rollout 2 #1372 — Modifies TranscriptManager builder and word handling; overlaps with the manager offset and partial words changes here.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request has no author-provided description, leaving reviewers without any context or summary of the changeset. Please add a descriptive summary outlining the purpose of preserving listener state, the key modifications made across the listener, session, and manager modules, and how these changes fulfill the pull request’s objectives.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title “Keep listener state when restarting” accurately and concisely describes the primary functionality introduced by the pull request, namely preserving and reconstructing the listener’s partial transcript state upon actor restarts.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch listener-state-restart

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d15703 and 4611186.

📒 Files selected for processing (3)
  • plugins/listener/src/actors/listener.rs (5 hunks)
  • plugins/listener/src/actors/session.rs (4 hunks)
  • plugins/listener/src/manager.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit configuration file

**/*.{js,ts,tsx,rs}: 1. Do not add any error handling. Keep the existing one.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • plugins/listener/src/actors/listener.rs
  • plugins/listener/src/actors/session.rs
  • plugins/listener/src/manager.rs
🧬 Code graph analysis (1)
plugins/listener/src/actors/listener.rs (1)
plugins/listener/src/manager.rs (3)
  • builder (39-41)
  • words (56-59)
  • words (71-74)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ci (windows, windows-latest)
  • GitHub Check: ci (macos, macos-14)

@yujonglee yujonglee merged commit ed2480b into main Sep 28, 2025
14 checks passed
@yujonglee yujonglee deleted the listener-state-restart branch September 28, 2025 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant