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;
|
||||
|
||||
Reference in New Issue
Block a user