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
@@ -0,0 +1,47 @@
import 'package:flutter/widgets.dart';
import '../../../core/api_gateway.dart';
import '../domain/chat_colors.dart';
import '../ui/sessions/chat_color_palette.dart';
/// The open chat's colour as a faint wash behind the top of the page: it
/// shows through the glass bar and fades out just below it, so even without
/// the list beside it the chat carries a gentle reminder of which one it is.
/// It sits under the transcript and takes no taps, so text contrast and
/// hit-testing are untouched. Nothing is drawn for a chat with no colour.
class ChatColorWash extends StatelessWidget {
const ChatColorWash({super.key, required this.session});
final JsonMap? session;
@override
Widget build(BuildContext context) {
final color = chatColorShade(context, chatSessionColor(session));
if (color == null) return const SizedBox.shrink();
final strength = chatColorDarkSurface(context) ? 0.20 : 0.14;
// The bar's height arrives as top padding; the wash reaches a little
// past it so the fade reads under the bar, not as an edge at it.
final height = MediaQuery.paddingOf(context).top + 72;
return Positioned(
top: 0,
left: 0,
right: 0,
height: height,
child: IgnorePointer(
child: DecoratedBox(
key: const Key('chat-color-wash'),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
color.withValues(alpha: strength),
color.withValues(alpha: 0),
],
),
),
),
),
);
}
}
@@ -11,14 +11,17 @@ import '../data/chat_repository.dart';
import '../domain/chat_activity_detail.dart';
import '../domain/chat_notice.dart';
import '../domain/chat_attachment_picker.dart';
import '../domain/chat_colors.dart';
import '../domain/chat_transcript.dart';
import '../ui/sessions/chat_adaptive.dart';
import '../ui/sessions/chat_color_picker.dart';
import '../ui/sessions/session_actions.dart';
import '../ui/transcript/chat_markdown_view.dart';
import '../ui/transcript/chat_message_view.dart';
import '../ui/transcript/chat_injected_rows.dart';
import 'chat_account_usage_section.dart';
import 'chat_background_tasks.dart';
import 'chat_color_wash.dart';
import 'chat_command_actions.dart';
import 'chat_composer_bar.dart';
import 'chat_composer_controller.dart';
@@ -75,9 +78,14 @@ class ChatThreadView extends StatefulWidget {
this.onCreatedSession,
this.onSessionRenamed,
this.onSessionClosed,
this.onColorSelected,
});
final ApiGateway gateway;
/// Sets the chat's shared colour (a palette name, null for none) from the
/// information sheet; null leaves the sheet without the Colour choice.
final ValueChanged<String?>? onColorSelected;
final String sessionId;
final VoidCallback onBack;
@@ -337,11 +345,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
context: context,
builder: (sheetContext) => Align(
alignment: Alignment.bottomCenter,
child: SafeArea(
child: CupertinoPopupSurface(
child: _ChatInfoSheet(controller: _controller),
),
),
child: SafeArea(child: CupertinoPopupSurface(child: _infoSheet())),
),
);
return;
@@ -351,10 +355,16 @@ class _ChatThreadViewState extends State<ChatThreadView> {
showDragHandle: true,
isScrollControlled: true,
useSafeArea: true,
builder: (sheetContext) => _ChatInfoSheet(controller: _controller),
builder: (sheetContext) => _infoSheet(),
);
}
Widget _infoSheet() => _ChatInfoSheet(
controller: _controller,
color: chatSessionColor(widget.session),
onColorSelected: widget.onColorSelected,
);
/// The transcript in recorded order; a sent turn is part of it from the
/// moment it is sent (ChatThreadController.insertLocal).
List<JsonMap> _visibleMessages() => _controller.messages;
@@ -927,6 +937,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
_rowWidgets.prune();
return Stack(
children: [
// Behind everything: the chat's colour under the bar.
ChatColorWash(session: widget.session),
// At rest the first item starts below the floating bar
// and the last one ends above the floating composer.
// Bottom-anchored at the split row, the newest rows are
@@ -1541,9 +1553,15 @@ String _chatInfoDollars(num value) {
/// The "Chat information" panel. It rebuilds from the controller, so metrics
/// that arrive while it is open replace the displayed snapshot.
class _ChatInfoSheet extends StatelessWidget {
const _ChatInfoSheet({required this.controller});
const _ChatInfoSheet({
required this.controller,
this.color,
this.onColorSelected,
});
final ChatThreadController controller;
final String? color;
final ValueChanged<String?>? onColorSelected;
@override
Widget build(BuildContext context) {
@@ -1562,6 +1580,8 @@ class _ChatInfoSheet extends StatelessWidget {
cupertino: cupertino,
doneKey: const Key('chat-info-close'),
),
if (onColorSelected case final onSelected?)
ChatColorSection(selected: color, onSelected: onSelected),
for (final metric in _chatInfoMetrics(controller.usage))
_ChatInfoRow(metric: metric, cupertino: cupertino),
ChatAccountUsageSection(
@@ -182,6 +182,12 @@ class ChatRepository {
gateway.call('chat_star', {
'chat_query': {'session_id': sessionId, 'starred': starred},
});
/// Sets the shared highlight colour by palette name; null clears it.
Future<JsonMap> setColor(String sessionId, String? color) =>
gateway.call('chat_color', {
'chat_query': {'session_id': sessionId, 'color': color},
});
Future<JsonMap> close(String sessionId) => gateway.call('chat_close', {
'chat_query': {'session_id': sessionId},
});
@@ -0,0 +1,23 @@
/// The fixed palette of shared chat highlight colours, by the names the
/// server stores, in picker order. Each host renders its own tuned shade.
const chatColorNames = [
'red',
'orange',
'amber',
'green',
'teal',
'blue',
'purple',
'pink',
];
/// The session's highlight name, or null when it has none (or one this
/// client does not know).
String? chatSessionColor(Map<String, dynamic>? session) {
final name = '${session?['color'] ?? ''}'.trim();
return chatColorNames.contains(name) ? name : null;
}
/// The colour's name as a person reads it.
String chatColorLabel(String name) =>
name.isEmpty ? name : name[0].toUpperCase() + name.substring(1);
@@ -34,6 +34,62 @@ List<({String directory, List<JsonMap> sessions})> groupChatSessions(
.toList();
}
/// The list's sections in on-screen order: Starred (open chats, by name, so
/// each keeps its place), Chats (open, server recency) and Closed (server
/// recency). Empty sections are left out.
List<({String title, List<JsonMap> sessions})> chatSessionSections(
List<JsonMap> visible,
) {
bool closed(JsonMap s) => s['closed_at'] != null;
bool starred(JsonMap s) => s['starred'] == true && !closed(s);
final sections = [
(
title: 'Starred',
sessions: sortStarredChatSessions(visible.where(starred)),
),
(
title: 'Chats',
sessions: visible.where((s) => !starred(s) && !closed(s)).toList(),
),
(title: 'Closed', sessions: visible.where(closed).toList()),
];
return [
for (final section in sections)
if (section.sessions.isNotEmpty) section,
];
}
/// Starred chats alphabetically by their shown title, ignoring case; equal
/// titles keep a fixed order by id.
List<JsonMap> sortStarredChatSessions(Iterable<JsonMap> sessions) =>
sessions.toList()..sort((a, b) {
final byTitle = chatSessionTitle(
a,
).toLowerCase().compareTo(chatSessionTitle(b).toLowerCase());
if (byTitle != 0) return byTitle;
return '${a['id'] ?? ''}'.compareTo('${b['id'] ?? ''}');
});
/// Whether a section's rows are split under directory headings. Starred keeps
/// its alphabetical order whole, so a name is always in the same place.
bool chatSectionGroupsByDirectory(String title) => title != 'Starred';
/// The rows of [sections] in the order the list draws them: each open
/// section's rows, directory group by directory group. A folded section
/// draws no rows.
List<JsonMap> chatSessionsInListOrder(
List<({String title, List<JsonMap> sessions})> sections, {
required bool Function(String title) isOpen,
}) => [
for (final section in sections)
if (isOpen(section.title))
if (chatSectionGroupsByDirectory(section.title))
for (final group in groupChatSessions(section.sessions))
...group.sessions
else
...section.sessions,
];
String chatSessionActivity({required bool running, required bool unseen}) =>
running
? 'streaming'
+1
View File
@@ -252,6 +252,7 @@ class _ChatScreenState extends State<ChatScreen> {
onCreatedSession: _openCreated,
onSessionRenamed: (title) => _renamed(selected, title),
onSessionClosed: _closed,
onColorSelected: (color) => _sessions.setColor(selected, color),
);
}
@@ -0,0 +1,49 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../domain/chat_colors.dart';
import 'chat_adaptive.dart';
/// The host's own shade for a chat colour name, tuned for the current
/// brightness: Cupertino's dynamic system colours, and Material's standard
/// swatches (a deeper tone on light surfaces, a lighter one on dark), so the
/// mark keeps its contrast in both. Null for no (or an unknown) colour.
Color? chatColorShade(BuildContext context, String? name) {
if (name == null || !chatColorNames.contains(name)) return null;
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
final CupertinoDynamicColor color = switch (name) {
'red' => CupertinoColors.systemRed,
'orange' => CupertinoColors.systemOrange,
'amber' => CupertinoColors.systemYellow,
'green' => CupertinoColors.systemGreen,
'teal' => CupertinoColors.systemTeal,
'blue' => CupertinoColors.systemBlue,
'purple' => CupertinoColors.systemPurple,
_ => CupertinoColors.systemPink,
};
return color.resolveFrom(context);
}
final dark = Theme.of(context).brightness == Brightness.dark;
final MaterialColor swatch = switch (name) {
'red' => Colors.red,
'orange' => Colors.orange,
'amber' => Colors.amber,
'green' => Colors.green,
'teal' => Colors.teal,
'blue' => Colors.blue,
'purple' => Colors.purple,
_ => Colors.pink,
};
if (dark) return swatch.shade300;
return switch (name) {
'orange' || 'amber' => swatch.shade800,
'red' || 'teal' || 'purple' || 'pink' => swatch.shade600,
_ => swatch.shade700,
};
}
/// Whether the surrounding theme is dark, on either host.
bool chatColorDarkSurface(BuildContext context) =>
chatControlsStyleOf(context) == ChatControlsStyle.cupertino
? CupertinoTheme.brightnessOf(context) == Brightness.dark
: Theme.of(context).brightness == Brightness.dark;
@@ -0,0 +1,192 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../../ui/layout/app_sheet_header.dart';
import '../../domain/chat_colors.dart';
import 'chat_adaptive.dart';
import 'chat_color_palette.dart';
/// The chat colour choices: None, then the palette, as the host's own icon
/// buttons. The chosen one shows a check. It keeps its own selection, so a
/// pick shows at once inside a sheet that the list's rebuild cannot reach.
class ChatColorSwatches extends StatefulWidget {
const ChatColorSwatches({
super.key,
required this.selected,
required this.onSelected,
});
/// The current colour name, or null for none.
final String? selected;
final ValueChanged<String?> onSelected;
@override
State<ChatColorSwatches> createState() => _ChatColorSwatchesState();
}
class _ChatColorSwatchesState extends State<ChatColorSwatches> {
late String? _selected = widget.selected;
@override
void didUpdateWidget(covariant ChatColorSwatches oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.selected != widget.selected) _selected = widget.selected;
}
void _pick(String? name) {
setState(() => _selected = name);
widget.onSelected(name);
}
@override
Widget build(BuildContext context) {
return Wrap(
spacing: 4,
runSpacing: 4,
children: [
_swatch(context, null),
for (final name in chatColorNames) _swatch(context, name),
],
);
}
Widget _swatch(BuildContext context, String? name) {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final selected = _selected == name;
final label = name == null ? 'No colour' : chatColorLabel(name);
final muted = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
final color = chatColorShade(context, name) ?? muted;
final IconData icon = name == null
? (cupertino ? CupertinoIcons.nosign : Icons.block)
: selected
? (cupertino
? CupertinoIcons.checkmark_circle_fill
: Icons.check_circle)
: (cupertino ? CupertinoIcons.circle_fill : Icons.circle);
final glyph = Icon(icon, color: color, size: 32);
// The None choice has no fill to check, so its selection is a ring.
final mark = name == null && selected
? DecoratedBox(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: color, width: 2),
),
child: Padding(padding: const EdgeInsets.all(2), child: glyph),
)
: glyph;
final button = cupertino
? CupertinoButton(
padding: const EdgeInsets.all(4),
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
onPressed: () => _pick(name),
child: mark,
)
: IconButton(
tooltip: label,
isSelected: selected,
onPressed: () => _pick(name),
icon: mark,
);
return Semantics(
key: Key('chat-color-${name ?? 'none'}'),
button: true,
selected: selected,
label: label,
excludeSemantics: true,
onTap: () => _pick(name),
child: button,
);
}
}
/// A titled "Colour" section: the heading, then the swatches.
class ChatColorSection extends StatelessWidget {
const ChatColorSection({
super.key,
required this.selected,
required this.onSelected,
this.padding = const EdgeInsetsDirectional.fromSTEB(24, 6, 24, 6),
});
final String? selected;
final ValueChanged<String?> onSelected;
final EdgeInsetsGeometry padding;
@override
Widget build(BuildContext context) {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final labelStyle =
(cupertino
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.bodySmall)
?.copyWith(
color: cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant,
);
return Padding(
key: const Key('chat-color-section'),
padding: padding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Colour', style: labelStyle),
const SizedBox(height: 4),
ChatColorSwatches(selected: selected, onSelected: onSelected),
],
),
);
}
}
/// Lets the operator pick [title]'s colour in a sheet. Each pick applies at
/// once through [onSelected]; Done closes the sheet.
Future<void> showChatColorPicker(
BuildContext context, {
required String title,
required String? selected,
required ValueChanged<String?> onSelected,
}) async {
final cupertino = chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
Widget content(BuildContext sheet) => Column(
key: const Key('chat-color-sheet'),
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
AppSheetHeader(
title: 'Colour for $title',
cupertino: cupertino,
doneKey: const Key('chat-color-done'),
),
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(20, 4, 20, 20),
child: ChatColorSwatches(selected: selected, onSelected: onSelected),
),
],
);
if (cupertino) {
await showCupertinoModalPopup<void>(
context: context,
builder: (sheet) => Align(
alignment: Alignment.bottomCenter,
child: SafeArea(
child: CupertinoPopupSurface(
child: SingleChildScrollView(child: content(sheet)),
),
),
),
);
return;
}
await showModalBottomSheet<void>(
context: context,
showDragHandle: true,
isScrollControlled: true,
useSafeArea: true,
builder: (sheet) => SingleChildScrollView(child: content(sheet)),
);
}
@@ -9,6 +9,17 @@ import 'session_row_style.dart';
typedef ChatSessionSection = ({String title, List<JsonMap> sessions});
/// Which list sections are folded away, kept by the list's screen so the
/// keyboard shortcuts count only rows on screen. Closed starts folded.
class ChatSectionFolds {
final Set<String> _folded = {'Closed'};
bool isOpen(String title) => !_folded.contains(title);
void set(String title, bool open) =>
open ? _folded.remove(title) : _folded.add(title);
}
/// Groups the visible sessions the way the server reports them.
class ChatSessionsBody extends StatelessWidget {
const ChatSessionsBody({
@@ -22,14 +33,17 @@ class ChatSessionsBody extends StatelessWidget {
required this.onClose,
required this.onReopen,
required this.onStar,
this.onColor,
required this.onHide,
required this.onClearSearch,
required this.isUnseen,
required this.errorFor,
this.folds,
this.activeSessionId,
this.onDismissError,
});
final ChatSectionFolds? folds;
final List<JsonMap> sessions;
final String? activeSessionId;
final String query;
@@ -40,6 +54,7 @@ class ChatSessionsBody extends StatelessWidget {
final ValueChanged<JsonMap> onClose;
final ValueChanged<JsonMap> onReopen;
final ValueChanged<JsonMap> onStar;
final ValueChanged<JsonMap>? onColor;
final ValueChanged<JsonMap> onHide;
final VoidCallback onClearSearch;
final bool Function(JsonMap) isUnseen;
@@ -49,27 +64,7 @@ class ChatSessionsBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
final visible = filterChatSessions(sessions, query);
final sections = <ChatSessionSection>[
if (visible.any((s) => s['starred'] == true && s['closed_at'] == null))
(
title: 'Starred',
sessions: visible
.where((s) => s['starred'] == true && s['closed_at'] == null)
.toList(),
),
if (visible.any((s) => s['starred'] != true && s['closed_at'] == null))
(
title: 'Chats',
sessions: visible
.where((s) => s['starred'] != true && s['closed_at'] == null)
.toList(),
),
if (visible.any((s) => s['closed_at'] != null))
(
title: 'Closed',
sessions: visible.where((s) => s['closed_at'] != null).toList(),
),
];
final sections = chatSessionSections(visible);
final emptyMessage = sessions.isEmpty
? error == null
? 'No chat sessions on this server yet.'
@@ -82,6 +77,7 @@ class ChatSessionsBody extends StatelessWidget {
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
return CupertinoSessionList(
sections: sections,
folds: folds,
activeSessionId: activeSessionId,
emptyMessage: visible.isEmpty ? emptyMessage : null,
duplicateTitles: duplicateTitles,
@@ -90,6 +86,7 @@ class ChatSessionsBody extends StatelessWidget {
onClose: onClose,
onReopen: onReopen,
onStar: onStar,
onColor: onColor,
onHide: onHide,
onClearSearch: clearSearch,
isUnseen: isUnseen,
@@ -99,6 +96,7 @@ class ChatSessionsBody extends StatelessWidget {
}
return MaterialSessionList(
sections: sections,
folds: folds,
activeSessionId: activeSessionId,
emptyMessage: visible.isEmpty ? emptyMessage : null,
duplicateTitles: duplicateTitles,
@@ -107,6 +105,7 @@ class ChatSessionsBody extends StatelessWidget {
onClose: onClose,
onReopen: onReopen,
onStar: onStar,
onColor: onColor,
onHide: onHide,
onClearSearch: clearSearch,
isUnseen: isUnseen,
@@ -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),
@@ -8,8 +8,12 @@ import '../../../../ui/layout/content_width.dart';
import '../../../../core/api_gateway.dart';
import '../../../../shell/shell_bar.dart';
import '../../../../shell/shell_list_shortcuts.dart';
import '../../data/chat_repository.dart';
import '../../domain/chat_colors.dart';
import '../../domain/chat_sessions.dart';
import 'chat_adaptive.dart';
import 'chat_color_picker.dart';
import 'chat_session_local.dart';
import 'chat_sessions_body.dart';
import 'chat_sessions_controller.dart';
@@ -76,6 +80,7 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
..activeSessionId = widget.activeSessionId
..refresh();
final _search = TextEditingController();
final _folds = ChatSectionFolds();
Timer? _undoTimer;
String? _markedActiveSessionId;
@@ -182,6 +187,26 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
void _star(JsonMap session) =>
_controller.star(_sessionId(session), session['starred'] != true);
Future<void> _color(JsonMap session) => showChatColorPicker(
context,
title: chatSessionTitle(session),
selected: chatSessionColor(session),
onSelected: (color) => _controller.setColor(_sessionId(session), color),
);
/// Ctrl+N: opens the Nth row the list draws (Starred first, then Chats by
/// directory, then Closed while it is unfolded), searched as shown.
bool _openIndex(int index) {
final visible = filterChatSessions(_controller.sessions, _search.text);
final rows = chatSessionsInListOrder(
chatSessionSections(visible),
isOpen: _folds.isOpen,
);
if (index < 0 || index >= rows.length) return false;
_open(rows[index]);
return true;
}
Future<void> _hide(JsonMap session) async {
await _controller.hide(_sessionId(session));
_undoTimer?.cancel();
@@ -235,7 +260,9 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
onClose: _close,
onReopen: _reopen,
onStar: _star,
onColor: _color,
onHide: _hide,
folds: _folds,
onClearSearch: () {
_search.clear();
setState(() {});
@@ -278,7 +305,7 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
child: ShellBadge(
kind: ShellBadgeKind.unread,
count: _controller.sessions.where(_controller.isUnseen).length,
child: body,
child: ShellListShortcut(onOpenIndex: _openIndex, child: body),
),
);
}
@@ -7,7 +7,7 @@ import 'chat_adaptive.dart';
import 'session_row_style.dart';
import '../../../../ui/layout/app_overflow_menu.dart';
enum SessionAction { star, rename, close, reopen, hide }
enum SessionAction { star, color, rename, close, reopen, hide }
/// The close confirmation's body, matching the web client's explanation.
String closeChatConfirmation(String title) =>
@@ -50,6 +50,7 @@ List<({SessionAction action, String label})> _items(JsonMap session) {
action: SessionAction.star,
label: session['starred'] == true ? 'Unstar' : 'Star',
),
(action: SessionAction.color, label: 'Colour…'),
(action: SessionAction.rename, label: 'Rename…'),
isClosed
? (action: SessionAction.reopen, label: 'Reopen')
@@ -17,15 +17,18 @@ class CupertinoSessionList extends StatelessWidget {
required this.onClose,
required this.onReopen,
required this.onStar,
this.onColor,
required this.onHide,
required this.onClearSearch,
required this.isUnseen,
required this.errorFor,
this.folds,
this.activeSessionId,
this.onDismissError,
});
final List<ChatSessionSection> sections;
final ChatSectionFolds? folds;
final String? activeSessionId;
final String? emptyMessage;
final Set<String> duplicateTitles;
@@ -34,6 +37,7 @@ class CupertinoSessionList extends StatelessWidget {
final ValueChanged<JsonMap> onClose;
final ValueChanged<JsonMap> onReopen;
final ValueChanged<JsonMap> onStar;
final ValueChanged<JsonMap>? onColor;
final ValueChanged<JsonMap> onHide;
final VoidCallback? onClearSearch;
final bool Function(JsonMap) isUnseen;
@@ -71,6 +75,7 @@ class CupertinoSessionList extends StatelessWidget {
Widget _section(ChatSessionSection section) => chatSessionSection(
section: section,
folds: folds ?? ChatSectionFolds(),
directoryHeader: _DirectoryHeader.new,
row: (session, {required divider}) => chatSessionRowItem(
session,
@@ -80,6 +85,7 @@ class CupertinoSessionList extends StatelessWidget {
isUnseen: isUnseen,
onOpen: onOpen,
onStar: onStar,
onColor: onColor,
onRename: onRename,
onClose: onClose,
onReopen: onReopen,
@@ -15,13 +15,16 @@ typedef SessionListItem = ({Key key, WidgetBuilder build});
/// screen. Material and Cupertino supply their own directory header.
Widget chatSessionSection({
required ChatSessionSection section,
required ChatSectionFolds folds,
required Widget Function(String directory) directoryHeader,
required SessionListItem Function(JsonMap session, {required bool divider})
row,
required String? Function(String sessionId) errorFor,
required ValueChanged<String>? onDismissError,
}) {
final groups = groupChatSessions(section.sessions);
final groups = chatSectionGroupsByDirectory(section.title)
? groupChatSessions(section.sessions)
: [(directory: '', sessions: section.sessions)];
final items = <SessionListItem>[
for (final group in groups) ...[
if (groups.length > 1)
@@ -67,7 +70,8 @@ Widget chatSessionSection({
key: ValueKey('chat-section-${section.title}'),
title: section.title,
count: section.sessions.length,
initiallyOpen: section.title != 'Closed',
initiallyOpen: folds.isOpen(section.title),
onOpenChanged: (open) => folds.set(section.title, open),
itemCount: items.length,
itemKey: (index) => items[index].key,
itemBuilder: (context, index) => items[index].build(context),
@@ -83,6 +87,7 @@ SessionListItem chatSessionRowItem(
required bool Function(JsonMap) isUnseen,
required ValueChanged<JsonMap> onOpen,
required ValueChanged<JsonMap> onStar,
required ValueChanged<JsonMap>? onColor,
required ValueChanged<JsonMap> onRename,
required ValueChanged<JsonMap> onClose,
required ValueChanged<JsonMap> onReopen,
@@ -99,6 +104,7 @@ SessionListItem chatSessionRowItem(
divider: divider,
onOpen: onOpen,
onStar: onStar,
onColor: onColor,
onRename: onRename,
onClose: onClose,
onReopen: onReopen,
@@ -16,15 +16,18 @@ class MaterialSessionList extends StatelessWidget {
required this.onClose,
required this.onReopen,
required this.onStar,
this.onColor,
required this.onHide,
required this.onClearSearch,
required this.isUnseen,
required this.errorFor,
this.folds,
this.activeSessionId,
this.onDismissError,
});
final List<ChatSessionSection> sections;
final ChatSectionFolds? folds;
final String? activeSessionId;
final String? emptyMessage;
final Set<String> duplicateTitles;
@@ -33,6 +36,7 @@ class MaterialSessionList extends StatelessWidget {
final ValueChanged<JsonMap> onClose;
final ValueChanged<JsonMap> onReopen;
final ValueChanged<JsonMap> onStar;
final ValueChanged<JsonMap>? onColor;
final ValueChanged<JsonMap> onHide;
final VoidCallback? onClearSearch;
final bool Function(JsonMap) isUnseen;
@@ -80,6 +84,7 @@ class MaterialSessionList extends StatelessWidget {
final heading = SectionHeadingStyle.of(context);
return chatSessionSection(
section: section,
folds: folds ?? ChatSectionFolds(),
directoryHeader: (directory) => ListTile(
dense: true,
leading: const Icon(Icons.folder_outlined),
@@ -96,6 +101,7 @@ class MaterialSessionList extends StatelessWidget {
isUnseen: isUnseen,
onOpen: onOpen,
onStar: onStar,
onColor: onColor,
onRename: onRename,
onClose: onClose,
onReopen: onReopen,
@@ -5,8 +5,10 @@ import '../../../../core/api_gateway.dart';
import '../../../../ui/layout/app_list_avatar.dart';
import '../../../../ui/layout/app_list_row.dart';
import '../../../../ui/text/relative_time_label.dart';
import '../../domain/chat_colors.dart';
import '../../domain/chat_sessions.dart';
import 'chat_adaptive.dart';
import 'chat_color_palette.dart';
import 'session_actions.dart';
import 'session_harness_icon.dart';
import 'session_row_style.dart';
@@ -16,8 +18,10 @@ import 'session_row_style.dart';
///
/// An unread chat is emphasised (heavier title, accent time) with an accent
/// dot ending its line; a starred chat shows a small star after its title; a
/// running chat carries an activity badge on its avatar. A narrow pane drops
/// the avatar and time but keeps the menu, the list's only way to its actions.
/// running chat carries an activity badge on its avatar. A chat with a colour
/// wears it as a bar on the row's leading edge, a faint row tint and a
/// coloured avatar. A narrow pane drops the avatar and time but keeps the
/// colour bar and the menu, the list's only way to its actions.
class ChatSessionRow extends StatelessWidget {
const ChatSessionRow({
super.key,
@@ -28,10 +32,12 @@ class ChatSessionRow extends StatelessWidget {
this.unseen = false,
this.divider = true,
this.duplicateTitles = const {},
this.onLongPress,
});
final JsonMap session;
final ValueChanged<JsonMap> onOpen;
final VoidCallback? onLongPress;
final ValueChanged<SessionAction> onAction;
final bool selected;
final bool unseen;
@@ -58,6 +64,8 @@ class ChatSessionRow extends StatelessWidget {
divider: divider,
keepMenuWhenCompact: true,
onTap: () => onOpen(session),
onLongPress: onLongPress,
accent: chatColorShade(context, chatSessionColor(session)),
leading: ChatSessionAvatar(
session: session,
running: session['running'] == true && !unseen,
@@ -161,7 +169,15 @@ class ChatSessionAvatar extends StatelessWidget {
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final Color fill;
final Color mark;
if (cupertino) {
final color = chatColorShade(context, chatSessionColor(session));
if (color != null) {
// The chat's colour is its identity, selected or not; the row's own
// fill marks the selection.
mark = color;
fill = color.withValues(
alpha: chatColorDarkSurface(context) ? 0.26 : 0.16,
);
} else if (cupertino) {
final primary = CupertinoTheme.of(context).primaryColor;
fill = selected
? primary.withValues(alpha: 0.2)
@@ -19,6 +19,7 @@ Widget memoChatSessionRow({
required bool divider,
required ValueChanged<JsonMap> onOpen,
required ValueChanged<JsonMap> onStar,
required ValueChanged<JsonMap>? onColor,
required ValueChanged<JsonMap> onRename,
required ValueChanged<JsonMap> onClose,
required ValueChanged<JsonMap> onReopen,
@@ -34,6 +35,7 @@ Widget memoChatSessionRow({
divider,
onOpen,
onStar,
onColor,
onRename,
onClose,
onReopen,
@@ -46,8 +48,11 @@ Widget memoChatSessionRow({
unseen: unseen,
divider: divider,
onOpen: onOpen,
// A long-press is the touch way to the colour, the row's quick mark.
onLongPress: onColor == null ? null : () => onColor(session),
onAction: (action) => switch (action) {
SessionAction.star => onStar(session),
SessionAction.color => onColor?.call(session),
SessionAction.rename => onRename(session),
SessionAction.close => onClose(session),
SessionAction.reopen => onReopen(session),
@@ -3,6 +3,7 @@ import '../../../ui/layout/app_list_row.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../shell/shell_list_shortcuts.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/status/run_status_icon.dart';
import '../pipeline_format.dart';
@@ -53,7 +54,18 @@ class PipelineListPanel extends StatelessWidget {
child: PipelineProgress(label: 'Refreshing pipelines'),
),
];
return _content(context, header);
// Ctrl+1…Ctrl+9 open the Nth pipeline shown, filtered and sorted.
return ShellListShortcut(
onOpenIndex: (index) {
if (!controller.pipelinesLoaded) return false;
final items = controller.visiblePipelines;
if (index >= items.length) return false;
final pipeline = items[index];
controller.openPipeline(pipeline.id, version: pipeline.version);
return true;
},
child: _content(context, header),
);
}
/// A state without rows: the controls stay at the top, below the bar.
+18 -2
View File
@@ -12,6 +12,7 @@ import '../../attention/runtime/attention_store.dart';
import '../../attention/ui/needs_you_runs_heading.dart';
import '../domain/run_models.dart';
import '../../../shell/shell_bar.dart';
import '../../../shell/shell_list_shortcuts.dart';
import 'run_list_row.dart';
import 'runs_controller.dart';
import 'runs_filter_options.dart';
@@ -79,7 +80,7 @@ class RunsList extends StatelessWidget {
title: bar.title,
subtitle: bar.subtitle,
actions: bar.actions,
child: _list(context),
child: _shortcutList(context),
);
}
final actions = [
@@ -110,11 +111,26 @@ class RunsList extends StatelessWidget {
child: ShellBadge(
kind: ShellBadgeKind.running,
count: controller.runs.where((run) => run['executing'] == true).length,
child: _list(context),
child: _shortcutList(context),
),
);
}
/// The list under the shell's Ctrl+1…Ctrl+9, which open the Nth run shown
/// (filtered and sorted as on screen). Select mode keeps keys for itself.
Widget _shortcutList(BuildContext context) => ShellListShortcut(
onOpenIndex: (index) {
if (controller.selection.active) return false;
final runs = controller.visibleRuns;
if (index >= runs.length) return false;
final id = runs[index]['id'];
if (id is! num) return false;
onSelected(id);
return true;
},
child: _list(context),
);
Widget _ownBar(BuildContext context, List<Widget> bar) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [