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:
2026-11-03 11:05:38 +00:00
parent a4c191a416
commit f7b5958d64
28 changed files with 1319 additions and 42 deletions
+9
View File
@@ -10,6 +10,7 @@ import 'attention_badge.dart';
import 'destination.dart';
import 'list_detail.dart';
import 'shell_bar.dart';
import 'shell_list_shortcuts.dart';
class AdaptiveShell extends StatefulWidget {
const AdaptiveShell({
@@ -222,7 +223,15 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
/// Handles this before focused text controls can insert or traverse on
/// Ctrl+Tab. The handler is scoped to the shell's lifetime, not onboarding.
///
/// Ctrl+1…Ctrl+9 open the Nth item of the open tab's list the same way, in
/// the list's on-screen order; a page (Settings) has no list.
bool _handleDestinationKeyEvent(KeyEvent event) {
final listIndex = shellListShortcutIndex(event, HardwareKeyboard.instance);
if (listIndex != null) {
if (!shellTabDestinations.contains(_selected)) return false;
return _bar.lists.open(_selected, listIndex);
}
if (event is! KeyDownEvent ||
event.logicalKey != LogicalKeyboardKey.tab ||
!HardwareKeyboard.instance.isControlPressed) {
+4
View File
@@ -1,6 +1,7 @@
import 'package:flutter/widgets.dart';
import 'destination.dart';
import 'shell_list_shortcuts.dart';
/// What the open screen of a tab puts in the app bar: its title, a Back
/// control and its actions. Absent, the bar shows the tab's own name.
@@ -65,6 +66,9 @@ class ShellBarRegistry extends ChangeNotifier {
final _Notifier _bar = _Notifier();
final _Notifier _badgeNotifier = _Notifier();
/// How each tab's list opens its Nth item (Ctrl+1…Ctrl+9).
final ShellListShortcuts lists = ShellListShortcuts();
/// The destination whose bar is on screen; null treats every destination
/// as shown. Bar changes of other destinations are kept without notifying:
/// the host rebuilds when it changes the focus.
+98
View File
@@ -0,0 +1,98 @@
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'destination.dart';
import 'shell_bar.dart';
/// Opens the Nth item of a tab's list: what each tab's list screen published
/// for Ctrl+1…Ctrl+9. One opener per tab; the latest mounted list wins.
class ShellListShortcuts {
final Map<AppDestination, (Object, bool Function(int index))> _openers = {};
/// Opens the item at [index] (0-based, on-screen order) of [destination]'s
/// list; false when the tab publishes no list or has no such item.
bool open(AppDestination destination, int index) =>
_openers[destination]?.$2(index) ?? false;
void _set(
AppDestination destination,
Object owner,
bool Function(int) open,
) => _openers[destination] = (owner, open);
void _clear(AppDestination destination, Object owner) {
if (_openers[destination]?.$1 == owner) _openers.remove(destination);
}
}
/// The 0-based list index a Ctrl+1…Ctrl+9 key event names, or null for any
/// other event. Shift, Alt and Meta must be up, so system and browser chords
/// built on the digits are left alone.
int? shellListShortcutIndex(KeyEvent event, HardwareKeyboard keyboard) {
if (event is! KeyDownEvent ||
!keyboard.isControlPressed ||
keyboard.isShiftPressed ||
keyboard.isAltPressed ||
keyboard.isMetaPressed) {
return null;
}
final index = _digits.indexOf(event.logicalKey);
return index < 0 ? null : index;
}
const _digits = [
LogicalKeyboardKey.digit1,
LogicalKeyboardKey.digit2,
LogicalKeyboardKey.digit3,
LogicalKeyboardKey.digit4,
LogicalKeyboardKey.digit5,
LogicalKeyboardKey.digit6,
LogicalKeyboardKey.digit7,
LogicalKeyboardKey.digit8,
LogicalKeyboardKey.digit9,
];
/// Publishes, while mounted, how its tab's list opens its Nth item, so the
/// shell's Ctrl+1…Ctrl+9 open it from anywhere in the tab (also while a text
/// field has focus). [onOpenIndex] reads the list at key time, in on-screen
/// order, and reports whether an item was opened. Outside a shell it does
/// nothing.
class ShellListShortcut extends StatefulWidget {
const ShellListShortcut({
super.key,
required this.onOpenIndex,
required this.child,
});
final bool Function(int index) onOpenIndex;
final Widget child;
@override
State<ShellListShortcut> createState() => _ShellListShortcutState();
}
class _ShellListShortcutState extends State<ShellListShortcut> {
final Object _owner = Object();
ShellBarScope? _scope;
bool _open(int index) => mounted && widget.onOpenIndex(index);
@override
void didChangeDependencies() {
super.didChangeDependencies();
final scope = ShellBarScope.maybeOf(context);
if (scope == _scope) return;
_scope?.registry.lists._clear(_scope!.destination, _owner);
_scope = scope;
scope?.registry.lists._set(scope.destination, _owner, _open);
}
@override
void dispose() {
_scope?.registry.lists._clear(_scope!.destination, _owner);
super.dispose();
}
@override
Widget build(BuildContext context) => widget.child;
}