fix(app): chat rows put the state word on the title line and recency in the meta, as on the web

This commit is contained in:
2026-10-23 12:40:37 +01:00
parent ad51437fbb
commit c5119146f2
6 changed files with 69 additions and 107 deletions
@@ -126,16 +126,13 @@ class _CupertinoSessionRow extends StatelessWidget {
Widget build(BuildContext context) {
final id = '${session['id'] ?? ''}';
// Cupertino's grouped list owns the separators and the native tile metrics;
// the row only decides where the title, its muted meta and the recency go.
// The recency sits at the trailing edge of the title line at the tile's
// body size; the meta line keeps the tile's native 12pt subtitle style by
// the row only decides where the title, its state word and the muted meta
// go. The meta line (recency first) keeps the tile's native 12pt style by
// passing colour only, so `Text` merges with `CupertinoListTile`'s own
// `DefaultTextStyle` instead of overriding it with the title's size.
final theme = CupertinoTheme.of(context);
final secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
final timeStyle = theme.textTheme.textStyle.copyWith(color: secondary);
final time = relativeChatSessionTime(session['updated_at']);
final meta = chatSessionMeta(session);
final meta = chatSessionRowMetaLine(session);
final status = chatSessionRowStatus(session, unseen: unseen);
final statusStyle = TextStyle(
color: status == 'Closed' ? secondary : theme.primaryColor,
@@ -143,18 +140,21 @@ class _CupertinoSessionRow extends StatelessWidget {
return CupertinoListTile(
key: Key('chat-row-$id'),
leading: Icon(sessionCupertinoIcon(session)),
title: ChatSessionRowTitle(
title: chatSessionTitle(session),
time: time,
timeStyle: timeStyle,
// As on the web: the title with the unread/closed word trailing, then
// the muted `recency · directory · model` line.
title: ChatSessionRowMeta(
meta: chatSessionTitle(session),
status: status,
metaStyle: const TextStyle(),
statusStyle: statusStyle,
),
subtitle: meta.isEmpty && status == null
subtitle: meta.isEmpty
? null
: ChatSessionRowMeta(
meta: meta,
status: status,
metaStyle: TextStyle(color: secondary),
statusStyle: statusStyle,
: Text(
meta,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: secondary),
),
onTap: () => onOpen(session),
trailing: Row(
@@ -139,18 +139,14 @@ class _MaterialSessionRow extends StatelessWidget {
@override
Widget build(BuildContext context) {
final id = '${session['id'] ?? ''}';
// The same content as the Cupertino row: title with trailing recency, then
// a muted `directory · model` line with the unread/closed word trailing.
// The same content as the Cupertino row: title with the unread/closed word
// trailing, then a muted `recency · directory · model` line.
// `ListTile` does not force one ellipsised line like `CupertinoListTile`,
// so both text widgets state their line limit themselves. The meta line
// passes colour only, so it keeps the tile's native subtitle style.
final theme = Theme.of(context);
final secondary = theme.colorScheme.onSurfaceVariant;
final timeStyle =
theme.textTheme.bodyMedium?.copyWith(color: secondary) ??
TextStyle(color: secondary);
final time = relativeChatSessionTime(session['updated_at']);
final meta = chatSessionMeta(session);
final meta = chatSessionRowMetaLine(session);
final status = chatSessionRowStatus(session, unseen: unseen);
final statusStyle = TextStyle(
color: status == 'Closed' ? secondary : theme.colorScheme.primary,
@@ -158,18 +154,21 @@ class _MaterialSessionRow extends StatelessWidget {
return ListTile(
key: Key('chat-row-$id'),
leading: Icon(sessionMaterialIcon(session)),
title: ChatSessionRowTitle(
title: chatSessionTitle(session),
time: time,
timeStyle: timeStyle,
// As on the web: the title with the unread/closed word trailing, then
// the muted `recency · directory · model` line.
title: ChatSessionRowMeta(
meta: chatSessionTitle(session),
status: status,
metaStyle: const TextStyle(),
statusStyle: statusStyle,
),
subtitle: meta.isEmpty && status == null
subtitle: meta.isEmpty
? null
: ChatSessionRowMeta(
meta: meta,
status: status,
metaStyle: TextStyle(color: secondary),
statusStyle: statusStyle,
: Text(
meta,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: secondary),
),
onTap: () => onOpen(session),
trailing: Row(
@@ -1,55 +1,7 @@
import 'package:flutter/material.dart';
/// The title line of a chat session row: the session's name, with its relative
/// recency at the trailing edge. Shared by the Material and Cupertino rows so
/// both hosts arrange the same facts the same way.
///
/// The recency takes at most 45% of the text column and ellipsises there, so a
/// long title keeps the larger share and a short row never overflows. The
/// recency is supplementary: at very large text scales it is the part that
/// gives way, while the session's name and state word stay whole.
class ChatSessionRowTitle extends StatelessWidget {
const ChatSessionRowTitle({
super.key,
required this.title,
required this.time,
required this.timeStyle,
});
final String title;
final String time;
final TextStyle timeStyle;
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) => Row(
children: [
Expanded(
child: Text(title, maxLines: 1, overflow: TextOverflow.ellipsis),
),
if (time.isNotEmpty) ...[
const SizedBox(width: 8),
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: constraints.maxWidth * 0.45,
),
child: Text(
time,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: timeStyle,
),
),
],
],
),
);
}
}
/// The muted second line of a chat session row: the recorded directory and
/// model, with the unread/closed word at the trailing edge.
/// A chat session row line with the unread/closed word at its trailing edge:
/// the row's title line, as on the web.
///
/// The directory/model is the part that ellipsises; the state word is the row's
/// only unread marker, so it keeps its intrinsic width and the metadata shrinks
@@ -50,6 +50,13 @@ String chatSessionMeta(JsonMap session) => [
'${session['model'] ?? ''}'.trim(),
].where((part) => part.isNotEmpty).join(' · ');
/// The row's muted second line as the web words it: recency first, then the
/// directory and model (`1 day ago · /srv/probe · model-a`).
String chatSessionRowMetaLine(JsonMap session, {DateTime? now}) => [
relativeChatSessionTime(session['updated_at'], now: now),
chatSessionMeta(session),
].where((part) => part.isNotEmpty).join(' · ');
/// The word on the row's trailing edge while the session has news or a state:
/// `Closed` from the row, otherwise `New`. A streaming session deliberately
/// says nothing, as on the web, where the row's activity logo carries it.