App: keep a left chat's cached transcript following its live frames

A left conversation stays subscribed on the server for the rest of the
connection, but the cached transcript was frozen when it was left. A reply
that arrived in the background only appeared after the reopened view's
subscribe and newest-page read (~1-2s over the network on large chats).
The cache now folds the session's chat events into the kept transcript,
so the reply is drawn the moment the chat opens; the page still replaces it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 14:43:52 +00:00
parent 61c7eee2b0
commit cf4579ab15
4 changed files with 211 additions and 11 deletions
@@ -246,6 +246,34 @@ void main() {
expect(reopened.position.pixels, closeTo(saved, 1));
});
testWidgets('a left conversation keeps folding its replies into the cache', (
tester,
) async {
final gateway = FakeChatGateway();
addTearDown(gateway.close);
gateway.history = (_) async => tallPage();
final transcripts = ChatTranscriptCache();
await tester.pumpWidget(
host(
ChatThreadView(
gateway: gateway,
sessionId: 's',
transcripts: transcripts,
onBack: () {},
),
),
);
await tester.pumpAndSettle();
await tester.pumpWidget(host(const SizedBox()));
// The session stays subscribed, so its reply still arrives.
gateway.emitEvent(chatTextFrame('reply while away', messageId: 'late'));
await tester.pump();
final held = transcripts.read('s')!.messages;
expect(held.last['id'], 'late');
expect((held.last['parts'] as List).single['text'], 'reply while away');
});
testWidgets('a conversation that fits its viewport offers no control', (
tester,
) async {