fix(chat): keep provided reasoning visible during live replies
This commit is contained in:
@@ -53,6 +53,7 @@ JsonMap mergeChatHistory(JsonMap previous, JsonMap page, {bool older = false}) {
|
||||
List<JsonMap> transcriptRows(
|
||||
List<JsonMap> messages, {
|
||||
List<JsonMap> trailing = const [],
|
||||
bool running = false,
|
||||
}) {
|
||||
final rows = <JsonMap>[];
|
||||
String? key;
|
||||
@@ -113,6 +114,19 @@ List<JsonMap> transcriptRows(
|
||||
}
|
||||
}
|
||||
flush();
|
||||
// Only the newest assistant turn can be live. A running step before the
|
||||
// first assistant delta must not reopen reasoning from an earlier reply.
|
||||
if (running && messages.isNotEmpty && messages.last['role'] == 'assistant') {
|
||||
for (final row in rows.reversed) {
|
||||
if (row['kind'] == 'assistant' &&
|
||||
(row['messageIds'] as List).contains(
|
||||
'${messages.last['id'] ?? ''}',
|
||||
)) {
|
||||
row['streaming'] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
rows.addAll(trailing);
|
||||
return rows;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user