Skip to content

Fix: pause local audio on room stop/play#43

Open
beastyrabbit wants to merge 1 commit intomainfrom
fix/stop-immediate-local-pause
Open

Fix: pause local audio on room stop/play#43
beastyrabbit wants to merge 1 commit intomainfrom
fix/stop-immediate-local-pause

Conversation

@beastyrabbit
Copy link
Copy Markdown
Owner

Summary

  • Pause local audio immediately for room stop/play commands

Somewhere a GPU is overheating so I don't have to think.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 22, 2026

Greptile Summary

This PR adds optimistic local audio control for room-mode play and pause commands, reducing the perceived latency between issuing a command and hearing the audio respond. Previously, the client had to wait for the server to echo back an execute message before ffplay acted; now play/pause is applied immediately on the local engine while the room command travels over the wire.

  • For pause: this.ffplay.pause() and this.playback.isPlaying = false are set immediately after sendCommand("pause"), matching the existing local-mode behaviour.
  • For play: this.ffplay.play() and this.playback.isPlaying = true are set immediately after sendCommand("play"), giving the same low-latency feel.
  • The ordering is safe: sendCommand() throws synchronously when the daemon is not connected, so the optimistic ffplay calls are only reached when the command was successfully dispatched.
  • Eventual consistency is maintained — incoming state messages from the server overwrite this.playback entirely (line 564), so any brief mismatch resolves itself quickly.
  • The toggle case in room mode is intentionally left without optimistic handling, since the target state is ambiguous without knowing the current server state.

Confidence Score: 5/5

  • Safe to merge — targeted, low-risk change that correctly mirrors existing local-mode behaviour for room-mode play/pause.
  • The diff is six lines across two symmetric hunks. The play/pause calls are placed after sendCommand(), so they are unreachable when the daemon is disconnected. Server state messages will reconcile any optimistic mismatch, and the engine's play/pause are idempotent when the server later echoes the execute message. No new error paths or state corruption vectors are introduced.
  • No files require special attention.

Important Files Changed

Filename Overview
apps/cli/src/daemon/runtime.ts Adds optimistic local audio play/pause for room mode commands, mirroring existing local-mode behavior and reducing perceived latency. Logic is sound: sendCommand() either throws or sends, so ffplay calls only execute on successful dispatch, and server state messages will overwrite optimistic playback state when they arrive.

Reviews (1): Last reviewed commit: "fix(cli): pause local audio immediately ..." | Re-trigger Greptile

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