Restore requested navigation and mobile chat controls
This commit is contained in:
@@ -133,13 +133,21 @@ class _ChatModeControlState extends State<ChatModeControl> {
|
||||
),
|
||||
);
|
||||
}
|
||||
return Tooltip(
|
||||
message: 'Change mode (currently $label)',
|
||||
child: TextButton(
|
||||
key: key,
|
||||
style: chatBarTextButtonStyle(context),
|
||||
onPressed: _open,
|
||||
child: content,
|
||||
return Semantics(
|
||||
container: true,
|
||||
button: true,
|
||||
label: 'Change mode, currently $label',
|
||||
onTap: _open,
|
||||
child: ExcludeSemantics(
|
||||
child: Tooltip(
|
||||
message: 'Change mode (currently $label)',
|
||||
child: TextButton(
|
||||
key: key,
|
||||
style: chatBarTextButtonStyle(context),
|
||||
onPressed: _open,
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -146,13 +146,21 @@ class _ChatModelControlState extends State<ChatModelControl> {
|
||||
),
|
||||
);
|
||||
}
|
||||
return Tooltip(
|
||||
message: 'Change model (currently $label)',
|
||||
child: TextButton(
|
||||
key: key,
|
||||
style: chatBarTextButtonStyle(context),
|
||||
onPressed: _open,
|
||||
child: content,
|
||||
return Semantics(
|
||||
container: true,
|
||||
button: true,
|
||||
label: 'Change model, currently $label',
|
||||
onTap: _open,
|
||||
child: ExcludeSemantics(
|
||||
child: Tooltip(
|
||||
message: 'Change model (currently $label)',
|
||||
child: TextButton(
|
||||
key: key,
|
||||
style: chatBarTextButtonStyle(context),
|
||||
onPressed: _open,
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import '../ui/sessions/chat_adaptive.dart';
|
||||
/// pill with the conversation's title and folder that opens the chat's
|
||||
/// information, a selector island holding [controls] (model and mode),
|
||||
/// then the Files action and a native More menu in a separate island.
|
||||
/// Narrow panes give readable model/mode values a separate row; exceptionally
|
||||
/// short viewports can scroll the header to keep controls reachable.
|
||||
/// Narrow panes keep the model/mode selectors as compact icons in the same row;
|
||||
/// their semantic labels and native pickers continue to expose the values.
|
||||
class ChatThreadHeader extends StatelessWidget {
|
||||
const ChatThreadHeader({
|
||||
super.key,
|
||||
@@ -53,8 +53,7 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final textScale = MediaQuery.textScalerOf(context).scale(14) / 14;
|
||||
final readableWidth = constraints.maxWidth / textScale;
|
||||
final narrow = readableWidth < 800;
|
||||
final compact = constraints.maxWidth / textScale < 800;
|
||||
final bar = SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
automaticallyImplyLeading: false,
|
||||
@@ -77,7 +76,7 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
titleKey: const Key('chat-info'),
|
||||
separateActionIslands: true,
|
||||
actions: [
|
||||
if (!narrow && controls.isNotEmpty)
|
||||
if (controls.isNotEmpty)
|
||||
_ControlIsland(
|
||||
key: const Key('chat-model-permission-island'),
|
||||
children: controls,
|
||||
@@ -104,35 +103,14 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
],
|
||||
bottomPadding: narrow ? 8 : 16,
|
||||
bottomPadding: compact ? 8 : 16,
|
||||
backdrop: backdrop,
|
||||
);
|
||||
return ColoredBox(
|
||||
color: cupertino
|
||||
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
child: SingleChildScrollView(
|
||||
primary: false,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
bar,
|
||||
if (narrow && controls.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 12, 8),
|
||||
child: SegmentedPill(
|
||||
cupertino: cupertino,
|
||||
child: _ControlIsland(
|
||||
key: const Key('chat-model-permission-island'),
|
||||
fill: true,
|
||||
vertical: readableWidth < 340,
|
||||
children: controls,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: bar,
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -142,27 +120,12 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
/// 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,
|
||||
this.fill = false,
|
||||
this.vertical = false,
|
||||
});
|
||||
const _ControlIsland({super.key, required this.children});
|
||||
final List<Widget> children;
|
||||
final bool fill;
|
||||
final bool vertical;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => vertical
|
||||
? Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: children,
|
||||
)
|
||||
: Row(
|
||||
mainAxisSize: fill ? MainAxisSize.max : MainAxisSize.min,
|
||||
children: [
|
||||
for (final child in children)
|
||||
if (fill) Expanded(child: child) else Flexible(child: child),
|
||||
],
|
||||
);
|
||||
Widget build(BuildContext context) => Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [for (final child in children) Flexible(child: child)],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1342,7 +1342,6 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
controls: [
|
||||
if (hasModel)
|
||||
ChatModelControl(
|
||||
showLabel: true,
|
||||
key: ValueKey<String>('chat-model-${widget.sessionId}'),
|
||||
gateway: widget.gateway,
|
||||
sessionId: widget.sessionId,
|
||||
@@ -1358,7 +1357,6 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
/// The session's permission mode, keyed per session so another chat
|
||||
/// re-reads its own modes.
|
||||
Widget _modeControl() => ChatModeControl(
|
||||
showLabel: true,
|
||||
key: ValueKey<String>('chat-mode-${widget.sessionId}'),
|
||||
gateway: widget.gateway,
|
||||
sessionId: widget.sessionId,
|
||||
|
||||
@@ -173,7 +173,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
// remounts a destination.
|
||||
//
|
||||
// While the tab shows its list beside an open item the bar moves under
|
||||
// the list pane, centred in the list's (dragged) width, so the open item
|
||||
// the leading edge of the list pane, so the open item
|
||||
// keeps its whole height: the list clears the bar and the item clears
|
||||
// only the system inset (see ListDetailPanes). The bar keeps its place
|
||||
// in the tree, so a split never replays its entrance.
|
||||
@@ -198,7 +198,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
currentIndex: index,
|
||||
onTap: (value) => _select(shellTabDestinations[value]),
|
||||
items: _destinationItems(),
|
||||
alignment: split ? Alignment.bottomCenter : null,
|
||||
alignment: split ? AlignmentDirectional.bottomStart : null,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -13,10 +13,11 @@ import 'floating_destination_labels.dart';
|
||||
/// frosted [GlassPill] buttons, one per tab, instead of a full-width system
|
||||
/// bar. Used for the app's destinations and for every page's own tabs.
|
||||
///
|
||||
/// The row is only as wide as its buttons and sits at the trailing (right,
|
||||
/// in left-to-right text) edge, near the thumb, keeping [kFloatingBarMargin]
|
||||
/// from the sides and above the bottom safe area. Only the buttons take
|
||||
/// taps: the gaps between and beside them reach the content behind. A row
|
||||
/// The row is only as wide as its buttons and, by default, sits at the trailing
|
||||
/// (right, in left-to-right text) edge, near the thumb, keeping
|
||||
/// [kFloatingBarMargin] from the sides and above the bottom safe area. Hosts
|
||||
/// can request another alignment for a pane-specific layout. Only the buttons
|
||||
/// take taps: the gaps between and beside them reach the content behind. A row
|
||||
/// squeezed below its natural width narrows its gaps, then scales down.
|
||||
///
|
||||
/// The selected button is filled with the host's selection tint, which
|
||||
@@ -48,8 +49,8 @@ class FloatingDestinationBar extends StatefulWidget {
|
||||
final bool showLabels;
|
||||
|
||||
/// Where the row sits in the width it is given, at [FloatingBarEdge.bottom]:
|
||||
/// the trailing end by default. The shell centres its tabs under the list
|
||||
/// pane while a list shows beside an open item.
|
||||
/// the trailing end by default. The shell can align its main tabs to the
|
||||
/// leading edge of a list pane while a list shows beside an open item.
|
||||
final AlignmentGeometry? alignment;
|
||||
|
||||
/// The edge the bar floats at. At [FloatingBarEdge.top] (an open item's
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Desktop main tabs leading alignment
|
||||
|
||||
Wide list-detail layouts now place the main destination tab row at the leading
|
||||
edge of the list pane. Narrow layouts retain their trailing placement, and
|
||||
page-specific tab bars remain unchanged. Focused shell tests cover Material and
|
||||
Cupertino geometry, including stored pane widths.
|
||||
@@ -0,0 +1,13 @@
|
||||
# Mobile chat selector controls
|
||||
|
||||
- Mobile chat headers keep model and permission-mode selectors in the single top row, together in their selector island before Files and More.
|
||||
- Mobile uses the existing memory and shield icons; semantic labels/tooltips retain the current-value explanation and native pickers.
|
||||
- Desktop keeps the existing readable selector labels and picker behavior.
|
||||
- Focused checks: `tool/memwatch/full.sh 'test/features/chat/conversation/chat_thread_header_test.dart test/features/chat/conversation/chat_model_picker_test.dart'` — 28 passed.
|
||||
- `tool/analyze.sh` — clean.
|
||||
- Fixture-browser captures were inspected for Material/Cupertino mobile (560x1000) and desktop (1280x1000), light theme:
|
||||
- `public/chat-material-mobile/01-mobile-material.png`
|
||||
- `public/chat-cupertino-mobile/01-mobile-cupertino.png`
|
||||
- `public/chat-material-desktop/01-desktop-material.png`
|
||||
- `public/chat-cupertino-desktop/01-desktop-cupertino.png`
|
||||
- No device installation or deployment was performed.
|
||||
@@ -38,7 +38,7 @@ void _useNarrowText(WidgetTester tester) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('short large-text header scrolls controls without overflow', (
|
||||
testWidgets('short large-text header keeps controls in its single row', (
|
||||
tester,
|
||||
) async {
|
||||
_useNarrowText(tester);
|
||||
@@ -55,15 +55,9 @@ void main() {
|
||||
onInfo: () {},
|
||||
showBack: true,
|
||||
onBack: () {},
|
||||
controls: [
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: const Text('Current model'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: const Text('Ask for permission'),
|
||||
),
|
||||
controls: const [
|
||||
IconButton(onPressed: null, icon: Icon(Icons.memory_outlined)),
|
||||
IconButton(onPressed: null, icon: Icon(Icons.shield_outlined)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -73,9 +67,10 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.ensureVisible(find.text('Ask for permission'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Ask for permission').hitTestable(), findsOneWidget);
|
||||
expect(
|
||||
find.byKey(const Key('chat-model-permission-island')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
@@ -83,7 +78,7 @@ void main() {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets(
|
||||
'$host narrow header keeps native back/title and readable model',
|
||||
'$host narrow header keeps native back/title and compact model icon',
|
||||
(tester) async {
|
||||
_useNarrowText(tester);
|
||||
final semantics = tester.ensureSemantics();
|
||||
@@ -124,19 +119,22 @@ void main() {
|
||||
|
||||
// One floating row of separate pieces: the round Back, the title pill
|
||||
// (which is the information control and holds the title), then the
|
||||
// model in the trailing pill.
|
||||
// selector island in the trailing row.
|
||||
double centerY(Finder finder) => tester.getCenter(finder).dy;
|
||||
expect((centerY(back) - centerY(info)).abs(), lessThan(16));
|
||||
expect(
|
||||
tester.getTopLeft(model).dy,
|
||||
greaterThanOrEqualTo(tester.getBottomLeft(info).dy),
|
||||
);
|
||||
expect((centerY(model) - centerY(info)).abs(), lessThan(16));
|
||||
expect(find.descendant(of: info, matching: title), findsOneWidget);
|
||||
double right(Finder finder) => tester.getTopRight(finder).dx;
|
||||
expect(right(back), lessThanOrEqualTo(tester.getTopLeft(info).dx));
|
||||
expect(find.byIcon(Icons.memory_outlined), findsOneWidget);
|
||||
if (!cupertino) {
|
||||
final semantics = tester.getSemantics(model);
|
||||
expect(semantics.label, contains('Change model'));
|
||||
expect(semantics.label, contains('currently'));
|
||||
}
|
||||
expect(
|
||||
find.textContaining('an-extremely-long-recorded-model-id'),
|
||||
findsOneWidget,
|
||||
findsNothing,
|
||||
);
|
||||
|
||||
await tester.tap(back);
|
||||
@@ -199,21 +197,43 @@ void main() {
|
||||
final actions = find.byKey(const Key('chat-actions-island'));
|
||||
expect(selectors, findsOneWidget);
|
||||
expect(actions, findsOneWidget);
|
||||
if (width / 2 >= 800) {
|
||||
expect(
|
||||
tester.getTopRight(selectors).dx,
|
||||
lessThan(tester.getTopLeft(actions).dx),
|
||||
);
|
||||
} else {
|
||||
expect(
|
||||
tester.getTopLeft(selectors).dy,
|
||||
greaterThanOrEqualTo(tester.getBottomLeft(actions).dy),
|
||||
);
|
||||
}
|
||||
expect(
|
||||
(tester.getCenter(selectors).dy - tester.getCenter(actions).dy)
|
||||
.abs(),
|
||||
lessThan(16),
|
||||
);
|
||||
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);
|
||||
if (width < 600) {
|
||||
expect(find.text('model-a'), findsNothing);
|
||||
expect(find.text('Ask before making changes'), findsNothing);
|
||||
expect(find.byIcon(Icons.memory_outlined), findsOneWidget);
|
||||
expect(
|
||||
find.byIcon(
|
||||
cupertino
|
||||
? CupertinoIcons.shield_lefthalf_fill
|
||||
: Icons.shield_outlined,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
if (!cupertino) {
|
||||
expect(
|
||||
tester.getSemantics(find.byKey(const Key('chat-model'))).label,
|
||||
contains('Change model, currently'),
|
||||
);
|
||||
expect(
|
||||
tester.getSemantics(find.byKey(const Key('chat-mode'))).label,
|
||||
contains('Change mode, currently'),
|
||||
);
|
||||
}
|
||||
expect(
|
||||
(tester.getCenter(selectors).dy - tester.getCenter(actions).dy)
|
||||
.abs(),
|
||||
lessThan(16),
|
||||
);
|
||||
}
|
||||
for (final key in ['chat-model', 'chat-mode']) {
|
||||
expect(
|
||||
tester.getSize(find.byKey(Key(key))).width,
|
||||
|
||||
@@ -6,9 +6,11 @@ import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_labels.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
|
||||
|
||||
/// Main navigation keeps visible captions and full-size targets, floating at
|
||||
/// the trailing edge on a phone and centered under the list on a wide window.
|
||||
/// the trailing edge on a phone and the leading edge under the list on a wide
|
||||
/// window.
|
||||
void main() {
|
||||
Finder pill() => find.descendant(
|
||||
of: find.byType(FloatingDestinationBar),
|
||||
@@ -110,7 +112,7 @@ void main() {
|
||||
expect(find.text('Chat — Not implemented'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('$host: wide bar hugs its tabs under the list column, content '
|
||||
testWidgets('$host: wide leading bar under the list, content '
|
||||
'keeps the width and taps beside the bar reach it', (tester) async {
|
||||
taps = 0;
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
@@ -118,13 +120,7 @@ void main() {
|
||||
final rect = tester.getRect(pill());
|
||||
// With no item open the bar still sits under the list column, where it
|
||||
// sits beside an open item, so it never jumps sides.
|
||||
expect(
|
||||
rect.center.dx,
|
||||
moreOrLessEquals(
|
||||
listDetailListWidth(1200, 1200, null) / 2,
|
||||
epsilon: 0.5,
|
||||
),
|
||||
);
|
||||
expect(rect.left, moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5));
|
||||
expect(rect.bottom, 800 - 16);
|
||||
expect(rect.width, lessThan(1200 * 0.6));
|
||||
// Captions participate in the bar's content-driven width.
|
||||
@@ -179,11 +175,8 @@ void main() {
|
||||
tester.view.physicalSize = const Size(1200, 800);
|
||||
await tester.pump();
|
||||
expect(
|
||||
tester.getRect(pill()).center.dx,
|
||||
moreOrLessEquals(
|
||||
listDetailListWidth(1200, 1200, null) / 2,
|
||||
epsilon: 0.5,
|
||||
),
|
||||
tester.getRect(pill()).left,
|
||||
moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5),
|
||||
);
|
||||
expect(tester.getRect(pill()).width, lessThan(1200 * 0.6));
|
||||
expect(tester.state(find.byType(StatefulBuilder)), same(state));
|
||||
|
||||
@@ -9,8 +9,8 @@ import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
|
||||
/// While a tab shows its list beside an open item, the shell's destination
|
||||
/// bar moves to the bottom of the list pane, centred in the list's (dragged)
|
||||
/// width. The list clears the bar; the item keeps its whole height, its own
|
||||
/// bar moves to the leading edge at the bottom of the list pane, including
|
||||
/// after the list's width is dragged. The list clears the bar; the item keeps its whole height, its own
|
||||
/// bottom control (its tabs, or a composer) at its bottom edge.
|
||||
void main() {
|
||||
Future<void> setSize(WidgetTester tester, Size size) async {
|
||||
@@ -128,8 +128,8 @@ void main() {
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
final pill = destinationPill(tester);
|
||||
// Centred at the bottom of the list pane, never over the detail.
|
||||
expect(pill.center.dx, closeTo(list.center.dx, 0.5));
|
||||
// Leading at the bottom of the list pane, never over the detail.
|
||||
expect(pill.left, closeTo(list.left + kFloatingBarMargin, 0.5));
|
||||
expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
expect(pill.right, lessThanOrEqualTo(list.right));
|
||||
expect(pill.overlaps(body), isFalse, reason: 'never over the detail');
|
||||
@@ -227,17 +227,24 @@ void main() {
|
||||
tester,
|
||||
) async {
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
final store = MemoryListPaneWidthStore({'chat': 300});
|
||||
await tester.pumpWidget(shell(cupertino: cupertino, store: store));
|
||||
await tester.pumpAndSettle();
|
||||
final list = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-list')),
|
||||
);
|
||||
expect(list.width, closeTo(300, 0.5));
|
||||
final pill = destinationPill(tester);
|
||||
expect(pill.center.dx, closeTo(list.center.dx, 0.5));
|
||||
expect(pill.left, greaterThanOrEqualTo(kFloatingBarMargin - 0.5));
|
||||
expect(pill.right, lessThanOrEqualTo(list.right - kFloatingBarMargin));
|
||||
for (final width in [300.0, 520.0]) {
|
||||
final store = MemoryListPaneWidthStore({'chat': width});
|
||||
await tester.pumpWidget(
|
||||
KeyedSubtree(
|
||||
key: ValueKey(width),
|
||||
child: shell(cupertino: cupertino, store: store),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final list = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-list')),
|
||||
);
|
||||
expect(list.width, closeTo(width, 0.5));
|
||||
final pill = destinationPill(tester);
|
||||
expect(pill.left, closeTo(list.left + kFloatingBarMargin, 0.5));
|
||||
expect(pill.left, greaterThanOrEqualTo(kFloatingBarMargin - 0.5));
|
||||
expect(pill.right, lessThanOrEqualTo(list.right - kFloatingBarMargin));
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('$host 1200 Settings: a page without a list keeps the bar '
|
||||
@@ -260,10 +267,7 @@ void main() {
|
||||
final pill = destinationPill(tester);
|
||||
// Same place as beside an open item (Search has no split), so opening
|
||||
// or closing an item never moves the bar across the window.
|
||||
expect(
|
||||
pill.center.dx,
|
||||
closeTo(listDetailListWidth(1200, 1200, null) / 2, 0.5),
|
||||
);
|
||||
expect(pill.left, closeTo(kFloatingBarMargin, 0.5));
|
||||
expect(pill.width, lessThan(1200 * 0.6));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user