Merge commit '1dcef23db2233e9877163a782ae5bee7509ec8db' into pipelines/run-20261112-0152-chat-tab-re-tap-opens-the-active-chats-ff7a

This commit is contained in:
2026-11-12 03:20:45 +00:00
145 changed files with 5828 additions and 920 deletions
+66 -9
View File
@@ -7,10 +7,13 @@ import '../ui/adaptive/floating_destination_bar.dart';
import 'attention_badge.dart';
import 'destination.dart';
import 'list_detail.dart';
import 'navigation_rail.dart';
import 'shell_rail_scope.dart';
import 'list_pane_widths.dart';
import 'shell_bar.dart';
import 'shell_chat_shortcut.dart';
import 'shell_list_shortcuts.dart';
import 'shell_runs_pipelines_shortcut.dart';
import 'shell_search_shortcut_labels.dart';
import 'tab_history.dart';
import '../ui/input/keyboard_owner.dart';
@@ -241,7 +244,8 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
);
// The scaffolds below swap the system insets for their bars'
// heights; panes beside a list read the real ones from here.
final system = MediaQuery.paddingOf(context);
final media = MediaQuery.of(context);
final system = media.padding;
// A page (Settings) closes to Pipelines on the system Back too; at a
// tab's root Back returns to the tab opened before it. Only with neither
// does Back reach the platform, so Android's (predictive) Back closes the
@@ -255,15 +259,60 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
},
child: child,
);
// On a wide window the destinations sit in a rail at the left edge, and
// the floating bar is not built; the scaffold gets the rest of the window.
// The tree has the same shape at every width (an empty rail slot on a
// phone), so resizing across the rail's threshold never remounts a
// destination.
final rail = showsNavigationRail(context);
final scaffold = Scaffold(
extendBodyBehindAppBar: true,
appBar: topBar,
body: _destinationStack(contents),
extendBody: true,
bottomNavigationBar: rail ? null : bar,
);
return backable(
ShellSystemInsets(
padding: system,
child: Scaffold(
extendBodyBehindAppBar: true,
appBar: topBar,
body: _destinationStack(contents),
extendBody: true,
bottomNavigationBar: bar,
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Badges (running runs, unread chats) rebuild the rail alone.
ListenableBuilder(
listenable: _bar.badges,
builder: (context, _) => rail
? ShellNavigationRail(
selected: _selected,
icon: (destination) => _icon(
destination,
destinationDetails(destination).icon,
),
onSelected: _select,
padding: EdgeInsets.only(
top: system.top,
bottom: system.bottom,
),
)
: const SizedBox.shrink(),
),
// Three children at every width, so the body keeps its slot.
rail
? const VerticalDivider(width: 1, thickness: 1)
: const SizedBox.shrink(),
Expanded(
// Beside the rail the panes lay out in the width the rail leaves,
// which the window's width fixes here (not in a layout pass), so
// the panes and their pages rebuild with the window.
child: ShellRailScope(
shown: rail,
bodyWidth: rail
? media.size.width - kNavigationRailSpace
: null,
child: scaffold,
),
),
],
),
),
);
@@ -292,8 +341,9 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
}
/// App-wide search and conversation-list selection are handled before text
/// fields. Split-pane navigation belongs to the chat workspace; tab changes
/// have no global keyboard chord.
/// fields. Split-pane navigation belongs to the chat workspace. Ctrl+A
/// bounces between Runs and Pipelines, but leaves text fields and the
/// terminal their own Ctrl+A (select all, line start).
bool _handleDestinationKeyEvent(KeyEvent event) {
final keyboard = HardwareKeyboard.instance;
// Ctrl+K is the terminal's kill-line while the terminal has the keyboard;
@@ -303,6 +353,13 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
if (event is KeyDownEvent) _openChat();
return true;
}
if (shellRunsPipelinesShortcut(event, keyboard)) {
if (primaryFocusTakesTyping()) return false;
if (event is KeyDownEvent) {
_select(shellRunsPipelinesTarget(_selected));
}
return true;
}
// A terminal keeps its keys (Escape, Ctrl+/, Ctrl+digits).
if (primaryFocusIsTypingSurface()) return false;
if (_selected == AppDestination.search &&
+4 -3
View File
@@ -2,9 +2,10 @@ import 'package:flutter/material.dart';
enum AppDestination { pipelines, runs, chat, search, settings }
/// The destinations the shell's tab bar offers, in order. Settings is a
/// destination the shell can show (its route is `/settings`), but it opens
/// as a page from the Pipelines bar's gear instead of being a tab.
/// The destinations the shell's tab bar (or, on a wide window, its rail) offers,
/// in order. Settings is a destination the shell can show (its route is
/// `/settings`), but it opens as a page, from the rail's foot on a wide window
/// or the Pipelines bar's gear on a phone, instead of being a tab.
const List<AppDestination> shellTabDestinations = [
AppDestination.pipelines,
AppDestination.runs,
+3 -2
View File
@@ -7,6 +7,7 @@ import 'detail_pane_navigator.dart';
import 'list_detail_policy.dart';
import 'list_pane_divider.dart';
import 'list_pane_widths.dart';
import 'shell_rail_scope.dart';
import 'shell_bar.dart';
export 'list_detail_policy.dart';
@@ -64,7 +65,7 @@ class ListPaneWidth extends StatelessWidget {
builder: (context, constraints) {
final width = split
? listDetailListWidth(
MediaQuery.sizeOf(context).width,
ShellRailScope.windowWidth(context),
constraints.maxWidth,
preferredWidth,
)
@@ -143,7 +144,7 @@ class _ListDetailPanesState extends State<ListDetailPanes> {
listenable: widths,
builder: (context, _) => LayoutBuilder(
builder: (context, constraints) {
final window = media.size.width;
final window = ShellRailScope.windowWidth(context);
final available = constraints.maxWidth;
final preferred = widths.widthFor(key);
final resizable =
+3 -1
View File
@@ -2,6 +2,8 @@ import 'dart:math' as math;
import 'package:flutter/widgets.dart';
import 'shell_rail_scope.dart';
/// At least this wide, a destination keeps its list beside the open item
/// (with the destination rail) instead of pushing the item as its own page.
const double kListDetailMinWidth = 600;
@@ -15,7 +17,7 @@ const double kListPaneMaxWidth = 440;
/// Whether the window at [context] shows list and detail side by side.
bool showsListBesideDetail(BuildContext context) =>
MediaQuery.sizeOf(context).width >= kListDetailMinWidth;
ShellRailScope.windowWidth(context) >= kListDetailMinWidth;
/// The narrowest list pane a drag leaves.
const double kListPaneMinWidth = 240;
+145
View File
@@ -0,0 +1,145 @@
import 'package:flutter/material.dart';
import 'destination.dart';
import 'list_detail_policy.dart';
/// The width of the destination rail on a wide window.
const double kNavigationRailWidth = 96;
/// The rail with its divider: what the rail takes from a wide window's width.
const double kNavigationRailSpace = kNavigationRailWidth + 1;
/// The narrowest window that shows the destination rail: the list-detail
/// minimum for the body beside it, plus the rail and its divider (the space the
/// shell takes from the window). Narrower windows keep the floating destination
/// bar, unchanged.
const double kNavigationRailMinWindowWidth =
kListDetailMinWidth + kNavigationRailSpace;
/// Whether the window at [context] shows the destination rail. Read from the
/// window's own [MediaQuery], so the shell and the floating windows layer
/// (which sits above the shell) agree.
bool showsNavigationRail(BuildContext context) =>
MediaQuery.sizeOf(context).width >= kNavigationRailMinWindowWidth;
/// The wide layout's left-edge navigation: a Material [NavigationRail] with
/// an icon and a label per tab, the selected tab marked by the rail's
/// indicator, and Settings pinned to its bottom.
///
/// [icon] builds each tab's icon (its running or unread badge included), so
/// the rail shows the same counts the floating bar did. [selected] is the
/// shell's destination: Settings (a page, not a tab) selects no tab but its
/// own item.
class ShellNavigationRail extends StatelessWidget {
const ShellNavigationRail({
super.key,
required this.selected,
required this.icon,
required this.onSelected,
this.padding = EdgeInsets.zero,
});
final AppDestination selected;
final Widget Function(AppDestination destination) icon;
final ValueChanged<AppDestination> onSelected;
/// The system insets the rail keeps clear of: the status bar above and the
/// navigation bar below.
final EdgeInsets padding;
@override
Widget build(BuildContext context) {
final index = shellTabDestinations.indexOf(selected);
return Padding(
padding: padding,
child: SizedBox(
width: kNavigationRailWidth,
child: NavigationRail(
key: const ValueKey('shell.navigation-rail'),
minWidth: kNavigationRailWidth,
labelType: NavigationRailLabelType.all,
selectedIndex: index < 0 ? null : index,
onDestinationSelected: (value) =>
onSelected(shellTabDestinations[value]),
destinations: [
for (final destination in shellTabDestinations)
NavigationRailDestination(
icon: KeyedSubtree(
key: ValueKey('shell.destination.${destination.name}'),
// The bar it replaces named each tab in a tooltip too.
child: Tooltip(
message: destinationDetails(destination).label,
child: icon(destination),
),
),
label: Text(destinationDetails(destination).label),
),
],
trailingAtBottom: true,
trailing: _SettingsRailItem(
selected: selected == AppDestination.settings,
onTap: () => onSelected(AppDestination.settings),
),
),
),
);
}
}
/// Settings at the rail's foot, drawn as a [NavigationRailDestination] is: an
/// icon on a stadium indicator with its label under it, and the same colours.
/// It is not a [NavigationRailDestination] itself because the rail's
/// destination list is the tabs, and `trailing` is what the rail pins.
class _SettingsRailItem extends StatelessWidget {
const _SettingsRailItem({required this.selected, required this.onTap});
final bool selected;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
final item = destinationDetails(AppDestination.settings);
final foreground = selected
? scheme.onSecondaryContainer
: scheme.onSurfaceVariant;
final textStyle = Theme.of(context).textTheme.labelMedium?.copyWith(
color: foreground,
fontWeight: selected ? FontWeight.w600 : FontWeight.w500,
);
return Semantics(
button: true,
selected: selected,
label: item.label,
child: ExcludeSemantics(
child: InkWell(
key: const ValueKey('shell.destination.settings'),
onTap: onTap,
child: SizedBox(
width: kNavigationRailWidth,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 56,
height: 32,
alignment: Alignment.center,
decoration: ShapeDecoration(
shape: const StadiumBorder(),
color: selected ? scheme.secondaryContainer : null,
),
child: Icon(item.icon, color: foreground),
),
const SizedBox(height: 4),
Text(item.label, style: textStyle),
],
),
),
),
),
),
);
}
}
+35
View File
@@ -0,0 +1,35 @@
import 'package:flutter/widgets.dart';
/// Marks the content beside the destination rail. A wide window's content
/// lays out in the width left beside the rail, so list and detail panes read
/// that width ([windowWidth]) instead of the window's. Outside the scope (a
/// phone, a route pushed over the shell) the window's own width applies.
class ShellRailScope extends InheritedWidget {
const ShellRailScope({
super.key,
required this.shown,
required this.bodyWidth,
required super.child,
});
/// Whether the rail is shown beside this content.
final bool shown;
/// The width beside the rail; null when no rail is shown.
final double? bodyWidth;
/// Whether the rail is shown beside [context]'s content.
static bool isShown(BuildContext context) =>
context.dependOnInheritedWidgetOfExactType<ShellRailScope>()?.shown ??
false;
/// The width the panes of [context] lay out in: the body beside the rail,
/// or else the window.
static double windowWidth(BuildContext context) =>
context.dependOnInheritedWidgetOfExactType<ShellRailScope>()?.bodyWidth ??
MediaQuery.sizeOf(context).width;
@override
bool updateShouldNotify(ShellRailScope oldWidget) =>
shown != oldWidget.shown || bodyWidth != oldWidget.bodyWidth;
}
@@ -0,0 +1,28 @@
import 'package:flutter/services.dart';
import 'destination.dart';
/// The chord that bounces between Runs and Pipelines, as the help page reads
/// it. It is the same on every platform.
const shellRunsPipelinesShortcutLabel = 'Ctrl+A';
/// Whether [event] is Ctrl+A. Only Ctrl counts: Alt, Shift, Cmd and chords
/// with both Ctrl and Alt are not the shortcut. Repeats of a held chord match
/// as well, so the caller can swallow them; only its first press acts.
bool shellRunsPipelinesShortcut(KeyEvent event, HardwareKeyboard keyboard) {
if (event is KeyUpEvent ||
keyboard.isAltPressed ||
keyboard.isShiftPressed ||
keyboard.isMetaPressed ||
!keyboard.isControlPressed) {
return false;
}
return event.logicalKey == LogicalKeyboardKey.keyA;
}
/// The destination Ctrl+A goes to from [current]: Pipelines from Runs, and
/// Runs from every other destination (Pipelines included).
AppDestination shellRunsPipelinesTarget(AppDestination current) =>
current == AppDestination.runs
? AppDestination.pipelines
: AppDestination.runs;
+1 -1
View File
@@ -37,7 +37,7 @@ class WindowEntry {
/// The saved frame; it is drawn fitted inside the window area.
final Rect frame;
/// Hidden by its minimise button; still listed and shown again with its
/// Hidden by the title bar's X; still listed and shown again with its
/// group.
final bool minimized;
final bool maximized;
+7 -11
View File
@@ -11,8 +11,9 @@ double windowTitleBarHeight(BuildContext context) =>
MediaQuery.textScalerOf(context).scale(40).clamp(40.0, 64.0);
/// A floating window's card and title bar: the title (drag to move, double
/// click to maximise), the kind's actions, then Minimise, Maximise and
/// Close. The content is drawn over the card's body by the window's
/// click to maximise), the kind's actions, then Maximise and the X. The X
/// minimises: it hides the window and keeps its state, like the chord does
/// in reverse. The content is drawn over the card's body by the window's
/// navigator.
class WindowFrame extends StatelessWidget {
const WindowFrame({
@@ -25,7 +26,6 @@ class WindowFrame extends StatelessWidget {
required this.onMoveEnd,
required this.onMinimize,
required this.onToggleMaximized,
required this.onClose,
});
final String title;
@@ -36,9 +36,10 @@ class WindowFrame extends StatelessWidget {
/// The drag's delta and the pointer's global position.
final void Function(Offset delta, Offset globalPosition) onMove;
final VoidCallback onMoveEnd;
/// The X: hides the window, keeping it listed and its state.
final VoidCallback onMinimize;
final VoidCallback onToggleMaximized;
final VoidCallback onClose;
@override
Widget build(BuildContext context) {
@@ -69,11 +70,6 @@ class WindowFrame extends StatelessWidget {
onPressed: action.onPressed,
icon: Icon(action.icon),
),
IconButton(
tooltip: 'Minimise',
onPressed: onMinimize,
icon: const Icon(Icons.minimize),
),
IconButton(
tooltip: maximized ? 'Restore size' : 'Maximise',
onPressed: onToggleMaximized,
@@ -82,8 +78,8 @@ class WindowFrame extends StatelessWidget {
),
),
IconButton(
tooltip: 'Close',
onPressed: onClose,
tooltip: 'Minimise',
onPressed: onMinimize,
icon: const Icon(Icons.close),
),
const SizedBox(width: 4),
+41 -19
View File
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../navigation_rail.dart';
import 'window_focus.dart';
import 'window_layer.dart';
import 'window_manager.dart';
@@ -18,7 +19,16 @@ import 'window_shortcuts.dart';
///
/// The host fills its parent and takes no input between windows.
class WindowHost extends StatefulWidget {
const WindowHost({super.key, required this.manager});
const WindowHost({
super.key,
required this.manager,
this.reservesRail = false,
});
/// Whether the shell beside this host shows the destination rail on the
/// window's left edge; the windows then keep to the right of it while the
/// window is wide enough for the rail (see [showsNavigationRail]).
final bool reservesRail;
final WindowManager manager;
@@ -119,24 +129,36 @@ class _WindowHostState extends State<WindowHost> {
]),
builder: (context, _) => LayoutBuilder(
builder: (context, constraints) {
final bounds = constraints.biggest;
return Stack(
fit: StackFit.expand,
children: [
for (final entry in windows)
if (manager.kinds[entry.kind] case final kind?)
WindowLayer(
key: ValueKey(entry.id),
manager: manager,
kind: kind,
entry: entry,
visible:
manager.isVisible(entry) &&
bounds.width >= kind.minHostWidth,
bounds: bounds,
focus: _focus,
),
],
// Beside the destination rail the windows keep to the page's
// right, so they never sit under the rail.
// The shell takes the rail and its divider (kNavigationRailSpace).
final leading = widget.reservesRail && showsNavigationRail(context)
? kNavigationRailSpace
: 0.0;
final bounds = Size(
constraints.maxWidth - leading,
constraints.maxHeight,
);
return Padding(
padding: EdgeInsetsDirectional.only(start: leading),
child: Stack(
fit: StackFit.expand,
children: [
for (final entry in windows)
if (manager.kinds[entry.kind] case final kind?)
WindowLayer(
key: ValueKey(entry.id),
manager: manager,
kind: kind,
entry: entry,
visible:
manager.isVisible(entry) &&
bounds.width >= kind.minHostWidth,
bounds: bounds,
focus: _focus,
),
],
),
);
},
),
+3 -3
View File
@@ -2,7 +2,7 @@ import 'package:flutter/widgets.dart';
import 'window_entry.dart';
/// One action in a window's title bar, before Minimise and Close (Dock on a
/// One action in a window's title bar, before Maximise and the X (Dock on a
/// chat, a kind's own menu).
class WindowAction {
const WindowAction({
@@ -42,7 +42,7 @@ abstract class WindowKind {
/// The window's content, below the title bar.
Widget build(BuildContext context, WindowEntry entry);
/// Title-bar actions before Minimise and Close.
/// Title-bar actions before Maximise and the X.
List<WindowAction> actions(BuildContext context, WindowEntry entry) =>
const [];
@@ -57,7 +57,7 @@ abstract class WindowKind {
/// as its window takes focus. The default leaves it on the window.
void focusContent(WindowEntry entry) {}
/// Called after the user closes the window (the X).
/// Called after the window is closed (Dock, Close all, a chat's /close).
void closed(WindowEntry entry) {}
/// Validates a saved window's [WindowEntry.data]; null drops the window.
-1
View File
@@ -259,7 +259,6 @@ class _WindowLayerState extends State<WindowLayer>
onMinimize: () => manager.setMinimized(_id, true),
onToggleMaximized: () =>
manager.setMaximized(_id, !entry.maximized),
onClose: () => manager.close(_id),
),
),
),