feat: 重构 Reminder Notification 系统并更新应用包名

This commit is contained in:
qzl
2026-03-30 18:36:57 +08:00
parent 9fb2a6857b
commit 91bf3c3f96
90 changed files with 5133 additions and 3017 deletions
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:typed_data';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -110,11 +111,13 @@ class ChatBloc extends Cubit<ChatState> implements ChatOrchestrator {
AgUiService? service,
required ChatApi chatApi,
ChatHistoryRepository? historyRepository,
Future<void> Function()? onCalendarMutated,
Duration recoveryPollInterval = const Duration(milliseconds: 700),
Duration recoveryTimeout = const Duration(seconds: 20),
}) : _service =
service ??
AgUiService(chatApi: chatApi, historyRepository: historyRepository),
_onCalendarMutated = onCalendarMutated,
_recoveryPollInterval = recoveryPollInterval,
_recoveryTimeout = recoveryTimeout,
super(const ChatState()) {
@@ -122,6 +125,7 @@ class ChatBloc extends Cubit<ChatState> implements ChatOrchestrator {
}
final AgUiService _service;
final Future<void> Function()? _onCalendarMutated;
final Duration _recoveryPollInterval;
final Duration _recoveryTimeout;
String? _activeUserId;
@@ -214,5 +218,33 @@ class ChatBloc extends Cubit<ChatState> implements ChatOrchestrator {
_attachmentPreviewCache.clear();
_attachmentPreviewInflight.clear();
emit(const ChatState());
if (normalizedUserId != null && epoch == _sessionEpoch) {
try {
await _loadHistory();
} catch (error) {
emit(state.copyWith(error: error.toString()));
}
}
}
bool _shouldRefreshCalendarForTool(ToolCallResultEvent event) {
final name = event.toolName.trim().toLowerCase();
final status = event.status.trim().toLowerCase();
if (name != 'calendar_write') {
return false;
}
return status == 'success' || status == 'partial';
}
Future<void> _refreshCalendarAfterToolMutation() async {
final callback = _onCalendarMutated;
if (callback == null) {
return;
}
try {
await callback();
} catch (error) {
emit(state.copyWith(error: error.toString()));
}
}
}
@@ -198,6 +198,9 @@ extension _ChatBlocEvents on ChatBloc {
}
void _handleToolCallResult(ToolCallResultEvent event) {
if (_shouldRefreshCalendarForTool(event)) {
unawaited(_refreshCalendarAfterToolMutation());
}
emit(
state.copyWith(
items: state.items.map((item) {