Chat: answered questions collapse into their turn like tool calls

This commit is contained in:
2026-11-03 19:31:40 +00:00
parent fa6c0864db
commit fc94210595
14 changed files with 760 additions and 38 deletions
+7
View File
@@ -12,11 +12,13 @@
// them, and keeps colours picked with chat_color;
// `?msgs=`, `?rich=1`, `?older=1`, `?live=N` vary the chat transcripts for
// scroll captures (tool/perf/chat_scroll_fixture.dart).
// `?question=` pushes an agent question (tool/perf/chat_question_fixture.dart).
// `/new` in a fixture chat moves it to a fresh, empty session
// (tool/perf/chat_new_session_fixture.dart).
import 'package:pipelines_app/core/api_gateway.dart';
import 'chat_new_session_fixture.dart';
import 'chat_question_fixture.dart';
import 'chat_scroll_fixture.dart';
Map<String, String> _params = const {};
@@ -25,6 +27,7 @@ Map<String, String> _params = const {};
void configurePerfFixture(Map<String, String> params) {
_params = params;
configureChatScrollFixture(params);
configureChatQuestionFixture(params);
}
int get _hits => int.tryParse(_params['hits'] ?? '') ?? 0;
@@ -91,6 +94,8 @@ bool get _scrollVariety => ['msgs', 'rich', 'older'].any(_params.containsKey);
/// Unsolicited envelopes that follow a reply: the `?quota=` usage frame.
List<JsonMap> perfChatFollowUps(JsonMap request) {
final answered = chatQuestionFollowUps(request);
if (answered.isNotEmpty) return answered;
final quota = _params['quota'];
if (_chats == 0 || quota == null || request['type'] != 'chat_subscribe') {
return const [];
@@ -189,6 +194,8 @@ String _answer(int i) =>
/// Chat replies for `?chats=N`, or null to fall through to the fixture.
JsonMap? perfChatReply(JsonMap request) {
if (_chats == 0) return null;
final question = chatQuestionReply(request);
if (question != null) return question;
final id = request['id'];
switch ('${request['type']}') {
case 'chat_sessions':