Merge branch 'worktree-agent-aae8756320b8309f6'
# Conflicts: # app/lib/features/chat/conversation/chat_thread_view.dart # app/tool/perf/perf_fixture.dart # internal/protocol/message.go # internal/server/chat_hub.go
This commit is contained in:
@@ -6,6 +6,7 @@ import '../../../core/api_gateway.dart';
|
||||
import '../data/chat_repository.dart';
|
||||
import '../domain/chat_account_usage.dart';
|
||||
import '../domain/chat_sessions.dart';
|
||||
import '../domain/chat_shown_items.dart';
|
||||
import '../domain/chat_transcript.dart';
|
||||
import '../domain/chat_turn_diffs.dart';
|
||||
import 'chat_server_queue.dart';
|
||||
@@ -73,6 +74,7 @@ class ChatThreadController extends ChangeNotifier {
|
||||
void Function(JsonMap queue)? onQueue;
|
||||
|
||||
List<JsonMap> _messages = const [];
|
||||
List<JsonMap> _shown = const [];
|
||||
bool _running = false;
|
||||
bool _loaded = false;
|
||||
bool _loading = false;
|
||||
@@ -116,6 +118,10 @@ class ChatThreadController extends ChangeNotifier {
|
||||
|
||||
List<JsonMap> get messages => _messages;
|
||||
|
||||
/// What the model showed through the Pipelines tools ([chatShownItemsOf]),
|
||||
/// as the server retains it, oldest first.
|
||||
List<JsonMap> get shown => _shown;
|
||||
|
||||
/// The prompts the server still holds for this session, in delivery order.
|
||||
List<JsonMap> get queuedPrompts => _queue.prompts;
|
||||
|
||||
@@ -312,6 +318,7 @@ class ChatThreadController extends ChangeNotifier {
|
||||
_subscribed = true;
|
||||
_subscriptionError = null;
|
||||
_applyQueue(reply['chat_queue']);
|
||||
_applyShown(reply['chat_shown'], replace: true);
|
||||
} catch (error) {
|
||||
// History stays usable, but the UI must report that live updates failed.
|
||||
if (_disposed) return;
|
||||
@@ -340,8 +347,20 @@ class ChatThreadController extends ChangeNotifier {
|
||||
_notify();
|
||||
}
|
||||
|
||||
/// Adopts the subscribe reply's retained list, or one pushed item.
|
||||
void _applyShown(Object? body, {bool replace = false}) {
|
||||
final items = chatShownItemsOf(body, sessionId);
|
||||
if (items == null) return;
|
||||
_shown = mergeChatShownItems(_shown, items, replace: replace);
|
||||
_notify();
|
||||
}
|
||||
|
||||
void _onFrame(JsonMap envelope) {
|
||||
if (_disposed) return;
|
||||
if (envelope['type'] == 'chat_shown') {
|
||||
_applyShown(envelope['chat_shown']);
|
||||
return;
|
||||
}
|
||||
if (envelope['type'] == 'chat_queue') {
|
||||
_applyQueue(envelope['chat_queue']);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user