Skip to content

Add recoverable listener session review#13

Merged
qyinm merged 4 commits into
mainfrom
listener-session-review
May 4, 2026
Merged

Add recoverable listener session review#13
qyinm merged 4 commits into
mainfrom
listener-session-review

Conversation

@qyinm
Copy link
Copy Markdown
Owner

@qyinm qyinm commented May 4, 2026

Summary

Adds persisted listener session state and a transcript chunk review surface for local STT sessions.

Why

Long recordings need recoverable runtime state and reviewable chunk evidence so interrupted or failed STT work can be inspected and retried without defaulting to whole-recording transcription.

Changes

  • Persist listener session lifecycle state in note metadata and expose recovering state after interrupted sessions.
  • Read latest stt-chunks.jsonl status into note detail for review.
  • Add Transcript tab runtime review UI with chunk status, errors, and targeted failed chunk retry.
  • Preserve runtime metadata on live transcript segments and support chunk retry options through preload/renderer.
  • Cover listener state normalization and latest chunk ledger selection in desktop main tests.

Validation:

  • npm run desktop:check
  • git diff --check HEAD~2..HEAD

Summary by CodeRabbit

  • New Features

    • Recording sessions now persistently track state, timestamps and recover across restarts.
    • Notes surface STT chunk ledger data so transcript chunks and their statuses are visible.
    • Transcript retry API accepts optional chunk filtering to retry specific chunks.
    • Live transcript segments include extra session and retry metadata for richer context.
  • Bug Fixes

    • Improved session state recovery and failure handling during start/stop flows.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 44b360d0-e0b1-4e6a-949f-8e3169d67483

📥 Commits

Reviewing files that changed from the base of the PR and between aad5aa4 and 3a715ac.

📒 Files selected for processing (1)
  • apps/desktop/main.cjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/desktop/main.cjs

📝 Walkthrough

Walkthrough

Persistent listener-session state per active note and STT chunk ledger loading were added. Session state is normalized, queued, and atomically persisted to note metadata across capture lifecycle events; notes now include parsed latest STT chunk records and related metadata.

Changes

Listener Session State & STT Chunk Persistence

Layer / File(s) Summary
Type Definitions
apps/desktop/src/types.ts
Added ListenerSessionState, STTChunkStatus, ListenerSession, STTChunk; extended NoteSummary, TranscriptSegment, NoteDetail; updated MirrorNoteAPI.retryTranscript signature to accept an optional options object with chunkIDs.
Core Session & Ledger Logic
apps/desktop/main.cjs
Added RECOVERABLE_LISTENER_SESSION_STATES, runtime state activeListenerSessionNoteId and listenerSessionWriteQueues; implemented normalizeListenerSessionState, listenerSessionFromMetadata, atomic writeListenerSessionState, and enqueueListenerSessionStateWrite; added noteIdFromCaptureEvent and persistCaptureEventSessionState; extended loadBundleSnapshot and noteSummaryFromRow to surface listenerSession; added parseSTTChunkLedgerJSONL (parses retryState, recordedAt) and latestSTTChunks(records) to select most-recent per chunkID; readNote now reads stt-chunks.jsonl and populates sttChunks; wired session persistence into broadcastCaptureEvent, handleStartCapture, and handleStopCapture; exported normalizeListenerSessionState and latestSTTChunks in test mode.
Preload IPC Bridge
apps/desktop/preload.cjs
mirrorNote.retryTranscript updated to accept (id, options) and forward both to ipcRenderer.invoke("transcript:retry", id, options).
App Integration
apps/desktop/src/App.tsx
appendLiveTranscriptSegment copies optional string fields sessionID, chunkID, eventType, retryState into segments when present; retryTranscript accepts optional chunkIDs?: string[] and conditionally calls api.retryTranscript with { chunkIDs }.
Tests
apps/desktop/main/native-launch.node-test.cjs
Imported and asserted normalizeListenerSessionState behavior; updated STT ledger test data to include recordedAt; replaced old ledger assertions with latestSTTChunks checks validating selected record IDs, retryState, and recordedAt.
sequenceDiagram
    actor User
    participant App as App.tsx
    participant Preload as preload.cjs
    participant Main as main.cjs
    participant FS as "File System"
    participant DB as "SQLite DB"

    User->>App: Start Capture
    App->>Preload: IPC startCapture
    Preload->>Main: startCapture event
    Main->>Main: set activeListenerSessionNoteId
    Main->>Main: normalizeListenerSessionState -> "recording"
    Main->>FS: writeListenerSessionState to metadata
    Main->>DB: sync metadata row
    Main-->>App: notify UI

    Main->>Main: broadcastCaptureEvent(stateChanged)
    Main->>Main: persistCaptureEventSessionState()
    Main->>FS: write updated metadata
    Main->>DB: sync

    User->>App: Stop Capture
    App->>Preload: IPC stopCapture
    Preload->>Main: stopCapture event
    Main->>Main: enqueue stopping -> completed writes
    Main->>FS: write stopping/completed
    Main->>DB: sync
    Main->>Main: clear activeListenerSessionNoteId
    Main-->>App: notify completion

    User->>App: Load Note
    App->>Preload: IPC readNote(id)
    Preload->>Main: readNote(id)
    Main->>FS: read metadata.json
    Main->>FS: read stt-chunks.jsonl
    Main->>Main: parseSTTChunkLedgerJSONL & latestSTTChunks
    Main-->>App: return NoteDetail with listenerSession & sttChunks
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰
I hop and store each listener's tale,
From start to stop, through wind and hail,
STT chunks lined up in a row,
Sessions marked where recordings go,
A rabbit cheers the saved playback trail.


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Review rate limit: 1/3 review remaining, refill in 37 minutes and 7 seconds.

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28fd2b0938

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/main.cjs Outdated
Comment thread apps/desktop/main.cjs
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a transcript runtime review feature, allowing users to monitor listener session states and individual STT chunk statuses. It includes backend updates for persisting session metadata and tracking active captures, alongside a new UI component in the transcript view for visualizing progress and retrying failed chunks. Feedback identifies a potential race condition in the metadata update logic, suggests improving error visibility by logging caught exceptions, and recommends adding default cases to state-to-label mapping functions for better robustness.

Comment thread apps/desktop/main.cjs
Comment thread apps/desktop/main.cjs Outdated
Comment thread apps/desktop/src/components/TranscriptView.tsx Outdated
@qyinm qyinm merged commit 0c7905b into main May 4, 2026
2 checks passed
@qyinm qyinm deleted the listener-session-review branch May 4, 2026 02:45
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