Skip to content

Add error haptic feedback to showErrorDialog - #2342

Open
sharayuwadghule wants to merge 1 commit into
zulip:mainfrom
sharayuwadghule:issue-2338-error-haptic-feedback
Open

Add error haptic feedback to showErrorDialog#2342
sharayuwadghule wants to merge 1 commit into
zulip:mainfrom
sharayuwadghule:issue-2338-error-haptic-feedback

Conversation

@sharayuwadghule

Copy link
Copy Markdown

Add error haptic feedback when displaying an error dialog.

Currently, showErrorDialog provides only visual feedback. This change calls HapticFeedback.errorNotification() when showing an error dialog, providing platform-appropriate tactile feedback on Android and iOS.

As requested in the issue, the change is scoped only to showErrorDialog and does not affect showSuggestedActionDialog.

Fixes #2338

Testing

  • Added test coverage in test/widgets/dialog_test.dart.
  • Verified that the platform channel receives a HapticFeedback.vibrate call with HapticFeedbackType.errorNotification.
  • Ran:
flutter test test/widgets/dialog_test.dart
flutter test

@Ruhdee

Ruhdee commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Thank you for this PR @sharayuwadghule! This looks promising. Please make the following changes so that this PR is reviewable by the maintainers:

  1. Please go through https://zulip.readthedocs.io/en/latest/contributing/commit-discipline.html#commit-messages and rewrite your commit message according to it.
  2. If you're using LLMs, please also go through https://zulip.readthedocs.io/en/latest/contributing/contributing.html#ai-use-policy-and-guidelines.
  3. I think it would be best to add an independent test for haptic feedback in the showErrorDialog group instead of folding it into an existing test.

@sharayuwadghule
sharayuwadghule force-pushed the issue-2338-error-haptic-feedback branch from 5209ea7 to 505e167 Compare June 22, 2026 10:36
@sharayuwadghule

Copy link
Copy Markdown
Author

@Ruhdee Thanks for the review!

I've updated the commit message to follow the commit-discipline guidelines and moved the haptic feedback verification into a dedicated test in the showErrorDialog group.

I've also reviewed the AI-use policy and verified the implementation and test behavior myself. The test suite passes successfully.

Please let me know if there are any other changes needed.

@Ruhdee Ruhdee 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.

Thank you for the revision! Some small comments below:

Comment thread test/widgets/dialog_test.dart Outdated
Comment on lines +50 to +52
return null;
},
);

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.

nit:

Suggested change
return null;
},
);
return null;
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Bumping this again, we generally prefer to avoid this code style pattern (unnecessary trailing comma + newline + closing-parenthesis).

Comment thread test/widgets/dialog_test.dart Outdated
Comment on lines +58 to +59
..has((c) => c.method, 'method').equals('HapticFeedback.vibrate')
..has((c) => c.arguments, 'arguments').equals('HapticFeedbackType.errorNotification'));

@Ruhdee Ruhdee Jun 23, 2026

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.

It is more idiomatic to add extensions in this codebase so that we can cascade properties and check directly:

extension MethodCallChecks on Subject<MethodCall> {
  Subject<String> get method => has((c) => c.method, 'method');
  Subject<Object?> get arguments => has((c) => c.arguments as Object?, 'arguments');
}

I believe the 'flutter/services.dart' section of test/flutter_checks.dart would be the right location for it.

Comment thread test/widgets/dialog_test.dart Outdated
Comment on lines +57 to +59
check(calls).any((it) => it
..has((c) => c.method, 'method').equals('HapticFeedback.vibrate')
..has((c) => c.arguments, 'arguments').equals('HapticFeedbackType.errorNotification'));

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.

I think there is only one method call being received, so why not something like this:

Suggested change
check(calls).any((it) => it
..has((c) => c.method, 'method').equals('HapticFeedback.vibrate')
..has((c) => c.arguments, 'arguments').equals('HapticFeedbackType.errorNotification'));
check(calls).single
..method.equals('HapticFeedback.vibrate')
..arguments.equals('HapticFeedbackType.errorNotification');

@sharayuwadghule
sharayuwadghule force-pushed the issue-2338-error-haptic-feedback branch from 505e167 to 6965eaf Compare June 23, 2026 11:05
@sharayuwadghule

Copy link
Copy Markdown
Author

@Ruhdee Updated, thanks for the suggestion.

@Ruhdee

Ruhdee commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

There are a lot of unrelated formatting changes. Please revert them.

@sharayuwadghule
sharayuwadghule force-pushed the issue-2338-error-haptic-feedback branch 4 times, most recently from 51d9673 to d4aa384 Compare June 24, 2026 08:04
@sharayuwadghule

Copy link
Copy Markdown
Author

@Ruhdee Thanks! I've addressed the comments and reverted the unrelated formatting changes.

@Ruhdee Ruhdee 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.

I strongly urge you to self-review your code before asking others for review. The changes given below could have easily been spotted in a self-review!🙂

Comment thread ios/Podfile.lock
FirebaseInstallations: 4e6e162aa4abaaeeeb01dd00179dfc5ad9c2194e
FirebaseMessaging: 341004946fa7ffc741344b20f1b667514fc93e31
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
Flutter: 71a624a5bc0c04062bf19101d501e466baf2fb47

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.

Revert this unrelated change.

Comment thread lib/widgets/dialog.dart
Comment on lines +4 to 7
import 'package:flutter/services.dart';


import '../generated/l10n/zulip_localizations.dart';

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.

nit:

Suggested change
import 'package:flutter/services.dart';
import '../generated/l10n/zulip_localizations.dart';
import 'package:flutter/services.dart';
import '../generated/l10n/zulip_localizations.dart';

@Ruhdee

Ruhdee commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Also, the commit author email has a malformed domain. Please fix it or the commit won't be attributed to you.

@sharayuwadghule
sharayuwadghule force-pushed the issue-2338-error-haptic-feedback branch 3 times, most recently from f0674cf to f4c2a68 Compare June 26, 2026 12:22
@sharayuwadghule
sharayuwadghule requested a review from Ruhdee June 26, 2026 13:34
@sharayuwadghule

Copy link
Copy Markdown
Author

@Ruhdee Thanks! I've reverted the unintended ios/Podfile.lock changes, removed the extra blank line, and fixed the commit author email. I also checked the current CI failures locally and found that tools/check l10n fails on a clean checkout of upstream/main as well, so the remaining CI failures appear unrelated to this PR.

@Ruhdee

Ruhdee commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks! The CI failures do seem to be unrelated to this PR. Moving to maintainer review.

@rajveermalviya rajveermalviya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for working on this @sharayuwadghule! Overall LGTM, just one nit below.

Comment thread test/widgets/dialog_test.dart Outdated
Comment on lines +47 to +51
final messenger = tester.binding.defaultBinaryMessenger;
messenger.setMockMethodCallHandler(SystemChannels.platform, (methodCall) async {
calls.add(methodCall);
return null;
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: inline variable

Suggested change
final messenger = tester.binding.defaultBinaryMessenger;
messenger.setMockMethodCallHandler(SystemChannels.platform, (methodCall) async {
calls.add(methodCall);
return null;
});
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform,
(methodCall) async {
calls.add(methodCall);
return null;
});

@sharayuwadghule
sharayuwadghule force-pushed the issue-2338-error-haptic-feedback branch from f4c2a68 to 6c1064f Compare July 3, 2026 14:09
@sharayuwadghule

Copy link
Copy Markdown
Author

@rajveermalviya addressed! thanks.

@rajveermalviya rajveermalviya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the revision! And thanks @Ruhdee for previous reviews. Just one nit below, otherwise looks good.

Moving over to Chris's review.

Comment thread test/widgets/dialog_test.dart Outdated
Comment on lines +50 to +52
return null;
},
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Bumping this again, we generally prefer to avoid this code style pattern (unnecessary trailing comma + newline + closing-parenthesis).

@rajveermalviya rajveermalviya added integration review Added by maintainers when PR may be ready for integration and removed maintainer review PR ready for review by Zulip maintainers labels Jul 3, 2026
@rajveermalviya
rajveermalviya requested a review from chrisbobbe July 3, 2026 14:29
@sharayuwadghule
sharayuwadghule force-pushed the issue-2338-error-haptic-feedback branch from 6c1064f to b5e8358 Compare July 3, 2026 16:24
@sharayuwadghule

Copy link
Copy Markdown
Author

@rajveermalviya Thanks for pointing this out. I've fixed the formatting issue and pushed the changes.

@chrisbobbe chrisbobbe 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.

Thanks @sharayuwadghule, and thanks @Ruhdee and @rajveermalviya for the reviews! Small comments below.

Comment thread lib/widgets/dialog.dart
String? message,
Uri? learnMoreButtonUrl,
}) {
HapticFeedback.errorNotification();

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.

Let's mention this new behavior in the dartdoc of showErrorDialog.

Comment thread test/widgets/dialog_test.dart Outdated
Comment on lines +57 to +59
check(calls).single
..method.equals('HapticFeedback.vibrate')
..arguments.equals('HapticFeedbackType.errorNotification');

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.

I think this can just be:

      check(calls).single.isMethodCall('HapticFeedback.vibrate',
        arguments: 'HapticFeedbackType.errorNotification');

with no need for our own MethodCallChecks in test/flutter_checks.dart.

Comment on lines +47 to +52
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform,
(methodCall) async {
calls.add(methodCall);
return null;
});

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.

I think we need an addTearDown for this?

@sharayuwadghule
sharayuwadghule force-pushed the issue-2338-error-haptic-feedback branch from b5e8358 to 3fa6dbd Compare July 8, 2026 14:48
@sharayuwadghule

Copy link
Copy Markdown
Author

@chrisbobbe Thanks for the review! Addressed all the comments:

  • added the dartdoc note about the error haptic feedback,
  • switched the test to use isMethodCall and removed the custom MethodCallChecks,
  • added addTearDown to clean up the mock method call handler.

@chrisbobbe chrisbobbe 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.

Thanks! Just a few nits below.

Comment thread lib/widgets/dialog.dart Outdated
Comment on lines +149 to +152
/// Displays an [AlertDialog] with a dismiss button
/// and optional "Learn more" button.
///
/// Triggers error haptic feedback notification when shown.

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.

nit: can say the same thing in fewer words, e.g.:

Suggested change
/// Displays an [AlertDialog] with a dismiss button
/// and optional "Learn more" button.
///
/// Triggers error haptic feedback notification when shown.
/// Displays an [AlertDialog] with a dismiss button
/// and optional "Learn more" button, and gives haptic feedback.

import 'package:zulip/model/settings.dart';
import 'package:zulip/widgets/app.dart';
import 'package:zulip/widgets/dialog.dart';

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.

Don't remove this blank line, which separates package: imports from relative imports.

Comment thread test/widgets/dialog_test.dart Outdated
Comment on lines +52 to +55
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform,
null,
);

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.

nit: can use fewer lines:

Suggested change
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform,
null,
);
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform, null);

@sharayuwadghule
sharayuwadghule force-pushed the issue-2338-error-haptic-feedback branch from 3fa6dbd to ba220b2 Compare July 9, 2026 06:55
@sharayuwadghule

Copy link
Copy Markdown
Author

@chrisbobbe Thanks! Done with the expected changes.

Comment thread test/widgets/dialog_test.dart Outdated
Comment on lines +60 to +63
check(calls).single.isMethodCall(
'HapticFeedback.vibrate',
arguments: 'HapticFeedbackType.errorNotification',
);

@chrisbobbe chrisbobbe Jul 9, 2026

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.

Bump on code style from #2342 (comment) (use two lines instead of four)

@sharayuwadghule

Copy link
Copy Markdown
Author

@chrisbobbe dart format reformats this back to four lines. Is there a formatter setting or different style you'd prefer here?

@chrisbobbe

Copy link
Copy Markdown
Collaborator

What does the project README say about dart format?

@sharayuwadghule
sharayuwadghule force-pushed the issue-2338-error-haptic-feedback branch from ba220b2 to 6d72e05 Compare July 17, 2026 11:14
@sharayuwadghule

Copy link
Copy Markdown
Author

@chrisbobbe I checked the README,it explicitly says not to use dart format and to follow the repository's existing style. I'll update this to match the two-line formatting from #2342. Thanks!

@chrisbobbe

Copy link
Copy Markdown
Collaborator

If you rebase atop current main it should fix the CI failure: #mobile-team > Multiple CI failures @ 💬

@sharayuwadghule

Copy link
Copy Markdown
Author

@chrisbobbe I rebased onto the current main and confirmed that my branch was already up to date. The CI log I initially checked was for the older commit c086365 and failed because pod install modified ios/Podfile.lock. The latest CI run is now testing my updated commit, but the iOS job is still failing, so I'll check the latest job's error details.

@chrisbobbe

Copy link
Copy Markdown
Collaborator

I triggered a rerun of the CI jobs; hopefully that fixes it.

@chrisbobbe

Copy link
Copy Markdown
Collaborator

Did you git fetch upstream main (or swap in the right remote name, maybe git fetch origin main) before rebasing? It looks like your branch is based on an outdated main, 01907d8.

Previously, showErrorDialog provided only visual feedback when
displaying an error. This can make error notifications easier
to miss on devices that support haptic feedback.

Call HapticFeedback.errorNotification() when showing an error
dialog so users receive platform-appropriate tactile feedback
in addition to the visual dialog.

Fixes zulip#2338.
@sharayuwadghule
sharayuwadghule force-pushed the issue-2338-error-haptic-feedback branch from 6d72e05 to 30443ef Compare July 25, 2026 10:09
@sharayuwadghule

Copy link
Copy Markdown
Author

@chrisbobbe Thanks, fixed - I had fetched from origin instead of upstream. Rebased onto the latest upstream/main now.

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

Labels

integration review Added by maintainers when PR may be ready for integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Give haptic feedback (errorNotification) when showing an error dialog

4 participants