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.
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
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',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -21,6 +21,7 @@
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
|
||||
import 'chat_new_session_fixture.dart';
|
||||
import 'chat_turn_diff_fixture.dart';
|
||||
import 'chat_question_fixture.dart';
|
||||
import 'chat_scroll_fixture.dart';
|
||||
|
||||
@@ -374,7 +375,11 @@ JsonMap? perfChatReply(JsonMap request) {
|
||||
'next_cursor': '',
|
||||
'has_more': false,
|
||||
},
|
||||
if (_params['turndiffs'] == '1')
|
||||
'chat_turn_diffs': chatTurnDiffFixtureList(session),
|
||||
};
|
||||
case 'chat_turn_diff':
|
||||
return chatTurnDiffFixtureReply(id, request);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user