Agent notifications are system notifications, never in-app toasts

An agent's notify call now always posts an OS notification when permitted,
whatever app is in front (only skipped while that chat is open in the
focused page); no toast or chime. Without permission the tab title counts
it. The browser's permission prompt is shown on the operator's first click.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 16:32:29 +00:00
parent e05b2f07dc
commit 355a5767fb
4 changed files with 71 additions and 73 deletions
+16
View File
@@ -6,6 +6,7 @@ import 'dart:async';
import '../features/runs/domain/run_tab_counts.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/material.dart';
@@ -15,6 +16,7 @@ import '../core/transport/pipelines_client.dart';
import '../shell/adaptive_shell.dart';
import '../shell/destination.dart';
import '../features/attention/notify/notification_controller.dart';
import '../features/attention/notify/notification_models.dart';
import '../features/attention/notify/chat_question_notices.dart';
import '../features/attention/notify/agent_notices.dart';
import '../features/attention/notify/page_signals.dart';
@@ -456,6 +458,11 @@ class _PipelinesAppState extends State<PipelinesApp>
);
};
unawaited(_notifications.load());
// Browsers only show the permission prompt from a user gesture: ask on
// the operator's first click anywhere, once, while undecided, so agent
// notifications can be real system notifications without a trip to
// Settings.
GestureBinding.instance.pointerRouter.addGlobalRoute(_askOnFirstPress);
bindAttentionAckSync(_session.gateway, _ackSync);
unawaited(_ackSync.load());
unawaited(_attention.load());
@@ -592,8 +599,17 @@ class _PipelinesAppState extends State<PipelinesApp>
}
}
void _askOnFirstPress(PointerEvent event) {
if (event is! PointerDownEvent || !_notifications.loaded) return;
GestureBinding.instance.pointerRouter.removeGlobalRoute(_askOnFirstPress);
if (_notifications.permission == NotificationPermissionState.notRequested) {
unawaited(_notifications.requestPermission());
}
}
@override
void dispose() {
GestureBinding.instance.pointerRouter.removeGlobalRoute(_askOnFirstPress);
_tabLocations.dispose();
WidgetsBinding.instance.removeObserver(this);
_deliveryHandoff?.dispose();