Merge: Next chat button cycles through the list

This commit is contained in:
2026-11-04 18:22:45 +00:00
9 changed files with 425 additions and 8 deletions
@@ -0,0 +1,24 @@
import '../../../core/api_gateway.dart';
import 'chat_sessions.dart';
/// The rows the chat list draws, top to bottom: the [query]'s matches in
/// Starred, then Chats by directory, then Closed, leaving out every section
/// [isOpen] reports folded. Ctrl+1…Ctrl+9 and Next chat both count these.
List<JsonMap> chatSessionsShown(
List<JsonMap> sessions, {
required String query,
required bool Function(String title) isOpen,
}) => chatSessionsInListOrder(
chatSessionSections(filterChatSessions(sessions, query)),
isOpen: isOpen,
);
/// The row after [currentId] in [shown], wrapping from the last row to the
/// first. A chat not among [shown] (its section is folded) moves to the
/// first row. Null when no other row is shown, so there is nothing to move to.
JsonMap? chatSessionAfter(List<JsonMap> shown, String currentId) {
final index = shown.indexWhere((row) => '${row['id'] ?? ''}' == currentId);
final others = index < 0 ? shown.length : shown.length - 1;
if (others < 1) return null;
return shown[(index + 1) % shown.length];
}