12c7642e35
Ctrl+K lists open chats most recently used first (tracked on open and pane focus, persisted per server) and preselects the previous chat, so Ctrl+K, Enter returns to it. Rows mark needs you / working / unread; a query also lists matching closed chats under Closed, and choosing one reopens it. Alt+N (Option+N) starts a new chat and Alt+J (Option+J) opens the next chat waiting for you, unread or failed, cycling; the terminal keeps both. In run detail, bare 1-4 switch tabs when not typing. Cheatsheet entries added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
135 lines
4.3 KiB
Dart
135 lines
4.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../domain/chat_list_activity.dart';
|
|
import '../domain/chat_quick_switch_order.dart';
|
|
import '../domain/chat_sessions.dart';
|
|
import '../ui/sessions/session_row_content.dart';
|
|
import '../ui/sessions/session_row_style.dart';
|
|
|
|
/// One chat in the quick switcher: the list's avatar (harness mark in the
|
|
/// chat's colour, with its running or awaiting badge), the title, and the
|
|
/// folder with the machine it is on, then small [markers] (needs you,
|
|
/// working, unread) and the star. A [closed] chat (listed under "Closed",
|
|
/// reopened when chosen) shows no live state. The selected row takes the selection fill; hover
|
|
/// and click work as on any list tile.
|
|
class ChatQuickSwitchRow extends StatelessWidget {
|
|
const ChatQuickSwitchRow({
|
|
super.key,
|
|
required this.session,
|
|
required this.selected,
|
|
required this.onTap,
|
|
this.serverName,
|
|
this.markers = const [],
|
|
this.closed = false,
|
|
});
|
|
|
|
final JsonMap session;
|
|
final bool selected;
|
|
final VoidCallback onTap;
|
|
final String? serverName;
|
|
final List<ChatQuickSwitchMarker> markers;
|
|
final bool closed;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final id = '${session['id'] ?? ''}';
|
|
final scheme = Theme.of(context).colorScheme;
|
|
final running = !closed && session['running'] == true;
|
|
final subtitle = [
|
|
homeRelativePath('${session['directory'] ?? ''}'.trim()),
|
|
?serverName,
|
|
].where((part) => part.isNotEmpty).join(' · ');
|
|
final trailing = [
|
|
for (final marker in markers) ChatQuickSwitchMarkerIcon(marker: marker),
|
|
if (session['starred'] == true)
|
|
Icon(Icons.star, color: scheme.primary, semanticLabel: 'Starred'),
|
|
];
|
|
return ListTile(
|
|
key: Key('chat-quick-switch-row-$id'),
|
|
selected: selected,
|
|
selectedTileColor: scheme.secondaryContainer,
|
|
selectedColor: scheme.onSecondaryContainer,
|
|
visualDensity: VisualDensity.compact,
|
|
leading: ChatSessionAvatar(
|
|
session: session,
|
|
running: running,
|
|
backgroundTasks: running ? 0 : chatSessionBackgroundTasks(session),
|
|
awaitingOperator: closed ? 0 : chatSessionAwaitingOperator(session),
|
|
),
|
|
title: Text(
|
|
chatSessionTitle(session),
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
subtitle: subtitle.isEmpty
|
|
? null
|
|
: Text(subtitle, maxLines: 1, overflow: TextOverflow.ellipsis),
|
|
trailing: trailing.isEmpty
|
|
? null
|
|
: Row(mainAxisSize: MainAxisSize.min, spacing: 6, children: trailing),
|
|
onTap: onTap,
|
|
);
|
|
}
|
|
}
|
|
|
|
/// One row marker: a small icon in the state's colour, named by its tooltip
|
|
/// and to assistive technology.
|
|
class ChatQuickSwitchMarkerIcon extends StatelessWidget {
|
|
const ChatQuickSwitchMarkerIcon({super.key, required this.marker});
|
|
|
|
final ChatQuickSwitchMarker marker;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final scheme = Theme.of(context).colorScheme;
|
|
final (icon, color) = switch (marker) {
|
|
ChatQuickSwitchMarker.needsYou => (
|
|
Icons.notifications_active,
|
|
scheme.error,
|
|
),
|
|
ChatQuickSwitchMarker.working => (
|
|
Icons.play_circle_outline,
|
|
scheme.onSurfaceVariant,
|
|
),
|
|
ChatQuickSwitchMarker.unread => (Icons.circle, scheme.primary),
|
|
};
|
|
return Tooltip(
|
|
message: marker.label,
|
|
child: Icon(
|
|
icon,
|
|
key: Key('chat-quick-switch-marker-${marker.name}'),
|
|
size: marker == ChatQuickSwitchMarker.unread ? 10 : 18,
|
|
color: color,
|
|
semanticLabel: marker.label,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// The heading over the switcher's closed chats.
|
|
class ChatQuickSwitchSectionHeader extends StatelessWidget {
|
|
const ChatQuickSwitchSectionHeader({super.key, required this.title});
|
|
|
|
final String title;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
return Container(
|
|
alignment: AlignmentDirectional.centerStart,
|
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
|
|
child: Semantics(
|
|
header: true,
|
|
child: Text(
|
|
title,
|
|
key: const Key('chat-quick-switch-closed-header'),
|
|
style: theme.textTheme.labelLarge?.copyWith(
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|