Resize chat list into compact rail and animate visible chat markers

This commit is contained in:
2026-11-07 13:20:12 +00:00
parent 19958e81c5
commit e2cfa90776
20 changed files with 555 additions and 173 deletions
@@ -20,6 +20,7 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
ChatSidebarMode _sidebarMode = ChatSidebarMode.expanded;
void _setSidebarMode(ChatSidebarMode mode) {
if (_sidebarMode == mode) return;
setState(() => _sidebarMode = mode);
_workspaceBinding?.changed();
}
@@ -43,6 +44,7 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
controller: _sessionsForSidebar,
folds: _foldsForSidebar,
activeSessionId: selected,
visibleSessionIds: _visibleSidebarSessions,
onOpen: _openSidebarSession,
onExpand: () => _setSidebarMode(ChatSidebarMode.expanded),
),
@@ -50,6 +52,21 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
);
}
Set<String> _visibleWorkspaceSessions = const {};
void _workspaceVisibilityChanged(Set<String> sessions) {
if (!mounted || setEquals(_visibleWorkspaceSessions, sessions)) return;
setState(() => _visibleWorkspaceSessions = Set.unmodifiable(sessions));
}
Set<String> get _visibleSidebarSessions {
if (!_workspaceVisible) return const {};
final retained = _workspace.panes.map((pane) => pane.sessionId).toSet();
final visible = _visibleWorkspaceSessions.intersection(retained);
final active = _workspace.activePane?.sessionId;
return visible.isNotEmpty ? visible : {?active};
}
ChatSessionsController get _sessionsForSidebar;
ChatSectionFolds get _foldsForSidebar;
void _openSidebarSession(JsonMap session);
@@ -72,6 +89,11 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
_sidebarMode = ChatSidebarMode.values.firstWhere(
(mode) => mode.name == snapshot.sidebarMode,
);
// Older snapshots could hide the rail. Keep their recovery affordance
// now that layout changes happen at the divider instead of a menu.
if (_sidebarMode == ChatSidebarMode.hidden) {
_sidebarMode = ChatSidebarMode.compact;
}
_usedWorkspace = true;
_workspaceVisible = _workspace.paneCount > 0;
});
+8 -4
View File
@@ -6,6 +6,7 @@ import '../../shell/list_detail.dart';
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart' show setEquals;
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
@@ -446,10 +447,6 @@ class _ChatScreenState extends State<ChatScreen>
showBackButton: pane == null
? null
: _page.open || !showsListBesideDetail(context),
sidebarControl:
pane == null || _page.open || !showsListBesideDetail(context)
? null
: ChatSidebarButton(mode: _sidebarMode, onChanged: _setSidebarMode),
paneControls: pane == null
? const []
: [
@@ -519,6 +516,7 @@ class _ChatScreenState extends State<ChatScreen>
onShortcutOpen: _openByShortcut,
onSessions: _adoptRows,
activeSessionId: selected,
visibleSessionIds: _visibleSidebarSessions,
publishShellBar:
(selected == null ||
!beside ||
@@ -572,6 +570,12 @@ class _ChatScreenState extends State<ChatScreen>
hideNavigation: true,
child: ListDetailPanes(
list: list,
compactListWidth: selected == null ? null : ChatCompactSidebar.width,
onListCompactChanged: selected == null
? null
: (compact) => _setSidebarMode(
compact ? ChatSidebarMode.compact : ChatSidebarMode.expanded,
),
listWidthOverride: selected == null
? null
: switch (_sidebarMode) {
@@ -5,6 +5,9 @@ import '../../../../core/api_gateway.dart';
import '../../domain/chat_cycle.dart';
import '../../domain/chat_sessions.dart';
import 'chat_adaptive.dart';
import '../../domain/chat_colors.dart';
import 'chat_color_palette.dart';
import 'chat_visibility_marker.dart';
import 'chat_sessions_body.dart';
import 'chat_sessions_controller.dart';
@@ -15,12 +18,14 @@ class ChatCompactSidebar extends StatelessWidget {
required this.controller,
required this.folds,
required this.activeSessionId,
this.visibleSessionIds = const {},
required this.onOpen,
required this.onExpand,
});
final ChatSessionsController controller;
final ChatSectionFolds folds;
final String? activeSessionId;
final Set<String> visibleSessionIds;
final ValueChanged<JsonMap> onOpen;
final VoidCallback onExpand;
static const width = 72.0;
@@ -54,6 +59,45 @@ class ChatCompactSidebar extends StatelessWidget {
);
}
Widget _session(BuildContext context, JsonMap row) {
final id = '${row['id'] ?? ''}';
final selected = id == activeSessionId;
final color =
chatColorShade(context, chatSessionColor(row)) ??
(chatControlsStyleOf(context) == ChatControlsStyle.cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary);
return ChatVisibilityMarker(
sessionId: id,
color: color,
visible: visibleSessionIds.contains(id),
active: selected,
child: AnimatedContainer(
duration: MediaQuery.disableAnimationsOf(context)
? Duration.zero
: const Duration(milliseconds: 200),
color: color.withValues(alpha: selected ? .24 : .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),
),
),
() {
unawaited(controller.markOpened(row));
onOpen(row);
},
selected: selected,
),
),
);
}
@override
Widget build(BuildContext context) => Align(
alignment: AlignmentDirectional.topStart,
@@ -81,26 +125,7 @@ class ChatCompactSidebar extends StatelessWidget {
isOpen: folds.isOpen,
);
return ListView(
children: [
for (final row in rows)
_button(
context,
chatSessionTitle(row),
Text(
chatSessionTitle(row).characters.take(2).toString(),
style: TextStyle(
fontWeight: row['id'] == activeSessionId
? FontWeight.bold
: null,
),
),
() {
unawaited(controller.markOpened(row));
onOpen(row);
},
selected: row['id'] == activeSessionId,
),
],
children: [for (final row in rows) _session(context, row)],
);
},
),
@@ -45,6 +45,7 @@ class ChatSessionsBody extends StatelessWidget {
required this.errorFor,
this.folds,
this.activeSessionId,
this.visibleSessionIds = const {},
this.onDismissError,
this.selectionOnly = false,
this.emptyMessageOverride,
@@ -56,6 +57,7 @@ class ChatSessionsBody extends StatelessWidget {
final ChatSectionFolds? folds;
final List<JsonMap> sessions;
final String? activeSessionId;
final Set<String> visibleSessionIds;
final String query;
final bool loading;
final String? error;
@@ -94,6 +96,7 @@ class ChatSessionsBody extends StatelessWidget {
sections: sections,
folds: folds,
activeSessionId: activeSessionId,
visibleSessionIds: visibleSessionIds,
emptyMessage: visible.isEmpty ? emptyMessage : null,
duplicateTitles: duplicateTitles,
onOpen: onOpen,
@@ -116,6 +119,7 @@ class ChatSessionsBody extends StatelessWidget {
sections: sections,
folds: folds,
activeSessionId: activeSessionId,
visibleSessionIds: visibleSessionIds,
emptyMessage: visible.isEmpty ? emptyMessage : null,
duplicateTitles: duplicateTitles,
onOpen: onOpen,
@@ -37,6 +37,7 @@ class ChatSessionsScreen extends StatefulWidget {
this.localStore,
this.controller,
this.activeSessionId,
this.visibleSessionIds = const {},
this.publishShellBar,
this.folds,
});
@@ -66,6 +67,7 @@ class ChatSessionsScreen extends StatefulWidget {
/// The conversation open above this list, or null when the list is showing.
/// Pushed activity for it is being read, so it never raises a New mark.
final String? activeSessionId;
final Set<String> visibleSessionIds;
/// A pushed phone page owns separate chrome. Keep the underlying list's bar
/// ready without pretending its open conversation is unread/inactive.
@@ -285,6 +287,7 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
child: ChatSessionsBody(
sessions: _controller.sessions,
activeSessionId: widget.activeSessionId,
visibleSessionIds: widget.visibleSessionIds,
query: _search.text,
loading: _controller.loading,
error: _controller.error,
@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
/// A chat's colour identifies it; this animated edge identifies where it is
/// visible. The active chat has a stronger edge in both list presentations.
class ChatVisibilityMarker extends StatelessWidget {
const ChatVisibilityMarker({
super.key,
required this.sessionId,
required this.color,
required this.visible,
required this.active,
required this.child,
});
final String sessionId;
final Color color;
final bool visible;
final bool active;
final Widget child;
@override
Widget build(BuildContext context) => Semantics(
label: active
? 'Active chat'
: visible
? 'Visible chat'
: null,
child: AnimatedContainer(
key: ValueKey('chat-visibility-$sessionId'),
duration: MediaQuery.disableAnimationsOf(context)
? Duration.zero
: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
foregroundDecoration: BoxDecoration(
border: BorderDirectional(
start: visible
? BorderSide(color: color, width: active ? 7 : 3)
: BorderSide.none,
),
),
child: child,
),
);
}
@@ -26,6 +26,7 @@ class CupertinoSessionList extends StatelessWidget {
required this.errorFor,
this.folds,
this.activeSessionId,
this.visibleSessionIds = const {},
this.onDismissError,
this.selectionOnly = false,
});
@@ -34,6 +35,7 @@ class CupertinoSessionList extends StatelessWidget {
final bool selectionOnly;
final ChatSectionFolds? folds;
final String? activeSessionId;
final Set<String> visibleSessionIds;
final String? emptyMessage;
final Set<String> duplicateTitles;
final ValueChanged<JsonMap> onOpen;
@@ -88,6 +90,7 @@ class CupertinoSessionList extends StatelessWidget {
selectionOnly: selectionOnly,
divider: divider,
activeSessionId: activeSessionId,
visibleSessionIds: visibleSessionIds,
duplicateTitles: duplicateTitles,
isUnseen: isUnseen,
onOpen: onOpen,
@@ -83,6 +83,7 @@ SessionListItem chatSessionRowItem(
JsonMap session, {
required bool divider,
required String? activeSessionId,
Set<String> visibleSessionIds = const {},
required Set<String> duplicateTitles,
required bool Function(JsonMap) isUnseen,
required ValueChanged<JsonMap> onOpen,
@@ -103,6 +104,7 @@ SessionListItem chatSessionRowItem(
session: session,
selectionOnly: selectionOnly,
selected: id == activeSessionId,
visible: visibleSessionIds.contains(id),
duplicateTitles: duplicateTitles,
unseen: isUnseen(session),
divider: divider,
@@ -25,6 +25,7 @@ class MaterialSessionList extends StatelessWidget {
required this.errorFor,
this.folds,
this.activeSessionId,
this.visibleSessionIds = const {},
this.onDismissError,
this.selectionOnly = false,
});
@@ -33,6 +34,7 @@ class MaterialSessionList extends StatelessWidget {
final bool selectionOnly;
final ChatSectionFolds? folds;
final String? activeSessionId;
final Set<String> visibleSessionIds;
final String? emptyMessage;
final Set<String> duplicateTitles;
final ValueChanged<JsonMap> onOpen;
@@ -104,6 +106,7 @@ class MaterialSessionList extends StatelessWidget {
selectionOnly: selectionOnly,
divider: divider,
activeSessionId: activeSessionId,
visibleSessionIds: visibleSessionIds,
duplicateTitles: duplicateTitles,
isUnseen: isUnseen,
onOpen: onOpen,
@@ -10,6 +10,7 @@ import '../../domain/chat_list_activity.dart';
import '../../domain/chat_sessions.dart';
import 'chat_adaptive.dart';
import 'chat_color_palette.dart';
import 'chat_visibility_marker.dart';
import 'session_actions.dart';
import 'session_activity_badge.dart';
import 'session_harness_icon.dart';
@@ -21,9 +22,9 @@ 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 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.
/// wears a faint row tint and a coloured avatar. An animated leading edge
/// marks visible chats, growing wider for the active chat. The menu remains
/// the row's way to its actions.
class ChatSessionRow extends StatelessWidget {
const ChatSessionRow({
super.key,
@@ -33,6 +34,7 @@ class ChatSessionRow extends StatelessWidget {
this.onOpenBelow,
required this.onAction,
this.selected = false,
this.visible = false,
this.unseen = false,
this.divider = true,
this.duplicateTitles = const {},
@@ -41,6 +43,7 @@ class ChatSessionRow extends StatelessWidget {
});
final JsonMap session;
/// A choosing surface keeps the normal row content but offers only opening.
final bool selectionOnly;
final ValueChanged<JsonMap> onOpen;
@@ -49,6 +52,7 @@ class ChatSessionRow extends StatelessWidget {
final VoidCallback? onLongPress;
final ValueChanged<SessionAction> onAction;
final bool selected;
final bool visible;
final bool unseen;
final bool divider;
final Set<String> duplicateTitles;
@@ -65,75 +69,82 @@ class ChatSessionRow extends StatelessWidget {
: Theme.of(context).colorScheme.primary;
final text = chatSessionSubtitle(session);
final updatedAt = _chatSessionInstant(session['updated_at']);
return AppListRow(
key: Key('chat-row-$id'),
cupertino: cupertino,
selected: selected,
emphasized: unread,
divider: divider,
onTap: () => onOpen(session),
onLongPress: selectionOnly ? null : onLongPress,
accent: chatColorShade(context, chatSessionColor(session)),
leading: ChatSessionAvatar(
session: session,
running: session['running'] == true && !unseen,
backgroundTasks: session['running'] == true
? 0
: chatSessionBackgroundTasks(session),
return ChatVisibilityMarker(
sessionId: id,
color: chatColorShade(context, chatSessionColor(session)) ?? accent,
visible: visible,
active: selected,
child: AppListRow(
key: Key('chat-row-$id'),
cupertino: cupertino,
selected: selected,
),
// The star rides in the title's own text, so a narrow row ellipsises
// them together.
title: Text.rich(
TextSpan(
text: chatSessionTitle(session),
children: [
if (session['starred'] == true)
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 4),
child: _Star(cupertino: cupertino, color: accent),
emphasized: unread,
divider: divider,
onTap: () => onOpen(session),
onLongPress: selectionOnly ? null : onLongPress,
accent: chatColorShade(context, chatSessionColor(session)),
showAccentBorder: false,
leading: ChatSessionAvatar(
session: session,
running: session['running'] == true && !unseen,
backgroundTasks: session['running'] == true
? 0
: chatSessionBackgroundTasks(session),
selected: selected,
),
// The star rides in the title's own text, so a narrow row ellipsises
// them together.
title: Text.rich(
TextSpan(
text: chatSessionTitle(session),
children: [
if (session['starred'] == true)
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 4),
child: _Star(cupertino: cupertino, color: accent),
),
),
),
],
],
),
),
),
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),
),
if (closed && text.isNotEmpty) const TextSpan(text: ' · '),
TextSpan(text: text),
],
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),
),
if (closed && text.isNotEmpty) const TextSpan(text: ' · '),
TextSpan(text: text),
],
),
),
subtitleTrailing: unread
? AppListStatusDot(
key: const Key('chat-row-unread'),
color: accent,
semanticLabel: 'New',
size: 10,
)
: null,
menu: selectionOnly
? null
: SessionActionsButton(
key: Key('chat-actions-$id'),
session: session,
duplicateTitles: duplicateTitles,
onSelected: onAction,
allowOpenBeside: onOpenBeside != null,
allowOpenBelow: onOpenBelow != null,
),
),
subtitleTrailing: unread
? AppListStatusDot(
key: const Key('chat-row-unread'),
color: accent,
semanticLabel: 'New',
size: 10,
)
: null,
menu: selectionOnly
? null
: SessionActionsButton(
key: Key('chat-actions-$id'),
session: session,
duplicateTitles: duplicateTitles,
onSelected: onAction,
allowOpenBeside: onOpenBeside != null,
allowOpenBelow: onOpenBelow != null,
),
);
}
}
@@ -15,6 +15,7 @@ Widget memoChatSessionRow({
required JsonMap session,
bool selectionOnly = false,
required bool selected,
bool visible = false,
required Set<String> duplicateTitles,
required bool unseen,
required bool divider,
@@ -33,6 +34,7 @@ Widget memoChatSessionRow({
MemoMap(session),
selectionOnly,
selected,
visible,
// The row reads the set only for its own title.
duplicateTitles.contains(chatSessionTitle(session)),
unseen,
@@ -51,6 +53,7 @@ Widget memoChatSessionRow({
session: session,
selectionOnly: selectionOnly,
selected: selected,
visible: visible,
duplicateTitles: duplicateTitles,
unseen: unseen,
divider: divider,
+41 -10
View File
@@ -96,12 +96,19 @@ class ListDetailPanes extends StatefulWidget {
required this.detail,
this.detailIdentity,
this.listWidthOverride,
this.compactListWidth,
this.onListCompactChanged,
});
final Widget list;
/// Focus layouts may retain the list offstage at zero/compact width.
final double? listWidthOverride;
/// Optional compact rail reached by dragging below the normal list minimum.
/// The grab handle remains available at the rail edge to expand it again.
final double? compactListWidth;
final ValueChanged<bool>? onListCompactChanged;
final Widget detail;
/// Which item [detail] shows; selecting another item closes any page the
@@ -139,11 +146,30 @@ class _ListDetailPanesState extends State<ListDetailPanes> {
final window = media.size.width;
final available = constraints.maxWidth;
final preferred = widths.widthFor(key);
final normalWidth = listDetailListWidth(
window,
available,
preferred,
final resizable =
widget.listWidthOverride == null ||
widget.listWidthOverride == widget.compactListWidth;
final bounds = resizable
? listPaneWidthBounds(
window,
available,
minimum: widget.compactListWidth ?? kListPaneMinWidth,
)
: null;
final compactThreshold = math.min(
kListPaneMinWidth,
listDetailListWidth(window, available) * .8,
);
// In a tight split the shell's bar and list share the default
// width policy. The rail can still collapse/expand there without
// making the shell's controls wider than their list.
final normalBounds = listPaneWidthBounds(window, available);
final normalWidth =
widget.compactListWidth != null &&
normalBounds != null &&
preferred != null
? preferred.clamp(compactThreshold, normalBounds.max).toDouble()
: listDetailListWidth(window, available, preferred);
final listWidth = (widget.listWidthOverride ?? normalWidth)
.clamp(0.0, math.max(0.0, available - kDetailPaneMinWidth))
.toDouble();
@@ -152,9 +178,11 @@ class _ListDetailPanesState extends State<ListDetailPanes> {
final retainedWidth = widget.listWidthOverride == null
? listWidth
: math.max(normalWidth, kListPaneMinWidth);
final bounds = widget.listWidthOverride == null
? listPaneWidthBounds(window, available)
: null;
void resize(double value) {
widths.preview(key, value);
widget.onListCompactChanged?.call(value < compactThreshold);
}
Widget body = widget.detail;
if (split) {
// Beside the list the item is not under the shell's top bar (it
@@ -236,11 +264,14 @@ class _ListDetailPanesState extends State<ListDetailPanes> {
width: kListPaneDividerGrabWidth,
child: ListPaneDivider(
width: listWidth,
min: bounds.min,
min: widget.compactListWidth ?? bounds.min,
max: bounds.max,
onChanged: (value) => widths.preview(key, value),
onChanged: resize,
onChangeEnd: () => widths.commit(key),
onReset: () => widths.reset(key),
onReset: () {
widths.reset(key);
widget.onListCompactChanged?.call(false);
},
),
),
],
+5 -4
View File
@@ -30,8 +30,9 @@ const double _listWindowMaximum = 0.6;
/// is too small for any width but the default policy's.
({double min, double max})? listPaneWidthBounds(
double window,
double available,
) {
double available, {
double minimum = kListPaneMinWidth,
}) {
final bodyMinimum = math.max(
window * _bodyWindowMinimum,
kDetailPaneMinWidth,
@@ -40,8 +41,8 @@ const double _listWindowMaximum = 0.6;
available - 1 - bodyMinimum,
window * _listWindowMaximum,
);
if (maximum < kListPaneMinWidth) return null;
return (min: kListPaneMinWidth, max: maximum);
if (maximum < minimum) return null;
return (min: minimum, max: maximum);
}
/// The open item's width beside a list, for a [window] this wide and
+10 -2
View File
@@ -74,6 +74,7 @@ class AppListRow extends StatelessWidget {
this.compactWidth = kAppListRowCompactWidth,
this.cupertino,
this.accent,
this.showAccentBorder = true,
});
/// The item's own colour (a chat's highlight): a bar on the row's leading
@@ -81,6 +82,9 @@ class AppListRow extends StatelessWidget {
/// marks the open row, so the two never read as one another.
final Color? accent;
/// Retain identity tint while a feature supplies its own visibility marker.
final bool showAccentBorder;
final Widget title;
final Widget? leading;
final String? time;
@@ -192,7 +196,7 @@ class AppListRow extends StatelessWidget {
// The colour bar runs the row's whole height, divider included, and
// the tint fills the divider's inset too, so coloured rows read as
// one band each.
Widget marked(Widget row) => accent == null
Widget marked(Widget row) => accent == null || !showAccentBorder
? row
: DecoratedBox(
key: appListRowAccentKey,
@@ -291,7 +295,11 @@ class AppListRow extends StatelessWidget {
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [titleLine, const SizedBox(height: _lineGap), timeLine],
children: [
titleLine,
const SizedBox(height: _lineGap),
timeLine,
],
);
}
return Column(
+35
View File
@@ -0,0 +1,35 @@
# Chat sidebar resizing and visibility marks
The chat panel no longer offers a list-layout menu. Dragging its list divider
below the full-list threshold switches to the existing 72px compact rail; the
handle remains draggable there, and the existing Expand button opens the full
list. The same held drag can reverse through the threshold. Generic list/detail
destinations retain their original minimums. Tight desktop splits also retain
a rail handle. Legacy hidden sidebar snapshots restore to compact so they can
always be expanded.
Chat identity colours remain in row tints/avatars. A chat-specific animated edge
is absent for nonvisible sessions, 3px for visible sessions, and 7px for the
visible active session. BorderSide.none avoids a zero-width coloured hairline.
Compact rows retain their chat colours with native avatar circles, row tints,
and the same visible/active edge. Marker animation has a reduced-motion path.
Source includes a `_workspaceVisibilityChanged(Set<String>)` integration seam.
The mobile/workspace lane adds ChatWorkspace.onVisibleSessionIdsChanged; root
must wire that callback into this seam after combining candidates. Without that
wire, the sidebar safely falls back to the current active session, and analyzer
reports this otherwise-unreferenced method as one warning. This is an explicit
integration dependency, not a clean analyzer claim.
Checks before integration:
- Focused session UI, chat split integration, workspace restore, shell drag and
compact tests: 151 passed; peak1894MB;16s; `/tmp/memwatch/out.nuKAoq`.
- Final marker and shell resize/compact subset:14 passed; peak1061MB;5s;
`/tmp/memwatch/out.q78Y6z`.
- Regression coverage includes invisible-but-selected chat (no edge), edge width
interpolation, compact colour identity, same-press collapse/re-expand, expand
button, fresh drag from rail, draft/pane retention, tight600px desktop rail,
and hidden snapshot recovery.
- Analyzer: zero errors/infos; one expected unused integration-seam warning.
- Combined browser capture/review is left to root after true-visibility callback
integration, so no standalone rendered evidence is claimed here.
@@ -172,42 +172,51 @@ void main() {
expect(tester.takeException(), isNull);
});
testWidgets('compact and hidden sidebar preserve panes and drafts', (
tester,
) async {
await _setup(tester);
await _split(tester, 'b', 'Open to the right');
final stateA = tester.state(_thread('a'));
final stateB = tester.state(_thread('b'));
await tester.enterText(_input('a'), 'Keep this draft');
final originalWidth = tester.getSize(_thread('a')).width;
Future<void> choose(String label) async {
testWidgets(
'drag compacts and expands sidebar without losing panes or drafts',
(tester) async {
await _setup(tester);
await _split(tester, 'b', 'Open to the right');
final stateA = tester.state(_thread('a'));
final stateB = tester.state(_thread('b'));
await tester.enterText(_input('a'), 'Keep this draft');
final divider = find.byKey(const ValueKey('list-detail-divider'));
final originalLeft = tester.getRect(_thread('a')).left;
final gesture = await tester.startGesture(tester.getCenter(divider));
await gesture.moveBy(const Offset(-250, 0));
await tester.pumpAndSettle();
expect(find.byTooltip('Expand chat list'), findsOneWidget);
expect(tester.getRect(_thread('a')).left, lessThan(originalLeft));
expect(tester.state(_thread('a')), same(stateA));
expect(tester.state(_thread('b')), same(stateB));
// The same drag can reverse across the threshold without dropping capture.
await gesture.moveBy(const Offset(250, 0));
await tester.pumpAndSettle();
expect(find.byTooltip('Expand chat list'), findsNothing);
expect(tester.getRect(_thread('a')).left, closeTo(originalLeft, 1));
await gesture.up();
await tester.drag(divider, const Offset(-500, 0));
await tester.pumpAndSettle();
expect(find.byTooltip('Expand chat list'), findsOneWidget);
await tester.tap(find.byTooltip('Expand chat list'));
await tester.pumpAndSettle();
expect(find.byTooltip('Expand chat list'), findsNothing);
expect(
tester.widget<EditableText>(_input('a')).controller.text,
'Keep this draft',
);
await tester.drag(divider, const Offset(-500, 0));
await tester.pumpAndSettle();
await tester.drag(divider, const Offset(250, 0));
await tester.pumpAndSettle();
expect(find.byTooltip('Expand chat list'), findsNothing);
expect(tester.state(_thread('b')), same(stateB));
await tester.tap(find.byTooltip('More actions').hitTestable().first);
await tester.pumpAndSettle();
await tester.tap(find.text('Chat list layout'));
await tester.pumpAndSettle();
await tester.pumpAndSettle();
await tester.tap(find.text(label));
await tester.pumpAndSettle();
}
await choose('Compact chat list');
expect(find.byTooltip('Expand chat list'), findsOneWidget);
expect(tester.getSize(_thread('a')).width, greaterThan(originalWidth));
expect(tester.state(_thread('a')), same(stateA));
expect(tester.state(_thread('b')), same(stateB));
await choose('Hide chat list');
expect(find.byTooltip('Expand chat list'), findsNothing);
expect(tester.getRect(_thread('a')).left, 0);
expect(tester.state(_thread('a')), same(stateA));
expect(
tester.widget<EditableText>(_input('a')).controller.text,
'Keep this draft',
);
await choose('Expanded chat list');
expect(tester.getSize(_thread('a')).width, closeTo(originalWidth, 1));
expect(tester.state(_thread('b')), same(stateB));
});
expect(find.text('Chat list layout'), findsNothing);
await tester.pumpWidget(const SizedBox());
},
);
testWidgets(
'nested splits preserve drafts, resize, collapse and narrow restore',
@@ -5,7 +5,6 @@ import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/core/servers/server_scope.dart';
import 'package:pipelines_app/features/chat/conversation/chat_sidebar_controls.dart';
import 'package:pipelines_app/features/chat/screen.dart';
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace_store.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
@@ -89,19 +88,8 @@ void main() {
findsOneWidget,
);
}
expect(
(tester
.widget<ChatThreadView>(find.byType(ChatThreadView).first)
.sidebarControl!
as ChatSidebarButton)
.mode,
ChatSidebarMode.hidden,
);
(tester
.widget<ChatThreadView>(find.byType(ChatThreadView).first)
.sidebarControl!
as ChatSidebarButton)
.onChanged(ChatSidebarMode.compact);
expect(find.byTooltip('Expand chat list'), findsOneWidget);
expect(find.byType(ChatSidebarButton), findsNothing);
} else {
expect(find.byType(ChatSidebarButton), findsNothing);
}
@@ -113,20 +101,13 @@ void main() {
);
final persisted = (await store.read())!;
expect((persisted.root as ChatWorkspaceSplit).ratio, .42);
expect(persisted.sidebarMode, width > 1000 ? 'compact' : 'hidden');
expect(persisted.sidebarMode, 'compact');
await tester.pumpWidget(const SizedBox.shrink());
await tester.pumpAndSettle();
await _mount(tester, gateway);
expect((_workspace(tester).root as ChatWorkspaceSplit).ratio, .42);
if (width > 1000) {
expect(
(tester
.widget<ChatThreadView>(find.byType(ChatThreadView).first)
.sidebarControl!
as ChatSidebarButton)
.mode,
ChatSidebarMode.compact,
);
expect(find.byTooltip('Expand chat list'), findsOneWidget);
}
await tester.pumpWidget(const SizedBox.shrink());
await tester.pumpAndSettle();
@@ -66,16 +66,15 @@ Future<void> _pump(
await tester.pumpAndSettle();
}
Finder _accent(String id) => find.descendant(
of: find.byKey(Key('chat-row-$id')),
matching: find.byKey(appListRowAccentKey),
Finder _accent(String id) => find.byWidgetPredicate(
(widget) =>
widget is AppListRow &&
widget.key == Key('chat-row-$id') &&
widget.accent != null,
);
Color _accentColor(WidgetTester tester, String id) {
final box = tester.widget<DecoratedBox>(_accent(id));
final border = (box.decoration as BoxDecoration).border as BorderDirectional;
return border.start.color;
}
Color _accentColor(WidgetTester tester, String id) =>
tester.widget<AppListRow>(_accent(id)).accent!;
void main() {
for (final cupertino in [false, true]) {
@@ -214,7 +213,8 @@ void main() {
AppListRow.selectedColor(context, cupertino: false),
reason: 'The selected fill, not the tint, marks the open row',
);
expect(find.byKey(appListRowAccentKey), findsOneWidget);
expect(find.byKey(appListRowAccentKey), findsNothing);
expect(find.byKey(const ValueKey('chat-visibility-s1')), findsOneWidget);
});
group('controller', () {
@@ -0,0 +1,135 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/features/chat/data/chat_repository.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_compact_sidebar.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_body.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_controller.dart';
import 'chat_test_harness.dart' show MemoryChatSessionLocalStore;
import 'fake_chat_gateway.dart';
BorderSide edge(WidgetTester tester, String id) {
final box = tester.widget<DecoratedBox>(
find
.descendant(
of: find.byKey(ValueKey('chat-visibility-$id')),
matching: find.byWidgetPredicate(
(widget) =>
widget is DecoratedBox &&
widget.position == DecorationPosition.foreground,
),
)
.first,
);
return ((box.decoration as BoxDecoration).border as BorderDirectional).start;
}
void main() {
testWidgets(
'only visible chats have an edge; active edge widens continuously',
(tester) async {
tester.platformDispatcher.accessibilityFeaturesTestValue =
const FakeAccessibilityFeatures(disableAnimations: false);
addTearDown(
tester.platformDispatcher.clearAccessibilityFeaturesTestValue,
);
var active = false;
late StateSetter update;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: StatefulBuilder(
builder: (context, setState) {
update = setState;
return Column(
children: [
ChatSessionRow(
selected: true,
session: const {
'id': 'off',
'title': 'Not visible',
'color': 'teal',
},
onOpen: (_) {},
onAction: (_) {},
),
ChatSessionRow(
session: const {
'id': 'on',
'title': 'Visible',
'color': 'red',
},
visible: true,
selected: active,
onOpen: (_) {},
onAction: (_) {},
),
],
);
},
),
),
),
);
expect(edge(tester, 'off').style, BorderStyle.none);
expect(edge(tester, 'on').width, 3);
expect(find.byKey(appListRowAccentKey), findsNothing);
update(() => active = true);
await tester.pump();
await tester.pump(const Duration(milliseconds: 100));
expect(edge(tester, 'on').width, greaterThan(3));
expect(edge(tester, 'on').width, lessThan(7));
await tester.pumpAndSettle();
expect(edge(tester, 'on').width, 7);
update(() => active = false);
await tester.pumpAndSettle();
expect(edge(tester, 'on').width, 3);
},
);
testWidgets('compact chats keep identity colours and visible/active edges', (
tester,
) async {
final gateway = FakeChatGateway()
..sessionsHandler = () async => {
'chat_sessions': [
{'id': 'a', 'title': 'Amber', 'color': 'red'},
{'id': 'b', 'title': 'Beta', 'color': 'teal'},
{'id': 'c', 'title': 'Charlie', 'color': 'blue'},
],
};
addTearDown(gateway.pushed.close);
final controller = ChatSessionsController(
ChatRepository(gateway),
localStore: MemoryChatSessionLocalStore(),
);
addTearDown(controller.dispose);
await controller.refresh();
final folds = ChatSectionFolds();
addTearDown(folds.dispose);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: ChatCompactSidebar(
controller: controller,
folds: folds,
activeSessionId: 'a',
visibleSessionIds: const {'a', 'b'},
onOpen: (_) {},
onExpand: () {},
),
),
),
);
await tester.pumpAndSettle();
expect(find.byTooltip('Expand chat list'), findsOneWidget);
expect(edge(tester, 'a').width, 7);
expect(edge(tester, 'b').width, 3);
expect(edge(tester, 'c').style, BorderStyle.none);
final avatars = tester
.widgetList<CircleAvatar>(find.byType(CircleAvatar))
.toList();
expect(avatars, hasLength(3));
expect(avatars.map((a) => a.foregroundColor).toSet(), hasLength(3));
});
}
@@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/list_detail.dart';
import 'package:pipelines_app/shell/list_pane_widths.dart';
void main() {
testWidgets('compact rail remains draggable in a tight desktop layout', (
tester,
) async {
tester.view.physicalSize = const Size(600, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final widths = ListPaneWidths(store: MemoryListPaneWidthStore());
addTearDown(widths.dispose);
var compact = false;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Align(
alignment: Alignment.topLeft,
child: SizedBox(
width: 544,
child: ListPaneWidthsScope(
widths: widths,
child: StatefulBuilder(
builder: (context, update) => ListDetailPanes(
list: const Text('List'),
detail: const Text('Detail'),
compactListWidth: 72,
listWidthOverride: compact ? 72 : null,
onListCompactChanged: (value) =>
update(() => compact = value),
),
),
),
),
),
),
),
);
await tester.pumpAndSettle();
final divider = find.byKey(const ValueKey('list-detail-divider'));
expect(divider, findsOneWidget);
final gesture = await tester.startGesture(tester.getCenter(divider));
await gesture.moveBy(const Offset(-90, 0));
await tester.pumpAndSettle();
expect(compact, isTrue);
expect(
tester.getTopLeft(find.byKey(const ValueKey('list-detail-body'))).dx,
73,
);
await gesture.moveBy(const Offset(110, 0));
await tester.pumpAndSettle();
expect(compact, isFalse);
await gesture.up();
expect(tester.takeException(), isNull);
});
}