Repository navigation
fix(live): one mic pipeline, one conversation per device, close idle sessions - #34
Merged
Merged
Conversation
A second tap while the mic was still connecting or opening started a second capture next to the first, and turning the mic "off" then stopped only one of them: the button said off while a track kept recording. AudioCapture now joins a start that is already open or opening instead of opening another mic, and a stop that lands mid-open releases whatever that open acquires. The mic button ignores taps while it is busy, and a session that ended while the mic was opening leaves it off. Browser repro (double-tap): 2 live mic tracks and 1 still live after "off" before; 1 track at 32 frames/s and none after "off" now. Bumps the cache version to 10. Refs #18 Co-authored-by: Claude Code <noreply@anthropic.com>
…lled app With Parley open in two windows, both could hold a conversation at once: two tutors talking over each other, each hearing the other through the mic. The app now keeps a random device id in localStorage and sends it with start. The server keeps one conversation per id: a newer start ends the older connection (even one still being set up) with code "replaced" and a plain message. In the browser, a BroadcastChannel claim makes the older window release its mic and socket at once and say why; a claim that arrives while it is still connecting cancels quietly. Browser repro (two-tabs): both tabs speaking before; now only the newer tab holds a conversation and the older one shows "Parley is open in another window". Refs #19 Co-authored-by: Claude Code <noreply@anthropic.com>
A tab left open, or a phone put down with the mic on, kept its tutor session running (and spending quota) until the upstream gave out. Each /live connection now closes after PARLEY_IDLE_TIMEOUT_MS (5 min by default, 0 disables it) without learner activity: transcribed speech, typed text or taps. Mic frames alone don't count, since an open mic streams silence too, and a socket that never starts is covered as well. The client is told why (code "idle") and its upstream and slot are freed. Leaving during setup and a second start on one socket were already closed by earlier fixes; their harness tests keep passing. Refs #20 Co-authored-by: Claude Code <noreply@anthropic.com>
…rror wording The takeover, idle and start-failure paths each sent an error and then closed the connection; they now share one helper, and the start failure carries a code too. The idle default sits with the other live timing defaults. The client keeps the wording for server error codes it owns (busy, replaced) in one table, and showError ignores an empty message, so the start-error wrapper goes. Co-authored-by: Claude Code <noreply@anthropic.com>
This was referenced Sep 29, 2026
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.
Stacked on #33 (
fix/honest-not-understood).What changes for the learner
BroadcastChanneltells the older window right away.start, and the server allows one conversation per id. This also covers a tab the phone has frozen, which cannot receive browser messages. An older conversation that is still connecting is ended too./liveconnection with no sign of the learner (speech, typed text or taps) forPARLEY_IDLE_TIMEOUT_MSis closed, and the app says why (code: "idle"). The default is 5 minutes, and0turns it off. Mic frames alone don't count, because an open mic also streams silence. A socket that never starts is closed the same way. Two cases from the issue were already fixed in fix(live): resume after upstream drops, never freeze, log session lifecycle #32, and their harness tests keep passing: a learner who leaves during setup, and a second start on the same socket.Public files changed, so the cache version is bumped to 10 (
?v=10inindex.html,CACHE_NAMEparley-v10, andsw.js?v=10).Closes #18
Closes #19
Closes #20
Test evidence
node scripts/repro-browser.mjs(headless Chrome, fake mic, real server, fake Gemini):Test suites. Both runs pass with 0 failures. The 2 remaining
todotests are outside this PR's scope: the thinking-state timer and ACCESS_TOKENS.GOOGLE_API_KEY=ci-placeholder-key npm test(node 26)/usr/bin/node --import tsx --test test/*.test.js(node 20)npm run typecheckis clean.New tests. I checked that each new test fails without its fix:
test/audio-capture.test.js: a start while opening joins it; a stop while opening releases the late mic; a start after a cancelled one opens exactly one mic; a failed open releases what it acquired.replacedand its upstream is closed. This also works while the older one is still being set up. Different devices don't affect each other.idle, the upstream is closed and the slot is freed, while transcribed speech and typed text keep the conversation open.PARLEY_IDLE_TIMEOUT_MSdefault,0to disable, and invalid values. data.js: the device id is created once and shared.No real-API run: these changes are about the connection lifecycle and never touch the Gemini setup or prompts.
🤖 Generated with Claude Code