Chat: an unchecked earlier send no longer flashes 'Not sent' on open

A message a previous visit sent but never saw acknowledged was restored as
'Not sent' and flipped to sent a moment later, once the history read showed
the server had it. It now stays 'sending' until that read, and only becomes
'Not sent' if the server really does not have it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 16:48:13 +00:00
parent 7d7d839ffa
commit c441400f36
2 changed files with 42 additions and 1 deletions
@@ -0,0 +1,33 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/conversation/chat_composer_send.dart';
import 'package:pipelines_app/features/chat/conversation/chat_deliveries.dart';
const _send = ChatComposerSend(
sessionId: 's',
text: 'Did it land?',
operationId: 'op-1',
nativeMessageId: 'msg_op-1',
);
final _message = {'role': 'user', 'id': 'msg_op-1', 'operation_id': 'op-1'};
void main() {
test('a restored unchecked send never shows "Not sent" before the history '
'read; the server having it makes it sent', () {
final deliveries = ChatDeliveries()..restore([_send]);
expect(deliveries.stateFor(_message), ChatDelivery.sending);
deliveries.reconcile([_message]);
// Settled as sent: an older accepted send is drawn quietly.
expect(deliveries.stateFor(_message), isNull);
expect(deliveries.unsent, isEmpty);
deliveries.dispose();
});
test('a restored send the history does not have becomes "Not sent"', () {
final deliveries = ChatDeliveries()..restore([_send]);
deliveries.reconcile(const []);
expect(deliveries.stateFor(_message), ChatDelivery.failed);
expect(deliveries.unsent, [_send]);
deliveries.dispose();
});
}