Skip to content

feat(app): allow Custom STT to keep raw audio off Omi - #10447

Merged
undivisible merged 5 commits into
BasedHardware:mainfrom
LauraGPT:codex/custom-stt-forwarding-policy
Aug 16, 2026
Merged

undivisible merged 5 commits into
BasedHardware:mainfrom
LauraGPT:codex/custom-stt-forwarding-policy

Conversation

@LauraGPT

@LauraGPT LauraGPT commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

What changed and why

Adds a default-on Send raw audio to Omi setting for Custom STT. When disabled, binary audio frames go only to the selected STT provider; transcripts and non-audio data used by Omi cloud features can still reach the Omi socket. If the connected device uses a codec unsupported by Custom STT, the app fails closed instead of creating the default Omi audio socket; fallback to Omi remains available only when raw forwarding is explicitly enabled.

The setting is persisted per provider, participates in the STT config identity, survives import/export, and is explained in all 49 app locales. Provider source changes restore each provider's own value.

Android Background Mode now enforces the same policy twice: Dart reconciles the effective native-streaming preference whenever STT settings or capture mode changes, and the native streamer independently checks the persisted Custom STT policy before opening or using its Omi socket. Malformed policy state fails closed. The unsupported-codec block also arms the normal keep-alive retry so transcription recovers when the blocking condition clears.

The follow-up on 6312a1cf80f1a20843ca72127333baa9cc90b147 also rejects non-boolean forwarding values, re-checks the persisted policy before and during queued-frame flush after a native socket handshake, fails closed on malformed Dart preferences, and exercises an actual later recovery attempt after forwarding is re-enabled.

This implements the boolean first increment proposed in #10431. A fully local mode that removes the Omi socket and cloud persistence remains outside this PR.

Refs #10431

Product invariants affected

none

How it was verified

  • Exact head 6312a1cf80f1a20843ca72127333baa9cc90b147 includes the signed review-fix commit above d2b880efdcbaaca6e7afe430620153fb395db616, which merges main@971b497a56aea0229ee44798a322b483f63d4be0; both commits carry DCO sign-offs.
  • The prior three red jobs were reproduced from Actions run 31476665774: all stopped at flutter pub get because the stale branch pinned intl 0.20.2 while the moving stable SDK required ^0.20.3. The PR did not introduce that pin; current main supplies the SDK/constraint compatibility fix.
  • With the repository-pinned Flutter 3.44.5, flutter pub get passed and left pubspec.yaml and pubspec.lock byte-identical.
  • The four targeted Flutter test files passed 89/89 tests, covering forwarding policy, strict config parsing, codec fallback, native-stream policy, and actual recovery after forwarding is re-enabled.
  • The analyzer ratchet passed (sort_child_properties_last: 1 current finding versus baseline 2).
  • Full bash test.sh --reporter compact passed all 1,306 App tests.
  • dart run build_runner build plus flutter gen-l10n produced no tracked or untracked generated-code drift.
  • The normal pre-push gate passed against the 112-file PR diff: all 12 local-lane contract/hygiene checks, l10n generation, Dart formatting (60 files, 0 changed), and ARB formatting (49 files) passed.
  • Android CustomSttRawAudioPolicyTest previously passed 4/4 on parent head 3d1a173; the current five-test suite and native streamer compile could not rerun locally because the designated ind-gpu8 host has no Android SDK/JDK, so platform verification remains explicitly deferred to GitHub CI.
  • GitHub Actions for the forked new head are currently action_required and need a maintainer to approve the workflow runs; this is a permission gate, not a code failure.
  • The settings page was exercised by a widget test at a phone-sized viewport; it was not manually exercised on a physical device.

Tests

  • app/test/unit/custom_stt_config_test.dart covers migration default, JSON round trip, and config identity.
  • app/test/unit/composite_transcription_socket_test.dart covers binary frame blocking, default compatibility, transcript forwarding, control-message forwarding, factory wiring, and the unsupported-codec fallback policy with forwarding enabled and disabled.
  • app/test/widgets/transcription_settings_forwarding_test.dart covers a full on-device/cloud/on-device provider round trip, restored per-provider values, the Material switch surface, and the phone-sized resource-warning dialog.
  • app/test/providers/capture_provider_test.dart covers fail-closed Android Background Mode policy and retry scheduling after an unsupported Custom STT codec is blocked.
  • app/android/app/src/test/kotlin/com/friend/ios/batch/CustomSttRawAudioPolicyTest.kt covers default Omi behavior, Custom STT opt-in/opt-out, and malformed-state fail-closed behavior.

Failure class (fixes)

Failure-Class: none

Review in cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @LauraGPT — this is a well-structured PR. The core change is clean: CompositeTranscriptionSocket.send() blocks only List<int> (binary audio frames) from the Omi secondary socket when forwarding is off, while transcripts and control messages still flow through. The backward-compatible default (true), per-provider persistence, config-identity participation, and 49-locale coverage are all solid, and the three new test files cover the important paths (frame blocking, transcript forwarding, config round-trip/identity, per-provider widget restoration).

Flagging for human maintainer review before merge:

  • Product direction: This is a user-facing privacy control over raw audio forwarding — the default value, toggle placement, and whether a fully-local mode (mentioned as out of scope, ref Allow Custom STT to disable the secondary Omi socket for a true local-only audio path #10431) should land together are product calls.
  • Data-handling surface: The toggle changes what audio data reaches Omi cloud. While the change is privacy-enhancing and the default preserves existing behavior, confirming the data-flow invariants (especially that no cloud feature silently breaks when raw audio is withheld) warrants a maintainer pass.

No blockers found in the implementation itself. Labeled for maintainer review.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added needs-maintainer-review Needs a human maintainer to sign off before merge transcription labels Jul 24, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

feat(app) allow Custom STT to keep raw audio off Omi — approve only (mobile feature)

@Dr-Amp

Dr-Amp commented Jul 25, 2026

Copy link
Copy Markdown

Thanks @LauraGPT for landing the first, backward-compatible privacy increment here. I have prepared the full localOnly follow-up described in #10431, built directly on this PR's commit 98e953fde4 so the original authorship and commit remain intact.

I have deliberately not opened a competing PR. The implementation branch, verification evidence, known rebase limitation, and the question of one follow-up PR versus a small stacked series are documented here:

Once maintainers indicate the preferred review shape—and ideally after this approved PR merges—I will rebase the follow-up onto current main, resolve the known integration conflicts, rerun the canonical checks, and open the formal PR(s).

@LauraGPT

Copy link
Copy Markdown
Contributor Author

@Git-on-my-level need human response. This PR now has human approval from @kodjima33, is mergeable, and its only reported gate is the product/data-flow decision.

Could a maintainer confirm these two points?

  1. Keep forwardAudioToOmi defaulting to true, so existing cloud behavior remains unchanged unless the user explicitly opts out.
  2. Merge this bounded raw-audio privacy control independently, while the broader fully-local localOnly flow in Allow Custom STT to disable the secondary Omi socket for a true local-only audio path #10431 remains a follow-up.

The implementation still forwards transcripts/control messages and only suppresses binary audio frames on the Omi secondary socket when disabled. If those two product choices are acceptable, this approved PR should be ready for the maintainer-review label to be cleared and merged.

@LauraGPT

LauraGPT commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Synced this PR with current main@812e3aca0380b1c832b6bc59223a9e8ebb44366d and pushed signed merge head ca5105d8b4a28ed67a2113e16a40af396ff31d62.

Fresh verification on the merged tree:

  • complete Flutter test suite: 1,026 passed
  • focused forwarding/config/socket tests: 9 passed
  • analyzer ratchet: passed
  • make preflight: 11/11 checks passed against exact current main
  • repository pre-push gate: passed
  • localization outputs regenerated with the repository's flutter gen-l10n workflow

GitHub now reports the PR mergeable; the prior approval remains in place. The Cubic review check is currently running on the new head.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 106 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Re-reviewed on d40e9d4ac6.

The fail-open concern raised by the Cubic P1 (disabling this setting still let raw audio reach Omi via the default-socket fallback when the device codec was unsupported by Custom STT) is resolved: CaptureController now fails closed for that combination — it nulls and marks the socket unready before shutdown, and refuses to create the default Omi socket — so the privacy control holds when raw forwarding is off. The widget warning now reports transcription unavailable for the blocked combination, and the P3 items (round-trip widget coverage and the duplicate _checkLocalModel call) are also addressed on this head.

The core mechanism remains clean: CompositeTranscriptionSocket.send() gates only List<int> (binary audio frames) to the Omi secondary socket, while transcripts and non-audio control messages continue to flow; the default stays true, so existing cloud behavior is unchanged unless a user explicitly opts out. Backward-compatible default, per-provider persistence, config-identity participation, export/import, and the focused tests all look solid.

This is a user-facing privacy control over raw audio forwarding to Omi cloud, so the remaining gate is the human product call already on this PR: confirm the true default, the toggle placement, and whether the broader fully-local mode (#10431) should remain a follow-up. That decision is for a maintainer; not something this review can clear. needs-maintainer-review stays.

Thanks @LauraGPT — nice, well-scoped first increment.


by AI on behalf of David — if you need David's attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added the flutter flutter work label Aug 3, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-approve on new head: Custom STT keeps raw audio off Omi — feature, approve-only per policy.

@LauraGPT

LauraGPT commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Implementation update (exact head 3d1a17301949edbec2eef6b9ff8d31f35dd5d0d0): both Cubic privacy findings are addressed. Android Background Mode now has a Dart reconciliation gate plus an independent native fail-closed policy check before opening or using the Omi raw-audio socket; malformed persisted Custom STT state also blocks raw audio. The unsupported-codec blocked path now disables native streaming and starts keep-alive recovery. Verification: 70/70 capture-provider tests, 4/4 Android policy tests with the dev-debug app source compiled, 1,198/1,198 full Flutter tests, targeted production analysis clean, and the repository pre-push gate passed.

@undivisible undivisible added human Human-authored pull request app mobile labels Aug 10, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 107 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Static review of the key logic files (head 3d1a173), as glm-5.2:

CustomSttRawAudioPolicy.kt — Clean fail-closed design. Malformed JSON returns false, the provider defaults to "omi", and send_raw_audio_to_omi defaults true. The unit tests cover the default-allow, opt-out-blocks, opt-in-allows, and malformed-fails-closed cases.

composite_transcription_socket.dart — The guard forwardRawAudioToSecondary || message is! List<int> correctly suppresses binary audio frames (Uint8List is a List<int>) to the secondary/Omi socket while still forwarding non-binary control and transcript messages. This matches the described invariant that transcripts and non-audio data can still reach Omi.

capture_controller.dart — The refactor to _shouldEnableNativeBackgroundStreaming (now including _nativeOmiRawAudioAllowed) plus _reconcileNativeBackgroundStreamingPolicy() called from onTranscriptionSettingsChanged() keeps the native streaming preference consistent with the STT policy. The unsupported-codec block correctly refuses the Omi fallback when raw forwarding is disabled, nulls the socket, and arms the keep-alive retry so transcription recovers when the blocking condition clears.

OmiBackgroundAudioStreamer.kt — The independent native check via CustomSttRawAudioPolicy.allowsForwarding(stringPref("customSttConfig")) in loadConfig() provides defense-in-depth: even if the Dart layer fails to reconcile, the native streamer independently blocks. Good.

custom_stt_config.dart — Round-trip serialization is correct: toJson writes the field, fromJson reads with != false default (legacy configs keep forwarding), and toRawConfigString includes it so the native prefs stay in sync. The config identity test verifies toggling the flag produces a different sttConfigId.

transcription_settings_page.dart — Per-provider persistence via _configsPerProvider, export includes the field, and switching providers now saves the current config before switching and repopulates from the target provider's stored value. The codec-incompatible warning correctly switches to a generic "transcription unavailable" message when raw forwarding is off.

The ~100-file diff is dominated by l10n translations across 49 locales plus generated localization dart; the English source strings include accurate @-metadata descriptions.

No security, supply-chain, or malicious-code concerns found. The implementation is privacy-enhancing and the layered enforcement is sound.

Leaving for human maintainer review: this is a privacy-sensitive raw-audio data-handling toggle that controls what user audio reaches Omi servers, and it needs maintainer sign-off on the privacy model and the default-on behavior before merge.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Dr-Amp

Dr-Amp commented Aug 15, 2026

Copy link
Copy Markdown

@Git-on-my-level @kodjima33 @LauraGPT — this bounded privacy increment is approved, all reported review findings were addressed, and the latest collaborator review confirms the fail-closed logic. It has now drifted into conflict with fast-moving main, while #10431 and its tested localOnly follow-up remain blocked on the fate of this base increment.

Could a maintainer please make the product/ownership decision explicitly:

  1. accept the feature and assign an owner for the current rebase + blocking CI fixes;
  2. ask the author/contributors for one final rebase, naming the exact required checks; or
  3. decline/close it so downstream work can stop waiting on an ambiguous dependency.

I can prepare the localOnly follow-up as a clean stacked PR preserving LauraGPT's authorship, but repeatedly rebasing 100+ generated/localization files without a maintainer commitment is wasted work. A concrete disposition here would unblock both PR #10447 and issue #10431.

@Git-on-my-level

Copy link
Copy Markdown
Member

Re-check of the current head 3d1a173 after the latest CI run (as glm-5.3, continuing the Aug 11 review):

Root cause of the three red checks — stale base, not this change. Dart Analyze & Tests, Android Compile Smoke, and Generated Files all fail at flutter pub get, before any compile or test step runs: the branch still carries intl: 0.20.2 as an exact pin (inherited from main when the branch was cut), while Flutter stable 3.47's flutter_localizations now requires intl ^0.20.3. This PR does not touch app/pubspec.yaml. main already fixed exactly this on Aug 12–13 (f4b4cd1 "track Flutter stable intl constraint", 2b57074 "support Flutter SDK intl pins", 9273811 "address lifecycle review and CI generator compatibility") — after this branch's last push on Aug 11. The PR has also since drifted into conflict with main, so those failures will repeat on every re-run until the branch is rebased/merged. A merge from main should clear all three checks without touching the feature code.

On disposition (picking up @Dr-Amp's question): the substantive review work is done — @kodjima33 approved this feature on d40e9d4 (Aug 3), and the Aug 11 static review of the current head confirmed the fail-closed layers (CustomSttRawAudioPolicy.kt malformed-config handling, the forwardRawAudioToSecondary || message is! List<int> binary-frame guard in composite_transcription_socket.dart, the unsupported-codec fallback block in capture_controller.dart, and the independent native gate in OmiBackgroundAudioStreamer.kt — re-verified today). What remains is mechanical: merge main (picks up the intl fix), let the three checks re-run, and land. The 107-file footprint is overwhelmingly generated l10n for two new strings. My recommendation is option 1/2 — accept the increment and either have a maintainer perform the merge-from-main or ask @LauraGPT for one final rebase — rather than closing: this is the bounded base increment that #10431 and the tested localOnly follow-up are stacked on, and it adds a user-facing privacy control consistent with Omi's direction.

Note that since the head moved after @kodjima33's approval, a maintainer re-approval on the rebased head is still needed before merge (that review would also cover the exact-pin → caret pubspec change arriving via main).

Specific human decision needed: explicit accept/decline of this privacy increment — including who owns the rebase and the final sign-off on the rebased head — which also unblocks #10431.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 111 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

LauraGPT and others added 4 commits August 16, 2026 11:03
Drop the openAIAPIKey override (removed from EnvFields upstream) and the
redundant composite_transcription_socket import. Unblocks the app analyzer
ratchet on the rebased head.
@undivisible
undivisible force-pushed the codex/custom-stt-forwarding-policy branch from 6312a1c to 2497eaa Compare August 16, 2026 03:11
…ated Files

The committed localizations were produced by a newer local Flutter whose
gen-l10n emits different formatting; regenerate so the Generated Files
check (Flutter 3.44.5) sees a clean tree.
@undivisible
undivisible merged commit af53c62 into BasedHardware:main Aug 16, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app flutter flutter work human Human-authored pull request mobile needs-maintainer-review Needs a human maintainer to sign off before merge transcription

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants