From fc5d3bc42b564db592efbc8f544fdc20769f0da9 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 26 Nov 2026 00:08:54 +0000 Subject: [PATCH] Test that a query answered in a later feed slice goes to onReply Co-Authored-By: Claude Opus 5.5 --- .../shell/chat_shell_terminal_feed_test.dart | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/app/test/features/chat/shell/chat_shell_terminal_feed_test.dart b/app/test/features/chat/shell/chat_shell_terminal_feed_test.dart index a83e34b7..bc8e4730 100644 --- a/app/test/features/chat/shell/chat_shell_terminal_feed_test.dart +++ b/app/test/features/chat/shell/chat_shell_terminal_feed_test.dart @@ -121,4 +121,48 @@ void main() { expect(longest, lessThan(const Duration(milliseconds: 60))); expect(session.terminal.buffer.lines.length, greaterThan(1000)); }); + + test('a query answered in a later slice of live output is a reply', () async { + final typed = []; + final replies = []; + final session = ChatShellTerminalSession( + ChatShellRun.fromJson({ + 'id': 'run_1', + 'command': 'sh', + 'directory': '/w', + 'status': 'running', + 'started_at': 1, + 'output': '', + 'output_bytes': 0, + 'terminal': true, + 'cols': 80, + 'rows': 24, + })!, + onInput: typed.add, + onResize: (_, _) {}, + onReply: replies.add, + ); + // Far more than one turn's budget, with the query at its very end. + final chunk = '${'z' * 200000}\x1b[6n'; + final run = ChatShellRun.fromJson({ + 'id': 'run_1', + 'command': 'sh', + 'directory': '/w', + 'status': 'running', + 'started_at': 1, + 'output': chunk, + 'output_bytes': chunk.length, + 'terminal': true, + 'cols': 80, + 'rows': 24, + })!; + session.append(run, chunk, 0, chunk.length); + for (var i = 0; i < 1000 && session.drawn < chunk.length; i++) { + await turn(); + } + expect(session.drawn, chunk.length); + expect(replies, hasLength(1)); + expect(replies.single, endsWith('R')); + expect(typed, isEmpty); + }); }