feat(app): a chat names its model (recorded, last reply's, or the agent default) and each reply shows the model that answered

This commit is contained in:
2026-10-23 18:57:36 +01:00
parent 1d9fd08b31
commit 35e343fe40
5 changed files with 102 additions and 2 deletions
@@ -56,6 +56,7 @@ List<JsonMap> transcriptRows(
}) {
final rows = <JsonMap>[];
String? key;
String model = '';
final ids = <String>[];
final parts = <JsonMap>[];
final activity = <JsonMap>[];
@@ -77,9 +78,12 @@ List<JsonMap> transcriptRows(
'key': key,
'messageIds': List<String>.of(ids),
'parts': List<JsonMap>.of(parts),
// The model that answered, as the server recorded it on the reply.
if (model.isNotEmpty) 'model': model,
});
}
key = null;
model = '';
ids.clear();
parts.clear();
activity.clear();
@@ -90,6 +94,8 @@ List<JsonMap> transcriptRows(
if (message['role'] == 'assistant') {
final id = '${message['id'] ?? ''}'.trim();
key ??= id;
final recorded = '${message['model'] ?? ''}'.trim();
if (recorded.isNotEmpty) model = recorded;
if (id.isNotEmpty) ids.add(id);
for (final part in (message['parts'] as List? ?? const [])) {
if (part is! Map) continue;
@@ -339,3 +345,13 @@ class ChatSendQueue {
return result;
}
}
/// The model of the latest stored reply, or empty when none recorded one.
String latestReplyModel(List<JsonMap> messages) {
for (final message in messages.reversed) {
if (message['role'] != 'assistant') continue;
final model = '${message['model'] ?? ''}'.trim();
if (model.isNotEmpty) return model;
}
return '';
}