Separate chat identity from pane state and retain compact attention facts
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'chat_session_state.dart';
|
||||
import 'session_activity_badge.dart';
|
||||
|
||||
/// Compact mode keeps task attention and pane state alongside identity.
|
||||
class ChatCompactAvatar extends StatelessWidget {
|
||||
const ChatCompactAvatar({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.color,
|
||||
required this.active,
|
||||
required this.visible,
|
||||
required this.running,
|
||||
required this.backgroundTasks,
|
||||
required this.unread,
|
||||
required this.cupertino,
|
||||
});
|
||||
final String title;
|
||||
final Color color;
|
||||
final bool active, visible, running, unread, cupertino;
|
||||
final int backgroundTasks;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
foregroundColor: color,
|
||||
backgroundColor: color.withValues(alpha: active ? .26 : .12),
|
||||
child: Text(
|
||||
title.characters.take(2).toString(),
|
||||
style: TextStyle(fontWeight: active ? FontWeight.bold : null),
|
||||
),
|
||||
),
|
||||
if (active || visible)
|
||||
PositionedDirectional(
|
||||
top: -2,
|
||||
start: -5,
|
||||
child: _Disc(
|
||||
cupertino: cupertino,
|
||||
child: Icon(
|
||||
active ? Icons.radio_button_checked : Icons.visibility_outlined,
|
||||
size: 14,
|
||||
color: chatStateForeground(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (chatSessionActivityBadge(
|
||||
cupertino: cupertino,
|
||||
running: running,
|
||||
backgroundTasks: backgroundTasks,
|
||||
)
|
||||
case final badge?)
|
||||
PositionedDirectional(bottom: -2, end: -3, child: badge),
|
||||
if (unread)
|
||||
PositionedDirectional(
|
||||
top: -2,
|
||||
end: -3,
|
||||
child: _Disc(
|
||||
cupertino: cupertino,
|
||||
child: Icon(
|
||||
Icons.mark_chat_unread_outlined,
|
||||
key: const Key('chat-compact-unread'),
|
||||
size: 14,
|
||||
color: chatStateForeground(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
class _Disc extends StatelessWidget {
|
||||
const _Disc({required this.cupertino, required this.child});
|
||||
final bool cupertino;
|
||||
final Widget child;
|
||||
@override
|
||||
Widget build(BuildContext context) => DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: cupertino
|
||||
? CupertinoColors.systemBackground.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
child: Padding(padding: const EdgeInsets.all(1), child: child),
|
||||
);
|
||||
}
|
||||
@@ -8,6 +8,9 @@ import 'chat_adaptive.dart';
|
||||
import '../../domain/chat_colors.dart';
|
||||
import 'chat_color_palette.dart';
|
||||
import 'chat_visibility_marker.dart';
|
||||
import 'chat_compact_avatar.dart';
|
||||
import 'session_row_style.dart';
|
||||
import '../../domain/chat_list_activity.dart';
|
||||
import 'chat_sessions_body.dart';
|
||||
import 'chat_sessions_controller.dart';
|
||||
|
||||
@@ -21,6 +24,7 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
this.visibleSessionIds = const {},
|
||||
required this.onOpen,
|
||||
required this.onExpand,
|
||||
this.navigation,
|
||||
});
|
||||
final ChatSessionsController controller;
|
||||
final ChatSectionFolds folds;
|
||||
@@ -28,6 +32,7 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
final Set<String> visibleSessionIds;
|
||||
final ValueChanged<JsonMap> onOpen;
|
||||
final VoidCallback onExpand;
|
||||
final Widget? navigation;
|
||||
static const width = 72.0;
|
||||
|
||||
Widget _button(
|
||||
@@ -62,6 +67,21 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
Widget _session(BuildContext context, JsonMap row) {
|
||||
final id = '${row['id'] ?? ''}';
|
||||
final selected = id == activeSessionId;
|
||||
final visible = visibleSessionIds.contains(id);
|
||||
final unread = controller.isUnseen(row);
|
||||
final running = row['running'] == true;
|
||||
final backgroundTasks = chatSessionBackgroundTasks(row);
|
||||
final title = chatSessionTitle(row);
|
||||
final details = [
|
||||
title,
|
||||
if (chatSessionSubtitle(row).isNotEmpty) chatSessionSubtitle(row),
|
||||
if (relativeChatSessionTime(row['updated_at']).isNotEmpty)
|
||||
'Updated ${relativeChatSessionTime(row['updated_at'])} ago',
|
||||
if (selected) 'Active chat' else if (visible) 'Visible chat',
|
||||
if (running) 'Working',
|
||||
if (backgroundTasks > 0) 'Background tasks running ($backgroundTasks)',
|
||||
if (unread) 'New messages',
|
||||
].join('\n');
|
||||
final color =
|
||||
chatColorShade(context, chatSessionColor(row)) ??
|
||||
(chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
@@ -70,7 +90,7 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
return ChatVisibilityMarker(
|
||||
sessionId: id,
|
||||
color: color,
|
||||
visible: visibleSessionIds.contains(id),
|
||||
visible: visible,
|
||||
active: selected,
|
||||
child: AnimatedContainer(
|
||||
duration: MediaQuery.disableAnimationsOf(context)
|
||||
@@ -79,13 +99,18 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
color: selected ? Colors.transparent : color.withValues(alpha: .07),
|
||||
child: _button(
|
||||
context,
|
||||
chatSessionTitle(row),
|
||||
CircleAvatar(
|
||||
foregroundColor: color,
|
||||
backgroundColor: color.withValues(alpha: selected ? .26 : .12),
|
||||
child: Text(
|
||||
chatSessionTitle(row).characters.take(2).toString(),
|
||||
style: TextStyle(fontWeight: selected ? FontWeight.bold : null),
|
||||
details,
|
||||
ExcludeSemantics(
|
||||
child: ChatCompactAvatar(
|
||||
title: title,
|
||||
color: color,
|
||||
active: selected,
|
||||
visible: visible,
|
||||
running: running,
|
||||
backgroundTasks: backgroundTasks,
|
||||
unread: unread,
|
||||
cupertino:
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino,
|
||||
),
|
||||
),
|
||||
() {
|
||||
@@ -108,10 +133,16 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
_button(
|
||||
context,
|
||||
'Expand chat list',
|
||||
Icon(
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoIcons.sidebar_left
|
||||
: Icons.menu_open,
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoIcons.sidebar_left
|
||||
: Icons.menu_open,
|
||||
),
|
||||
const Text('Expand', textAlign: TextAlign.center),
|
||||
],
|
||||
),
|
||||
onExpand,
|
||||
),
|
||||
@@ -130,6 +161,7 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
),
|
||||
?navigation,
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
|
||||
/// State uses neutral text and shapes; the chat's chosen color stays identity.
|
||||
Color chatStateForeground(BuildContext context) =>
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurface;
|
||||
|
||||
Color chatMetadataForeground(BuildContext context) =>
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoColors.label.resolveFrom(context).withValues(alpha: .82)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
|
||||
class ChatSessionStateLine extends StatelessWidget {
|
||||
const ChatSessionStateLine({
|
||||
super.key,
|
||||
required this.active,
|
||||
required this.visible,
|
||||
required this.running,
|
||||
required this.backgroundTasks,
|
||||
required this.unread,
|
||||
});
|
||||
final bool active, visible, running, unread;
|
||||
final int backgroundTasks;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final entries = <(IconData, String)>[
|
||||
if (active)
|
||||
(Icons.radio_button_checked, 'Active')
|
||||
else if (visible)
|
||||
(Icons.visibility_outlined, 'Visible'),
|
||||
if (running) (Icons.play_circle_outline, 'Working'),
|
||||
if (backgroundTasks > 0)
|
||||
(Icons.pending_actions, '$backgroundTasks background'),
|
||||
if (unread) (Icons.mark_chat_unread_outlined, 'New'),
|
||||
];
|
||||
return Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
for (final (icon, label) in entries)
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: 14, color: chatStateForeground(context)),
|
||||
const SizedBox(width: 4),
|
||||
Flexible(
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(color: chatStateForeground(context)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ChatSessionSubtitle extends StatelessWidget {
|
||||
const ChatSessionSubtitle({
|
||||
super.key,
|
||||
required this.metadata,
|
||||
required this.closed,
|
||||
required this.active,
|
||||
required this.visible,
|
||||
required this.running,
|
||||
required this.backgroundTasks,
|
||||
required this.unread,
|
||||
});
|
||||
final String metadata;
|
||||
final bool closed, active, visible, running, unread;
|
||||
final int backgroundTasks;
|
||||
@override
|
||||
Widget build(BuildContext context) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
if (closed)
|
||||
const TextSpan(
|
||||
text: 'Closed',
|
||||
style: TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
if (closed && metadata.isNotEmpty) const TextSpan(text: ' · '),
|
||||
TextSpan(text: metadata),
|
||||
],
|
||||
),
|
||||
style: TextStyle(color: chatMetadataForeground(context)),
|
||||
),
|
||||
if (active || visible || running || backgroundTasks > 0 || unread)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: ChatSessionStateLine(
|
||||
active: active,
|
||||
visible: visible,
|
||||
running: running,
|
||||
backgroundTasks: backgroundTasks,
|
||||
unread: unread,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -28,7 +28,7 @@ Widget? chatSessionActivityBadge({
|
||||
excludeFromSemantics: true,
|
||||
child: Semantics(
|
||||
label: label,
|
||||
child: _BackgroundBadge(cupertino: cupertino),
|
||||
child: _BackgroundBadge(cupertino: cupertino, count: backgroundTasks),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -72,9 +72,10 @@ class _WorkingBadge extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _BackgroundBadge extends StatelessWidget {
|
||||
const _BackgroundBadge({required this.cupertino});
|
||||
const _BackgroundBadge({required this.cupertino, required this.count});
|
||||
|
||||
final bool cupertino;
|
||||
final int count;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -83,10 +84,13 @@ class _BackgroundBadge extends StatelessWidget {
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
return _BadgeDisc(
|
||||
cupertino: cupertino,
|
||||
child: Icon(
|
||||
cupertino ? CupertinoIcons.ellipsis_circle_fill : Icons.pending,
|
||||
size: 12,
|
||||
color: color,
|
||||
child: Text(
|
||||
'$count',
|
||||
style: TextStyle(
|
||||
color: color,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import '../../domain/chat_sessions.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
import 'chat_color_palette.dart';
|
||||
import 'chat_visibility_marker.dart';
|
||||
import 'chat_session_state.dart';
|
||||
import 'session_actions.dart';
|
||||
import 'session_activity_badge.dart';
|
||||
import 'session_harness_icon.dart';
|
||||
@@ -112,20 +113,21 @@ class ChatSessionRow extends StatelessWidget {
|
||||
),
|
||||
timeWidget: updatedAt == null
|
||||
? null
|
||||
: RelativeTimeLabel(instant: updatedAt),
|
||||
// `Closed` leads the line of a closed chat, then the model and folder.
|
||||
subtitle: Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
if (closed)
|
||||
const TextSpan(
|
||||
text: 'Closed',
|
||||
style: TextStyle(fontWeight: FontWeight.w600),
|
||||
: DefaultTextStyle.merge(
|
||||
style: TextStyle(
|
||||
color: unread ? accent : chatMetadataForeground(context),
|
||||
),
|
||||
if (closed && text.isNotEmpty) const TextSpan(text: ' · '),
|
||||
TextSpan(text: text),
|
||||
],
|
||||
),
|
||||
child: RelativeTimeLabel(instant: updatedAt),
|
||||
),
|
||||
// `Closed` leads the line of a closed chat, then the model and folder.
|
||||
subtitle: ChatSessionSubtitle(
|
||||
metadata: text,
|
||||
closed: closed,
|
||||
active: selected,
|
||||
visible: visible,
|
||||
running: session['running'] == true,
|
||||
backgroundTasks: chatSessionBackgroundTasks(session),
|
||||
unread: unread,
|
||||
),
|
||||
subtitleTrailing: unread
|
||||
? AppListStatusDot(
|
||||
|
||||
Reference in New Issue
Block a user