Refine Settings destination shell integration
Keep Settings navigation independent while preserving shell actions and destination-specific state. Add the reviewed chat, run-entry, layout, and regression-test updates needed by the destination behavior.
This commit is contained in:
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,36 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/servers/server_context.dart';
|
||||
import '../../../ui/adaptive/app_popups.dart';
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
||||
import 'chat_bar_tint.dart';
|
||||
import '../workspace/chat_workspace_pane_scope.dart';
|
||||
|
||||
/// Below this width (in text-scaled logical pixels) the selectors leave the
|
||||
/// bar for its More menu's settings entry, so the title keeps
|
||||
/// [chatHeaderTitleShare].
|
||||
const double chatHeaderNarrowWidth = 600;
|
||||
|
||||
/// The share of a narrow bar the conversation's title always keeps.
|
||||
const double chatHeaderTitleShare = 0.6;
|
||||
|
||||
/// The open conversation's bar: the app's [SegmentedBar] above the
|
||||
/// transcript.
|
||||
///
|
||||
/// 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, a selector island holding [controls] (model and mode),
|
||||
/// then the Files action and a native More menu in a separate island.
|
||||
/// 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.
|
||||
/// information, a selector island holding [controls] (model, mode and
|
||||
/// thinking), then the Files action and a native More menu in a separate
|
||||
/// island.
|
||||
///
|
||||
/// A narrow bar ([chatHeaderNarrowWidth]) keeps the title at
|
||||
/// [chatHeaderTitleShare] of the bar: the [controls] join the More menu as one
|
||||
/// "Chat settings" entry that opens them in a sheet, and the overflowable
|
||||
/// actions join it too. A floating chat passes [showTitle] false, since its window bar names
|
||||
/// the chat.
|
||||
///
|
||||
/// A chat with a [chatColor] carries it in the bar: each glass piece is
|
||||
/// filled with its shade over the raised surface and its labels and icons
|
||||
@@ -26,6 +42,7 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
required this.title,
|
||||
required this.folder,
|
||||
required this.onInfo,
|
||||
this.showTitle = true,
|
||||
this.showBack = false,
|
||||
this.onBack,
|
||||
this.controls = const [],
|
||||
@@ -41,6 +58,10 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
final String folder;
|
||||
final VoidCallback onInfo;
|
||||
|
||||
/// Whether the title pill (and its folder) shows; false in a floating
|
||||
/// window, whose own bar names the chat.
|
||||
final bool showTitle;
|
||||
|
||||
/// Whether the bar shows Back at all.
|
||||
final bool showBack;
|
||||
|
||||
@@ -62,21 +83,36 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final textScale = MediaQuery.textScalerOf(context).scale(14) / 14;
|
||||
final compact = constraints.maxWidth / textScale < 800;
|
||||
final scaledWidth = constraints.maxWidth / textScale;
|
||||
final compact = scaledWidth < 800;
|
||||
final narrow = scaledWidth < chatHeaderNarrowWidth;
|
||||
// A narrow bar moves the selectors, and the overflowable actions, into
|
||||
// its More menu; the others stay in the bar.
|
||||
final menuActions = [
|
||||
if (narrow) ...actions.whereType<SegmentedOverflowable>(),
|
||||
...moreActions.whereType<SegmentedOverflowable>(),
|
||||
];
|
||||
final settingsEntry = narrow && controls.isNotEmpty
|
||||
? SegmentedOverflowEntry(
|
||||
label: 'Chat settings',
|
||||
icon: Icons.tune,
|
||||
onPressed: () => unawaited(_showSettings(context, controls)),
|
||||
)
|
||||
: null;
|
||||
final actionChildren = [
|
||||
...actions,
|
||||
for (final action in actions)
|
||||
if (!narrow || action is! SegmentedOverflowable) action,
|
||||
for (final action in moreActions)
|
||||
if (action is! SegmentedOverflowable) action,
|
||||
if (moreActions.whereType<SegmentedOverflowable>().isNotEmpty)
|
||||
if (settingsEntry != null || menuActions.isNotEmpty)
|
||||
SegmentedMoreButton(
|
||||
entries: [
|
||||
for (final action
|
||||
in moreActions.whereType<SegmentedOverflowable>())
|
||||
action.overflowEntry,
|
||||
?settingsEntry,
|
||||
for (final action in menuActions) action.overflowEntry,
|
||||
],
|
||||
),
|
||||
];
|
||||
final Widget bar = SegmentedBar(
|
||||
final bar = SegmentedBar(
|
||||
pillColor: tint?.fill,
|
||||
foregroundColor: tint?.foreground,
|
||||
automaticallyImplyLeading: false,
|
||||
@@ -88,16 +124,17 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
onPressed: onBack,
|
||||
)
|
||||
: null,
|
||||
title: title.isEmpty ? 'Chat' : title,
|
||||
titleLeading: identity,
|
||||
subtitle: ServerContext.metadata(context, folder),
|
||||
title: !showTitle ? '' : (title.isEmpty ? 'Chat' : title),
|
||||
titleLeading: showTitle ? identity : null,
|
||||
subtitle: showTitle ? ServerContext.metadata(context, folder) : null,
|
||||
subtitleIcon: Icons.folder_outlined,
|
||||
onTitlePressed: onInfo,
|
||||
onTitlePressed: showTitle ? onInfo : null,
|
||||
titleSemanticLabel: 'Chat information',
|
||||
titleKey: const Key('chat-info'),
|
||||
separateActionIslands: true,
|
||||
titleShare: narrow && showTitle ? chatHeaderTitleShare : null,
|
||||
actions: [
|
||||
if (controls.isNotEmpty)
|
||||
if (controls.isNotEmpty && !narrow)
|
||||
ChatWorkspacePaneActionBar(
|
||||
child: _ControlIsland(
|
||||
key: const Key('chat-model-permission-island'),
|
||||
@@ -105,7 +142,7 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
children: controls,
|
||||
),
|
||||
),
|
||||
if (actions.isNotEmpty || moreActions.isNotEmpty)
|
||||
if (actionChildren.isNotEmpty)
|
||||
ChatWorkspacePaneActionBar(
|
||||
child: Row(
|
||||
key: const Key('chat-actions-island'),
|
||||
@@ -136,6 +173,24 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// A narrow bar's selectors (model, mode and thinking), each with its label,
|
||||
/// in a sheet opened from the More menu.
|
||||
Future<void> _showSettings(BuildContext context, List<Widget> controls) =>
|
||||
showAppChoiceMenu<void>(
|
||||
context,
|
||||
semanticLabel: 'Chat settings',
|
||||
builder: (_) => SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: controls,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/// Related selectors share the available width. Each remains a real control;
|
||||
/// they never migrate into the unrelated actions menu.
|
||||
class _ControlIsland extends StatelessWidget {
|
||||
|
||||
@@ -1428,15 +1428,23 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
? ModalRoute.of(context)?.impliesAppBarDismissal ?? false
|
||||
: true);
|
||||
final answeredBy = latestReplyModel(_controller.messages);
|
||||
return _chrome.widgetFor('header', answeredBy, [
|
||||
widget,
|
||||
inShellBar,
|
||||
canGoBack,
|
||||
// The thinking control says when a turn is running.
|
||||
_controller.running,
|
||||
// The More menu offers Dismiss all finished commands only with one.
|
||||
_shellRuns.finishedIds.isNotEmpty,
|
||||
], () => _buildHeader(session, inShellBar, canGoBack, answeredBy));
|
||||
// A floating window's own bar names the chat, so the header omits it.
|
||||
final inWindow = WindowScope.maybeOf(context) != null;
|
||||
return _chrome.widgetFor(
|
||||
'header',
|
||||
answeredBy,
|
||||
[
|
||||
widget,
|
||||
inShellBar,
|
||||
canGoBack,
|
||||
inWindow,
|
||||
// The thinking control says when a turn is running.
|
||||
_controller.running,
|
||||
// The More menu offers Dismiss all finished commands only with one.
|
||||
_shellRuns.finishedIds.isNotEmpty,
|
||||
],
|
||||
() => _buildHeader(session, inShellBar, canGoBack, answeredBy, inWindow),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader(
|
||||
@@ -1444,6 +1452,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
bool inShellBar,
|
||||
bool canGoBack,
|
||||
String answeredBy,
|
||||
bool inWindow,
|
||||
) {
|
||||
final hasModel =
|
||||
session != null && supportsChatModels('${session['backend'] ?? ''}');
|
||||
@@ -1466,6 +1475,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
? null
|
||||
: ChatSessionAvatar(session: session, selected: true),
|
||||
onInfo: _openInfo,
|
||||
showTitle: !inWindow,
|
||||
showBack: canGoBack,
|
||||
// A pushed page keeps the platform's stock Back (pop this route); a
|
||||
// standalone conversation calls its owner.
|
||||
@@ -1518,6 +1528,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
),
|
||||
],
|
||||
controls: [
|
||||
// Labelled, so a narrow bar's settings sheet shows their names.
|
||||
if (hasModel)
|
||||
ChatModelControl(
|
||||
key: ValueKey<String>('chat-model-${widget.sessionId}'),
|
||||
@@ -1526,6 +1537,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
session: session,
|
||||
onChanged: widget.onModelChanged,
|
||||
answeredBy: answeredBy,
|
||||
showLabel: true,
|
||||
),
|
||||
if (hasMode) _modeControl(),
|
||||
// Only a model with levels gets the control (and its pill).
|
||||
@@ -1537,6 +1549,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
session: session,
|
||||
running: _controller.running,
|
||||
onChanged: widget.onEffortChanged,
|
||||
showLabel: true,
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -1551,6 +1564,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
mode: '${widget.session?['mode'] ?? ''}'.trim(),
|
||||
modeName: '${widget.session?['mode_name'] ?? ''}'.trim(),
|
||||
onChanged: widget.onModeChanged,
|
||||
showLabel: true,
|
||||
);
|
||||
|
||||
/// Stops the running turn, as the composer's `/stop` does.
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/motion/motion.dart';
|
||||
|
||||
/// The opacity of the surface scrim over an inactive split pane. The pane's
|
||||
/// transcript and bars keep reading through it at about two thirds emphasis.
|
||||
const double chatPaneDimOpacity = 0.35;
|
||||
|
||||
/// Covers a pane that is not the active one with the theme's surface colour,
|
||||
/// so the active pane reads as the one in focus. The scrim ignores pointers:
|
||||
/// taps reach the pane's content, and its activation listener still runs.
|
||||
/// Reduced motion switches the scrim at once; otherwise it fades briefly.
|
||||
class ChatPaneDim extends StatelessWidget {
|
||||
const ChatPaneDim({super.key, required this.dimmed, required this.child});
|
||||
|
||||
final bool dimmed;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final surface = Theme.of(context).colorScheme.surface;
|
||||
return Stack(
|
||||
fit: StackFit.passthrough,
|
||||
children: [
|
||||
child,
|
||||
Positioned.fill(
|
||||
child: IgnorePointer(
|
||||
child: AnimatedContainer(
|
||||
key: const ValueKey('chat-pane-dim-scrim'),
|
||||
duration: Motion.of(context, Motion.standard),
|
||||
curve: Motion.curve,
|
||||
// The clear end keeps the surface hue, so the fade never greys.
|
||||
color: dimmed
|
||||
? surface.withValues(alpha: chatPaneDimOpacity)
|
||||
: surface.withValues(alpha: 0),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import 'chat_pane_move_motion.dart';
|
||||
import 'chat_pane_move_shortcuts.dart';
|
||||
import 'chat_pane_switch_motion.dart';
|
||||
import 'chat_pane_backdrop.dart';
|
||||
import 'chat_pane_dim.dart';
|
||||
import 'chat_workspace_pane_scope.dart';
|
||||
import 'chat_workspace_surface.dart';
|
||||
import '../../../ui/input/keyboard_owner.dart';
|
||||
@@ -509,8 +510,11 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
|
||||
onPreferredWidthChanged: (width) =>
|
||||
_reportPaneExtraWidth(pane.id, width),
|
||||
child: Builder(
|
||||
builder: (paneContext) =>
|
||||
widget.paneBuilder(paneContext, pane, active),
|
||||
builder: (paneContext) => ChatPaneDim(
|
||||
// A single pane is always the active one, so it never dims.
|
||||
dimmed: widget.controller.paneCount > 1 && !active,
|
||||
child: widget.paneBuilder(paneContext, pane, active),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user