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:
@@ -89,9 +89,10 @@ class ChatRepository {
|
||||
}))['chat_shells'],
|
||||
);
|
||||
|
||||
Future<JsonMap> automations(String sessionId) => gateway.call('chat_automations', {
|
||||
'chat_query': {'session_id': sessionId},
|
||||
});
|
||||
Future<JsonMap> automations(String sessionId) =>
|
||||
gateway.call('chat_automations', {
|
||||
'chat_query': {'session_id': sessionId},
|
||||
});
|
||||
Future<List<String>> directories() async {
|
||||
final value = (await gateway.call('chat_directories'))['chat_directories'];
|
||||
if (value is! List) {
|
||||
@@ -139,20 +140,37 @@ class ChatRepository {
|
||||
'chat_query': {'session_id': sessionId, 'limit': limit, 'cursor': cursor},
|
||||
});
|
||||
final page = reply['chat_history'];
|
||||
// The session's recorded per-turn changes ride with its history.
|
||||
final turnDiffs = reply['chat_turn_diffs'];
|
||||
if (page is Map) {
|
||||
return {
|
||||
'messages': _maps(page['messages']),
|
||||
'nextCursor': '${page['next_cursor'] ?? ''}',
|
||||
'hasMore': page['has_more'] == true,
|
||||
'turnDiffs': ?turnDiffs,
|
||||
};
|
||||
}
|
||||
return {
|
||||
'messages': _maps(reply['chat_messages']),
|
||||
'nextCursor': '',
|
||||
'hasMore': false,
|
||||
'turnDiffs': ?turnDiffs,
|
||||
};
|
||||
}
|
||||
|
||||
/// One turn's recorded file changes: the `chat_turn_diff` body with its
|
||||
/// `summary` and `changes` (a `file_changes`-shaped capture).
|
||||
Future<JsonMap> turnDiff(String sessionId, String turnId) async {
|
||||
final reply = await gateway.call('chat_turn_diff', {
|
||||
'chat_turn_diff': {'session_id': sessionId, 'turn_id': turnId},
|
||||
});
|
||||
final body = reply['chat_turn_diff'];
|
||||
if (body is! Map || body['changes'] is! Map) {
|
||||
throw StateError('The server returned no changes for this turn.');
|
||||
}
|
||||
return Map<String, dynamic>.from(body);
|
||||
}
|
||||
|
||||
Future<JsonMap> subscribe(String sessionId) =>
|
||||
gateway.call('chat_subscribe', {
|
||||
'chat_subscribe': {'session_id': sessionId},
|
||||
|
||||
Reference in New Issue
Block a user