[PR #1288] [MERGED] fix(calls): 1.1.1 — keep every recorded clip and stop cutting slow-checked speech (#1285) #1386

Closed
opened 2026-10-21 05:10:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Agents/pull/1288
Author: @SpicyMarinara
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/1285-calls-mic-cutoff


📝 Commits (2)

  • ae811f0 fix(calls): 1.1.1 — keep every recorded clip and stop cutting slow-checked speech (#1285)
  • 922b7c6 fix(calls): limit media uploads to one file and 16 fields

📊 Changes

19 files changed (+580 additions, -251 deletions)

View changed files

📝 .github/workflows/pull-request-checks.yml (+3 -0)
➕ artifacts/conversation-calls-1.1.1.zip (+0 -0)
📝 catalog/catalog.json (+8 -8)
📝 catalog/notes.json (+6 -0)
📝 catalog/v2/catalog.json (+8 -8)
📝 catalog/v2/notes.json (+6 -0)
📝 catalog/v3/catalog.json (+8 -8)
📝 catalog/v3/notes.json (+6 -0)
📝 packages/conversation-calls/CHANGELOG.md (+5 -0)
📝 packages/conversation-calls/client.js (+11 -11)
📝 packages/conversation-calls/manifest.json (+5 -5)
📝 packages/conversation-calls/server.mjs (+154 -154)
📝 packages/conversation-calls/src/engine/packages/client/src/components/chat/ConversationCallSurface.tsx (+13 -48)
➕ packages/conversation-calls/src/engine/packages/client/src/lib/call-mic-segmenter.ts (+62 -0)
📝 packages/conversation-calls/src/engine/packages/server/src/routes/conversation-calls.routes.ts (+7 -7)
➕ packages/conversation-calls/src/engine/packages/server/src/services/conversation/call-upload.ts (+39 -0)
📝 scripts/build-feature-packages.mjs (+3 -1)
➕ tests/calls-mic-segments.regression.ts (+235 -0)
📝 tests/conversation-calls-summary.regression.mjs (+1 -1)

📄 Description

Pull request

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #1285

Reported in Pasta-Devs/Marinara-Engine#7344 ("the mic cuts off before I've barely finished a sentence"). Follows Pasta-Devs/Marinara-Agents#1281 (Calls 1.1.0).

Why this change

  • In Mic recording calls, some clips were lost with "Selected provider/model cannot receive provider-native audio input." The upload route read its form fields as soon as it had read the audio file. The Calls client sends transcriptionMode (and every other field) after the file, so when the request arrived in pieces the field was not parsed yet. The clip was then sent down the provider-native path and failed. The speech was gone. The Pasta-Devs/Marinara-Agents#1281 verifier saw this in 1–2 of 12 uploads.
  • The maintainer asked whether end-of-speech detection broke ("It's supposed to detect longer pauses. Maybe something broke"). The history shows that the detector itself never changed (details below). It does have one real flaw. It decided "3 seconds of silence" from wall-clock time since the last loud check, not from quiet it had actually measured. Browsers run timers about once a second when a tab is hidden or covered, and late when the page is busy. Then three quiet samples a second apart, which land between words, ended a clip in the middle of a sentence.

What changed

Package conversation-calls 1.1.0 → 1.1.1. The staging catalog has published up to 1.1.0, and the only higher number ever used (1.0.18) was on a closed, unmerged branch.

Upload race (server)

  • New services/conversation/call-upload.ts → readCallUpload(req.parts(...)) reads every part of the upload. It buffers the first file with toBuffer(), so the route's existing 25 MB limit still applies (an oversized upload now gets 413 instead of being silently truncated). It collects every text field in whatever order it arrives. Because the route now reads the whole body, it also bounds it: files: 1, fields: 16 (the client sends one file and six fields). A second file gets 413. Too many fields are refused too: 413 on @fastify/multipart 9.4, and a "Premature close" 500 on 10.1. Fields keep @fastify/multipart's { value } shape, so the rest of POST /:id/media is unchanged.
  • The client form is built in use-conversation-calls.ts, which is still a vendored copy under sources/engine, not package-owned. Its field order is unchanged, and the server now handles either order. The soundboard upload has the same req.file() pattern. It is left alone because its only trailing field (name) falls back to the same file name the client sends.

Silence check (client)

  • The level-check decisions move out of the setInterval in ConversationCallSurface.tsx into a package-owned lib/call-mic-segmenter.ts (createCallMicSegmenter().check(rms, now, clipStartedAt) → start | speech | split | end | wait). The surface still owns the recorder, voicedMs/peakRms and the send filter.
  • The one behaviour change: a clip ends only after 3 s of quiet that the mic measured. A late check counts as at most two checks (240 ms). At the normal 120 ms cadence every decision is the same as before. With checks once a second (a hidden or covered tab), a real pause now ends the clip after about 13 s instead of 3 s, and short pauses no longer cut a sentence apart.
  • The CALL_MIC_* constants move unchanged into the new module, and the regression pins them.

History (step 3 of the investigation)

  • git log -S CALL_MIC_SILENCE_MS / -S CALL_MIC_RMS_CONTINUE / -G CALL_MIC_ on Marinara-Engine: the values have been set only once, in 73efb4e28 ("Add Conversation call support for v2.1.0", 2026-07-05). They were later moved unchanged during extraction (5610c23f9, Engine → Agents). The whole startRecording function, which holds the stream constraints (echoCancellation/noiseSuppression/autoGainControl), the AudioContext/analyser setup (fftSize 1024, smoothing 0.15), the timer, the start/continue thresholds, the timer reset on resumed speech, the 60 s split and the min-voiced/min-peak filter, is byte-identical in all 16 Engine revisions of the surface and in Calls 1.1.0. No threshold or timer was changed by mistake, so nothing is restored.
  • What did change: Marinara-Engine 7a44d5d9c (2026-07-10) added a one-clip gate that dropped any clip recorded while the previous one was being processed ("Still processing your last voice message"). Pasta-Devs/Marinara-Agents#571 narrowed it, and Pasta-Devs/Marinara-Agents#1281 (1.1.0) replaced it with a three-place queue. Together with the upload race above, these are the ways speech was actually being lost.
  • Checked and found correct at the normal cadence: the silence timer resets on every loud check; the analyser reads silence (not garbage) before it warms up; the 60 s split and the 180 ms / 0.022 filters cannot end a clip early (the filter only decides whether a finished clip is sent); nothing in the "Responding" state stops or pauses the recorder; the next clip starts on the first loud check after a clip ends.

Package and security impact

  • Affected package IDs: conversation-calls
  • Engine compatibility impact: none. engine.min stays 2.4.1. req.parts(), part.type and toBuffer() exist in @fastify/multipart 9.4 (Engine 2.4.1) and 10.1 (current Engine), and both were exercised (see checks).
  • New or changed permissions/entrypoints: none.
  • Restart, storage, update, or uninstall impact: none beyond the usual restart after updating.

Validation

  • node scripts/validate-catalog.mjs passes locally
  • git diff --check passes locally
  • Rebuilt every affected manifest, payload, artifact, and catalog entry
  • Installed or updated the affected package through Marinara Engine
  • Checked supported modes, restart behavior, and uninstall cleanup
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Manually verify that in a Mic recording + Local Whisper call, a dozen short clips in a row are all transcribed, and none fails with "Selected provider/model cannot receive provider-native audio input."
  • Manually verify that speaking with 1–2 second pauses in the foreground still sends one message, and that about 3 seconds of quiet still sends it (no change expected).
  • Manually verify that with the call tab hidden or covered by another window, a sentence with short pauses arrives as one message (it may take longer to send), in Chrome and in Safari.
  • Manually verify that the speaking indicator and interrupting a character's voice by talking over it still work.
  • Manually verify that uploading a soundboard sound and a provider-native audio/video call clip still work.

Agent-run checks: npm run check, npm run typecheck:packages, npm run test:security, the Calls regressions (calls-playback, calls-speech-to-text, new calls-mic-segments, conversation-calls-summary, calls-swarmui-video), node scripts/test-catalog-lanes.mjs, node scripts/validate-package-locales.mjs, node scripts/validate-package-locale-keys.mjs, node scripts/validate-catalog.mjs, node scripts/tests/catalog-release-notes.regression.mjs, node scripts/tests/catalog-generatedat-determinism.regression.mjs, node scripts/tests/vendored-engine.regression.mjs, node scripts/tests/ruleset-package.regression.mjs, node scripts/tests/ui-translation-retention.regression.mjs, node scripts/validate-pr-triage.mjs and git diff --check all pass. The same list passes on a pristine origin/staging worktree (83c4016d), and lint output is identical. Build: MARINARA_ENGINE_ROOT at Engine d71106851. At that root, rebuilding Calls 1.1.0 from pristine origin/staging changes nothing (byte for byte). Rebuilding this branch twice gives identical outputs. sources/engine and scripts/vendored-engine-baseline.json are unchanged. The CALL_MIC_* constants pass straight through, and the built client.js contains the new 240 ms cap; the regression checks it. Types: a strict tsc of the Calls files overlaid on Engine d71106851 sources, with the Engine's module augmentations loaded, reports only the pre-existing ProviderConnection error in the routes. That error is identical on pristine. req.parts() → readCallUpload and the new client module typecheck cleanly. Upload race, real parser (temporary script, not committed): a Fastify server using the Engine's own @fastify/multipart 10.1.1 received a 160 KB file part with its fields, and the body was split so that transcriptionMode arrived 30 ms after the file. The old req.file() pattern read transcriptionMode in 0/12 uploads; readCallUpload read it in 12/12. Both read it in 12/12 with the fields first or the body in one write. The same results hold with @fastify/multipart 9.4.0 (Engine 2.4.1). An oversized upload or a second file returns 413, and 17 fields are refused. Silence check, synthetic speech (temporary script, not committed): macOS say produced WAVs with pauses. The analyser's 1024-sample byte snapshot was emulated at every check and run through the old and new logic. In the foreground (with and without ±60 ms jitter) both give identical clips: pauses of 1.5/2.0/2.5 s stay in one clip at three voice levels, and 2.8 s of silence ends it. With 1-second checks, a hesitant sentence ("I think, … what I wanted to say is, … that the movie was, … how do you say, … a little bit boring") was cut into 3 clips by the old logic and kept as 1 by the new. The committed regression fails with wall-clock silence restored: 11 clips instead of 1. A real-browser run with Chromium's fake audio capture hung on getUserMedia in headless mode here, so it was not used. Local CodeRabbit (one run, on ae811f02): one finding, fixed in 922b7c6e. It said to bound the multipart upload now that every part is read (files/fields limits). The fix, the rebuild (byte-identical when rebuilt twice) and the full check list above were rerun after it. The release note wording ("background tab or behind other windows") changed in the same commit.

Documentation impact

  • No documentation changes needed
  • Updated this README catalog and package guidance
  • Updated linked Marinara Engine documentation

No documentation states the silence behaviour in hidden tabs. The package release notes cover it.

UI evidence (if applicable)

No visual change.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed microphone calls losing speech due to an audio input error.
    • Calls in background or covered tabs now wait for about three seconds of quiet before responding, reducing interruptions during natural pauses.
    • Improved media upload handling, including uploads with additional fields or multiple files.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Agents/pull/1288 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/1285-calls-mic-cutoff` --- ### 📝 Commits (2) - [`ae811f0`](https://github.com/Pasta-Devs/Marinara-Agents/commit/ae811f02fe1a8ba8cf7c8c8576bfdc55fb8fff8a) fix(calls): 1.1.1 — keep every recorded clip and stop cutting slow-checked speech (#1285) - [`922b7c6`](https://github.com/Pasta-Devs/Marinara-Agents/commit/922b7c6e9d689b089676808b148d6346ec579212) fix(calls): limit media uploads to one file and 16 fields ### 📊 Changes **19 files changed** (+580 additions, -251 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/pull-request-checks.yml` (+3 -0) ➕ `artifacts/conversation-calls-1.1.1.zip` (+0 -0) 📝 `catalog/catalog.json` (+8 -8) 📝 `catalog/notes.json` (+6 -0) 📝 `catalog/v2/catalog.json` (+8 -8) 📝 `catalog/v2/notes.json` (+6 -0) 📝 `catalog/v3/catalog.json` (+8 -8) 📝 `catalog/v3/notes.json` (+6 -0) 📝 `packages/conversation-calls/CHANGELOG.md` (+5 -0) 📝 `packages/conversation-calls/client.js` (+11 -11) 📝 `packages/conversation-calls/manifest.json` (+5 -5) 📝 `packages/conversation-calls/server.mjs` (+154 -154) 📝 `packages/conversation-calls/src/engine/packages/client/src/components/chat/ConversationCallSurface.tsx` (+13 -48) ➕ `packages/conversation-calls/src/engine/packages/client/src/lib/call-mic-segmenter.ts` (+62 -0) 📝 `packages/conversation-calls/src/engine/packages/server/src/routes/conversation-calls.routes.ts` (+7 -7) ➕ `packages/conversation-calls/src/engine/packages/server/src/services/conversation/call-upload.ts` (+39 -0) 📝 `scripts/build-feature-packages.mjs` (+3 -1) ➕ `tests/calls-mic-segments.regression.ts` (+235 -0) 📝 `tests/conversation-calls-summary.regression.mjs` (+1 -1) </details> ### 📄 Description # Pull request > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #1285 Reported in Pasta-Devs/Marinara-Engine#7344 ("the mic cuts off before I've barely finished a sentence"). Follows Pasta-Devs/Marinara-Agents#1281 (Calls 1.1.0). ## Why this change - In Mic recording calls, some clips were lost with "Selected provider/model cannot receive provider-native audio input." The upload route read its form fields as soon as it had read the audio file. The Calls client sends `transcriptionMode` (and every other field) after the file, so when the request arrived in pieces the field was not parsed yet. The clip was then sent down the provider-native path and failed. The speech was gone. The Pasta-Devs/Marinara-Agents#1281 verifier saw this in 1–2 of 12 uploads. - The maintainer asked whether end-of-speech detection broke ("It's supposed to detect longer pauses. Maybe something broke"). The history shows that the detector itself never changed (details below). It does have one real flaw. It decided "3 seconds of silence" from wall-clock time since the last loud check, not from quiet it had actually measured. Browsers run timers about once a second when a tab is hidden or covered, and late when the page is busy. Then three quiet samples a second apart, which land between words, ended a clip in the middle of a sentence. ## What changed Package `conversation-calls` **1.1.0 → 1.1.1**. The staging catalog has published up to 1.1.0, and the only higher number ever used (1.0.18) was on a closed, unmerged branch. **Upload race (server)** - New `services/conversation/call-upload.ts` → `readCallUpload(req.parts(...))` reads every part of the upload. It buffers the first file with `toBuffer()`, so the route's existing 25 MB limit still applies (an oversized upload now gets 413 instead of being silently truncated). It collects every text field in whatever order it arrives. Because the route now reads the whole body, it also bounds it: `files: 1, fields: 16` (the client sends one file and six fields). A second file gets 413. Too many fields are refused too: 413 on `@fastify/multipart` 9.4, and a "Premature close" 500 on 10.1. Fields keep `@fastify/multipart`'s `{ value }` shape, so the rest of `POST /:id/media` is unchanged. - The client form is built in `use-conversation-calls.ts`, which is still a vendored copy under `sources/engine`, not package-owned. Its field order is unchanged, and the server now handles either order. The soundboard upload has the same `req.file()` pattern. It is left alone because its only trailing field (`name`) falls back to the same file name the client sends. **Silence check (client)** - The level-check decisions move out of the `setInterval` in `ConversationCallSurface.tsx` into a package-owned `lib/call-mic-segmenter.ts` (`createCallMicSegmenter().check(rms, now, clipStartedAt)` → `start | speech | split | end | wait`). The surface still owns the recorder, `voicedMs`/`peakRms` and the send filter. - The one behaviour change: a clip ends only after 3 s of quiet that the mic **measured**. A late check counts as at most two checks (240 ms). At the normal 120 ms cadence every decision is the same as before. With checks once a second (a hidden or covered tab), a real pause now ends the clip after about 13 s instead of 3 s, and short pauses no longer cut a sentence apart. - The `CALL_MIC_*` constants move unchanged into the new module, and the regression pins them. **History (step 3 of the investigation)** - `git log -S CALL_MIC_SILENCE_MS` / `-S CALL_MIC_RMS_CONTINUE` / `-G CALL_MIC_` on Marinara-Engine: the values have been set only once, in 73efb4e28 ("Add Conversation call support for v2.1.0", 2026-07-05). They were later moved unchanged during extraction (5610c23f9, Engine → Agents). The whole `startRecording` function, which holds the stream constraints (`echoCancellation`/`noiseSuppression`/`autoGainControl`), the AudioContext/analyser setup (`fftSize` 1024, smoothing 0.15), the timer, the start/continue thresholds, the timer reset on resumed speech, the 60 s split and the min-voiced/min-peak filter, is **byte-identical** in all 16 Engine revisions of the surface and in Calls 1.1.0. No threshold or timer was changed by mistake, so nothing is restored. - What did change: Marinara-Engine 7a44d5d9c (2026-07-10) added a one-clip gate that dropped any clip recorded while the previous one was being processed ("Still processing your last voice message"). Pasta-Devs/Marinara-Agents#571 narrowed it, and Pasta-Devs/Marinara-Agents#1281 (1.1.0) replaced it with a three-place queue. Together with the upload race above, these are the ways speech was actually being lost. - Checked and found correct at the normal cadence: the silence timer resets on every loud check; the analyser reads silence (not garbage) before it warms up; the 60 s split and the 180 ms / 0.022 filters cannot end a clip early (the filter only decides whether a finished clip is sent); nothing in the "Responding" state stops or pauses the recorder; the next clip starts on the first loud check after a clip ends. ## Package and security impact - Affected package IDs: `conversation-calls` - Engine compatibility impact: none. `engine.min` stays 2.4.1. `req.parts()`, `part.type` and `toBuffer()` exist in `@fastify/multipart` 9.4 (Engine 2.4.1) and 10.1 (current Engine), and both were exercised (see checks). - New or changed permissions/entrypoints: none. - Restart, storage, update, or uninstall impact: none beyond the usual restart after updating. ## Validation - [ ] `node scripts/validate-catalog.mjs` passes locally - [ ] `git diff --check` passes locally - [ ] Rebuilt every affected manifest, payload, artifact, and catalog entry - [ ] Installed or updated the affected package through Marinara Engine - [ ] Checked supported modes, restart behavior, and uninstall cleanup - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Manually verify that in a **Mic recording + Local Whisper** call, a dozen short clips in a row are all transcribed, and none fails with "Selected provider/model cannot receive provider-native audio input." - Manually verify that speaking with 1–2 second pauses in the foreground still sends one message, and that about 3 seconds of quiet still sends it (no change expected). - Manually verify that with the call tab hidden or covered by another window, a sentence with short pauses arrives as one message (it may take longer to send), in Chrome and in Safari. - Manually verify that the speaking indicator and interrupting a character's voice by talking over it still work. - Manually verify that uploading a soundboard sound and a provider-native audio/video call clip still work. Agent-run checks: `npm run check`, `npm run typecheck:packages`, `npm run test:security`, the Calls regressions (`calls-playback`, `calls-speech-to-text`, new `calls-mic-segments`, `conversation-calls-summary`, `calls-swarmui-video`), `node scripts/test-catalog-lanes.mjs`, `node scripts/validate-package-locales.mjs`, `node scripts/validate-package-locale-keys.mjs`, `node scripts/validate-catalog.mjs`, `node scripts/tests/catalog-release-notes.regression.mjs`, `node scripts/tests/catalog-generatedat-determinism.regression.mjs`, `node scripts/tests/vendored-engine.regression.mjs`, `node scripts/tests/ruleset-package.regression.mjs`, `node scripts/tests/ui-translation-retention.regression.mjs`, `node scripts/validate-pr-triage.mjs` and `git diff --check` all pass. The same list passes on a pristine `origin/staging` worktree (`83c4016d`), and lint output is identical. **Build:** `MARINARA_ENGINE_ROOT` at Engine `d71106851`. At that root, rebuilding Calls 1.1.0 from pristine `origin/staging` changes nothing (byte for byte). Rebuilding this branch twice gives identical outputs. `sources/engine` and `scripts/vendored-engine-baseline.json` are unchanged. The `CALL_MIC_*` constants pass straight through, and the built `client.js` contains the new 240 ms cap; the regression checks it. **Types:** a strict `tsc` of the Calls files overlaid on Engine `d71106851` sources, with the Engine's module augmentations loaded, reports only the pre-existing `ProviderConnection` error in the routes. That error is identical on pristine. `req.parts()` → `readCallUpload` and the new client module typecheck cleanly. **Upload race, real parser (temporary script, not committed):** a Fastify server using the Engine's own `@fastify/multipart` 10.1.1 received a 160 KB file part with its fields, and the body was split so that `transcriptionMode` arrived 30 ms after the file. The old `req.file()` pattern read `transcriptionMode` in **0/12** uploads; `readCallUpload` read it in **12/12**. Both read it in 12/12 with the fields first or the body in one write. The same results hold with `@fastify/multipart` 9.4.0 (Engine 2.4.1). An oversized upload or a second file returns 413, and 17 fields are refused. **Silence check, synthetic speech (temporary script, not committed):** macOS `say` produced WAVs with pauses. The analyser's 1024-sample byte snapshot was emulated at every check and run through the old and new logic. In the foreground (with and without ±60 ms jitter) both give identical clips: pauses of 1.5/2.0/2.5 s stay in one clip at three voice levels, and 2.8 s of silence ends it. With 1-second checks, a hesitant sentence ("I think, … what I wanted to say is, … that the movie was, … how do you say, … a little bit boring") was cut into 3 clips by the old logic and kept as 1 by the new. The committed regression fails with wall-clock silence restored: 11 clips instead of 1. A real-browser run with Chromium's fake audio capture hung on `getUserMedia` in headless mode here, so it was not used. **Local CodeRabbit** (one run, on `ae811f02`): one finding, fixed in `922b7c6e`. It said to bound the multipart upload now that every part is read (`files`/`fields` limits). The fix, the rebuild (byte-identical when rebuilt twice) and the full check list above were rerun after it. The release note wording ("background tab or behind other windows") changed in the same commit. ## Documentation impact - [ ] No documentation changes needed - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation No documentation states the silence behaviour in hidden tabs. The package release notes cover it. ## UI evidence (if applicable) No visual change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Fixed microphone calls losing speech due to an audio input error. - Calls in background or covered tabs now wait for about three seconds of quiet before responding, reducing interruptions during natural pauses. - Improved media upload handling, including uploads with additional fields or multiple files. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-21 05:10:12 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Agents#1386
No description provided.