Skip to content

fix(app): surface capture failures from Quick Actions and the Home stop - #25071

Open
sauranshbhardwaj wants to merge 2 commits into
BasedHardware:mainfrom
sauranshbhardwaj:fix/19245-capture-errors-surface
Open

sauranshbhardwaj wants to merge 2 commits into
BasedHardware:mainfrom
sauranshbhardwaj:fix/19245-capture-errors-surface

Conversation

@sauranshbhardwaj

@sauranshbhardwaj sauranshbhardwaj commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #19245

What changed and why

Since capture commands became coordinator dispatches, pauseCapture, resumeCapture and finishCapture throw when their effect fails (outcome.throwIfFailed()). The live page, the processing card and Device settings catch that and show "Something went wrong". Two callers did not, so a failed pause, resume or stop was an unhandled async error and the user saw nothing:

  • Quick Actions Mute / Unmute (app/lib/services/quick_actions_service.dart): _toggleMute called pauseCapture() / resumeCapture() without awaiting them. It now awaits the command inside a try and on failure shows OmiFeedback.error(context, context.l10n.somethingWentWrong) behind a context.mounted guard. _handleShortcut returns Future<void> so the mute cases can await, and the platform callback wraps it in unawaited to say the fire-and-forget is intended.
  • Home record button, stop path (app/lib/pages/home/widgets/battery_info_widget.dart): _startPhoneRecording awaited finishCapture() with no try, and the two tap handlers plus the pendant sheet's "Record with phone" dropped the future. The stop now mirrors the start path in the same method (try / OmiFeedback.error / return), so the phoneMicRecordingStopped analytics event and the options tip are skipped when the stop did not happen. The three call sites use unawaited.

Both failure paths also log the error at debug level (Logger.debug), as the rest of the app does, so a refused pause, resume or stop can be read back from the in-app log. Nothing changes on success. This takes the same shape as #21303 (approved, then withdrawn by its author) and #24835 (closed by its author). Changelog fragment: app/changelog/unreleased/quick-actions-home-record-failure-feedback.json.

Product invariants affected

none

How it was verified

  • flutter analyze on the four changed files: no issues.
  • flutter test test/services/quick_actions_service_test.dart test/widgets/capture_home_ui_test.dart: 40 passed, 2 skipped.
  • bash test.sh (the full hermetic app suite): 8,545 passed, 10 skipped, exit 0.
  • The two failure tests below were run against main with only the test changes applied: both fail with Found 0 widgets with text "Something went wrong! Please try again later", the error having gone to the zone's handler instead.
  • Not exercised on a device: the failure needs a dispatch that refuses the pause, resume or stop (for example the transcription socket cannot be reopened). The widget tests stand in for that with a fake CaptureProvider that throws.

Tests

  • test/services/quick_actions_service_test.dart, "Mute and Unmute shortcuts await the capture command and say so when it fails": the QuickActions fake now keeps the handler the service registers, so the test fires mute and unmute through the production dispatch. A failing resume shows the feedback and tester.takeException() stays null.
  • test/widgets/capture_home_ui_test.dart, "a tap while the phone records finishes the capture" (one finishCapture, no start, no toast) and "a stop that fails says so instead of an unhandled error". The fake CaptureProvider gains finishCapture with an injectable failure.

UI evidence

UI-Evidence: none -- error handling only; the feedback is the existing OmiFeedback snackbar, and no layout or visual state changes.

Failure class (fixes)

Failure-Class: none

Since capture commands became coordinator dispatches, pauseCapture,
resumeCapture and finishCapture throw when their effect fails. The live
page and the processing card catch that and say "Something went wrong";
two callers did not:

- The home-screen Quick Actions Mute / Unmute called pauseCapture and
  resumeCapture without awaiting them, so a failure was an unhandled
  async error and the user saw nothing.
- The Home record button's stop path awaited finishCapture without a
  try, and its tap handlers dropped the future, so a failed stop was
  unhandled too and the button kept its state.

Both now await the command inside a try and show the same feedback as
the live page; the fire-and-forget call sites say so with unawaited.
The stop analytics event and the options tip are skipped when the stop
did not happen.

Fixes BasedHardware#19245
@Git-on-my-level

Copy link
Copy Markdown
Member

The production change here is correct and nicely scoped - both silent-failure paths now match the error handling the live page already has, with real tests through the production dispatch path. Positive signal rather than formal approval; a maintainer should take the merge.

Verified against the diff and current main:

  • app/lib/services/quick_actions_service.dart - _toggleMute now awaits pauseCapture()/resumeCapture() inside a try and on failure shows OmiFeedback.error(...somethingWentWrong) behind a context.mounted guard. I confirmed the premise on main: CaptureController.pauseCapture/resumeCapture (capture_controller.dart:4737/4743) call outcome.throwIfFailed(), and main's _toggleMute dispatches them un-awaited - the silent failure is real. _handleShortcut returning Future with the platform callback wrapped in unawaited(...) is the right shape.
  • app/lib/pages/home/widgets/battery_info_widget.dart - the stop path's try / catch (_) / return mirrors the existing streamRecording() start path in the same method, and correctly skips the phoneMicRecordingStopped analytics event and the options tip when the stop did not happen. The three call sites (both onTap handlers, the pendant sheet's onRecordWithPhone) now declare fire-and-forget with unawaited.
  • app/test/services/quick_actions_service_test.dart - good test design: _QuickActions.initialize captures the registered handler, so handler!('mute') exercises the production dispatch path and asserts the pause ran, feedback shows only on failure, and takeException() stays null.
  • app/test/widgets/capture_home_ui_test.dart - covers both the happy-path stop (finishes == 1, no toast) and the failing stop (toast shown, no unhandled exception).
  • app/changelog/unreleased/quick-actions-home-record-failure-feedback.json - accurate, user-facing wording.

Also confirmed this is not superseded: issue #19245 is still open and main still carries the unguarded _toggleMute (this is the third attempt after #21303 and #24835).

UX: users get a visible "Something went wrong" instead of nothing when mute/unmute/stop fails; the success path is unchanged.
Blast radius: contained to two UI callers, catch-only handling; no data, permission, or dependency changes.

USER IMPACT: when muting or unmuting from the home-screen shortcut, or stopping a recording from Home, fails, the app now tells you instead of staying silent.

What I'd still want: nothing blocking. Optional nit - both new catch (_) blocks discard the error object; a debug-level log would aid field diagnosis, though this matches the existing start-path style in the same file.


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 positive-signal Automation verified a genuine fix/quality contribution flutter flutter work labels Nov 10, 2026
Both new catch blocks showed the feedback but dropped the error. Log it at
debug level, as the rest of the app does, so a refused pause, resume or stop
can be read back from the in-app log.
@sauranshbhardwaj

Copy link
Copy Markdown
Contributor Author

Added a debug log in both new catch blocks so the failure shows up in the in-app log. Tests re-run locally and still green.

@Git-on-my-level

Copy link
Copy Markdown
Member

Since my last review: addressed (the one outstanding nit — both new catch blocks now keep the error and log it at debug level: Logger.debug in quick_actions_service.dart (_toggleMute) and battery_info_widget.dart (stop path); commit 29a6c7e changes nothing else, verified against its file list) · still open (nothing) · newly introduced (nothing).

My conclusion stands: a correct, well-scoped fix with tests exercising the production dispatch path. Positive signal rather than formal approval; a maintainer can take the merge.

USER IMPACT: when muting or unmuting from the home-screen shortcut, or stopping a recording from Home, fails, the app now tells you — and logs why — instead of staying silent.

Nothing further requested.


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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quick Actions Mute/Unmute and the Home record button drop capture failures silently

2 participants