fix(chat): keep streamed reasoning live across queued follow-ups

This commit is contained in:
2026-10-24 02:04:44 +01:00
parent de7c308fdb
commit 8e980564cb
4 changed files with 61 additions and 6 deletions
@@ -43,6 +43,7 @@ class ChatThreadController extends ChangeNotifier {
bool _hasMore = false;
String _cursor = '';
String _nativeTurnId = '';
String? _liveAssistantMessageId;
JsonMap? _usage;
String? _error;
@@ -55,6 +56,7 @@ class ChatThreadController extends ChangeNotifier {
List<JsonMap> get messages => _messages;
bool get running => _running;
String? get liveAssistantMessageId => _liveAssistantMessageId;
bool get loaded => _loaded;
bool get loading => _loading;
bool get hasMore => _hasMore;
@@ -160,6 +162,7 @@ class ChatThreadController extends ChangeNotifier {
// keep claiming to run until the re-subscribe proves otherwise.
_running = false;
_nativeTurnId = '';
_liveAssistantMessageId = null;
_notify();
await _attach(force: true);
if (!_owned(token)) return;
@@ -253,6 +256,11 @@ class ChatThreadController extends ChangeNotifier {
.map((message) => Map<String, dynamic>.from(message))
.toList();
_running = next['running'] == true;
if (!_running) {
_liveAssistantMessageId = null;
} else if (const ['text', 'reasoning', 'tool'].contains(body['kind'])) {
_liveAssistantMessageId = body['message_id'] as String?;
}
_nativeTurnId = '${next['nativeTurnId'] ?? ''}';
_notify();
}