fix(app): a sent message keeps its place in the transcript, so each reply follows it
This commit is contained in:
@@ -304,6 +304,28 @@ class ChatThreadController extends ChangeNotifier {
|
||||
|
||||
bool _owned(int token) => !_disposed && token == _generation;
|
||||
|
||||
/// Puts a sent turn into the transcript where it was sent, as the web does:
|
||||
/// after everything held so far and before any reply frame that follows. It
|
||||
/// carries the id the harness will persist, so the live echo is ignored and
|
||||
/// the history copy replaces it in place instead of moving it.
|
||||
void insertLocal(JsonMap message) {
|
||||
if (_disposed) return;
|
||||
_messages = [..._messages, message];
|
||||
_notify();
|
||||
}
|
||||
|
||||
/// Removes a sent turn the server refused.
|
||||
void removeLocal(String operationId) {
|
||||
if (_disposed) return;
|
||||
final next = [
|
||||
for (final message in _messages)
|
||||
if (message['operation_id'] != operationId) message,
|
||||
];
|
||||
if (next.length == _messages.length) return;
|
||||
_messages = next;
|
||||
_notify();
|
||||
}
|
||||
|
||||
void _notify() {
|
||||
if (!_disposed) notifyListeners();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user