Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

fix(desktop): a thread read on another device shows as read here (#2250)

0xken15c439938cdb3e
diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dart
index cc6d2d576..880d0cf2a 100644
--- a/desktop/lib/super_tabs/controller.dart
+++ b/desktop/lib/super_tabs/controller.dart
@@ -1015,11 +1015,12 @@ class SuperTabController extends ChangeNotifier {
final thread = SuperTabThread.fromJson(superTabMap(row));
if ((held[thread.id]?.lastSequence ?? -1) > thread.lastSequence) continue;
held[thread.id] = thread;
- // A thread first seen here is read as far as the conversation is:
- // replies the reader passed before threads were counted stay read.
+ // A thread first seen here is read as far as the conversation is,
+ // here or on another device: replies the reader passed before threads
+ // were counted stay read.
_threadSeen.putIfAbsent(
thread.id,
- () => min(_readAt[id] ?? 0, thread.lastSequence),
+ () => min(readMark(id), thread.lastSequence),
);
if (openedThread?.root == thread.id) _seeThread(thread.id);
}
diff --git a/desktop/test/super_tab_threads_test.dart b/desktop/test/super_tab_threads_test.dart
index f4dfef2bd..59cf4de61 100644
--- a/desktop/test/super_tab_threads_test.dart
+++ b/desktop/test/super_tab_threads_test.dart
@@ -478,6 +478,49 @@ void main() {
expect(countWeight(tester, 'message-1'), isNot(FontWeight.w700));
});
+ test('a thread read on another device, with no mark kept here, shows as '
+ 'read', () async {
+ final server = threaded();
+ // The reader read the whole chat elsewhere, up to its last message.
+ server.markReadElsewhere('lead', server.revision);
+ final c = server.controller();
+ addTearDown(c.dispose);
+ await c.refresh();
+ await c.loadMessages('lead');
+ final thread = c.thread('lead', 'message-1')!;
+ // The last reply is the peer's, so only the read mark keeps it quiet.
+ expect(thread.authors.first['id'], 'peer');
+ expect(thread.lastSequence, 3);
+ expect(c.readMark('lead'), server.revision);
+ expect(c.threadUnread(thread), isFalse);
+ });
+
+ test(
+ 'a reply past the mark read on another device is still unread',
+ () async {
+ final server = threaded();
+ server.markReadElsewhere('lead', 2);
+ final c = server.controller();
+ addTearDown(c.dispose);
+ await c.refresh();
+ await c.loadMessages('lead');
+ expect(c.threadUnread(c.thread('lead', 'message-1')!), isTrue);
+ },
+ );
+
+ test(
+ 'another person\'s read mark never reads the reader\'s thread',
+ () async {
+ final server = threaded();
+ server.markReadElsewhere('lead', server.revision, reader: 'peer');
+ final c = server.controller();
+ addTearDown(c.dispose);
+ await c.refresh();
+ await c.loadMessages('lead');
+ expect(c.threadUnread(c.thread('lead', 'message-1')!), isTrue);
+ },
+ );
+
testWidgets('the read mark passes thread replies after the last row shown', (
tester,
) async {