Merge commit '2eeca633096f2fc59a2397b6208e3cb518828de5' into pipelines/run-20261112-1043-dim-inactive-chat-panes-a498

This commit is contained in:
2026-11-12 10:59:05 +00:00
22 changed files with 844 additions and 254 deletions
+13 -3
View File
@@ -41,7 +41,6 @@ import '../shell/windows/window_host.dart';
import '../shell/windows/window_kind.dart';
import '../shell/windows/window_manager.dart';
import '../shell/windows/window_store.dart';
import '../shell/windows/windows_menu_button.dart';
import 'app_terminals.dart';
import '../features/chat/chat_runtime.dart';
import '../features/chat/windows/chat_windows.dart';
@@ -706,6 +705,16 @@ class _PipelinesAppState extends State<PipelinesApp>
}
void _selectDestination(AppDestination destination) {
// Settings is shown from its own nav item and has no Back, so its route
// (filed under the Pipelines tab) must not trap the Pipelines item: that
// item leaves Settings for the Pipelines body it showed before.
if (destination == AppDestination.pipelines &&
_delegate.shellRoute.kind == AppRouteKind.settings) {
_delegate.goTo(
_bodyRoutes[AppDestination.pipelines] ?? AppRoute.pipelines,
);
return;
}
final last = _tabRoutes[destination];
_delegate.goTo(last ?? _routeOf(destination));
}
@@ -845,9 +854,10 @@ class _PipelinesAppState extends State<PipelinesApp>
// The terminal button sits on the Chat tab's shell bar on wide layouts;
// a narrow layout has it in the chat's own bar instead. The keyboard
// shortcut still toggles the terminal everywhere.
// The Windows button (shown on every tab while the app has floating
// windows) is the shell's: it lists the manager's windows.
windowManager: _windows,
barActions: [
// Shown on every tab while the app has floating windows.
WindowsMenuButton(manager: _windows),
if (_destinationOf(route.kind) == AppDestination.chat)
?_terminals.barToggle(context),
],
@@ -147,13 +147,11 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
visualDensity: VisualDensity.compact,
),
onPressed: _open,
// The layers turn only while a task runs; automations stay still.
// A ring around the running count while tasks run; automations stay
// on their static schedule icon.
icon: automationOnly
? const Icon(Icons.schedule, size: 16)
: ChatTaskSpinner(
spinning: count > 0,
child: const Icon(Icons.layers_outlined, size: 16),
),
: ChatTaskSpinner(running: count),
label: caption(),
);
return Padding(
@@ -170,7 +168,7 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
: 'Background work, $label; task list unavailable')
: 'Background work, $label',
child: Tooltip(
message: label,
message: count > 0 ? 'Background tasks ($count running)' : label,
excludeFromSemantics: true,
child: button,
),
@@ -1,71 +1,50 @@
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
/// Turns [child] once every [period] while [spinning]; static otherwise. With
/// reduced motion it never turns. Hidden UI is silenced by TickerMode.
class ChatTaskSpinner extends StatefulWidget {
const ChatTaskSpinner({
super.key,
required this.spinning,
required this.child,
});
/// Background-task glyph for the composer. While [running] is above zero it
/// shows a thin Material progress ring around the count; with reduced motion
/// the ring holds one static quarter segment instead of spinning. With no
/// running task it is the plain layers icon, with no ring. Always [size] square
/// so the button keeps the same dimensions in every state.
class ChatTaskSpinner extends StatelessWidget {
const ChatTaskSpinner({super.key, required this.running, this.size = 16});
final bool spinning;
final Widget child;
final int running;
final double size;
/// One full turn while tasks run.
static const Duration period = Duration(milliseconds: 2500);
/// Fraction of the ring drawn while reduced motion holds it still.
static const double reducedSegment = 0.25;
@override
State<ChatTaskSpinner> createState() => _ChatTaskSpinnerState();
}
class _ChatTaskSpinnerState extends State<ChatTaskSpinner>
with SingleTickerProviderStateMixin {
late final AnimationController _turns = AnimationController(
vsync: this,
duration: ChatTaskSpinner.period,
);
bool _reduced = false;
@override
void initState() {
super.initState();
_sync();
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
_reduced = MediaQuery.maybeDisableAnimationsOf(context) ?? false;
_sync();
}
@override
void didUpdateWidget(covariant ChatTaskSpinner oldWidget) {
super.didUpdateWidget(oldWidget);
_sync();
}
void _sync() {
if (widget.spinning && !_reduced) {
if (!_turns.isAnimating) _turns.repeat();
} else {
_turns
..stop()
..value = 0;
}
}
@override
void dispose() {
_turns.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => RotationTransition(
key: const Key('chat-background-tasks-spinner'),
turns: _turns,
child: widget.child,
);
Widget build(BuildContext context) {
final theme = Theme.of(context);
final reduced = MediaQuery.maybeDisableAnimationsOf(context) ?? false;
final content = running > 0
? Stack(
alignment: Alignment.center,
children: [
SizedBox.square(
dimension: size,
child: CircularProgressIndicator(
strokeWidth: 2,
color: theme.colorScheme.primary,
value: reduced ? reducedSegment : null,
),
),
FittedBox(
fit: BoxFit.scaleDown,
child: Text(
'$running',
key: const Key('chat-background-tasks-count'),
style: theme.textTheme.labelSmall,
),
),
],
)
: Icon(Icons.layers_outlined, size: size);
return SizedBox.square(
key: const Key('chat-background-tasks-spinner'),
dimension: size,
child: content,
);
}
}
+4 -3
View File
@@ -2,7 +2,7 @@ import '../../ui/adaptive/segmented_bar.dart';
import '../../shell/destination.dart';
import '../../shell/detail_page.dart';
import '../../shell/list_detail.dart';
import '../../shell/shell_rail_scope.dart';
import '../../shell/navigation_rail.dart';
import 'package:flutter/material.dart';
import '../../core/api_gateway.dart';
@@ -289,9 +289,10 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
if (listShown && widget.onOpenSchedules != null)
_schedulesButton(context),
_refreshButton(context),
// A wide window's rail offers Settings; the gear stays on a phone.
// The phone's bar and the rail both offer Settings; the gear is only
// left where the floating tab bar (tabs only) is the shell's nav.
if (listShown &&
!ShellRailScope.isShown(context) &&
showsFloatingTabBarOnly(context) &&
widget.onOpenSettings != null)
_settingsButton(context),
],
+48 -2
View File
@@ -17,6 +17,8 @@ import 'shell_list_shortcuts.dart';
import 'shell_runs_pipelines_shortcut.dart';
import 'shell_search_shortcut_labels.dart';
import 'tab_history.dart';
import 'windows/window_manager.dart';
import 'windows/windows_menu_button.dart';
import '../ui/input/keyboard_owner.dart';
class AdaptiveShell extends StatefulWidget {
@@ -33,12 +35,18 @@ class AdaptiveShell extends StatefulWidget {
this.runningRunCount,
this.listPaneWidthStore = const SharedPreferencesListPaneWidthStore(),
this.barActions = const [],
this.windowManager,
});
/// Actions every destination's bar ends with (the Terminal toggle), after
/// the screen's own or Search.
final List<Widget> barActions;
/// The floating windows the bar's Windows button lists. The button is shown
/// only while one is open, so the bar draws no empty action island; null
/// (plain shells) shows none.
final WindowManager? windowManager;
/// Where each destination's dragged list-pane width is kept on this device.
final ListPaneWidthStore listPaneWidthStore;
@@ -77,6 +85,11 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
late AppDestination _selected;
final Set<AppDestination> _visited = {};
final TabHistory _history = TabHistory();
// The destination a shell control (rail, bar, floating bar) asked for and
// that is not shown yet. Settings reached this way is a destination; any
// other way in (a route, a deep link, the Pipelines gear) is a page to Back.
AppDestination? _navigatingTo;
bool _settingsPushed = false;
// Whether a navigator inside each destination (an open item's pane) has a
// page of its own for the system Back to close first.
final Map<AppDestination, bool> _nestedCanPop = {};
@@ -100,6 +113,9 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
super.initState();
_bar.onNavigate = _select;
_selected = widget.destination ?? AppDestination.pipelines;
// A first load that opens Settings (a deep link, a restored page) was not
// reached from a shell control, so its Back closes the page.
_settingsPushed = _selected == AppDestination.settings;
_visited.add(_selected);
HardwareKeyboard.instance.addHandler(_handleDestinationKeyEvent);
}
@@ -109,12 +125,23 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
super.didUpdateWidget(oldWidget);
final destination = widget.destination;
if (destination != null) {
if (destination != _selected) _noteShown(destination);
_history.record(_selected, destination);
_selected = destination;
_visited.add(destination);
}
}
/// Records that [destination] is becoming the shown one. Settings opened by
/// a shell control is a destination (no Back); opened any other way it is a
/// page that Back closes.
void _noteShown(AppDestination destination) {
if (destination == AppDestination.settings) {
_settingsPushed = _navigatingTo != AppDestination.settings;
}
_navigatingTo = null;
}
/// The entry every tab control calls when tapped: a destination shown
/// already is re-selected (see [AdaptiveShell.onDestinationReselected]), any
/// other is selected.
@@ -124,6 +151,13 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
reselected(destination);
return;
}
if (destination != _selected) {
_navigatingTo = destination;
// A selection the route never applies must not mark a later route.
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted && _navigatingTo == destination) _navigatingTo = null;
});
}
_select(destination);
}
@@ -134,6 +168,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
return;
}
setState(() {
if (destination != _selected) _noteShown(destination);
_history.record(_selected, destination);
_selected = destination;
_visited.add(destination);
@@ -241,7 +276,11 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
SegmentedBar currentBar() =>
_segmentedBar(_bar.specFor(_selected), details.label, page: page);
final topBar = _ListPaneBar(
listenable: Listenable.merge([_bar.bar, _paneWidths]),
listenable: Listenable.merge([
_bar.bar,
_paneWidths,
?widget.windowManager,
]),
initial: currentBar(),
split: () => _bar.split(_selected),
preferredWidth: () => _paneWidths.widthFor(_selected.name),
@@ -440,9 +479,12 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
String label, {
required bool page,
}) {
final onBack = spec?.onBack ?? (page ? _closePage : null);
// Settings reached from a shell control has no Back: it is a destination.
final onBack =
spec?.onBack ?? (page && _settingsPushed ? _closePage : null);
final published = spec?.actions ?? const <Widget>[];
final onSearch = widget.onSearch;
final windows = widget.windowManager;
return SegmentedBar(
automaticallyImplyLeading: false,
leading: onBack == null
@@ -477,6 +519,10 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
tooltip: 'Search (${shellSearchShortcutLabels().join(', ')})',
icon: const Icon(Icons.search),
),
// The Windows button leads the shell's own actions, only while a
// floating window is listed; an empty button would draw an empty island.
if (windows != null && WindowsMenuButton.hasWindows(windows))
WindowsMenuButton(manager: windows),
...widget.barActions,
],
);
+4 -3
View File
@@ -2,10 +2,11 @@ import 'package:flutter/material.dart';
enum AppDestination { pipelines, runs, chat, search, settings }
/// The destinations the shell's tab bar (or, on a wide window, its rail) offers,
/// The tabs the shell's floating 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.
/// `/settings`) and the rail and phone bar offer it too; it is a page of the
/// Pipelines tab, not a tab. Only the floating bar's width leaves Settings to
/// the Pipelines bar's gear.
const List<AppDestination> shellTabDestinations = [
AppDestination.pipelines,
AppDestination.runs,
+42 -27
View File
@@ -22,6 +22,12 @@ const double kNavigationRailMinWindowWidth =
bool showsNavigationRail(BuildContext context) =>
MediaQuery.sizeOf(context).width >= kNavigationRailMinWindowWidth;
/// Whether the window shows the floating tab bar alone: wide enough for a list
/// beside an open item, too narrow for the rail. That bar lists the tabs only,
/// so there Settings is reached from the Pipelines bar's gear.
bool showsFloatingTabBarOnly(BuildContext context) =>
showsListBesideDetail(context) && !showsNavigationRail(context);
/// 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.
@@ -50,35 +56,44 @@ class ShellNavigationRail extends StatelessWidget {
@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),
final surface = Theme.of(context).colorScheme.surface;
// The surface runs under the top inset too: the padding only moves the
// rail's content below the system's top, so no unpainted strip shows above
// the rail's background.
return ColoredBox(
key: const ValueKey('shell.navigation-rail.surface'),
color: surface,
child: Padding(
padding: padding,
child: SizedBox(
width: kNavigationRailWidth,
child: NavigationRail(
key: const ValueKey('shell.navigation-rail'),
backgroundColor: surface,
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),
),
label: Text(destinationDetails(destination).label),
),
],
trailingAtBottom: true,
trailing: _SettingsRailItem(
selected: selected == AppDestination.settings,
onTap: () => onSelected(AppDestination.settings),
],
trailingAtBottom: true,
trailing: _SettingsRailItem(
selected: selected == AppDestination.settings,
onTap: () => onSelected(AppDestination.settings),
),
),
),
),
@@ -12,6 +12,11 @@ class WindowsMenuButton extends StatelessWidget {
final WindowManager manager;
/// Whether [manager] has a window to list: the shell bar keeps the button
/// out of its actions otherwise, so no empty action island is drawn.
static bool hasWindows(WindowManager manager) =>
manager.windows.any((w) => manager.kinds[w.kind] != null);
@override
Widget build(BuildContext context) => ListenableBuilder(
listenable: Listenable.merge([