Mark chats seen after user interaction

Prevent passive open, restored, or unfocused chats from clearing notifications. Track qualifying focused interactions and cover passive and active seen-watermark behavior with tests and notes.
This commit is contained in:
2026-11-12 02:25:09 +00:00
parent e4f3ebdcab
commit 746e23788d
10 changed files with 1013 additions and 65 deletions
@@ -46,6 +46,23 @@ class ServerConnections extends ChangeNotifier {
return true;
}
String? _chatOpenId;
/// A chat the user opened from a notification. The tap is the user's own
/// interaction, so the chat it opens is read; a route restored without a tap
/// never sets this.
void requestChatOpen(String sessionId) {
_chatOpenId = sessionId;
notifyListeners();
}
/// Consumes the notification open of [sessionId], once.
bool takeChatOpenIntent(String sessionId) {
if (sessionId.isEmpty || sessionId != _chatOpenId) return false;
_chatOpenId = null;
return true;
}
/// Keep the intent outside the app that selecting another machine disposes.
Future<bool> requestNewChat(String id) async {
if (_busy || _disposed) return false;