b91ef04ab0
- Server: chat ntfy messages carry a sequence id derived from their app id; clearing a chat app notification also clears it in ntfy (PUT /<topic>/<seq>/clear, verified on ntfy v2.38.1). - Server: a turn that sent an agent notify does not also send chat_reply. - notify tool and MCP instructions: Pipelines already notifies at reply end and for questions/approvals; notify is for mid-turn or background news. - Shown notify items carry channels (apps/phone); the transcript row says where it went. - App: NotificationBridge.close(tag); web closes tracked Notifications and tells other tabs over a BroadcastChannel; native bridge cancels by tag and now supports macOS. AgentNotices closes on notifications_cleared and on resubscribe cleared ids, and a tap sends clear_notifications. - Docs: skill, chat reference, ntfy/notifications docs, app note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
2.3 KiB
Dart
62 lines
2.3 KiB
Dart
// An agent's notify call for captures of the web notification paths. Off by
|
|
// default.
|
|
//
|
|
// `?agentNotice=<ms>` answers subscribe_notifications with no backlog, then
|
|
// <ms> after it pushes one `chat_notify` notification
|
|
// for the `ui-review` chat (add `ui-review=1` so the
|
|
// chat has its title). `agentNoticePriority=2|3|4`
|
|
// sets its priority (default 3).
|
|
// `?agentNoticeClear=<ms>` then pushes `notifications_cleared` for it <ms>
|
|
// after the subscription, as when the operator opens
|
|
// the chat or taps the notification on another device.
|
|
import 'dart:async';
|
|
|
|
import 'package:pipelines_app/core/api_gateway.dart';
|
|
|
|
Map<String, String> _params = const {};
|
|
|
|
void configureAgentNoticeFixture(Map<String, String> params) =>
|
|
_params = params;
|
|
|
|
/// The subscribe reply for [request], or null when the fixture is off or the
|
|
/// request is not a subscription. Schedules the push through [emit].
|
|
JsonMap? agentNoticeReply(JsonMap request, void Function(JsonMap) emit) {
|
|
if (request['type'] != 'subscribe_notifications') return null;
|
|
final delay = int.tryParse(_params['agentNotice'] ?? '');
|
|
if (delay != null) {
|
|
final priority = int.tryParse(_params['agentNoticePriority'] ?? '') ?? 3;
|
|
Timer(Duration(milliseconds: delay), () {
|
|
emit({
|
|
'type': 'notification',
|
|
'notification': {
|
|
'id': 'chat:ui-review:notify:shown_capture',
|
|
'kind': 'chat_notify',
|
|
'title': 'Build finished',
|
|
'message':
|
|
'All 412 tests pass. The release branch is ready to merge.',
|
|
'click': 'pipelines://chat/ui-review',
|
|
'priority': priority,
|
|
'tags': <String>[],
|
|
'created_at': DateTime.now().toUtc().toIso8601String(),
|
|
'group': 'chat:ui-review',
|
|
},
|
|
});
|
|
});
|
|
}
|
|
final clear = int.tryParse(_params['agentNoticeClear'] ?? '');
|
|
if (clear != null) {
|
|
Timer(Duration(milliseconds: clear), () {
|
|
emit({
|
|
'type': 'notifications_cleared',
|
|
'ids': ['chat:ui-review:notify:shown_capture'],
|
|
});
|
|
});
|
|
}
|
|
return {
|
|
'id': request['id'],
|
|
'type': 'notifications_subscribed',
|
|
'notifications': <JsonMap>[],
|
|
'ids': <String>[],
|
|
};
|
|
}
|