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:
@@ -7,6 +7,7 @@ import '../data/chat_repository.dart';
|
||||
import '../domain/chat_account_usage.dart';
|
||||
import '../domain/chat_sessions.dart';
|
||||
import '../domain/chat_transcript.dart';
|
||||
import '../domain/chat_turn_diffs.dart';
|
||||
import 'chat_server_queue.dart';
|
||||
import 'chat_thread_cards.dart';
|
||||
import 'chat_transcript_cache.dart';
|
||||
@@ -60,6 +61,13 @@ class ChatThreadController extends ChangeNotifier {
|
||||
final _transcriptChanges = ChangeNotifier();
|
||||
final ChatServerQueue _queue = ChatServerQueue();
|
||||
|
||||
/// The per-turn change summaries the transcript's change chips show.
|
||||
final ChatTurnDiffs turnDiffs = ChatTurnDiffs();
|
||||
|
||||
/// Fetches one turn's recorded changes through this chat's own gateway.
|
||||
Future<JsonMap> turnDiff(String turnId) =>
|
||||
_repository.turnDiff(sessionId, turnId);
|
||||
|
||||
/// Told about every queue body the server sends (the subscribe reply's and
|
||||
/// each `chat_queue` frame), so delivery states follow the server.
|
||||
void Function(JsonMap queue)? onQueue;
|
||||
@@ -208,6 +216,7 @@ class ChatThreadController extends ChangeNotifier {
|
||||
limit: 200,
|
||||
);
|
||||
if (!_owned(token)) return;
|
||||
turnDiffs.apply(page['turnDiffs'], sessionId);
|
||||
final merged = mergeChatHistory(
|
||||
{'messages': _messages},
|
||||
page,
|
||||
@@ -260,6 +269,7 @@ class ChatThreadController extends ChangeNotifier {
|
||||
try {
|
||||
final page = await _repository.history(sessionId, limit: 200);
|
||||
if (!_owned(token)) return;
|
||||
turnDiffs.apply(page['turnDiffs'], sessionId);
|
||||
if (replaceHeldTurn) {
|
||||
_messages = (page['messages'] as List? ?? const [])
|
||||
.whereType<Map>()
|
||||
@@ -336,6 +346,10 @@ class ChatThreadController extends ChangeNotifier {
|
||||
_applyQueue(envelope['chat_queue']);
|
||||
return;
|
||||
}
|
||||
if (envelope['type'] == 'chat_turn_diffs') {
|
||||
if (turnDiffs.apply(envelope['chat_turn_diffs'], sessionId)) _notify();
|
||||
return;
|
||||
}
|
||||
if (envelope['type'] == 'chat_permission') {
|
||||
final permission = envelope['chat_permission'];
|
||||
if (permission is! Map) return;
|
||||
|
||||
@@ -15,6 +15,7 @@ import '../domain/chat_notice.dart';
|
||||
import '../domain/chat_attachment_picker.dart';
|
||||
import '../domain/chat_colors.dart';
|
||||
import '../domain/chat_transcript.dart';
|
||||
import '../domain/chat_turn_diffs.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import '../ui/sessions/chat_color_picker.dart';
|
||||
import '../ui/sessions/session_actions.dart';
|
||||
@@ -24,6 +25,7 @@ import '../ui/transcript/chat_message_view.dart';
|
||||
import '../ui/transcript/chat_transcript_selection.dart';
|
||||
import '../ui/transcript/chat_injected_rows.dart';
|
||||
import '../ui/transcript/chat_task_notices_group.dart';
|
||||
import '../ui/transcript/chat_turn_diff_chip.dart';
|
||||
import '../../artifacts/actions/artifact_file_bridge.dart';
|
||||
import '../domain/chat_session_handoff.dart';
|
||||
import 'chat_account_usage_section.dart';
|
||||
@@ -977,24 +979,28 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
);
|
||||
// Answered approvals and questions fold into their turn's chips, like
|
||||
// tool calls; only cards still waiting on the operator stay full cards.
|
||||
final allRows = groupSettledQuestions(
|
||||
groupSettledPermissions(
|
||||
transcriptRows(
|
||||
messages,
|
||||
trailing: cards,
|
||||
running:
|
||||
_controller.running &&
|
||||
!_reconnecting &&
|
||||
!_staleTranscript &&
|
||||
!cards.any(chatCardAwaitingOperator),
|
||||
awaitingResponse:
|
||||
_controller.awaitingResponse &&
|
||||
!_reconnecting &&
|
||||
!_staleTranscript &&
|
||||
!cards.any(chatCardAwaitingOperator),
|
||||
liveMessageId: _controller.liveAssistantMessageId,
|
||||
// A turn that changed files carries its summary for the change chip.
|
||||
final allRows = attachChatTurnDiffs(
|
||||
groupSettledQuestions(
|
||||
groupSettledPermissions(
|
||||
transcriptRows(
|
||||
messages,
|
||||
trailing: cards,
|
||||
running:
|
||||
_controller.running &&
|
||||
!_reconnecting &&
|
||||
!_staleTranscript &&
|
||||
!cards.any(chatCardAwaitingOperator),
|
||||
awaitingResponse:
|
||||
_controller.awaitingResponse &&
|
||||
!_reconnecting &&
|
||||
!_staleTranscript &&
|
||||
!cards.any(chatCardAwaitingOperator),
|
||||
liveMessageId: _controller.liveAssistantMessageId,
|
||||
),
|
||||
),
|
||||
),
|
||||
_controller.turnDiffs,
|
||||
);
|
||||
// A transcript held from before a socket gap may still say a compaction is
|
||||
// running even when the repair's read is refused. That running state is
|
||||
@@ -1454,6 +1460,11 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
if (permissions is List<ChatPermissionCardData> && permissions.isNotEmpty)
|
||||
ChatPermissionsChip(permissions: permissions),
|
||||
...chatQuestionChips(row),
|
||||
if (row['turnDiff'] case final Map diff)
|
||||
ChatTurnDiffChip(
|
||||
summary: Map<String, dynamic>.from(diff),
|
||||
load: () => _controller.turnDiff('${diff['turn_id']}'),
|
||||
),
|
||||
];
|
||||
if (kind == 'permissions') {
|
||||
return Align(
|
||||
|
||||
Reference in New Issue
Block a user