fix(mobile): send Siri Bestie messages without confirmations (#9779)

Saying "Message my Bestie" to Siri (or running it from the Action button
or Shortcuts) now sends the dictated message straight away. Siri no
longer asks "Send … to <Bestie>?" before sending or shows a "Sent."
dialog afterward.

The Bestie's display name was looked up only to word that confirmation,
so that lookup is gone too: the Flutter side no longer preloads the
Bestie's profile or returns its name, and the bridge's `confirm`
callback is removed.

### Regressions

- A misheard message, or a Bestie changed on another device that this
one hasn't synced yet, now sends without a chance to cancel. We accept
that: the point of the shortcut is a hands-free send, and the message
still appears in the Bestie DM, where it can be deleted.
- This includes runs while the phone is locked and Shortcuts automations
that supply the message: both send immediately, by design.
- The community-switch guard stays: a Bestie looked up in one account or
community still can't be sent to from another.
- Nothing outside the Siri intent changes.

### Validation

- The app code at this head (the last commit only touches a test) is
built into a Buzz Dev development build installed on an iPhone 16e. The
Siri flow itself has not yet been run on that build.
- Updated
[quick_send_test.dart](https://github.com/block/buzz/blob/tomb/siri-no-confirm/mobile/test/features/channels/quick_send_test.dart)
for the `bestie` reply without a name.
- No before/after captures: the change is in Siri's own UI, which can't
be driven or recorded in the simulator.

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz>
This commit is contained in:
Tom Brow
2026-11-19 22:07:17 -08:00
committed by GitHub
parent 34c8f5c7a5
commit a303d7d5b5
3 changed files with 16 additions and 72 deletions

View File

@@ -54,15 +54,10 @@ final class QuickSendBridge {
}
}
/// Sends [text] to the Bestie once [confirm] accepts its name, or throws a
/// message Siri can read.
/// Sends [text] to the Bestie, or throws a message Siri can read.
@MainActor
func send(
_ text: String,
deadline: Duration = .seconds(20),
confirm: (_ bestieName: String?) async throws -> Void
) async throws {
// One at a time, so two quick sends post in the order they were confirmed.
func send(_ text: String, deadline: Duration = .seconds(20)) async throws {
// One at a time, so two quick sends post in the order they were spoken.
guard !sending else { throw QuickSendError("Another message is still sending.") }
sending = true
defer { sending = false }
@@ -73,7 +68,6 @@ final class QuickSendBridge {
guard let pubkey = bestie?["pubkey"] as? String, let scope = bestie?["scope"] as? String else {
throw QuickSendError("Buzz couldn't find your Bestie.")
}
try await confirm(bestie?["name"] as? String)
let start = ContinuousClock.now
do {
_ = try await call("send", arguments: ["text": text, "bestie": pubkey, "scope": scope])
@@ -116,16 +110,11 @@ struct MessageBestieIntent: AppIntent {
var message: String
@MainActor
func perform() async throws -> some IntentResult & ProvidesDialog {
func perform() async throws -> some IntentResult {
let text = message.trimmingCharacters(in: .whitespacesAndNewlines)
guard !text.isEmpty else { throw QuickSendError("Say a message to send.") }
try await QuickSendBridge.shared.send(text) { name in
try await requestConfirmation(
result: .result(dialog: "Send “\(text)” to \(name ?? "your Bestie")?"),
confirmationActionName: .send
)
}
return .result(dialog: "Sent.")
try await QuickSendBridge.shared.send(text)
return .result()
}
}

View File

@@ -7,7 +7,6 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../shared/me/default_agent.dart';
import '../../shared/profile/user_cache_provider.dart';
import '../../shared/relay/relay.dart';
import '../../shared/drafts/compose_drafts_provider.dart';
import 'bestie_conversation.dart';
@@ -73,10 +72,7 @@ class QuickSendHost extends HookConsumerWidget {
}
}
/// The Bestie a quick send will go to, named so the person can confirm it.
///
/// This is the saved choice, which may predate a change made on another
/// device that this one hasn't synced; naming it lets the person catch that.
/// The Bestie a quick send will go to.
Future<Map<String, String?>> _bestie(WidgetRef ref) async {
// Captured first: a switch during the awaits must not pair this
// community's scope with another's Bestie.
@@ -87,31 +83,18 @@ Future<Map<String, String?>> _bestie(WidgetRef ref) async {
if (bestie == null) {
throw const _QuickSendRefused('Choose a Bestie in Buzz first.');
}
if (ref.read(userCacheProvider)[bestie] == null) {
// Briefly: Siri can say "your Bestie" rather than keep the person waiting.
await ref
.read(userCacheProvider.notifier)
.preload([bestie])
.timeout(const Duration(seconds: 2), onTimeout: () => false);
}
_ensureScope(ref, scope);
return {
'pubkey': bestie,
'name': ref.read(userCacheProvider)[bestie]?.label,
'scope': scope,
};
return {'pubkey': bestie, 'scope': scope};
}
/// The account and community a confirmed Bestie belongs to.
/// The account and community a looked-up Bestie belongs to.
String _scope(WidgetRef ref) =>
'${ref.read(relayConfigProvider).baseUrl} ${ref.read(myPubkeyProvider)}';
/// Refuses a send whose confirmation was for another account or community.
/// Refuses a send whose Bestie was looked up in another account or community.
void _ensureScope(WidgetRef ref, String scope) {
if (_scope(ref) != scope) {
throw const _QuickSendRefused(
'Buzz switched communities. Try again to confirm the new Bestie.',
);
throw const _QuickSendRefused('Buzz switched communities. Try again.');
}
}

View File

@@ -13,7 +13,6 @@ import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:nostr/nostr.dart' as nostr;
import 'package:pointycastle/digests/sha256.dart';
import 'package:shared_preferences/shared_preferences.dart';
class _EmptyChannels extends ChannelsNotifier {
@@ -38,9 +37,8 @@ class _Config extends RelayConfigNotifier {
/// A relay that is not connected until the test says so, accepts every
/// publish and serves back the DM its open command finds or creates.
class _Relay extends RelaySessionNotifier {
_Relay(this.owner, this.profile);
_Relay(this.owner);
final nostr.Keys owner;
final NostrEvent profile;
final published = <NostrEvent>[];
/// Rejects the next message the way an over-quota relay does.
@@ -82,14 +80,13 @@ class _Relay extends RelaySessionNotifier {
Future<List<NostrEvent>> queryRelay(
List<NostrFilter> filters, {
Duration timeout = const Duration(seconds: 8),
}) async => [profile];
}) async => const [];
@override
Future<List<NostrEvent>> fetchHistory(
NostrFilter filter, {
Duration timeout = const Duration(seconds: 8),
}) async {
if (filter.kinds.contains(0)) return [profile];
final ds = filter.tags['#d'];
return _stored.reversed
.where(
@@ -183,28 +180,7 @@ void main() {
SharedPreferences.setMockInitialValues({});
final prefs = await SharedPreferences.getInstance();
final owner = nostr.Keys.generate(), bestie = nostr.Keys.generate();
final digest = SHA256Digest()
.process(
Uint8List.fromList(utf8.encode('nostr:agent-auth:${bestie.public}:')),
)
.map((v) => v.toRadixString(16).padLeft(2, '0'))
.join();
final profile = NostrEvent.fromJson(
nostr.Event.from(
kind: 0,
content: jsonEncode({'display_name': 'Bestie'}),
secretKey: bestie.secret,
tags: [
[
'auth',
owner.public,
'',
nostr.Schnorr.sign(secretKey: owner.secret, message: digest),
],
],
).toMap(),
);
final relay = _Relay(owner, profile);
final relay = _Relay(owner);
String? chosenBestie;
await tester.pumpWidget(
ProviderScope(
@@ -251,12 +227,8 @@ void main() {
replied = true;
},
);
// Ownership verification runs in a real isolate.
for (var i = 0; i < 100 && !replied; i++) {
await tester.pump(const Duration(milliseconds: 50));
await tester.runAsync(
() => Future<void>.delayed(const Duration(milliseconds: 50)),
);
}
expect(replied, isTrue, reason: '$method never answered');
return (result, failure);
@@ -278,9 +250,9 @@ void main() {
await tester.pump();
final (named, _) = await siri('bestie');
final scope = (named! as Map)['scope'];
expect(named, {'pubkey': bestie.public, 'name': 'Bestie', 'scope': scope});
expect(named, {'pubkey': bestie.public, 'scope': scope});
// A confirmation from before a community switch can't send here.
// A Bestie looked up before a community switch can't send here.
final (_, switched) = await siri('send', {
'text': 'Remind me to call Sam',
'bestie': bestie.public,