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): New session shows only where the server takes it; a refusal reads plainly (#2424)

0xken158c23b987cb32
diff --git a/backend/integration/superTabBuddySessions.test.ts b/backend/integration/superTabBuddySessions.test.ts
index 29d6d7378..31b6f0dd8 100644
--- a/backend/integration/superTabBuddySessions.test.ts
+++ b/backend/integration/superTabBuddySessions.test.ts
@@ -8,6 +8,7 @@ import { MongoMemoryReplSet } from 'mongodb-memory-server-core'
import { PrismaClient } from '@prisma/client'
import type { AuthUser } from '../src/lib/ssoAuth.js'
import { SuperTabStore } from '../src/superTabs/store.js'
+import { SwarmReads } from '../src/superTabs/read/service.js'
import { MemoryAttachmentStore } from '../src/superTabs/attachments.js'
import type { Command } from '../src/superTabs/commands.js'
import { poolRows } from './hostRows.test-support.js'
@@ -87,6 +88,16 @@ async function swarm({ capable = true, maxAgents = 6, engine = 'claude' } = {})
const text = (page: { messages: Array<{ text: string }> }) => page.messages.map(m => m.text)
describe('a Buddy thread session', () => {
+ it('is announced in every Swarm read, so an app offers New session only on a server that takes it', async () => {
+ const f = await swarm()
+ const reads = new SwarmReads(f.store)
+ const first = await reads.firstLoad(peer, f.tab)
+ expect(first.derived.threadSessions).toBe(true)
+ await f.say('Moving the cursor on')
+ const changes = await reads.changes(peer, f.tab, first.cursor)
+ expect(changes.reload === false && changes.derived.threadSessions).toBe(true)
+ })
+
it('starts from a thread reply on its Buddy\'s machine, with no message text in its start, and hears that reply once it joins', async () => {
const f = await swarm()
const root = await f.say('Two things today')
diff --git a/backend/src/superTabs/read/contract.ts b/backend/src/superTabs/read/contract.ts
index dc131a284..cb2ef23fb 100644
--- a/backend/src/superTabs/read/contract.ts
+++ b/backend/src/superTabs/read/contract.ts
@@ -90,6 +90,10 @@ export interface Derived {
/** Present, and false, only in a Swarm Harness Team accounts are not tried in yet (machines.ts teamAccountSwarm): this
* Mac's daemon and Desktop then offer no team account for it. Absent is every older backend's "yes". */
teamAccounts?: false
+ /** This server takes a thread reply's `newSession` (buddySessions.ts): Desktop offers New session only where it is
+ * true and the Buddy's machine reports it can run sessions. Absent from an older backend, whose strict schema refuses
+ * the field. */
+ threadSessions?: true
}
export interface OtherProjectWorkView {
conversationId: string; projectName: string; title: string; owns: string[]; status: WorkStatus; agentName: string; pr: string | null
diff --git a/backend/src/superTabs/read/views.test.ts b/backend/src/superTabs/read/views.test.ts
index b8d421307..2870c60f4 100644
--- a/backend/src/superTabs/read/views.test.ts
+++ b/backend/src/superTabs/read/views.test.ts
@@ -86,6 +86,13 @@ describe('reader view of the parts (design 4.1, 4.3)', () => {
expect(keys(readerView(parts, agentActor(s.worker), NOW, { teamMachines: [] }).parts.groups)).not.toContain(leads)
})
+ it('says to every reader that this server takes New session in a thread reply', () => {
+ const { s, parts } = scene()
+ for (const actor of [owner, peer, agentActor(s.worker)]) {
+ expect(readerView(parts, actor, NOW, { teamMachines: [] }).derived.threadSessions).toBe(true)
+ }
+ })
+
it('keeps time-based agent values out of the part and puts them in derived', () => {
const { s, parts } = scene()
const view = readerView(parts, peer, NOW, { teamMachines: [] })
diff --git a/backend/src/superTabs/read/views.ts b/backend/src/superTabs/read/views.ts
index 5b5fa9b87..faaf7504f 100644
--- a/backend/src/superTabs/read/views.ts
+++ b/backend/src/superTabs/read/views.ts
@@ -149,5 +149,6 @@ function derive(state: SuperTabState, visible: SuperTabState, actor: Actor, now:
...(actor.kind === 'person' && extras.decisionsWaiting !== undefined ? { decisionsWaiting: extras.decisionsWaiting } : {}),
...(actor.kind === 'person' && extras.decisionsDigest !== undefined ? { decisionsDigest: extras.decisionsDigest } : {}),
...(teamAccountSwarm(state) ? {} : { teamAccounts: false as const }),
+ threadSessions: true as const,
}
}
diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dart
index 347fc477b..93007fbfd 100644
--- a/desktop/lib/super_tabs/controller.dart
+++ b/desktop/lib/super_tabs/controller.dart
@@ -62,6 +62,18 @@ String superTabMessageId({
const _unsentReason = 'Not sent before this window closed.';
const _unsentKey = 'unsent';
+/// What a thread reply refused for New session says: the server does not
+/// take it yet (an older backend, or one of its servers during a release).
+const superTabSessionsUnavailable =
+ "New sessions aren't available yet; send without it?";
+
+/// What a message refused for its form says, in place of the schema's own
+/// words ('command: Unrecognized key: ...'), which name fields, not causes.
+const superTabRefusedAsSent = "The server couldn't take this message yet.";
+
+/// The schema's own words, as a refusal saved before this version kept them.
+final _schemaWords = RegExp(r'Unrecognized key|^command(\.\w+)*: ');
+
class SuperTabFailure implements Exception {
const SuperTabFailure(this.code, this.message, {this.statusCode = 0});
final String code, message;
@@ -241,7 +253,11 @@ class SuperTabController extends ChangeNotifier {
in superTabMap(row['mentions']).entries)
if (token is String) agent: token,
},
- error: row[_unsentKey] == true ? '' : row['error'] as String,
+ error: row[_unsentKey] == true
+ ? ''
+ : _schemaWords.hasMatch(row['error'] as String)
+ ? superTabRefusedAsSent
+ : row['error'] as String,
),
];
if (kept.isNotEmpty) _refused[key] = kept;
@@ -1408,7 +1424,8 @@ class SuperTabController extends ChangeNotifier {
));
if (ids == null) return null;
final before = _pending;
- final sending = command({
+ final operationId = superTabOperationId();
+ final sending = command(operationId: operationId, {
'type': 'message.send',
'conversationId': open.conversationId,
'text': text,
@@ -1429,14 +1446,64 @@ class SuperTabController extends ChangeNotifier {
}
final result = await sending;
_forgetRefusedUploads(result);
+ if (result == null && newSession) {
+ _restoreSessionRefusal(open.conversationId, open.root, operationId);
+ }
return result;
}
+ /// A reply the server refused only for New session goes back into its
+ /// thread's box, ready to send without it, when nothing was typed there
+ /// since and it carries no files; else it stays Not sent, and its Retry
+ /// goes without New session.
+ void _restoreSessionRefusal(
+ String conversationId,
+ String root,
+ String operationId,
+ ) {
+ final kept = _refused[conversationId];
+ final i = kept?.indexWhere((r) => r.operationId == operationId) ?? -1;
+ if (i < 0) return;
+ final refused = kept![i];
+ final files = refused.command['attachmentIds'];
+ if (refused.error != superTabSessionsUnavailable ||
+ (files is List && files.isNotEmpty) ||
+ threadDraft(root).trim().isNotEmpty) {
+ return;
+ }
+ kept.removeAt(i);
+ if (kept.isEmpty) _refused.remove(conversationId);
+ _sendOrder.remove(operationId);
+ _threadDrafts[root] = refused.command['text'] as String? ?? '';
+ unawaited(
+ _persist().catchError((Object _) {
+ error = 'Could not save this change on this computer.';
+ _changed();
+ }),
+ );
+ _changed();
+ }
+
// ── Buddy thread sessions (spec 2026-10-30-buddy-thread-sessions) ───────
/// How many thread sessions a Buddy chat may run at once (backend limit).
static const maxBuddySessions = 3;
+ /// When the server last refused a reply's New session as a field it does not
+ /// know, though it said it takes them (one of its servers older during a
+ /// release): New session is not offered for [_sessionsRefusedFor] after.
+ DateTime? _sessionsRefusedAt;
+ static const _sessionsRefusedFor = Duration(minutes: 10);
+
+ /// Whether this Swarm's server takes New session: it says so in its reads,
+ /// and has not just refused one.
+ bool get _serverTakesThreadSessions {
+ if (snapshot?.threadSessions != true) return false;
+ final refused = _sessionsRefusedAt;
+ return refused == null ||
+ clock.now().difference(refused) >= _sessionsRefusedFor;
+ }
+
/// The open thread's chat when it is the reader's own Buddy chat, where a
/// thread may have a session of its own; null anywhere else.
SuperTabConversation? get _ownBuddyChat {
@@ -1456,7 +1523,7 @@ class SuperTabController extends ChangeNotifier {
/// ([threadSessionBlocked]).
bool offersThreadSessions([String? root]) {
final chat = _ownBuddyChat;
- if (chat == null) return false;
+ if (chat == null || !_serverTakesThreadSessions) return false;
return buddy(chat.projectId) != null || (root != null && _hadSession(root));
}
@@ -3550,11 +3617,12 @@ class SuperTabController extends ChangeNotifier {
_pending = pending;
}
} else if (!_disposed && !accessRevoked) {
+ final command = superTabMap(pending['command']);
_failOperation(
failure is SuperTabFailure
- ? failure.message
+ ? _refusalText(failure, command)
: 'The action is not confirmed. Retry to check it.',
- command: superTabMap(pending['command']),
+ command: command,
code: failure is SuperTabFailure ? failure.code : null,
);
if (failure is SuperTabFailure &&
@@ -3563,7 +3631,20 @@ class SuperTabController extends ChangeNotifier {
!const {408, 429}.contains(failure.statusCode)) {
// A definitive rejection made no change. Keep the message for the
// person to correct; a lost reply retains its exact receipt ID.
- _refuse(pending, operationError!);
+ // One refused for New session is kept without it: its Retry, or
+ // its text back in the box, sends a plain reply.
+ final unsupported = operationError == superTabSessionsUnavailable;
+ if (unsupported) _sessionsRefusedAt = clock.now();
+ _refuse(
+ unsupported
+ ? {
+ ...pending,
+ 'command': Map<String, dynamic>.of(command)
+ ..remove('newSession'),
+ }
+ : pending,
+ operationError!,
+ );
_pending = null;
try {
await _persist();
@@ -3604,6 +3685,24 @@ class SuperTabController extends ChangeNotifier {
}
}
+ /// What a person reads for [failure] of [command]: the server's own words,
+ /// except where a message was refused for its form (`VALIDATION_ERROR`, the
+ /// schema naming fields): a thread reply with New session, by a server that
+ /// does not take it yet, says so; any other says it plainly. Text length is
+ /// held to the limit before sending, so a form refusal is a newer app's field.
+ static String _refusalText(
+ SuperTabFailure failure,
+ Map<String, dynamic> command,
+ ) {
+ if (command['type'] != 'message.send' ||
+ failure.code != 'VALIDATION_ERROR') {
+ return failure.message;
+ }
+ return command['newSession'] == true
+ ? superTabSessionsUnavailable
+ : superTabRefusedAsSent;
+ }
+
static String _excerpt(String text) {
final line = text.trim().replaceAll(RegExp(r'\s+'), ' ');
return line.length <= 80 ? line : '${line.substring(0, 79)}…';
diff --git a/desktop/lib/super_tabs/model.dart b/desktop/lib/super_tabs/model.dart
index 4117713fe..e7a8a9d70 100644
--- a/desktop/lib/super_tabs/model.dart
+++ b/desktop/lib/super_tabs/model.dart
@@ -440,6 +440,7 @@ class SuperTabSnapshot {
}),
localModels = SuperTabLocalModels.read(row['localModels']),
teamAccounts = row['teamAccounts'] != false,
+ threadSessions = row['threadSessions'] == true,
mentionsWaiting = (row['mentionsWaiting'] as num?)?.toInt() ?? 0,
mentionsDigest = row['mentionsDigest'] as String?,
decisionsWaiting = (row['decisionsWaiting'] as num?)?.toInt() ?? 0,
@@ -521,6 +522,11 @@ class SuperTabSnapshot {
/// Whether this Swarm's server uses Harness Team accounts: false only where
/// it says it does not try them yet (backend read/contract.ts `teamAccounts`).
final bool teamAccounts;
+
+ /// Whether this Swarm's server takes a thread reply's New session: true only
+ /// where it says so (backend read/contract.ts `threadSessions`); an older
+ /// server's schema refuses the field.
+ final bool threadSessions;
final int mentionsWaiting;
/// Which tags wait, as a digest that moves when they change though the
diff --git a/desktop/lib/super_tabs/parts.dart b/desktop/lib/super_tabs/parts.dart
index 16b46af98..bd968cd4f 100644
--- a/desktop/lib/super_tabs/parts.dart
+++ b/desktop/lib/super_tabs/parts.dart
@@ -346,6 +346,8 @@ class SuperTabParts {
}
// Sent only where the server does not try Harness Team accounts yet.
if (_derived['teamAccounts'] == false) state['teamAccounts'] = false;
+ // Sent by a server that takes a thread reply's New session.
+ if (_derived['threadSessions'] == true) state['threadSessions'] = true;
if (_readMarks.isNotEmpty) state['readMarks'] = Map.of(_readMarks);
if (_threadMarks.isNotEmpty) {
state['threadMarks'] = {
diff --git a/desktop/lib/super_tabs/thread_panel.dart b/desktop/lib/super_tabs/thread_panel.dart
index 2eebbe865..433f1e43b 100644
--- a/desktop/lib/super_tabs/thread_panel.dart
+++ b/desktop/lib/super_tabs/thread_panel.dart
@@ -234,6 +234,17 @@ class _SuperTabThreadPanelState extends State<SuperTabThreadPanel> {
}
},
);
+ // Refused for New session, the reply's text is back as this thread's
+ // draft: it shows in the box, ready to send without it, unless another
+ // thread is shown or something was typed meanwhile.
+ if (!mounted || widget.root != root || _composer.text.isNotEmpty) return;
+ final restored = c.threadDraft(root);
+ if (restored.isEmpty) return;
+ _composer.value = TextEditingValue(
+ text: restored,
+ selection: TextSelection.collapsed(offset: restored.length),
+ );
+ setState(() {});
}
@override
diff --git a/desktop/test/super_tab_buddy_sessions_test.dart b/desktop/test/super_tab_buddy_sessions_test.dart
index c87649c22..1e4246d66 100644
--- a/desktop/test/super_tab_buddy_sessions_test.dart
+++ b/desktop/test/super_tab_buddy_sessions_test.dart
@@ -1,5 +1,6 @@
import 'dart:async';
+import 'package:clock/clock.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
@@ -38,9 +39,11 @@ void main() {
(server.state['conversations'] as List)[1] as Map<String, dynamic>;
/// The reader's own Buddy chat ('offline' in the fixture) with their Buddy
- /// running, a root, and a second thread to switch to.
- ConversationServer buddyChat({bool buddy = true}) {
+ /// running, a root, and a second thread to switch to, on a server that takes
+ /// New session unless [sessions] is false (an older backend).
+ ConversationServer buddyChat({bool buddy = true, bool sessions = true}) {
final server = ConversationServer()..threads = true;
+ if (sessions) server.state['threadSessions'] = true;
final chat = chatOf(server)
..['kind'] = 'buddy'
..['buddyOwnerId'] = 'owner'
@@ -130,10 +133,11 @@ void main() {
ConversationServer server, {
Brightness brightness = Brightness.dark,
bool select = true,
+ Map<String, dynamic>? initial,
}) async {
await tester.binding.setSurfaceSize(const Size(1400, 900));
addTearDown(() => tester.binding.setSurfaceSize(null));
- final c = shown = server.controller();
+ final c = shown = server.controller(initial: initial);
await c.refresh();
await tester.pumpWidget(
MaterialApp(
@@ -570,6 +574,263 @@ void main() {
expect(box(tester, newSession).onChanged, isNotNull);
});
+ // ── An older server (2026-10-31, Scholes): a test build offered New session
+ // against production, whose schema refused it with its raw text. ──────────
+
+ const unavailable = "New sessions aren't available yet; send without it?";
+ const rawRefusal = 'command: Unrecognized key: "newSession"';
+ final threadError = find.byKey(const ValueKey('super-thread-error'));
+
+ /// Makes [server] refuse every command as a backend from before New session
+ /// refuses one with it.
+ void refuseAsOlderServer(ConversationServer server) {
+ server
+ ..refuse = {'code': 'VALIDATION_ERROR', 'message': rawRefusal}
+ ..refuseStatus = 400;
+ }
+
+ testSessions('a server that does not take New session never offers it, '
+ 'and offers it once it says it does', (tester) async {
+ final server = buddyChat(sessions: false);
+ server.state['machines'] = [machine()];
+ final c = await show(tester, server);
+ await openThread(tester, c, 'message-1');
+ // The Buddy's machine can run sessions; the server cannot start them.
+ expect(newSession, findsNothing);
+ expect(alsoSend, findsOneWidget);
+ expect(c.offersThreadSessions('message-1'), isFalse);
+ await tester.enterText(composer, 'Plain reply');
+ await tester.pump();
+ await tester.tap(send);
+ await tester.pumpAndSettle();
+ expect(lastCommand(server).containsKey('newSession'), isFalse);
+
+ // The server is updated: the next changes read says so.
+ server.state['threadSessions'] = true;
+ server.revision++;
+ await c.refresh();
+ await tester.pumpAndSettle();
+ expect(newSession, findsOneWidget);
+ expect(box(tester, newSession).onChanged, isNotNull);
+ });
+
+ testSessions('a server rolled back to before New session hides it again', (
+ tester,
+ ) async {
+ final server = buddyChat();
+ final c = await show(tester, server);
+ await openThread(tester, c, 'message-1');
+ expect(newSession, findsOneWidget);
+ server.state.remove('threadSessions');
+ server.revision++;
+ await c.refresh();
+ await tester.pumpAndSettle();
+ expect(newSession, findsNothing);
+ expect(alsoSend, findsOneWidget);
+ });
+
+ testSessions('a New session reply the server refuses keeps its text in the '
+ 'box, says so plainly, and sends without it', (tester) async {
+ final server = buddyChat();
+ final c = await show(tester, server);
+ await openThread(tester, c, 'message-1');
+ refuseAsOlderServer(server);
+ await tester.tap(newSession);
+ await tester.pump();
+ await tester.enterText(composer, 'Measure it now');
+ await tester.pump();
+ await tester.tap(send);
+ await tester.pumpAndSettle();
+ expect(lastCommand(server)['newSession'], isTrue);
+
+ expect(
+ tester.widget<TextField>(composer).controller!.text,
+ 'Measure it now',
+ );
+ expect(tester.widget<Text>(threadError).data, unavailable);
+ expect(find.textContaining('Unrecognized key'), findsNothing);
+ // Nothing waits as Not sent: the text is in the box, ready to go.
+ expect(find.text('Not sent'), findsNothing);
+ expect(c.outgoing('offline'), isEmpty);
+ // New session is no longer offered, so Send goes without it.
+ expect(newSession, findsNothing);
+
+ server.refuse = null;
+ await tester.tap(send);
+ await tester.pumpAndSettle();
+ final sent = lastCommand(server);
+ expect(sent['text'], 'Measure it now');
+ expect(sent['replyTo'], 'message-1');
+ expect(sent.containsKey('newSession'), isFalse);
+ expect(threadError, findsNothing);
+ expect(tester.widget<TextField>(composer).controller!.text, isEmpty);
+ });
+
+ testSessions('after a refusal New session comes back a while later, if the '
+ 'server still says it takes it', (tester) async {
+ final server = buddyChat();
+ final c = await show(tester, server);
+ await openThread(tester, c, 'message-1');
+ refuseAsOlderServer(server);
+ await tester.tap(newSession);
+ await tester.enterText(composer, 'Measure it now');
+ await tester.pump();
+ await tester.tap(send);
+ await tester.pumpAndSettle();
+ expect(c.offersThreadSessions('message-1'), isFalse);
+ final later = clock.now().add(const Duration(minutes: 11));
+ expect(
+ withClock(Clock.fixed(later), () => c.offersThreadSessions('message-1')),
+ isTrue,
+ );
+ });
+
+ testSessions('a refusal that lands after more was typed keeps the new text '
+ 'and the refused reply, whose Retry goes without New session', (
+ tester,
+ ) async {
+ final server = buddyChat();
+ final c = await show(tester, server);
+ await openThread(tester, c, 'message-1');
+ refuseAsOlderServer(server);
+ final hold = server.holdCommands = Completer<void>();
+ await tester.tap(newSession);
+ await tester.enterText(composer, 'First');
+ await tester.pump();
+ await tester.tap(send);
+ await tester.pump();
+ await tester.enterText(composer, 'Second, typed meanwhile');
+ await tester.pump();
+ hold.complete();
+ server.holdCommands = null;
+ await tester.pumpAndSettle();
+
+ expect(
+ tester.widget<TextField>(composer).controller!.text,
+ 'Second, typed meanwhile',
+ );
+ expect(find.textContaining('Unrecognized key'), findsNothing);
+ final refused = c.outgoing('offline').single;
+ expect(refused.state, SuperTabOutgoingState.refused);
+ expect(refused.text, 'First');
+ expect(refused.error, unavailable);
+
+ server.refuse = null;
+ await c.retryOutgoing(refused);
+ await tester.pumpAndSettle();
+ final sent = lastCommand(server);
+ expect(sent['text'], 'First');
+ expect(sent.containsKey('newSession'), isFalse);
+ });
+
+ testSessions('a refusal that lands after another thread opened changes only '
+ 'its own thread', (tester) async {
+ final server = buddyChat();
+ final c = await show(tester, server);
+ await openThread(tester, c, 'message-1');
+ refuseAsOlderServer(server);
+ final hold = server.holdCommands = Completer<void>();
+ await tester.tap(newSession);
+ await tester.enterText(composer, 'For the first thread');
+ await tester.pump();
+ await tester.tap(send);
+ await tester.pump();
+ await openThread(tester, c, 'message-2');
+ hold.complete();
+ server.holdCommands = null;
+ await tester.pumpAndSettle();
+ // The open thread's box is left as it was, and says nothing of another's.
+ expect(tester.widget<TextField>(composer).controller!.text, isEmpty);
+ expect(threadError, findsNothing);
+ expect(c.threadDraft('message-2'), isEmpty);
+ // Its own thread has the text back.
+ await openThread(tester, c, 'message-1');
+ expect(
+ tester.widget<TextField>(composer).controller!.text,
+ 'For the first thread',
+ );
+ });
+
+ testSessions('access lost while a New session reply is on its way leaves '
+ 'nothing behind', (tester) async {
+ final server = buddyChat();
+ final c = await show(tester, server);
+ await openThread(tester, c, 'message-1');
+ refuseAsOlderServer(server);
+ final hold = server.holdCommands = Completer<void>();
+ await tester.tap(newSession);
+ await tester.enterText(composer, 'Private words');
+ await tester.pump();
+ await tester.tap(send);
+ await tester.pump();
+ c.revokeAccess('You no longer have access to this Swarm.');
+ hold.complete();
+ server.holdCommands = null;
+ await tester.pumpAndSettle();
+ expect(c.threadDraft('message-1'), isEmpty);
+ expect(c.outgoing('offline'), isEmpty);
+ expect(find.text('Private words'), findsNothing);
+ expect(find.textContaining('Unrecognized key'), findsNothing);
+ });
+
+ testSessions('a message the server refuses for its form says so plainly '
+ 'under it, never in the server\'s own words', (tester) async {
+ final server = buddyChat();
+ final c = await show(tester, server);
+ server
+ ..refuse = {
+ 'code': 'VALIDATION_ERROR',
+ 'message': 'command: Unrecognized key: "agentOnly"',
+ }
+ ..refuseStatus = 400;
+ c.setDraft('offline', 'In the main chat');
+ await c.send();
+ await tester.pumpAndSettle();
+ expect(find.textContaining('Unrecognized key'), findsNothing);
+ expect(find.text('Not sent'), findsOneWidget);
+ expect(
+ find.text("The server couldn't take this message yet."),
+ findsOneWidget,
+ );
+ });
+
+ testSessions('a refusal saved with the server\'s own words before this '
+ 'version shows plainly', (tester) async {
+ final server = buddyChat();
+ final c = await show(
+ tester,
+ server,
+ initial: {
+ 'tabId': 'tab',
+ 'accountId': 'owner',
+ 'refused': {
+ 'offline': [
+ {
+ 'operationId': 'op-old',
+ 'command': {
+ 'type': 'message.send',
+ 'conversationId': 'offline',
+ 'text': 'Saved before',
+ 'replyTo': null,
+ 'recipientIds': <String>[],
+ },
+ 'mentions': <String, String>{},
+ 'error': rawRefusal,
+ },
+ ],
+ },
+ },
+ );
+ await tester.pumpAndSettle();
+ expect(c.outgoing('offline').single.text, 'Saved before');
+ expect(find.text('Not sent'), findsOneWidget);
+ expect(find.textContaining('Unrecognized key'), findsNothing);
+ expect(
+ find.text("The server couldn't take this message yet."),
+ findsOneWidget,
+ );
+ });
+
testSessions('Ending… cannot be pressed again while its end is on its way', (
tester,
) async {
diff --git a/desktop/test/support/super_tab_fixture.dart b/desktop/test/support/super_tab_fixture.dart
index f2e3c071e..c91156a47 100644
--- a/desktop/test/support/super_tab_fixture.dart
+++ b/desktop/test/support/super_tab_fixture.dart
@@ -87,6 +87,7 @@ class SwarmPartsBackend {
'readMarks',
'threadMarks',
'teamAccounts',
+ 'threadSessions',
}.contains(entry.key))
entry.key: entry.value,
};
@@ -165,6 +166,8 @@ class SwarmPartsBackend {
if (state['avatars'] != null) 'avatars': state['avatars'],
// Only where the server does not try Team accounts (backend read/views.ts).
if (state['teamAccounts'] == false) 'teamAccounts': false,
+ // A server that takes a thread reply's New session (backend read/views.ts).
+ if (state['threadSessions'] == true) 'threadSessions': true,
// The reader's own read marks alone, as backend readMarks.ts sends them.
if ((state['readMarks'] as Map?)?[reader ?? 'owner'] case final Map marks)
'readMarks': Map<String, dynamic>.from(marks),