Keep chat controls readable and expose labeled app navigation

This commit is contained in:
2026-11-07 20:46:02 +00:00
parent 68c0ad3caa
commit 4bbbe01633
20 changed files with 582 additions and 159 deletions
@@ -29,6 +29,7 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
final mode = selected == null || !beside
? ChatSidebarMode.expanded
: _sidebarMode;
final navigation = ShellBarScope.maybeOf(context);
return Stack(
fit: StackFit.expand,
children: [
@@ -41,6 +42,15 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
),
if (mode == ChatSidebarMode.compact)
ChatCompactSidebar(
navigation: navigation?.registry.canNavigate == true
? ShellDestinationMenu(
cupertino:
chatControlsStyleOf(context) ==
ChatControlsStyle.cupertino,
current: AppDestination.chat,
onSelected: navigation!.registry.navigateTo,
)
: null,
controller: _sessionsForSidebar,
folds: _foldsForSidebar,
activeSessionId: selected,
@@ -1,6 +1,7 @@
import 'package:flutter/widgets.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/segmented_bar_overlay.dart';
import '../domain/chat_colors.dart';
import '../ui/sessions/chat_color_palette.dart';
@@ -65,12 +66,13 @@ class ChatColorWash extends StatelessWidget {
);
}
final top = MediaQuery.paddingOf(context).top;
final barHeight = top + SegmentedBarOverlay.reservedHeightOf(context);
return Positioned(
top: top,
left: 0,
right: 0,
height: fadeBelowBar,
child: wash(top, top, top + fadeBelowBar),
child: wash(barHeight, barHeight, barHeight + fadeBelowBar),
);
}
}
@@ -23,8 +23,10 @@ class ChatModeControl extends StatefulWidget {
required this.mode,
required this.modeName,
this.onChanged,
this.showLabel = false,
});
final bool showLabel;
final ApiGateway gateway;
final String sessionId;
@@ -98,7 +100,8 @@ 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 = MediaQuery.sizeOf(context).width < 600;
final iconOnly =
!widget.showLabel && MediaQuery.sizeOf(context).width < 600;
final content = Row(
mainAxisSize: MainAxisSize.min,
children: [
@@ -22,6 +22,7 @@ class ChatModelControl extends StatefulWidget {
required this.sessionId,
required this.session,
this.onChanged,
this.showLabel = false,
this.answeredBy = '',
});
@@ -29,6 +30,7 @@ class ChatModelControl extends StatefulWidget {
/// no model on record.
final String answeredBy;
final bool showLabel;
final ApiGateway gateway;
final String sessionId;
@@ -116,7 +118,7 @@ class _ChatModelControlState extends State<ChatModelControl> {
: widget.answeredBy.isNotEmpty
? widget.answeredBy
: '${backend.isEmpty ? 'opencode' : backend} default';
final compact = MediaQuery.sizeOf(context).width < 600;
final compact = !widget.showLabel && MediaQuery.sizeOf(context).width < 600;
final content = compact
? const Icon(Icons.memory_outlined)
: Row(
@@ -48,55 +48,86 @@ class ChatThreadHeader extends StatelessWidget {
Widget build(BuildContext context) {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
return SegmentedBar(
cupertino: cupertino,
automaticallyImplyLeading: false,
// The platform's own Back, so it reads and behaves as every other
// page's Back; its key stays for finders.
leading: showBack
? SegmentedBackButton(
key: const Key('chat-back'),
cupertino: cupertino,
onPressed: onBack,
)
: null,
title: title.isEmpty ? 'Chat' : title,
subtitle: folder,
subtitleIcon: cupertino ? CupertinoIcons.folder : Icons.folder_outlined,
onTitlePressed: onInfo,
titleSemanticLabel: 'Chat information',
titleKey: const Key('chat-info'),
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'),
return LayoutBuilder(
builder: (context, constraints) {
final narrow = constraints.maxWidth < 800;
final bar = SegmentedBar(
cupertino: cupertino,
automaticallyImplyLeading: false,
// The platform's own Back, so it reads and behaves as every other
// page's Back; its key stays for finders.
leading: showBack
? SegmentedBackButton(
key: const Key('chat-back'),
cupertino: cupertino,
onPressed: onBack,
)
: null,
title: title.isEmpty ? 'Chat' : title,
subtitle: folder,
subtitleIcon: cupertino
? CupertinoIcons.folder
: Icons.folder_outlined,
onTitlePressed: onInfo,
titleSemanticLabel: 'Chat information',
titleKey: const Key('chat-info'),
separateActionIslands: true,
actions: [
if (!narrow && 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: narrow ? 8 : 16,
backdrop: backdrop,
);
return ColoredBox(
color: cupertino
? CupertinoTheme.of(context).scaffoldBackgroundColor
: Theme.of(context).colorScheme.surface,
child: Column(
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,
],
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: constraints.maxWidth < 340,
children: controls,
),
),
),
],
),
],
bottomPadding: 16,
backdrop: backdrop,
);
},
);
}
}
@@ -104,11 +135,27 @@ 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});
const _ControlIsland({
super.key,
required this.children,
this.fill = false,
this.vertical = false,
});
final List<Widget> children;
final bool fill;
final bool vertical;
@override
Widget build(BuildContext context) => Row(
mainAxisSize: MainAxisSize.min,
children: [for (final child in children) Flexible(child: child)],
);
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),
],
);
}
@@ -1040,8 +1040,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
// Under the app shell the conversation takes over the app's bar (title,
// Back, model, information) instead of drawing a second bar below it.
final inShellBar = ShellBar.available(context);
// The conversation's bar floats over the transcript's top and history
// scrolls behind it; the transcript ends at the composer's top edge, so
// The measured header owns its space so scrolled text never falls
// behind the controls; the transcript ends at the composer's top edge, so
// nothing renders behind the composer and the viewport shrinks as the
// composer grows.
// Every input of the composer comes from this widget's configuration,
@@ -1072,6 +1072,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
final page = FloatingBarOverlay(
bar: ChatPaneBarReveal(bar: composerBar),
child: SegmentedBarOverlay(
reserveSpace: true,
bar: ChatPaneBarReveal(bar: _header(context, inShellBar)),
child: NotificationListener<ScrollMetricsNotification>(
onNotification: _onScrollMetrics,
@@ -1341,6 +1342,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
controls: [
if (hasModel)
ChatModelControl(
showLabel: true,
key: ValueKey<String>('chat-model-${widget.sessionId}'),
gateway: widget.gateway,
sessionId: widget.sessionId,
@@ -1356,6 +1358,7 @@ 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,
+1
View File
@@ -1,5 +1,6 @@
import '../../shell/destination.dart';
import '../../shell/shell_bar.dart';
import '../../shell/shell_destination_menu.dart';
import '../../shell/detail_page.dart';
import '../../shell/empty_detail_pane.dart';
import '../../shell/list_detail.dart';