Reserve chat list viewport above labeled navigation
This commit is contained in:
@@ -45,7 +45,11 @@ class ChatCompactSidebar extends StatelessWidget {
|
|||||||
final cupertino =
|
final cupertino =
|
||||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||||
return Semantics(
|
return Semantics(
|
||||||
|
label: title,
|
||||||
|
button: true,
|
||||||
selected: selected,
|
selected: selected,
|
||||||
|
onTap: onPressed,
|
||||||
|
excludeSemantics: true,
|
||||||
child: cupertino
|
child: cupertino
|
||||||
? Tooltip(
|
? Tooltip(
|
||||||
message: title,
|
message: title,
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
/// The shell publishes its measured destination bar as bottom media padding.
|
||||||
|
/// Reserve that area instead of letting rows paint beneath its opaque captions.
|
||||||
|
/// SafeArea removes the consumed inset so the list cannot count it twice.
|
||||||
|
class ChatListViewport extends StatelessWidget {
|
||||||
|
const ChatListViewport({super.key, required this.builder});
|
||||||
|
final WidgetBuilder builder;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => SafeArea(
|
||||||
|
top: false,
|
||||||
|
left: false,
|
||||||
|
right: false,
|
||||||
|
child: ClipRect(child: Builder(builder: builder)),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import '../../../../core/api_gateway.dart';
|
import '../../../../core/api_gateway.dart';
|
||||||
import 'chat_adaptive.dart';
|
import 'chat_adaptive.dart';
|
||||||
import 'chat_sessions_body.dart';
|
import 'chat_sessions_body.dart';
|
||||||
|
import 'chat_list_viewport.dart';
|
||||||
import 'session_list_items.dart';
|
import 'session_list_items.dart';
|
||||||
import '../../../../ui/adaptive/floating_bar_layout.dart';
|
import '../../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
|
|
||||||
@@ -53,33 +54,40 @@ class CupertinoSessionList extends StatelessWidget {
|
|||||||
final ValueChanged<String>? onDismissError;
|
final ValueChanged<String>? onDismissError;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => ChatListViewport(
|
||||||
return CustomScrollView(
|
builder: (context) {
|
||||||
slivers: [
|
return CustomScrollView(
|
||||||
SliverPadding(
|
slivers: [
|
||||||
// Starts below a floating top bar (its height arrives as media top
|
SliverPadding(
|
||||||
// padding) and ends clear of a floating bottom bar.
|
// Starts below a floating top bar (its height arrives as media top
|
||||||
padding: withFloatingBarClearance(
|
// padding) and ends clear of a floating bottom bar.
|
||||||
context,
|
padding: withFloatingBarClearance(
|
||||||
EdgeInsets.only(top: MediaQuery.paddingOf(context).top, bottom: 24),
|
context,
|
||||||
),
|
EdgeInsets.only(
|
||||||
sliver: SliverMainAxisGroup(
|
top: MediaQuery.paddingOf(context).top,
|
||||||
slivers: [
|
bottom: 24,
|
||||||
for (final section in sections) _section(section),
|
),
|
||||||
if (emptyMessage != null)
|
),
|
||||||
SliverToBoxAdapter(
|
sliver: SliverMainAxisGroup(
|
||||||
child: ChatCupertinoMessage(
|
slivers: [
|
||||||
message: emptyMessage!,
|
for (final section in sections) _section(section),
|
||||||
actionLabel: onClearSearch == null ? null : 'Clear search',
|
if (emptyMessage != null)
|
||||||
onAction: onClearSearch,
|
SliverToBoxAdapter(
|
||||||
|
child: ChatCupertinoMessage(
|
||||||
|
message: emptyMessage!,
|
||||||
|
actionLabel: onClearSearch == null
|
||||||
|
? null
|
||||||
|
: 'Clear search',
|
||||||
|
onAction: onClearSearch,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
);
|
||||||
);
|
},
|
||||||
}
|
);
|
||||||
|
|
||||||
Widget _section(ChatSessionSection section) => chatSessionSection(
|
Widget _section(ChatSessionSection section) => chatSessionSection(
|
||||||
section: section,
|
section: section,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../../../../core/api_gateway.dart';
|
import '../../../../core/api_gateway.dart';
|
||||||
import 'chat_sessions_body.dart';
|
import 'chat_sessions_body.dart';
|
||||||
|
import 'chat_list_viewport.dart';
|
||||||
import 'session_list_items.dart';
|
import 'session_list_items.dart';
|
||||||
|
|
||||||
class MaterialSessionList extends StatelessWidget {
|
class MaterialSessionList extends StatelessWidget {
|
||||||
@@ -52,41 +53,42 @@ class MaterialSessionList extends StatelessWidget {
|
|||||||
final ValueChanged<String>? onDismissError;
|
final ValueChanged<String>? onDismissError;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => ChatListViewport(
|
||||||
// Clears the media padding above and below (a floating top bar's height
|
builder: (context) {
|
||||||
// arrives as top padding) and leaves only the side padding to the rows,
|
// The viewport has already consumed the bottom bar. Pad the list's
|
||||||
// as a ListView does.
|
// start below its floating top bar, leaving side insets to the rows.
|
||||||
final media = MediaQuery.of(context);
|
final media = MediaQuery.of(context);
|
||||||
return CustomScrollView(
|
return CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverPadding(
|
SliverPadding(
|
||||||
padding: media.padding.copyWith(left: 0, right: 0),
|
padding: media.padding.copyWith(left: 0, right: 0),
|
||||||
sliver: MediaQuery(
|
sliver: MediaQuery(
|
||||||
data: media.copyWith(
|
data: media.copyWith(
|
||||||
padding: media.padding.copyWith(top: 0, bottom: 0),
|
padding: media.padding.copyWith(top: 0, bottom: 0),
|
||||||
),
|
),
|
||||||
child: SliverMainAxisGroup(
|
child: SliverMainAxisGroup(
|
||||||
slivers: [
|
slivers: [
|
||||||
for (final section in sections) _section(context, section),
|
for (final section in sections) _section(context, section),
|
||||||
if (emptyMessage != null)
|
if (emptyMessage != null)
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
title: Text(emptyMessage!),
|
title: Text(emptyMessage!),
|
||||||
trailing: onClearSearch == null
|
trailing: onClearSearch == null
|
||||||
? null
|
? null
|
||||||
: TextButton(
|
: TextButton(
|
||||||
onPressed: onClearSearch,
|
onPressed: onClearSearch,
|
||||||
child: const Text('Clear search'),
|
child: const Text('Clear search'),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
);
|
||||||
);
|
},
|
||||||
}
|
);
|
||||||
|
|
||||||
Widget _section(BuildContext context, ChatSessionSection section) {
|
Widget _section(BuildContext context, ChatSessionSection section) {
|
||||||
final heading = SectionHeadingStyle.of(context);
|
final heading = SectionHeadingStyle.of(context);
|
||||||
|
|||||||
@@ -24,3 +24,15 @@ Tests: 132 session tests passed (/tmp/memwatch/out.CVA6FK); six final state,
|
|||||||
compact-facts and native palette tests passed (/tmp/memwatch/out.iFGOhB).
|
compact-facts and native palette tests passed (/tmp/memwatch/out.iFGOhB).
|
||||||
Analyzer clean (flutter-analyze.WdYBd8). Parent owns integrated browser captures
|
Analyzer clean (flutter-analyze.WdYBd8). Parent owns integrated browser captures
|
||||||
and shell launcher testing. No server or device operations performed.
|
and shell launcher testing. No server or device operations performed.
|
||||||
|
|
||||||
|
Follow-up: expanded chat lists now consume the shell's measured bottom media
|
||||||
|
inset as a real clipped viewport through ChatListViewport/SafeArea, rather
|
||||||
|
than allowing rows to paint beneath opaque navigation and merely appending
|
||||||
|
scroll padding. The consumed inset is removed for the inner list, avoiding a
|
||||||
|
double footer. Existing top/side behavior and resting scroll position remain.
|
||||||
|
The last row and its metadata can scroll fully clear and remain tappable;
|
||||||
|
resizing preserves the Scrollable state and offset. Compact rail controls
|
||||||
|
also publish their full Active/Visible/Working labels and tap action explicitly,
|
||||||
|
so the shape indicators are not their sole accessible meaning.
|
||||||
|
139 focused list/session tests pass (/tmp/memwatch/out.VxtAN0), including both
|
||||||
|
hosts at normal and enlarged text. Analyzer clean (flutter-analyze.bYWSTe).
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/ui/sessions/session_list_cupertino.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/ui/sessions/session_list_material.dart';
|
||||||
|
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||||
|
import 'package:pipelines_app/shell/destination.dart';
|
||||||
|
import 'package:pipelines_app/shell/list_detail.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
for (final cupertino in [false, true]) {
|
||||||
|
for (final scale in [1.0, 2.0]) {
|
||||||
|
testWidgets(
|
||||||
|
'chat list stays above labeled navigation ($cupertino, $scale)',
|
||||||
|
(tester) async {
|
||||||
|
tester.view.physicalSize = const Size(1200, 900);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
tester.platformDispatcher.textScaleFactorTestValue = scale;
|
||||||
|
addTearDown(tester.view.reset);
|
||||||
|
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||||
|
String? opened;
|
||||||
|
final sessions = [
|
||||||
|
for (var i = 0; i < 14; i++)
|
||||||
|
{
|
||||||
|
'id': 's$i',
|
||||||
|
'title': 'Chat item $i',
|
||||||
|
'model': 'model',
|
||||||
|
'directory': '/work/project-$i',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
Widget list() => cupertino
|
||||||
|
? CupertinoSessionList(
|
||||||
|
sections: [(title: 'Chats', sessions: sessions)],
|
||||||
|
emptyMessage: null,
|
||||||
|
duplicateTitles: const {},
|
||||||
|
onOpen: (row) => opened = row['id'] as String,
|
||||||
|
onRename: (_) {},
|
||||||
|
onClose: (_) {},
|
||||||
|
onReopen: (_) {},
|
||||||
|
onStar: (_) {},
|
||||||
|
onHide: (_) {},
|
||||||
|
onClearSearch: null,
|
||||||
|
isUnseen: (_) => false,
|
||||||
|
errorFor: (_) => null,
|
||||||
|
)
|
||||||
|
: MaterialSessionList(
|
||||||
|
sections: [(title: 'Chats', sessions: sessions)],
|
||||||
|
emptyMessage: null,
|
||||||
|
duplicateTitles: const {},
|
||||||
|
onOpen: (row) => opened = row['id'] as String,
|
||||||
|
onRename: (_) {},
|
||||||
|
onClose: (_) {},
|
||||||
|
onReopen: (_) {},
|
||||||
|
onStar: (_) {},
|
||||||
|
onHide: (_) {},
|
||||||
|
onClearSearch: null,
|
||||||
|
isUnseen: (_) => false,
|
||||||
|
errorFor: (_) => null,
|
||||||
|
);
|
||||||
|
final shell = AdaptiveShell(
|
||||||
|
cupertino: cupertino,
|
||||||
|
destination: AppDestination.chat,
|
||||||
|
destinationBodies: {
|
||||||
|
AppDestination.chat: (_) => ListDetailPanes(
|
||||||
|
list: list(),
|
||||||
|
detail: const SizedBox.expand(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final navigation = tester.getRect(
|
||||||
|
find.byKey(FloatingDestinationBar.rowKey),
|
||||||
|
);
|
||||||
|
final scrollView = find.byType(CustomScrollView);
|
||||||
|
final viewport = tester.getRect(scrollView);
|
||||||
|
expect(viewport.bottom, lessThanOrEqualTo(navigation.top + .5));
|
||||||
|
expect(viewport.width, greaterThan(0));
|
||||||
|
final scrollable = tester.state<ScrollableState>(
|
||||||
|
find.descendant(of: scrollView, matching: find.byType(Scrollable)),
|
||||||
|
);
|
||||||
|
scrollable.position.jumpTo(scrollable.position.maxScrollExtent);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final last = find.byKey(const Key('chat-row-s13'));
|
||||||
|
expect(
|
||||||
|
tester.getRect(last).bottom,
|
||||||
|
lessThanOrEqualTo(navigation.top + .5),
|
||||||
|
);
|
||||||
|
final metadata = find.descendant(
|
||||||
|
of: last,
|
||||||
|
matching: find.text('model · /work/project-13'),
|
||||||
|
);
|
||||||
|
expect(metadata, findsOneWidget);
|
||||||
|
expect(
|
||||||
|
tester.getRect(metadata).bottom,
|
||||||
|
lessThanOrEqualTo(navigation.top + .5),
|
||||||
|
);
|
||||||
|
await tester.tap(find.text('Chat item 13'));
|
||||||
|
await tester.pump();
|
||||||
|
expect(opened, 's13');
|
||||||
|
final retainedOffset = scrollable.position.pixels;
|
||||||
|
tester.view.physicalSize = const Size(1440, 900);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(
|
||||||
|
tester.state<ScrollableState>(
|
||||||
|
find.descendant(
|
||||||
|
of: scrollView,
|
||||||
|
matching: find.byType(Scrollable),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
same(scrollable),
|
||||||
|
);
|
||||||
|
expect(scrollable.position.pixels, closeTo(retainedOffset, .5));
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -107,6 +107,60 @@ void main() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
testWidgets('compact focus and execution labels are explicit beyond shapes', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final semantics = tester.ensureSemantics();
|
||||||
|
final gateway = FakeChatGateway()
|
||||||
|
..sessionsReply = {
|
||||||
|
'chat_sessions': [
|
||||||
|
{
|
||||||
|
'id': 'a',
|
||||||
|
'title': 'Active title',
|
||||||
|
'activity': {'turn_running': true, 'seq': 1},
|
||||||
|
},
|
||||||
|
{'id': 'b', 'title': 'Visible title'},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
final controller = ChatSessionsController(
|
||||||
|
ChatRepository(gateway),
|
||||||
|
localStore: MemoryChatSessionLocalStore(),
|
||||||
|
);
|
||||||
|
final folds = ChatSectionFolds();
|
||||||
|
addTearDown(controller.dispose);
|
||||||
|
addTearDown(folds.dispose);
|
||||||
|
addTearDown(gateway.pushed.close);
|
||||||
|
await controller.refresh();
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: ChatCompactSidebar(
|
||||||
|
controller: controller,
|
||||||
|
folds: folds,
|
||||||
|
activeSessionId: 'a',
|
||||||
|
visibleSessionIds: const {'a', 'b'},
|
||||||
|
onOpen: (_) {},
|
||||||
|
onExpand: () {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pump();
|
||||||
|
final tips = tester.widgetList<Tooltip>(find.byType(Tooltip));
|
||||||
|
final active = tips
|
||||||
|
.firstWhere((t) => t.message!.startsWith('Active title'))
|
||||||
|
.message!;
|
||||||
|
final visible = tips
|
||||||
|
.firstWhere((t) => t.message!.startsWith('Visible title'))
|
||||||
|
.message!;
|
||||||
|
expect(active, contains('Active chat'));
|
||||||
|
expect(active, contains('Working'));
|
||||||
|
expect(visible, contains('Visible chat'));
|
||||||
|
expect(find.bySemanticsLabel(RegExp('Working')), findsWidgets);
|
||||||
|
expect(find.bySemanticsLabel(RegExp('Visible chat')), findsWidgets);
|
||||||
|
semantics.dispose();
|
||||||
|
});
|
||||||
|
|
||||||
for (final cupertino in [false, true]) {
|
for (final cupertino in [false, true]) {
|
||||||
for (final brightness in Brightness.values) {
|
for (final brightness in Brightness.values) {
|
||||||
testWidgets(
|
testWidgets(
|
||||||
|
|||||||
Reference in New Issue
Block a user