Files
pipelines/app/tool/perf/chat_turn_diff_fixture.dart
alan 3374bea2ef Show a chat turn's changed files as a chip that opens its diff
The answer footer shows '3 files changed +9 -2'; tapping opens the turn's
files in the sheet (wide) or a full-screen page (narrow), and a file opens
the run Changes diff viewer. Patches load through the chat's own gateway.
2026-11-09 16:08:35 +00:00

92 lines
3.1 KiB
Dart

import 'package:pipelines_app/core/api_gateway.dart';
/// `?turndiffs=1`: the bench transcript's last answer (`perf-m19`) changed
/// two files, one of them truncated, so captures can review the transcript's
/// change chip and the turn changes viewer. Fixture data only; it never
/// contacts a server.
const chatTurnDiffFixtureTurn = 'turn_fixture';
JsonMap chatTurnDiffFixtureList(String session) => {
'session_id': session,
'turn_diffs': [
{
'turn_id': chatTurnDiffFixtureTurn,
'message_ids': ['perf-m19'],
'files': 3,
'additions': 9,
'deletions': 2,
'truncated': true,
'status': 'partial',
'diagnostic':
'Some changed files exceeded capture limits and are listed without '
'patches; this is not a complete workspace diff.',
},
],
};
JsonMap chatTurnDiffFixtureReply(Object? id, JsonMap request) {
final body = request['chat_turn_diff'];
final session = body is Map ? '${body['session_id'] ?? ''}' : '';
return {
'id': id,
'type': 'chat_turn_diff',
'chat_turn_diff': {
'session_id': session,
'turn_id': chatTurnDiffFixtureTurn,
'summary': (chatTurnDiffFixtureList(session)['turn_diffs'] as List).first,
'changes': {
'status': 'partial',
'scope': 'Git tracked and nonignored files in the run directory',
'diagnostic':
'Some changed files exceeded capture limits and are listed '
'without patches; this is not a complete workspace diff.',
'skipped': 0,
'files': [
{
'path': 'lib/search/search_box.dart',
'kind': 'modified',
'before_mode': '0644',
'after_mode': '0644',
'patch':
'--- "a/lib/search/search_box.dart"\n'
'+++ "b/lib/search/search_box.dart"\n'
'@@ -10,7 +10,12 @@\n'
' class SearchBox extends StatelessWidget {\n'
'- const SearchBox({super.key});\n'
'+ const SearchBox({super.key, this.onSubmit});\n'
'+\n'
'+ /// Runs the query when the operator presses Enter.\n'
'+ final ValueChanged<String>? onSubmit;\n'
' \n'
' @override\n'
'- Widget build(BuildContext context) => const TextField();\n'
'+ Widget build(BuildContext context) =>\n'
'+ TextField(onSubmitted: onSubmit);\n'
' }\n',
},
{
'path': 'docs/search.md',
'kind': 'added',
'after_mode': '0644',
'patch':
'--- "/dev/null"\n'
'+++ "b/docs/search.md"\n'
'@@ -0,0 +1,3 @@\n'
'+# Search\n'
'+\n'
'+Press Enter to run the query.\n',
},
{
'path': 'assets/fixtures/large.json',
'kind': 'added',
'after_mode': '0644',
'truncated': true,
'no_patch': true,
'no_patch_reason': 'lines',
},
],
},
},
};
}