App: chat colours, Ctrl+1-9 opens the Nth list item, starred chats alphabetical
A chat's colour is picked from its row menu (Colour...), a long-press or the chat information sheet. The list shows it as a leading bar, a faint row tint and a coloured avatar; the open chat shows a faint wash under its top bar. Shades are Cupertino's dynamic system colours and Material swatches tuned per brightness. Changes from other devices apply live. Ctrl+1...Ctrl+9 open the Nth item of the open tab's list (chats, runs, pipelines) in on-screen order, also while typing. Starred chats are sorted by name, case-insensitively, as one alphabetical group.
This commit is contained in:
@@ -74,6 +74,7 @@ class ChatSessionsController extends ChangeNotifier {
|
||||
}
|
||||
|
||||
void _onFrame(JsonMap frame) {
|
||||
if (frame['type'] == 'chat_session_changed') return _sessionChanged(frame);
|
||||
final effect = chatSessionFrameEffect(frame);
|
||||
if (effect == null) return;
|
||||
final id = effect.sessionId;
|
||||
@@ -86,6 +87,38 @@ class ChatSessionsController extends ChangeNotifier {
|
||||
if (effect.attention && id == activeSessionId) _scheduleActiveAck(id);
|
||||
}
|
||||
|
||||
/// Another device changed a chat's shared colour, star or title: the row
|
||||
/// takes the server's values at once, with no re-list. Each field the
|
||||
/// registry row omits is cleared, since omitted means unset on the wire.
|
||||
void _sessionChanged(JsonMap frame) {
|
||||
final changed = frame['chat_session'];
|
||||
if (changed is! Map) return;
|
||||
final id = '${changed['id'] ?? ''}';
|
||||
if (id.isEmpty || _disposed) return;
|
||||
var found = false;
|
||||
_sessions = [
|
||||
for (final row in _sessions)
|
||||
if ('${row['id'] ?? ''}' == id)
|
||||
() {
|
||||
found = true;
|
||||
final next = <String, dynamic>{...row};
|
||||
for (final key in const ['color', 'starred', 'starred_at']) {
|
||||
if (changed.containsKey(key)) {
|
||||
next[key] = changed[key];
|
||||
} else {
|
||||
next.remove(key);
|
||||
}
|
||||
}
|
||||
final title = '${changed['title'] ?? ''}'.trim();
|
||||
if (title.isNotEmpty) next['title'] = title;
|
||||
return next;
|
||||
}()
|
||||
else
|
||||
row,
|
||||
];
|
||||
if (found) _notify();
|
||||
}
|
||||
|
||||
void _bindAckSync(AttentionAckSync? sync) {
|
||||
if (identical(sync, _ackSync)) return;
|
||||
_ackSync?.removeListener(_ackChanged);
|
||||
@@ -245,6 +278,13 @@ class ChatSessionsController extends ChangeNotifier {
|
||||
patch: {'starred': starred},
|
||||
);
|
||||
|
||||
/// Sets [sessionId]'s shared colour (a palette name, null for none).
|
||||
Future<void> setColor(String sessionId, String? color) => _mutate(
|
||||
sessionId,
|
||||
() => repository.setColor(sessionId, color),
|
||||
patch: {'color': color},
|
||||
);
|
||||
|
||||
Future<void> close(String sessionId) => _mutate(
|
||||
sessionId,
|
||||
() => repository.close(sessionId),
|
||||
|
||||
Reference in New Issue
Block a user