Separate chat selectors from Files and More actions

This commit is contained in:
2026-11-07 02:49:44 +00:00
parent 9e6d55942f
commit e9d66af785
15 changed files with 353 additions and 200 deletions
@@ -98,7 +98,7 @@ class _ChatModeControlState extends State<ChatModeControl> {
final label = _name;
// At phone widths the title and a named mode cannot both remain useful.
// Keep the mode's shield, whose semantic label and picker still name it.
final iconOnly = cupertino && MediaQuery.sizeOf(context).width < 600;
final iconOnly = MediaQuery.sizeOf(context).width < 600;
final content = Row(
mainAxisSize: MainAxisSize.min,
children: [
@@ -116,14 +116,19 @@ class _ChatModelControlState extends State<ChatModelControl> {
: widget.answeredBy.isNotEmpty
? widget.answeredBy
: '${backend.isEmpty ? 'opencode' : backend} default';
final content = Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(child: Text(label, overflow: TextOverflow.ellipsis)),
const SizedBox(width: 4),
Icon(cupertino ? CupertinoIcons.chevron_down : Icons.expand_more),
],
);
final compact = MediaQuery.sizeOf(context).width < 600;
final content = compact
? Icon(
cupertino ? CupertinoIcons.sparkles : Icons.auto_awesome_outlined,
)
: Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(child: Text(label, overflow: TextOverflow.ellipsis)),
const SizedBox(width: 4),
Icon(cupertino ? CupertinoIcons.chevron_down : Icons.expand_more),
],
);
const key = Key('chat-model');
if (cupertino) {
return Semantics(
@@ -1,11 +1,13 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../ui/sessions/chat_adaptive.dart';
import '../../../ui/adaptive/segmented_bar.dart';
enum ChatSidebarMode { expanded, compact, hidden }
/// Pinned rather than overflowed: the list can always be restored from a pane.
class ChatSidebarButton extends StatelessWidget {
/// Native list-layout selector, also available in the chat actions menu.
class ChatSidebarButton extends StatelessWidget
implements SegmentedOverflowable {
const ChatSidebarButton({
super.key,
required this.mode,
@@ -14,6 +16,20 @@ class ChatSidebarButton extends StatelessWidget {
final ChatSidebarMode mode;
final ValueChanged<ChatSidebarMode> onChanged;
@override
SegmentedOverflowEntry get overflowEntry => SegmentedOverflowEntry(
label: 'Chat list layout',
icon: Icons.view_sidebar_outlined,
choices: [
for (final value in ChatSidebarMode.values)
SegmentedMenuChoice(
label: _label(value),
selected: value == mode,
onSelected: () => onChanged(value),
),
],
);
Future<void> _choose(BuildContext context) async {
final ChatSidebarMode? choice;
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/segmented_bar.dart';
import '../../../ui/adaptive/segmented_bar_overflow.dart';
import '../ui/sessions/chat_adaptive.dart';
/// The open conversation's bar: the app's [SegmentedBar] above the
@@ -9,7 +10,8 @@ import '../ui/sessions/chat_adaptive.dart';
///
/// From the leading edge: a round Back (only where the page can go back), a
/// pill with the conversation's title and folder that opens the chat's
/// information, and a pill holding [controls] (model and mode).
/// information, a selector island holding [controls] (model and mode),
/// then the Files action and a native More menu in a separate island.
class ChatThreadHeader extends StatelessWidget {
const ChatThreadHeader({
super.key,
@@ -19,6 +21,8 @@ class ChatThreadHeader extends StatelessWidget {
this.showBack = false,
this.onBack,
this.controls = const [],
this.actions = const [],
this.moreActions = const [],
this.backdrop,
});
@@ -34,6 +38,8 @@ class ChatThreadHeader extends StatelessWidget {
/// What Back does; null keeps the platform's stock action (pop the route).
final VoidCallback? onBack;
final List<Widget> controls;
final List<Widget> actions;
final List<Widget> moreActions;
/// Painted over the bar's scrim, under its pieces (the chat's colour).
final Widget? backdrop;
@@ -60,9 +66,49 @@ class ChatThreadHeader extends StatelessWidget {
onTitlePressed: onInfo,
titleSemanticLabel: 'Chat information',
titleKey: const Key('chat-info'),
actions: controls,
separateActionIslands: true,
actions: [
if (controls.isNotEmpty)
_ControlIsland(
key: const Key('chat-model-permission-island'),
children: controls,
),
if (actions.isNotEmpty || moreActions.isNotEmpty)
Row(
key: const Key('chat-actions-island'),
mainAxisSize: MainAxisSize.min,
children: [
...actions,
// Unknown action widgets retain their original behavior and stay
// visible; only the explicit overflow contract becomes a menu.
for (final action in moreActions)
if (action is! SegmentedOverflowable) action,
if (moreActions.whereType<SegmentedOverflowable>().isNotEmpty)
SegmentedMoreButton(
cupertino: cupertino,
entries: [
for (final action
in moreActions.whereType<SegmentedOverflowable>())
action.overflowEntry,
],
),
],
),
],
bottomPadding: 16,
backdrop: backdrop,
);
}
}
/// Related selectors share the available width. Each remains a real control;
/// they never migrate into the unrelated actions menu.
class _ControlIsland extends StatelessWidget {
const _ControlIsland({super.key, required this.children});
final List<Widget> children;
@override
Widget build(BuildContext context) => Row(
mainAxisSize: MainAxisSize.min,
children: [for (final child in children) Flexible(child: child)],
);
}
@@ -15,7 +15,6 @@ import '../domain/chat_attachment_picker.dart';
import '../domain/chat_colors.dart';
import '../domain/chat_transcript.dart';
import '../ui/sessions/chat_adaptive.dart';
import 'chat_next_chat_button.dart';
import '../ui/sessions/chat_color_picker.dart';
import '../ui/sessions/session_actions.dart';
import '../ui/transcript/chat_markdown_view.dart';
@@ -104,7 +103,7 @@ class ChatThreadView extends StatefulWidget {
final ApiGateway gateway;
/// Opens the chat after this one in the list (wrapping to the first), from
/// the bar's Next chat button; null when there is no other chat to open.
/// Keyboard chat switching callback; no button is drawn in the header.
final VoidCallback? onNextChat;
final List<Widget> paneControls;
final Widget? sidebarControl;
@@ -1326,12 +1325,9 @@ class _ChatThreadViewState extends State<ChatThreadView> {
: widget.showBackButton == true
? widget.onBack
: (inShellBar ? null : widget.onBack),
// Each control is its own action, so each pops in (and sinks) on its
// own. Natural width while the bar has room; past the title's share
// the model ellipsises, and the mode keeps its whole name until it
// would take more than half the pill. A session without a mode draws
// no mode control, so no empty pill is ever drawn.
controls: [
// Keep selectors in their own island before Files and the actions menu.
// Sidebar and pane actions retain their native overflow contracts.
actions: [
ChatBarAction(
label: 'Files',
identifier: 'chat-files-toggle',
@@ -1341,8 +1337,9 @@ class _ChatThreadViewState extends State<ChatThreadView> {
? CupertinoIcons.folder_fill
: CupertinoIcons.folder,
),
?widget.sidebarControl,
...widget.paneControls,
],
moreActions: [?widget.sidebarControl, ...widget.paneControls],
controls: [
if (hasModel)
ChatModelControl(
key: ValueKey<String>('chat-model-${widget.sessionId}'),
@@ -1353,8 +1350,6 @@ class _ChatThreadViewState extends State<ChatThreadView> {
answeredBy: answeredBy,
),
if (hasMode) _modeControl(),
if (widget.onNextChat case final next?)
ChatNextChatButton(key: const Key('chat-next'), onPressed: next),
],
);
}
+30 -3
View File
@@ -63,6 +63,7 @@ class SegmentedBar extends StatefulWidget
this.titleSemanticLabel,
this.titleKey,
this.actions = const [],
this.separateActionIslands = false,
this.actionsKey,
this.backgroundColor,
this.pillColor,
@@ -115,6 +116,10 @@ class SegmentedBar extends StatefulWidget
/// its own (see [SegmentedEntrancePlanner]).
final List<Widget> actions;
/// Each action is an independently filled island, ordered before the next.
/// Use non-overflowable group widgets to keep related controls together.
final bool separateActionIslands;
/// Who supplies [actions] (a shell's open screen): when it changes, every
/// action is new and pops in, though one has the same key as before.
final Object? actionsKey;
@@ -338,7 +343,18 @@ class _SegmentedBarState extends State<SegmentedBar> {
cupertino: cupertino,
tint: widget.foregroundColor,
enabled: actions.length > 1,
child: action,
child: widget.separateActionIslands
? Padding(
padding: EdgeInsetsDirectional.only(
start: index == 0 ? 0 : 8,
),
child: SegmentedPill(
cupertino: cupertino,
fill: widget.pillColor,
child: action,
),
)
: action,
),
),
),
@@ -346,6 +362,14 @@ class _SegmentedBarState extends State<SegmentedBar> {
);
}
Widget _actionsIsland({
required bool cupertino,
Color? fill,
required Widget child,
}) => widget.separateActionIslands
? child
: SegmentedPill(cupertino: cupertino, fill: fill, child: child);
@override
Widget build(BuildContext context) {
final cupertino = widget.cupertino;
@@ -417,6 +441,9 @@ class _SegmentedBarState extends State<SegmentedBar> {
width * SegmentedBar.maxTitleShare,
),
);
final minimumTitleShare = widget.separateActionIslands
? .10
: SegmentedBar.minTitleShare;
final besideTitle =
width -
(leading == null ? 0 : segmentedPieceHeight(cupertino) + 8) -
@@ -426,7 +453,7 @@ class _SegmentedBarState extends State<SegmentedBar> {
// before the title goes under its own width.
final actionsMaxWidth = math.max(
0.0,
besideTitle - width * SegmentedBar.minTitleShare,
besideTitle - width * minimumTitleShare,
);
final overflowWidth = math.max(0.0, besideTitle - titleMinimum);
return Row(
@@ -479,7 +506,7 @@ class _SegmentedBarState extends State<SegmentedBar> {
cupertino: cupertino,
tint: foregroundColor,
enabled: actions.length == 1,
child: SegmentedPill(
child: _actionsIsland(
cupertino: cupertino,
fill: pillColor,
child: _actionRow(
+19
View File
@@ -0,0 +1,19 @@
# Chat header islands
The header now orders Back/title, model and permission selectors, then Files and
More. More retains the sidebar layout choices and pane actions through their
explicit overflow contracts. Next chat is absent from both the bar and menu;
existing keyboard switching remains unchanged. At phone widths selectors use
icons with full semantic labels and tooltips, and keep separate touch targets.
Focused verification: 489 conversation tests and 151 adaptive UI tests passed.
Header tests cover 320, 390 and 1280 logical pixels at text scale 2 on both hosts,
including callable menu actions, selector ordering and absent Next chat. The
broader chat suite also covers routing, keyboard switching and sidebar restore.
Rendered fixture: `chats=2&header=1`. Inspected captures under
`/tmp/review/header-final-material-wide`, `/tmp/review/header-final-cupertino-wide`,
`/tmp/review/header-islands-material-phone` and
`/tmp/review/header-islands-cupertino-phone`. Both hosts have narrow and wide
captures; phone layout was widget-tested at actual phone widths in addition to
the 560px browser capture workaround. No device testing was performed.
+16 -108
View File
@@ -4,7 +4,6 @@ import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/screen.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'conversation/chat_thread_fixtures.dart';
@@ -79,113 +78,22 @@ Future<ValueNotifier<String?>> _pump(
Finder _thread(String id) => find.byKey(ValueKey('chat-thread-$id'));
final _next = find.byKey(const Key('chat-next'));
bool _rowSelected(WidgetTester tester, String id) =>
tester.widget<AppListRow>(find.byKey(Key('chat-row-$id'))).selected;
Future<void> _pressNext(WidgetTester tester) async {
await tester.tap(_next);
await tester.pumpAndSettle();
}
void main() {
testWidgets('wide: Next chat walks the list order, wraps, syncs the row', (
tester,
) async {
final route = await _pump(tester, const Size(1280, 800));
await tester.tap(find.byKey(const Key('chat-row-a')));
await tester.pumpAndSettle();
expect(_thread('a'), findsOneWidget);
expect(
tester
.widget<IconButton>(
find.descendant(of: _next, matching: find.byType(IconButton)),
)
.tooltip,
'Next chat',
);
final visited = <String>[];
for (var i = 0; i < 5; i++) {
await _pressNext(tester);
visited.add(route.value!);
expect(_thread(route.value!), findsOneWidget);
expect(_rowSelected(tester, route.value!), isTrue);
}
// Closed is folded, so Done is skipped; after the last row comes the
// first again.
expect(visited, ['z', 'r', 's', 'd', 'a']);
expect(_rowSelected(tester, 'd'), isFalse);
final navigator = tester.state<NavigatorState>(
find.byType(Navigator).first,
);
expect(navigator.canPop(), isFalse);
await tester.pumpWidget(const SizedBox.shrink());
});
testWidgets('phone: Next chat replaces the open page, never stacks one', (
tester,
) async {
final route = await _pump(tester, const Size(390, 844));
await tester.tap(find.text('Second'));
await tester.pumpAndSettle();
expect(_thread('s'), findsOneWidget);
await _pressNext(tester);
expect(route.value, 'd');
expect(_thread('d'), findsOneWidget);
expect(_thread('s'), findsNothing);
await _pressNext(tester);
expect(route.value, 'a', reason: 'wraps past the last row');
// One Back leaves the chat: no earlier chat page waits beneath it.
await tester.pageBack();
await tester.pumpAndSettle();
expect(route.value, isNull);
expect(_thread('a'), findsNothing);
final navigator = tester.state<NavigatorState>(
find.byType(Navigator).first,
);
expect(navigator.canPop(), isFalse);
expect(_rowSelected(tester, 'a'), isFalse);
await tester.pumpWidget(const SizedBox.shrink());
});
testWidgets('only one chat to show hides Next chat', (tester) async {
await _pump(
for (final size in [const Size(1280, 800), const Size(390, 844)]) {
testWidgets('Next chat is absent from header and More at $size', (
tester,
const Size(390, 844),
rows: const [
{'id': 'r', 'title': 'Recent', 'directory': '/w'},
{'id': 'c', 'title': 'Done', 'directory': '/w', 'closed_at': 1},
],
);
await tester.tap(find.text('Recent'));
await tester.pumpAndSettle();
expect(_thread('r'), findsOneWidget);
expect(_next, findsNothing);
await tester.pumpWidget(const SizedBox.shrink());
});
testWidgets('unfolding Closed offers Next chat and includes its rows', (
tester,
) async {
final route = await _pump(
tester,
const Size(1280, 800),
rows: const [
{'id': 'r', 'title': 'Recent', 'directory': '/w'},
{'id': 'c', 'title': 'Done', 'directory': '/w', 'closed_at': 1},
],
);
await tester.tap(find.text('Recent'));
await tester.pumpAndSettle();
expect(_next, findsNothing);
await tester.tap(find.text('Closed'));
await tester.pumpAndSettle();
expect(_next, findsOneWidget);
await _pressNext(tester);
expect(route.value, 'c');
await tester.pumpWidget(const SizedBox.shrink());
});
) async {
await _pump(tester, size);
await tester.tap(find.byKey(const Key('chat-row-a')));
await tester.pumpAndSettle();
expect(_thread('a'), findsOneWidget);
expect(_next, findsNothing);
expect(find.byTooltip('Next chat'), findsNothing);
await tester.tap(find.byTooltip('More actions').hitTestable().first);
await tester.pumpAndSettle();
expect(find.text('Next chat'), findsNothing);
expect(find.text('Add chat pane'), findsOneWidget);
await tester.pumpWidget(const SizedBox.shrink());
});
}
}
@@ -86,25 +86,25 @@ void main() {
await tester.tap(find.byKey(const Key('chat-row-s')));
await tester.pumpAndSettle();
expect(find.text('model-a'), findsOneWidget);
expect(find.byTooltip('Change model (currently model-a)'), findsOneWidget);
await tester.tap(find.byKey(const Key('chat-model')));
await tester.pumpAndSettle();
await tester.tap(find.text('Model Beta'));
await tester.pumpAndSettle();
expect(find.text('model-b'), findsOneWidget);
expect(find.byTooltip('Change model (currently model-b)'), findsOneWidget);
await tester.tap(findNativeBack());
await tester.pumpAndSettle();
expect(find.text('model-b'), findsNothing);
expect(find.byTooltip('Change model (currently model-b)'), findsNothing);
// The list still carries the row it read before the switch; reopening must
// still show the model the server accepted.
await tester.tap(find.byKey(const Key('chat-row-s')));
await tester.pumpAndSettle();
expect(find.text('model-b'), findsOneWidget);
expect(find.text('model-a'), findsNothing);
expect(find.byTooltip('Change model (currently model-b)'), findsOneWidget);
expect(find.byTooltip('Change model (currently model-a)'), findsNothing);
await tester.tap(find.byKey(const Key('chat-model')));
await tester.pumpAndSettle();
@@ -133,7 +133,7 @@ void main() {
// The deep link opened before any row was tapped: the list's own read
// supplies the title and the recorded model, with no second list request.
expect(find.text('Wire chat'), findsOneWidget);
expect(find.text('model-a'), findsOneWidget);
expect(find.byTooltip('Change model (currently model-a)'), findsOneWidget);
expect(find.byKey(const Key('chat-model')), findsOneWidget);
expect(gateway.count('chat_sessions'), 1);
@@ -149,7 +149,7 @@ void main() {
expect(gateway.calls.last.fields, {
'chat_model': {'session_id': 's', 'provider': 'p2', 'model': 'model-b'},
});
expect(find.text('model-b'), findsOneWidget);
expect(find.byTooltip('Change model (currently model-b)'), findsOneWidget);
});
testWidgets(
@@ -85,33 +85,28 @@ Future<void> _tap(
}
Finder _row(String id) => find.byKey(Key('chat-row-$id'));
final _next = find.byKey(const Key('chat-next'));
final _desktop = TargetPlatformVariant.only(TargetPlatform.macOS);
final _mobile = TargetPlatformVariant.only(TargetPlatform.android);
void main() {
testWidgets(
'desktop, wide: a clicked row and Next chat focus the composer',
(tester) async {
await _pump(tester, const Size(1280, 800));
await _tap(tester, _row('r'), kind: PointerDeviceKind.mouse);
expect(_thread('r'), findsOneWidget);
expect(_composerFocused(tester, 'r'), isTrue);
testWidgets('desktop, wide: clicked rows focus the composer', (tester) async {
await _pump(tester, const Size(1280, 800));
await _tap(tester, _row('r'), kind: PointerDeviceKind.mouse);
expect(_thread('r'), findsOneWidget);
expect(_composerFocused(tester, 'r'), isTrue);
// Focus elsewhere, then the chat already open: clicking returns it.
FocusManager.instance.primaryFocus?.unfocus();
await tester.pump();
await _tap(tester, _row('r'), kind: PointerDeviceKind.mouse);
expect(_composerFocused(tester, 'r'), isTrue);
// Focus elsewhere, then the chat already open: clicking returns it.
FocusManager.instance.primaryFocus?.unfocus();
await tester.pump();
await _tap(tester, _row('r'), kind: PointerDeviceKind.mouse);
expect(_composerFocused(tester, 'r'), isTrue);
await _tap(tester, _next, kind: PointerDeviceKind.mouse);
expect(_thread('s'), findsOneWidget);
expect(_composerFocused(tester, 's'), isTrue);
await tester.pumpWidget(const SizedBox.shrink());
},
variant: _desktop,
);
await _tap(tester, _row('s'), kind: PointerDeviceKind.mouse);
expect(_thread('s'), findsOneWidget);
expect(_composerFocused(tester, 's'), isTrue);
await tester.pumpWidget(const SizedBox.shrink());
}, variant: _desktop);
testWidgets(
'desktop, narrow window: a tapped row focuses the chat page composer',
@@ -125,33 +120,29 @@ void main() {
variant: _desktop,
);
testWidgets(
'desktop: a closed chat leaves its composer unfocused',
(tester) async {
await _pump(tester, const Size(1280, 800));
await _tap(tester, find.text('Closed'));
await _tap(tester, _row('c'), kind: PointerDeviceKind.mouse);
expect(_thread('c'), findsOneWidget);
expect(_composerFocused(tester, 'c'), isFalse);
await tester.pumpWidget(const SizedBox.shrink());
},
variant: _desktop,
);
testWidgets('desktop: a closed chat leaves its composer unfocused', (
tester,
) async {
await _pump(tester, const Size(1280, 800));
await _tap(tester, find.text('Closed'));
await _tap(tester, _row('c'), kind: PointerDeviceKind.mouse);
expect(_thread('c'), findsOneWidget);
expect(_composerFocused(tester, 'c'), isFalse);
await tester.pumpWidget(const SizedBox.shrink());
}, variant: _desktop);
testWidgets(
'mobile: a finger tap and Next chat do not raise the keyboard',
(tester) async {
await _pump(tester, const Size(390, 844));
await _tap(tester, find.text('Recent'));
expect(_thread('r'), findsOneWidget);
expect(_composerFocused(tester, 'r'), isFalse);
await _tap(tester, _next);
expect(_thread('s'), findsOneWidget);
expect(_composerFocused(tester, 's'), isFalse);
await tester.pumpWidget(const SizedBox.shrink());
},
variant: _mobile,
);
testWidgets('mobile: finger taps do not raise the keyboard', (tester) async {
await _pump(tester, const Size(390, 844));
await _tap(tester, find.text('Recent'));
expect(_thread('r'), findsOneWidget);
expect(_composerFocused(tester, 'r'), isFalse);
await tester.pageBack();
await tester.pumpAndSettle();
await _tap(tester, find.text('Second'));
expect(_thread('s'), findsOneWidget);
expect(_composerFocused(tester, 's'), isFalse);
await tester.pumpWidget(const SizedBox.shrink());
}, variant: _mobile);
testWidgets(
'mobile, wide: a touch tap leaves focus, a mouse click focuses',
@@ -179,7 +179,10 @@ void main() {
await tester.enterText(_input('a'), 'Keep this draft');
final originalWidth = tester.getSize(_thread('a')).width;
Future<void> choose(String label) async {
await tester.tap(find.byTooltip('Chat list layout').first);
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();
@@ -259,10 +262,12 @@ void main() {
.hitTestable();
if (closePane.evaluate().isEmpty) {
await tester.tap(
find.descendant(
of: _thread('c'),
matching: find.byTooltip('More actions'),
),
find
.descendant(
of: _thread('c'),
matching: find.byTooltip('More actions'),
)
.hitTestable(),
);
await tester.pumpAndSettle();
await tester.tap(find.text('Close pane'));
@@ -5,6 +5,7 @@ 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,13 +90,17 @@ void main() {
);
}
expect(
tester
.widget<ChatSidebarButton>(find.byType(ChatSidebarButton).first)
(tester
.widget<ChatThreadView>(find.byType(ChatThreadView).first)
.sidebarControl!
as ChatSidebarButton)
.mode,
ChatSidebarMode.hidden,
);
tester
.widget<ChatSidebarButton>(find.byType(ChatSidebarButton).first)
(tester
.widget<ChatThreadView>(find.byType(ChatThreadView).first)
.sidebarControl!
as ChatSidebarButton)
.onChanged(ChatSidebarMode.compact);
} else {
expect(find.byType(ChatSidebarButton), findsNothing);
@@ -115,8 +120,10 @@ void main() {
expect((_workspace(tester).root as ChatWorkspaceSplit).ratio, .42);
if (width > 1000) {
expect(
tester
.widget<ChatSidebarButton>(find.byType(ChatSidebarButton).first)
(tester
.widget<ChatThreadView>(find.byType(ChatThreadView).first)
.sidebarControl!
as ChatSidebarButton)
.mode,
ChatSidebarMode.compact,
);
@@ -2,6 +2,10 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
import 'package:pipelines_app/features/chat/conversation/chat_thread_header.dart';
import 'package:pipelines_app/features/chat/conversation/chat_sidebar_controls.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_adaptive.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import '../../../native_back.dart';
import 'chat_thread_fixtures.dart';
@@ -95,6 +99,129 @@ void main() {
});
}
for (final cupertino in [false, true]) {
for (final width in [320.0, 390.0, 1280.0]) {
testWidgets(
'${cupertino ? 'Cupertino' : 'Material'} grouped actions at $width and text scale 2',
(tester) async {
_useNarrowText(tester);
tester.view.physicalSize = Size(width, 800);
final gateway = FakeChatGateway();
addTearDown(gateway.close);
gateway.history = (_) async => chatPage(const []);
gateway.subscribe = () async => const {};
var sidebar = 0;
var pane = 0;
var next = 0;
await tester.pumpWidget(
_host(
ChatThreadView(
gateway: gateway,
sessionId: 's',
title: _title,
session: {
..._session,
'mode': 'safe',
'mode_name': 'Ask before making changes',
},
onBack: () {},
onNextChat: () => next++,
sidebarControl: ChatBarAction(
label: 'Sidebar action',
onPressed: () => sidebar++,
materialIcon: Icons.menu,
cupertinoIcon: CupertinoIcons.sidebar_left,
),
paneControls: [
ChatBarAction(
label: 'Pane action',
onPressed: () => pane++,
materialIcon: Icons.add_box,
cupertinoIcon: CupertinoIcons.plus_square,
),
],
),
cupertino: cupertino,
),
);
await tester.pumpAndSettle();
final selectors = find.byKey(
const Key('chat-model-permission-island'),
);
final actions = find.byKey(const Key('chat-actions-island'));
expect(selectors, findsOneWidget);
expect(actions, findsOneWidget);
expect(
tester.getTopRight(selectors).dx,
lessThan(tester.getTopLeft(actions).dx),
);
expect(find.byKey(const Key('chat-next')), findsNothing);
expect(find.text('Next chat'), findsNothing);
expect(find.byKey(const Key('chat-model')), findsOneWidget);
expect(find.byKey(const Key('chat-mode')), findsOneWidget);
for (final key in ['chat-model', 'chat-mode']) {
expect(
tester.getSize(find.byKey(Key(key))).width,
greaterThanOrEqualTo(cupertino ? 44 : 48),
);
}
expect(find.text('Sidebar action'), findsNothing);
expect(find.text('Pane action'), findsNothing);
expect(tester.takeException(), isNull);
// Both More entries retain their original callbacks in native menus.
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
await tester.pumpAndSettle();
await tester.tap(find.text('Sidebar action'));
await tester.pumpAndSettle();
expect(sidebar, 1);
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
await tester.pumpAndSettle();
await tester.tap(find.text('Pane action'));
await tester.pumpAndSettle();
expect(pane, 1);
expect(next, 0);
expect(tester.takeException(), isNull);
},
);
}
}
for (final cupertino in [false, true]) {
testWidgets(
'sidebar layout submenu retains callback on ${cupertino ? 'Cupertino' : 'Material'}',
(tester) async {
ChatSidebarMode? picked;
await tester.pumpWidget(
_host(
ChatThreadHeader(
title: 'Chat',
folder: 'demo',
onInfo: () {},
actions: const [Icon(Icons.folder_outlined)],
moreActions: [
ChatSidebarButton(
mode: ChatSidebarMode.expanded,
onChanged: (value) => picked = value,
),
],
),
cupertino: cupertino,
),
);
await tester.pumpAndSettle();
expect(find.byType(ChatSidebarButton), findsNothing);
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
await tester.pumpAndSettle();
await tester.tap(find.text('Chat list layout'));
await tester.pumpAndSettle();
await tester.tap(find.text('Hide chat list'));
await tester.pumpAndSettle();
expect(picked, ChatSidebarMode.hidden);
expect(tester.takeException(), isNull);
},
);
}
testWidgets('a conversation without a model keeps the same compact row', (
tester,
) async {
+2
View File
@@ -157,3 +157,5 @@ The tree has an assets subfolder, a hidden folder, PNG/JPEG miniatures, text,
JSON, CSV, PDF, archive, log and video entries. Image/text/table/archive files
have bundled bytes; PDF and video entries demonstrate type labels and menus
only. Use the real server for their external handlers and playback acceptance.
Chat header grouping: `?chats=2&header=1` supplies a model and permission mode to the fixture chat so the selector island and Files/More island can both be reviewed.
+5
View File
@@ -75,6 +75,11 @@ JsonMap _chatRow(int i) {
'id': id,
'title': 'Fixture chat ${i + 1}',
'directory': '/workspace/demo',
if (_params['header'] == '1') ...{
'model': 'openai/gpt-6.1',
'mode': 'default',
'mode_name': 'Ask for permission',
},
// Server-shaped handoff facts (chat_sessions rows carry them).
if (_harness != 'opencode') 'backend': _harness,
'resume_command': _resumeCommand(id),