Test that a query answered in a later feed slice goes to onReply
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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 = <String>[];
|
||||
final replies = <String>[];
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user