Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Merge origin/main into feat/grid-scale-phase-a

Kelvinaa98f476fcb1
diff --cc desktop/lib/core/models.dart
index c73ecaa80,e259548a3..be530f20d
--- a/desktop/lib/core/models.dart
+++ b/desktop/lib/core/models.dart
@@@ -387,10 -385,9 +393,11 @@@ class Agent
this.engineDisplayName,
this.engineIconHint,
this.codexHome,
+ this.modelName,
this.gridModel,
this.gridWebSearch,
+ this.gridState,
+ this.gridNote,
this.parentAgentId,
this.project,
this.lastActivityAt,
@@@ -513,10 -510,13 +520,15 @@@
engineDisplayName: _safeLabel(j['engineDisplayName']),
engineIconHint: _safeLabel(j['engineIconHint']),
codexHome: j['engine'] == 'codex' ? _safeCodexHome(j['codexHome']) : null,
+ modelName: runtimeModelName(
+ j['selectedModel'],
+ agentId: j['id'] as String,
+ engine: _safeEngine(j['engine']),
+ ),
gridModel: _safeLabel(grid?['model']),
gridWebSearch: GridWebSearch.fromWire(grid?['webSearch']),
+ gridState: GridSectionState.parse(grid?['state']),
+ gridNote: GridNote.fromWire(grid?['note']),
parentAgentId: _safeLabel(j['parentAgentId'] ?? j['parentId']),
project: AgentProject.fromJson(j['project']),
lastActivityAt: j['updatedAt'] is String
@@@ -566,10 -566,9 +578,11 @@@
engineDisplayName: engineDisplayName,
engineIconHint: engineIconHint,
codexHome: codexHome,
+ modelName: modelName,
gridModel: gridModel,
gridWebSearch: gridWebSearch,
+ gridState: gridState,
+ gridNote: gridNote,
parentAgentId: parentAgentId,
project: project,
lastActivityAt: lastActivityAt,
diff --cc desktop/lib/widgets/grid_model_picker.dart
index fc5e81b8e,9adef7862..5e0d4842b
--- a/desktop/lib/widgets/grid_model_picker.dart
+++ b/desktop/lib/widgets/grid_model_picker.dart
@@@ -10,11 -17,9 +17,12 @@@ import '../shared/theme/app_type.dart'
import '../theme/app_theme.dart';
import '../usage/models_menu_controller.dart';
import 'engine_identity.dart';
+import 'model_picker_answer.dart';
import 'model_picker_chrome.dart';
import 'pane_menu.dart';
+import 'resting_model_words.dart';
+import 'resting_section.dart';
+ import 'workspace_bar_control.dart';
/// The engines whose panes carry a model picker.
///
diff --cc desktop/lib/widgets/pane_model_status.dart
index db658a268,000000000..a4dbd4801
mode 100644,000000..100644
--- a/desktop/lib/widgets/pane_model_status.dart
+++ b/desktop/lib/widgets/pane_model_status.dart
@@@ -1,175 -1,0 +1,170 @@@
+/// What a pane says about the model its agent is on, when that model is resting or not answering
+/// (grid-reads-without-waking, issue 03): the header chip between a message and its first answer,
+/// and the note under the header while the daemon notes the agent's model will not answer.
+///
+/// Presentation only. When the chip shows is [ModelStartWatch]'s to say; what the note says is the
+/// daemon's (`grid.note`), in the words of `resting_model_words.dart`.
+library;
+
+import 'package:flutter/material.dart';
+
+import '../core/models.dart';
+import '../shared/theme/app_theme.dart' as grid;
+import '../state/model_start_watch.dart';
+import '../theme/app_theme.dart';
+import 'resting_model_words.dart';
+
+/// The chip's mark, the gap after it, and its padding — one set of numbers for the chip and for
+/// the room [paneStartingChipWidth] asks the header to leave it.
+const double _kChipMark = 14;
+const double _kChipGap = 6;
+const EdgeInsets _kChipPadding = EdgeInsets.symmetric(horizontal: 6, vertical: 4);
+
+/// The note strip's one line: tall enough for its "Pick another" button, and the same height with
+/// or without one, so a note that loses its action does not resize the terminal again.
+const double _kNoteHeight = 30;
+
- /// Opens a pane's model picker from somewhere other than its control — the model note's
- /// "Pick another". Owned by the pane; handed to the picker as its `openRequests`.
- class ModelPickerOpener extends ChangeNotifier {
- void open() => notifyListeners();
- }
+
+/// The chip's words for [phase].
+String startingChipLabel(ModelStartPhase phase) => switch (phase) {
+ ModelStartPhase.starting => kStartingUp,
+ ModelStartPhase.stillStarting => kStillStarting,
+};
+
+TextStyle _chipStyle() => grid.AppType.monoLabel(
+ fontWeight: FontWeight.w400,
+ color: AppColors.textSoft,
+);
+
+/// The pane header's "Starting up…" chip. Not a button: there is nothing to do but wait, and the
+/// tooltip says why the wait happens at all. [narrow] draws only the mark, the way a narrow header
+/// draws its status chip, with the words on hover.
+class PaneStartingChip extends StatelessWidget {
+ const PaneStartingChip({super.key, required this.phase, this.narrow = false});
+
+ final ModelStartPhase phase;
+ final bool narrow;
+
+ @override
+ Widget build(BuildContext context) {
+ final label = startingChipLabel(phase);
+ final mark = Icon(
+ Icons.hourglass_top,
+ size: _kChipMark,
+ color: AppColors.textSoft,
+ );
+ return Semantics(
+ liveRegion: true,
+ label: label,
+ child: Tooltip(
+ message: narrow ? '$label\n$kRestingTooltip' : kRestingTooltip,
+ child: Padding(
+ padding: _kChipPadding,
+ child: narrow
+ ? mark
+ : Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ mark,
+ const SizedBox(width: _kChipGap),
+ Flexible(
+ child: Text(
+ label,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: _chipStyle(),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+/// The room [PaneStartingChip] asks for in a header, so the header can leave it that much beside
+/// the agent's name.
+double paneStartingChipWidth(ModelStartPhase phase, TextScaler scaler) {
+ final painter = TextPainter(
+ text: TextSpan(text: startingChipLabel(phase), style: _chipStyle()),
+ textDirection: TextDirection.ltr,
+ textScaler: scaler,
+ maxLines: 1,
+ )..layout();
+ final width = painter.width;
+ painter.dispose();
+ return _kChipMark + _kChipGap + width + _kChipPadding.horizontal;
+}
+
+/// The strip under a pane's header while its agent's model will not answer — one line, in flow, so
+/// it covers none of the terminal. [onPickAnother] opens the pane's model picker; it is offered
+/// only for a model that is not being served (an offline computer comes back by itself) and only
+/// where the pane has a picker to open.
+class PaneModelNote extends StatelessWidget {
+ const PaneModelNote({super.key, required this.note, this.onPickAnother});
+
+ final GridNote note;
+ final VoidCallback? onPickAnother;
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ final pick = switch (note) {
+ GridNoteNotServed() => onPickAnother,
+ GridNoteOffline() => null,
+ };
+ final sentence = noteSentence(note);
+ return Semantics(
+ container: true,
+ liveRegion: true,
+ child: Container(
+ height: _kNoteHeight,
+ padding: const EdgeInsets.only(left: 14, right: 8),
+ decoration: BoxDecoration(
+ color: Color.alphaBlend(
+ AppColors.warning.withValues(alpha: 0.10),
+ grid.AppPalette.panelBg,
+ ),
+ border: Border(bottom: BorderSide(color: AppColors.border)),
+ ),
+ child: Row(
+ children: [
+ Icon(
+ switch (note) {
+ GridNoteOffline() => Icons.cloud_off,
+ GridNoteNotServed() => Icons.info_outline,
+ },
+ size: _kChipMark,
+ color: AppColors.warning,
+ ),
+ const SizedBox(width: 8),
+ Flexible(
+ child: Tooltip(
+ message: pick == null ? sentence : '$sentence — $kPickAnother',
+ child: Text(
+ pick == null ? sentence : '$sentence —',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: grid.AppType.body(color: AppColors.textSoft),
+ ),
+ ),
+ ),
+ if (pick != null)
+ TextButton(
+ onPressed: pick,
+ style: TextButton.styleFrom(
+ minimumSize: Size.zero,
+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,
+ padding: _kChipPadding,
+ foregroundColor: AppColors.accent,
+ textStyle: grid.AppType.monoLabel(),
+ ),
+ child: const Text(kPickAnother),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --cc desktop/lib/widgets/terminal_panel.dart
index e977bbceb,97943ca65..cee1f0af2
--- a/desktop/lib/widgets/terminal_panel.dart
+++ b/desktop/lib/widgets/terminal_panel.dart
@@@ -240,16 -227,6 +235,16 @@@ class _TerminalPanelState extends State
Object? _headerPresentation;
Widget? _header;
+ /// Opens this pane's model picker from outside its header — the model note's "Pick another".
- final ModelPickerOpener _pickerOpener = ModelPickerOpener();
++ final GridModelPickerController _pickerController = GridModelPickerController();
+
+ /// What this pane's "Starting up…" chip said at the last build, so a change for another agent's
+ /// pane does not rebuild this one. See [ModelStartWatch].
+ ModelStartPhase? _startPhase;
+
+ /// Whether the model note holds a line under the header — see [_syncNoteLine].
+ bool _noted = false;
+
/// Set while the in-pane control banner is answering a keystroke that went
/// nowhere (see [_nudgeControlBanner]); cleared by [_controlNudgeTimer].
bool _controlNudged = false;
@@@ -445,8 -399,6 +440,8 @@@
widget.session.detachViewport(this);
terminalFontStore.removeListener(_onFontChanged);
terminalThemeStore.removeListener(_onFontChanged);
+ widget.notifier.modelStarts.removeListener(_onModelStartsChanged);
- _pickerOpener.dispose();
++ _pickerController.dispose();
_cancelDialInertia();
_cursorBlinkTimer?.cancel();
_controlNudgeTimer?.cancel();
@@@ -1814,42 -1765,6 +1809,42 @@@
);
}
+ /// This agent's model note (`grid.note`), or null when nothing is wrong. Read from the app's
+ /// agents, which the pane grid rebuilds this panel on.
+ GridNote? _gridNote() => widget.notifier
+ .stateOf(widget.session.machineId)
+ ?.agents
+ .where((agent) => agent.id == widget.session.agentId)
+ .firstOrNull
+ ?.gridNote;
+
+ /// The note taking or giving back its line resizes the terminal, so the pane re-measures then,
+ /// as it does when the composer comes or goes.
+ void _syncNoteLine() {
+ final noted = _gridNote() != null;
+ if (noted == _noted) return;
+ _noted = noted;
+ _afterTerminalMounted(claimFocus: false, scrollToEnd: false);
+ }
+
+ /// The note under the header while the daemon says this agent's model will not answer, or null.
+ ///
+ /// In flow rather than over the output, like the composer: a note can stand for hours, and a
+ /// band that long over the top rows would hide what the agent last said. "Pick another" is
+ /// offered only where the header has a picker to open.
+ Widget? _modelNote() {
+ final note = _gridNote();
+ if (note == null) return null;
+ final hasPicker =
+ widget.showHeader &&
+ !widget.readOnly &&
+ modelPickerSupports(widget.session.engineId);
+ return PaneModelNote(
+ note: note,
- onPickAnother: hasPicker ? _pickerOpener.open : null,
++ onPickAnother: hasPicker ? _pickerController.open : null,
+ );
+ }
+
/// Visibility and focus affect the renderer, not its title and controls.
/// Retain that subtree until its presentation changes. Callback wrappers
/// resolve the current widget so cached controls never retain an old action.
@@@ -1914,13 -1822,7 +1903,9 @@@
? null
: () => widget.onDelete?.call(),
onReconnect: () => unawaited(_takeControl()),
- composerVisible: widget.composerVisible,
- onToggleComposer: widget.onToggleComposer == null
- ? null
- : () => widget.onToggleComposer?.call(),
paneDrag: widget.paneDrag,
+ starting: _startPhase,
- pickerOpener: _pickerOpener,
++ pickerController: _pickerController,
);
}
return _header!;
@@@ -1959,14 -1857,6 +1940,14 @@@ class _TerminalHeader extends Stateless
/// share one drag. The window is moved from HarnessTopBar now.
final PaneDragHandle? paneDrag;
+ /// What the "Starting up…" chip says, or null when this pane is not waiting on a resting model.
+ /// Drawn where the status chip goes, and only when there is no status: "Connecting" or
+ /// "Reconnect" is the more urgent thing to know.
+ final ModelStartPhase? starting;
+
- /// Opens this pane's model picker from the model note — see [GridModelPicker.openRequests].
- final Listenable? pickerOpener;
++ /// Opens this pane's model picker from the model note — see [GridModelPicker.controller].
++ final GridModelPickerController? pickerController;
+
const _TerminalHeader({
required this.notifier,
required this.session,
@@@ -1981,10 -1869,6 +1960,8 @@@
this.onToggleZoom,
this.zoomed = false,
this.paneDrag,
- this.onToggleComposer,
- this.composerVisible = false,
+ this.starting,
- this.pickerOpener,
++ this.pickerController,
});
@override
@@@ -2082,224 -1968,197 +2062,228 @@@
// A fork says so first: "forked from X" is the one fact about this pane
// that the folder and the branch — shared with its source — cannot tell.
final forkedFrom = agent?.forkedFrom;
- final strip = PaneHeaderHover(
- child: SizedBox(
- height: compact ? 38 : 46,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: _stripPadding),
- child: LayoutBuilder(
- builder: (context, constraints) {
- final scale = grid.appTextScaleOf(context);
- final narrow = constraints.maxWidth < 560 * math.max(1, scale);
- // Keep PR state visible before spending space on branch prose.
- // A compact badge also fits beside the compact action menu.
- final showPr =
- agent != null &&
- project?.shownBranch != null &&
- constraints.maxWidth >= 360 * math.max(1, scale);
- final badgeWidth = showPr ? (narrow ? 150.0 : 180.0) : 0.0;
- // The room the left side needs: the mark, the whole name as it will be drawn, and
- // the status beside it — capped at 45% so a very long name still leaves the right
- // side most of the header.
- double titleRoom() {
- final name = TextPainter(
- text: TextSpan(
- text: session.agentName,
- style: grid.AppType.monoLabel(fontWeight: FontWeight.w600),
- ),
- textDirection: TextDirection.ltr,
- textScaler: MediaQuery.textScalerOf(context),
- maxLines: 1,
- )..layout();
- final width = name.width;
- name.dispose();
- final statusRoom = status != null
- ? 120.0
- : starting != null
- ? paneStartingChipWidth(
- starting,
- MediaQuery.textScalerOf(context),
- )
- : 16.0;
- return math.min(
- 17 + 10 + width + 8 + statusRoom + 8,
- constraints.maxWidth * .45,
- );
- }
-
- final rightWidth = narrow
- ? math.max(
- (showModelPicker ? 100.0 : 28.0) + badgeWidth,
- constraints.maxWidth * .36,
+ final header = SizedBox(
+ height: compact ? 38 : 46,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: _stripPadding),
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ final scale = grid.appTextScaleOf(context);
+ final narrow = constraints.maxWidth < 560 * math.max(1, scale);
+ // Workspace panes show PR state once in the main status bar.
+ // Standalone terminals retain their own PR badge.
+ final showPr =
+ !compact &&
+ agent != null &&
+ project?.shownBranch != null &&
+ constraints.maxWidth >= 360 * math.max(1, scale);
+ final badgeWidth = showPr ? (narrow ? 150.0 : 180.0) : 0.0;
+ // The room the left side needs: the mark, the whole name as it will be drawn, and
+ // the status beside it — capped at 45% so a very long name still leaves the right
+ // side most of the header.
+ double titleRoom() {
+ final name = TextPainter(
+ text: TextSpan(text: session.agentName, style: titleStyle),
+ textDirection: TextDirection.ltr,
+ textScaler: MediaQuery.textScalerOf(context),
+ maxLines: 1,
+ )..layout();
+ final width = name.width;
+ name.dispose();
++ final statusRoom = status != null
++ ? 120.0
++ : starting != null
++ ? paneStartingChipWidth(
++ starting,
++ MediaQuery.textScalerOf(context),
+ )
- : math.max(
- actionsWidth + badgeWidth,
- // Everything the name does not use. A fixed 55% left the folder and branch
- // shortened to "…" beside a short name with half the header empty.
- constraints.maxWidth - titleRoom(),
- );
- return Row(
- children: [
- if (agent != null)
- EngineMark.forAgent(agent, size: 17)
- else
- EngineMark(engine: session.engineId, size: 17),
- // Icon and name, the same as every other pane (owner,
- // 2026-09-15): a harness agent is its harness here, and the
- // engine it runs on is the dialog's and the tooltip's to say.
- const SizedBox(width: 10),
- Expanded(
- child: Row(
- children: [
- Flexible(
- child: Tooltip(
- message: identityDetail,
- waitDuration: const Duration(milliseconds: 700),
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
- onDoubleTap: () => unawaited(
- showAgentRenameDialog(
- context,
- notifier,
- session.machineId,
- session.agentId,
- session.agentName,
- ),
- ),
- child: Text(
++ : 16.0;
+ return math.min(
- 17 + 10 + width + 8 + (status == null ? 16 : 120) + 8,
++ 17 + 10 + width + 8 + statusRoom + 8,
+ constraints.maxWidth * .45,
+ );
+ }
+
+ final desiredRightWidth = narrow
+ ? math.max(
+ (showModelPicker ? 96.0 : 0.0) + badgeWidth,
+ constraints.maxWidth * .36,
+ )
+ : math.max(
+ actionsWidth + badgeWidth,
+ // Everything the name does not use. A fixed 55% left the folder and branch
+ // shortened to "…" beside a short name with half the header empty.
+ constraints.maxWidth - titleRoom(),
+ );
+ // The name/status retain space while model and project text yield.
+ final rightWidth = math.min(
+ compact ? closeWidth : desiredRightWidth,
+ math.max(0.0, constraints.maxWidth - 99),
+ );
+ return Row(
+ children: [
+ if (agent != null)
+ EngineMark.forAgent(agent, size: 17)
+ else
+ EngineMark(engine: session.engineId, size: 17),
+ // Icon and name, the same as every other pane (owner,
+ // 2026-09-15): a harness agent is its harness here, and the
+ // engine it runs on is the dialog's and the tooltip's to say.
+ const SizedBox(width: 10),
+ Expanded(
+ child: Row(
+ children: [
+ Flexible(
+ child: Tooltip(
+ message: identityDetail,
+ waitDuration: const Duration(milliseconds: 700),
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onDoubleTap: () => unawaited(
+ showAgentRenameDialog(
+ context,
+ notifier,
+ session.machineId,
+ session.agentId,
session.agentName,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: grid.AppType.monoLabel(
- color: AppColors.text,
- fontWeight: FontWeight.w600,
- ),
),
),
+ child: Text(
+ session.agentName,
+ key: const ValueKey('terminal-pane-title'),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: titleStyle,
+ ),
),
),
- if (status != null || starting != null || !compact)
- const SizedBox(width: 8),
- if (status != null && narrow)
- Tooltip(
- message: '${status.label}: ${status.detail}',
- child: IconButton(
- tooltip: status.actionLabel ?? status.label,
- onPressed: statusAction,
- icon: Icon(status.icon, size: 14),
- style: IconButton.styleFrom(
- foregroundColor: color,
- disabledForegroundColor: color,
- fixedSize: const Size(28, 28),
- minimumSize: const Size(28, 28),
- padding: EdgeInsets.zero,
- tapTargetSize: MaterialTapTargetSize.shrinkWrap,
- ),
+ ),
- if (status != null || !compact) const SizedBox(width: 8),
++ if (status != null || starting != null || !compact)
++ const SizedBox(width: 8),
+ if (status != null && narrow)
+ Tooltip(
+ message: '${status.label}: ${status.detail}',
+ child: IconButton(
+ tooltip: status.actionLabel ?? status.label,
+ onPressed: statusAction,
+ icon: Icon(status.icon, size: 14),
+ style: IconButton.styleFrom(
+ foregroundColor: color,
+ disabledForegroundColor: color,
+ fixedSize: const Size(28, 28),
+ minimumSize: const Size(28, 28),
+ padding: EdgeInsets.zero,
+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
- )
- else if (status != null)
- ConstrainedBox(
- constraints: BoxConstraints(
- maxWidth: math.max(
- 0,
- math.min(
- constraints.maxWidth * .22,
- constraints.maxWidth - actionsWidth - 110,
- ),
+ ),
+ )
+ else if (status != null)
+ ConstrainedBox(
+ constraints: BoxConstraints(
+ maxWidth: math.max(
+ 0,
+ math.min(
+ constraints.maxWidth * .22,
+ constraints.maxWidth - actionsWidth - 110,
),
),
- child: Align(
- alignment: Alignment.centerLeft,
- child: Tooltip(
- message: status.detail,
- child: TextButton(
- onPressed: statusAction,
- style: TextButton.styleFrom(
- foregroundColor: color,
- disabledForegroundColor: AppColors.textSoft,
- minimumSize: Size.zero,
- tapTargetSize:
- MaterialTapTargetSize.shrinkWrap,
- padding: const EdgeInsets.symmetric(
- horizontal: 6,
- vertical: 4,
- ),
+ ),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Tooltip(
+ message: status.detail,
+ child: TextButton(
+ onPressed: statusAction,
+ style: TextButton.styleFrom(
+ foregroundColor: color,
+ disabledForegroundColor: AppColors.textSoft,
+ minimumSize: Size.zero,
+ tapTargetSize:
+ MaterialTapTargetSize.shrinkWrap,
+ padding: const EdgeInsets.symmetric(
+ horizontal: 6,
+ vertical: 4,
),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(status.icon, size: 14),
- const SizedBox(width: 6),
- Flexible(
- child: Text(
- // The chip names the STATE; what
- // pressing it does is in the tooltip
- // and in `actionLabel`. "Link
- // required" that can be pressed reads
- // better than a bare verb where every
- // neighbour is a status.
- status.label,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: grid.AppType.monoLabel(
- fontWeight: FontWeight.w400,
- ),
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Icon(status.icon, size: 14),
+ const SizedBox(width: 6),
+ Flexible(
+ child: Text(
+ // The chip names the STATE; what
+ // pressing it does is in the tooltip
+ // and in `actionLabel`. "Link
+ // required" that can be pressed reads
+ // better than a bare verb where every
+ // neighbour is a status.
+ status.label,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: grid.AppType.monoLabel(
+ fontWeight: FontWeight.w400,
),
),
- ],
- ),
+ ),
+ ],
),
),
),
- )
- else if (starting != null && narrow)
- PaneStartingChip(phase: starting, narrow: true)
- else if (starting != null)
- // Never wider than the room this row is sure to have: the name's
- // share (at most 45%) or what the actions and the PR badge leave —
- // less [_headerFurniture]. Its words shorten rather than push the
- // row past the header's edge.
- ConstrainedBox(
- constraints: BoxConstraints(
- maxWidth: math.max(
- 0,
- math.min(
- constraints.maxWidth * .45 - _headerFurniture,
- constraints.maxWidth -
- actionsWidth -
- badgeWidth -
- _headerFurniture,
- ),
+ ),
+ )
++ else if (starting != null && narrow)
++ PaneStartingChip(phase: starting, narrow: true)
++ else if (starting != null)
++ // Never wider than the room this row is sure to have: the name's
++ // share (at most 45%) or what the actions and the PR badge leave —
++ // less [_headerFurniture]. Its words shorten rather than push the
++ // row past the header's edge.
++ ConstrainedBox(
++ constraints: BoxConstraints(
++ maxWidth: math.max(
++ 0,
++ math.min(
++ constraints.maxWidth * .45 - _headerFurniture,
++ constraints.maxWidth -
++ actionsWidth -
++ badgeWidth -
++ _headerFurniture,
+ ),
+ ),
- child: PaneStartingChip(phase: starting),
- )
- else if (!compact)
- Padding(
- padding: const EdgeInsets.all(4),
- child: Icon(Icons.circle, size: 8, color: color),
+ ),
- ],
- ),
++ child: PaneStartingChip(phase: starting),
++ )
+ else if (!compact)
+ Padding(
+ padding: const EdgeInsets.all(4),
+ child: Icon(Icons.circle, size: 8, color: color),
+ ),
+ ],
),
- const SizedBox(width: 8),
- // Which of the three paths carries this pane's bytes. Absent for a local machine's own
- // terminal, which has no such distinction and so gets no badge.
- //
- // The wire word and the word a person reads differ for the middle state, deliberately:
- // the CLI sends 'turn' (it is a TURN allocation) but both middle and last are relays to
- // a reader, so they read as "relay" and "ws". 'relay' on the wire kept its original
- // meaning — the backend WebSocket — so an older CLI is never mislabelled.
- if (!compact && !narrow && session.linkMode != null)
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 2),
- child: _LinkModeMark(mode: session.linkMode!),
- ),
- ConstrainedBox(
- constraints: BoxConstraints(maxWidth: rightWidth),
- child: PaneHeaderActions(
- trailing: showPr
- ? ConstrainedBox(
+ ),
+ const SizedBox(width: 8),
+ // Which of the three paths carries this pane's bytes. Absent for a local machine's own
+ // terminal, which has no such distinction and so gets no badge.
+ //
+ // The wire word and the word a person reads differ for the middle state, deliberately:
+ // the CLI sends 'turn' (it is a TURN allocation) but both middle and last are relays to
+ // a reader, so they read as "relay" and "ws". 'relay' on the wire kept its original
+ // meaning — the backend WebSocket — so an older CLI is never mislabelled.
+ if (!compact && !narrow && session.linkMode != null)
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 2),
+ child: _LinkModeMark(mode: session.linkMode!),
+ ),
+ ConstrainedBox(
+ constraints: BoxConstraints(maxWidth: rightWidth),
+ child: PaneHeaderActions(
+ trailing: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (showPr)
+ Flexible(
+ child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: badgeWidth),
child: PullRequestBadge(
compact: narrow,
@@@ -2314,116 -2173,85 +2298,86 @@@
agent.id,
),
),
- )
- : null,
- // One ⋮ menu for the pane's actions at every width, not a row of icons.
- compact: true,
- // Keep the current model visible, including while the
- // terminal reconnects, without shifting the other controls.
- modelPicker: showModelPicker
- ? GridModelPicker(
- compact: narrow,
- notifier: notifier,
- machineId: session.machineId,
- currentModel: agent?.gridModel,
- webSearch: agent?.gridWebSearch,
- engineLabel: session.engineId,
- openRequests: pickerOpener,
- onSelected: (model) => unawaited(
- notifier.retargetAgentToGridModel(
- session.machineId,
- session.agentId,
- model.id,
- gridName: model.grid,
- ),
+ ),
+ ),
+ if (onClose != null)
+ PaneCloseButton(onPressed: onClose!),
+ ],
+ ),
+ modelPicker: showModelPicker
+ ? GridModelPicker(
+ key: ValueKey((
+ 'pane-model',
+ session.machineId,
+ session.agentId,
+ )),
+ paneHeader: true,
+ enabled: !readOnly && !session.readOnly,
+ compact: narrow,
+ notifier: notifier,
+ machineId: session.machineId,
+ currentModel: agent?.gridModel,
+ subscriptionModel: agent?.modelName,
+ webSearch: agent?.gridWebSearch,
+ engineLabel: session.engineId,
++ controller: pickerController,
+ onSelected: (model) => unawaited(
+ notifier.retargetAgentToGridModel(
+ session.machineId,
+ session.agentId,
+ model.id,
+ gridName: model.grid,
),
- onUseOwnLogin: () => unawaited(
- notifier.clearAgentGrid(
- session.machineId,
- session.agentId,
- ),
+ ),
+ onUseOwnLogin: () => unawaited(
+ notifier.clearAgentGrid(
+ session.machineId,
+ session.agentId,
),
- // Discovery opens the local Models popover. Selection above
- // continues to target this pane's existing session.
- onRunLocalModel: () => unawaited(
- notifier.runLocalModel(
- context,
- machineId: session.machineId,
- ),
+ ),
+ // Discovery opens the local Models popover. Selection above
+ // continues to target this pane's existing session.
+ onRunLocalModel: () => unawaited(
+ notifier.runLocalModel(
+ context,
+ machineId: session.machineId,
),
- )
- : null,
- onShare:
- readOnly ||
- notifier
- .stateOf(session.machineId)
- ?.machine
- .isShared ==
- true
- ? null
- : () => showShareHarnessDialog(
- context,
- notifier,
- session.machineId,
- session.agentId,
- session.agentName,
),
- zoomed: zoomed,
- onZoom: onToggleZoom,
- onRestart: onRestart,
- onFork: onFork,
- onDelete: onDelete,
- onClose: onClose,
- terminal: isTerminalEngine(session.engineId),
- onToggleComposer: remoteComposer,
- composerVisible: composerVisible,
- // A harness agent's viewer, shown or hidden from the
- // pane it belongs to.
- onToggleViewer:
- agent?.viewerUrl == null && agent?.viewerError == null
- ? null
- : () => notifier.toggleViewerPane(
- session.machineId,
- agent!.id,
+ )
+ : null,
+ details: compact || narrow
+ ? null
+ : Tooltip(
+ message: [
+ if (forkedFrom != null)
+ 'Forked from ${forkedFrom.name}',
+ if (project != null) project.cwd,
+ ?project?.branchDetail,
+ machineName,
+ ].join('\n'),
+ child: PromptContextView(
+ contextData: PromptContext(
+ // This computer goes without saying.
+ machine: machine?.isLocalMachine == true
+ ? null
+ : machineName,
+ // The folder as it was chosen and its repository's branch;
+ // the full working folder is in the tooltip.
+ project: narrow ? null : project?.label,
+ // Not a branch Harness made up that waits for the
+ // session's name, nor a commit an agent checked out.
+ branch: narrow ? null : project?.shownBranch,
+ leading: !narrow && forkedFrom != null
+ ? 'forked from ${forkedFrom.name}'
+ : null,
+ ),
),
- viewerVisible:
- agent != null &&
- notifier.viewerPaneShown(session.machineId, agent.id),
- viewerColor: agent == null
- ? null
- : agentIdentity(agent).color,
- details: Tooltip(
- message: [
- if (forkedFrom != null)
- 'Forked from ${forkedFrom.name}',
- if (project != null) project.cwd,
- ?project?.branchDetail,
- machineName,
- ].join('\n'),
- child: PromptContextView(
- contextData: PromptContext(
- // This computer goes without saying.
- machine: machine?.isLocalMachine == true
- ? null
- : machineName,
- // The folder as it was chosen and its repository's branch;
- // the full working folder is in the tooltip.
- project: narrow ? null : project?.label,
- // Not a branch Harness made up that waits for the
- // session's name, nor a commit an agent checked out.
- branch: narrow ? null : project?.shownBranch,
- leading: !narrow && forkedFrom != null
- ? 'forked from ${forkedFrom.name}'
- : null,
),
- ),
- ),
- ),
),
- ],
- );
- },
- ),
+ ),
+ ],
+ );
+ },
),
),
);
diff --cc desktop/test/pane_model_status_test.dart
index f1f8990e3,000000000..383ad68ff
mode 100644,000000..100644
--- a/desktop/test/pane_model_status_test.dart
+++ b/desktop/test/pane_model_status_test.dart
@@@ -1,334 -1,0 +1,335 @@@
+// The pane saying what its model is doing (grid-reads-without-waking, issue 03): the chip from a
+// message sent to a resting model until its first output, and the note on an agent whose model is
+// not answering — and, for an agent whose frame says neither, the header it always had.
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/core/models.dart';
+import 'package:harness/state/app_state.dart';
+import 'package:harness/state/model_start_watch.dart';
+import 'package:harness/terminal/terminal_session.dart';
+import 'package:harness/widgets/terminal_panel.dart';
+
+import 'support/real_fonts.dart';
+import 'support/resting_models.dart';
+import 'swarm_state_test.dart' show createApp;
+
+void main() {
+ setUpAll(loadRealFonts);
+
+ late AppNotifier app;
+ late RecordingDaemon daemon;
+ late TerminalSession session;
+
+ /// A pane on agent `agent-1`, whose frame's `grid` block is [grid].
+ Future<void> pane(
+ WidgetTester tester,
+ Map<String, Object?> grid, {
+ double width = 900,
+ String name = 'Desktop',
+ }) async {
+ tester.view.physicalSize = const Size(1200, 800);
+ tester.view.devicePixelRatio = 1;
+ addTearDown(tester.view.reset);
+ daemon = RecordingDaemon(
+ modelsReply([
+ section('home', own: true, models: [row('Gemma-4-12B', 'macbook')]),
+ ]),
+ );
+ app = createApp(connectionForTest: (_) => daemon);
+ addTearDown(app.dispose);
+ app.machineStates['m']!.agents = [_agent(grid)];
+ session =
+ TerminalSession(
+ machineId: 'm',
+ agentId: 'agent-1',
+ agentName: name,
+ engineId: 'codex',
+ send: (_, _) async => true,
+ sendBinary: (_) async => true,
+ )
+ ..status = TerminalSessionStatus.controlling
+ ..streamId = 'stream-1';
+ addTearDown(session.dispose);
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: SizedBox(
+ width: width,
+ height: 320,
+ // Rebuilt on every change to the app, as the pane grid rebuilds it.
+ child: ListenableBuilder(
+ listenable: app,
+ builder: (context, _) =>
+ TerminalPanel(notifier: app, session: session, focused: true),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pump();
+ }
+
+ /// The daemon re-pushing the agent with [grid] (`agent_synced`) — as it does when the state or
+ /// the note of its model's grid moves.
+ Future<void> agentSays(WidgetTester tester, Map<String, Object?> grid) async {
+ await app.handleEventForTest('m', {
+ 'type': 'agent_synced',
+ 'payload': {'agent': _json(grid)},
+ });
+ await tester.pump();
+ }
+
+ Future<void> event(
+ WidgetTester tester,
+ String type, {
+ Map<String, Object?> payload = const {},
+ bool replay = false,
+ }) async {
+ await app.handleEventForTest('m', {
+ 'type': type,
+ 'agentId': 'agent-1',
+ 'payload': payload,
+ if (replay) 'replay': true,
+ });
+ await tester.pump();
+ }
+
+ /// Let the turn's own watchdog (12 s) run out, so no timer outlives the test.
+ Future<void> settle(WidgetTester tester) =>
+ tester.pump(const Duration(seconds: 13));
+
+ testWidgets('an agent whose frame says neither keeps the header it had', (
+ tester,
+ ) async {
+ await pane(tester, {'model': 'Qwen3.5-4B', 'webSearch': 'on'});
- // What the build before this one drew for this very frame, captured from it.
- expect(textsUnder(tester), ['Desktop', 'Qwen3.5-4B', 'Test host']);
++ // The header as it was drawn before this ticket, nothing added — its order is main's since
++ // #329, which put the model after the machine.
++ expect(textsUnder(tester), ['Desktop', 'Test host', 'Qwen3.5-4B']);
+ await event(tester, 'turn_started', payload: {'userMessage': 'hi'});
- expect(textsUnder(tester), ['Desktop', 'Qwen3.5-4B', 'Test host']);
++ expect(textsUnder(tester), ['Desktop', 'Test host', 'Qwen3.5-4B']);
+ await settle(tester);
+ });
+
+ testWidgets(
+ 'a message to a resting model says Starting up… until the first output',
+ (tester) async {
+ await pane(tester, {'model': 'Qwen3.5-4B', 'state': 'asleep'});
+ expect(find.text('Starting up…'), findsNothing);
+
+ await event(tester, 'turn_started', payload: {'userMessage': 'hi'});
+ expect(find.text('Starting up…'), findsOneWidget);
+ expect(saysGrid, findsNothing);
+
+ // The terminal echoing the prompt and drawing its spinner is not the model answering.
+ session.terminal.write('hi\r\n⠋ Working');
+ await tester.pump();
+ expect(find.text('Starting up…'), findsOneWidget);
+ // Nor is the grid coming up: the chip is about THIS message's answer.
+ await agentSays(tester, {'model': 'Qwen3.5-4B', 'state': 'awake'});
+ expect(find.text('Starting up…'), findsOneWidget);
+
+ await tester.pump(kStillStartingAfter);
+ expect(find.text('Starting up…'), findsNothing);
+ expect(
+ find.text('Still starting — this can take up to a minute'),
+ findsOneWidget,
+ );
+ expect(saysGrid, findsNothing);
+
+ await event(tester, 'text_delta', payload: {'content': 'Hello'});
+ expect(
+ find.text('Still starting — this can take up to a minute'),
+ findsNothing,
+ );
+ expect(find.text('Starting up…'), findsNothing);
+ await settle(tester);
+ },
+ );
+
+ // A reasoning model's first output is its thinking, long before any text — and every other kind
+ // of output the CLI's normalizers emit for a turn counts the same way.
+ for (final kind in [
+ 'thinking_delta',
+ 'thinking_title',
+ 'tool_end',
+ 'subagent_finished',
+ 'done',
+ ]) {
+ testWidgets('$kind is the model answering', (tester) async {
+ await pane(tester, {'model': 'Qwen3.5-4B', 'state': 'asleep'});
+ await event(tester, 'turn_started', payload: {'userMessage': 'hi'});
+ expect(find.text('Starting up…'), findsOneWidget);
+ await event(tester, kind, payload: {'content': 'Let me think'});
+ expect(find.text('Starting up…'), findsNothing);
+ await settle(tester);
+ });
+ }
+
+ testWidgets('a sub-agent starting its own turn is not a message sent here', (
+ tester,
+ ) async {
+ await pane(tester, {'model': 'Qwen3.5-4B', 'state': 'asleep'});
+ app.machineStates['m']!.agents = [
+ Agent.fromJson({
+ ..._json({'model': 'Qwen3.5-4B', 'state': 'asleep'}),
+ 'sessionId': 'own',
+ }),
+ ];
+ await app.handleEventForTest('m', {
+ 'type': 'turn_started',
+ 'agentId': 'agent-1',
+ 'dbSessionId': 'a-sub-agent',
+ 'payload': {'userMessage': 'specialist task'},
+ });
+ await tester.pump();
+ expect(find.text('Starting up…'), findsNothing);
+ await settle(tester);
+ });
+
+ testWidgets('a tool call is output too, and so is the turn ending', (
+ tester,
+ ) async {
+ await pane(tester, {'model': 'Qwen3.5-4B', 'state': 'waking'});
+ await event(tester, 'turn_started', payload: {'userMessage': 'hi'});
+ expect(find.text('Starting up…'), findsOneWidget);
+ await event(tester, 'tool_start', payload: {'id': 't', 'tool': 'Read'});
+ expect(find.text('Starting up…'), findsNothing);
+ await settle(tester);
+
+ await event(tester, 'turn_started', payload: {'userMessage': 'again'});
+ expect(find.text('Starting up…'), findsOneWidget);
+ await app.handleEventForTest('m', {
+ 'type': 'turn_ended',
+ 'agentId': 'agent-1',
+ 'payload': const <String, dynamic>{},
+ });
+ await tester.pump();
+ expect(find.text('Starting up…'), findsNothing);
+ await tester.pump(const Duration(minutes: 1));
+ });
+
+ testWidgets(
+ 'no chip for an awake model, a daemon that did not say, or a replayed turn',
+ (tester) async {
+ await pane(tester, {'model': 'Qwen3.5-4B', 'state': 'awake'});
+ await event(tester, 'turn_started', payload: {'userMessage': 'hi'});
+ expect(find.text('Starting up…'), findsNothing);
+
+ await agentSays(tester, {'model': 'Qwen3.5-4B'});
+ await event(tester, 'turn_started', payload: {'userMessage': 'hi'});
+ expect(find.text('Starting up…'), findsNothing);
+
+ // A turn picked back up at attach is not a message sent now.
+ await agentSays(tester, {'model': 'Qwen3.5-4B', 'state': 'asleep'});
+ await event(
+ tester,
+ 'turn_started',
+ payload: {'userMessage': 'hi'},
+ replay: true,
+ );
+ expect(find.text('Starting up…'), findsNothing);
+ await settle(tester);
+ },
+ );
+
+ for (final width in [420.0, 600.0, 760.0, 900.0, 1100.0]) {
+ testWidgets('the chip fits a header $width wide, beside a long name', (
+ tester,
+ ) async {
+ await pane(
+ tester,
+ {'model': 'Qwen3.6-35B-A3B-UD-Q5_K_XL', 'state': 'asleep'},
+ width: width,
+ name: 'A harness with a very long name indeed, for the header',
+ );
+ await event(tester, 'turn_started', payload: {'userMessage': 'hi'});
+ await tester.pump(kStillStartingAfter);
+ expect(tester.takeException(), isNull);
+ // A narrow header draws the chip's mark and says the words on hover, as it does its status.
+ expect(
+ width < 560
+ ? find.byTooltip(
+ 'Still starting — this can take up to a minute\n'
+ 'Resting to save resources. It starts by itself when you send a message.',
+ )
+ : find.text('Still starting — this can take up to a minute'),
+ findsOneWidget,
+ );
+ await event(tester, 'text_delta', payload: {'content': 'Hello'});
+ await settle(tester);
+ });
+ }
+
+ testWidgets('the chip never outlives its cap', (tester) async {
+ await pane(tester, {'model': 'Qwen3.5-4B', 'state': 'asleep'});
+ await event(tester, 'turn_started', payload: {'userMessage': 'hi'});
+ await tester.pump(kStartWatchCap - const Duration(seconds: 1));
+ expect(
+ find.text('Still starting — this can take up to a minute'),
+ findsOneWidget,
+ );
+ await tester.pump(const Duration(seconds: 1));
+ expect(
+ find.text('Still starting — this can take up to a minute'),
+ findsNothing,
+ );
+ expect(find.text('Starting up…'), findsNothing);
+ });
+
+ testWidgets(
+ "a model no longer served says so, and Pick another opens this pane's picker",
+ (tester) async {
+ await pane(tester, {
+ 'model': 'Qwen3.5-4B',
+ 'state': 'awake',
+ 'note': {'reason': 'not_served', 'model': 'Qwen3.5-4B'},
+ });
+ expect(
+ find.textContaining("Qwen3.5-4B isn't being served right now"),
+ findsOneWidget,
+ );
+ expect(find.text('Pick another'), findsOneWidget);
+ expect(saysGrid, findsNothing);
+
+ await tester.tap(find.text('Pick another'));
+ await tester.pumpAndSettle();
+ // The pane's own model picker, open on its models.
+ expect(find.text('SUBSCRIPTION'), findsOneWidget);
+ expect(find.text('Gemma-4-12B'), findsOneWidget);
+ },
+ );
+
+ testWidgets('a model whose computer seems offline says until when', (
+ tester,
+ ) async {
+ await pane(tester, {
+ 'model': 'Qwen3.5-4B',
+ 'state': 'asleep',
+ 'note': {'reason': 'offline', 'model': 'Qwen3.5-4B', 'machine': 'Studio'},
+ });
+ expect(
+ find.text(
+ "Studio seems offline — Qwen3.5-4B won't answer until it's back",
+ ),
+ findsOneWidget,
+ );
+ expect(find.text('Pick another'), findsNothing);
+ expect(saysGrid, findsNothing);
+
+ // Cleared by the daemon re-pushing the agent once the model is served again.
+ await agentSays(tester, {'model': 'Qwen3.5-4B', 'state': 'awake'});
+ expect(find.textContaining('seems offline'), findsNothing);
+ // The note gave its line back to the terminal, which tells the machine its new size.
+ await tester.pump(const Duration(milliseconds: 100));
+ });
+}
+
+Map<String, Object?> _json(Map<String, Object?> grid) => {
+ 'id': 'agent-1',
+ 'name': 'Desktop',
+ 'engine': 'codex',
+ 'terminal': {'available': true},
+ 'grid': grid,
+};
+
+Agent _agent(Map<String, Object?> grid) => Agent.fromJson(_json(grid));
diff --cc desktop/test/resting_models_panel_test.dart
index f6941aff6,000000000..87f283b8d
mode 100644,000000..100644
--- a/desktop/test/resting_models_panel_test.dart
+++ b/desktop/test/resting_models_panel_test.dart
@@@ -1,321 -1,0 +1,321 @@@
+// The Models panel saying what a resting computer is doing (grid-reads-without-waking, issue 03):
+// every state of the contract's table on its shared sections, "Show models", greyed offline rows,
+// and the Model Manager's row for a model parked while this computer's models rest — and, with a
+// daemon that sends none of it, the panel it always drew.
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/core/models.dart';
+import 'package:harness/models/model_manager_controller.dart';
+import 'package:harness/models/models_panel.dart';
+import 'package:harness/shared/theme/app_theme.dart';
+import 'package:harness/usage/models_menu_controller.dart';
+
+import 'support/model_manager.dart';
+import 'support/real_fonts.dart';
+import 'support/resting_models.dart';
+
+class _NoSubscriptions extends ModelsMenuController {
+ @override
+ List<Map<String, Object?>> get rows => const [];
+ @override
+ Future<void> refresh() async {}
+}
+
+/// This computer's daemon, recording the `grid_models_list` asks that go to it for real — the
+/// wake. The panel's plain reads go through [ModelManagerTestApp.gridModels], which answers from
+/// its `inventory`.
+class _Daemon extends ModelManagerConnection {
+ final asks = <Map<String, dynamic>>[];
+ Map<String, dynamic> wakeReply = const {};
+
+ @override
+ Future<Map<String, dynamic>> request(
+ String type, {
+ Map<String, dynamic> payload = const {},
+ Duration timeout = const Duration(seconds: 20),
+ }) async {
+ if (type != 'grid_models_list') {
+ return super.request(type, payload: payload, timeout: timeout);
+ }
+ asks.add(Map.of(payload));
+ return wakeReply;
+ }
+}
+
+void main() {
+ setUpAll(loadRealFonts);
+
+ late _Daemon daemon;
+ late ModelManagerTestApp app;
+ late ModelManagerController controller;
+
+ Future<void> show(
+ WidgetTester tester,
+ List<Map<String, Object?>> grids, {
+ Map<String, dynamic>? local,
+ ModelsTab tab = ModelsTab.all,
+ }) async {
+ tester.view.physicalSize = const Size(900, 1600);
+ tester.view.devicePixelRatio = 1;
+ addTearDown(tester.view.reset);
+ daemon = _Daemon();
+ app = ModelManagerTestApp(daemon);
+ app.inventory = GridModels.fromReply(modelsReply(grids));
+ app.localInventory = local ?? modelInventory(scenario: 'ready');
+ controller = ModelManagerController(app, poll: false);
+ final subscriptions = _NoSubscriptions();
+ addTearDown(() {
+ controller.dispose();
+ subscriptions.dispose();
+ app.dispose();
+ });
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: Center(
+ child: SizedBox(
+ width: 640,
+ child: ModelsPanel(
+ controller: controller,
+ subscriptions: subscriptions,
+ initialTab: tab,
+ onClose: () {},
+ onManage: () {},
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ await controller.refresh(force: true);
+ await tester.pump();
+ }
+
+ double top(WidgetTester tester, Finder finder) =>
+ tester.getTopLeft(finder).dy;
+
+ testWidgets('with no new field the panel is exactly the one it always was', (
+ tester,
+ ) async {
+ // What the build before this one drew for this very answer, text for text, captured from it.
+ await show(tester, [
+ section(
+ 'home',
+ own: true,
+ models: [
+ row('Qwen3.5-4B', 'macbook'),
+ row('LFM2.5-8B', 'studio · seems offline'),
+ ],
+ ),
+ section('team', models: [row('DeepSeek-V4-Flash', 'scholes-60001')]),
+ section('empty-team'),
+ ]);
+ expect(textsUnder(tester), [
+ 'Models',
- 'Search models…',
++ 'Search models',
+ 'All 6',
+ 'Subscriptions 0',
+ 'Local 5',
+ 'Shared 1',
+ 'APIs 0',
+ 'This computer · 64 GB memory',
+ 'Qwen3.8-27B',
+ '16.2 GB · 17.6 tok/s · 42 requests / 24h',
+ 'gemma-4-12B',
+ '7.3 GB',
+ 'Qwen3.8-8B',
+ '4.8 GB',
+ 'Qwen3-Coder-30B-A3B',
+ '18.6 GB',
+ 'gpt-oss-20b',
+ '12.1 GB',
+ 'Shared · team',
+ 'DeepSeek-V4-Flash',
+ 'scholes-60001',
+ 'Select models in a session’s model picker.',
+ 'Manage models',
+ ]);
+ });
+
+ testWidgets('every state of a shared section reads as the table says', (
+ tester,
+ ) async {
+ await show(tester, [
+ section('home', own: true),
+ section(
+ 'team',
+ state: 'asleep',
+ lastKnownAge: 2 * 3600,
+ models: [
+ row('DeepSeek-V4-Flash', 'scholes-60001'),
+ row('Kimi-K2', 'zeus', offlineMachine: 'Zeus'),
+ ],
+ ),
+ section('lab', state: 'asleep'),
+ section('attic', state: 'asleep', lastKnownAge: 60),
+ section(
+ 'garage',
+ state: 'unknown',
+ seenAt: '2026-09-24T08:00:00.000Z',
+ models: [row('Gemma-4-12B', 'garage-box')],
+ ),
+ section('shed', state: 'waking'),
+ section('barn', state: 'asleep', wakeOutcome: 'not_started'),
+ section('loft', state: 'awake', wakeOutcome: 'nobody_serving'),
+ ]);
+
+ const subtitle =
+ 'Asleep · starts when you send a message (about 10–30 s) · list from 2 h ago';
+ expect(find.text(subtitle), findsOneWidget);
+ expect(
+ find.byTooltip(
+ 'Resting to save resources. It starts by itself when you send a message.',
+ ),
+ findsOneWidget,
+ );
+ expect(
+ top(tester, find.text('Shared · team')) <
+ top(tester, find.text(subtitle)),
+ isTrue,
+ );
+
+ // A section with no record is drawn, with the way to find out what it serves.
+ expect(find.text('Shared · lab'), findsOneWidget);
+ expect(find.text('Show models'), findsOneWidget);
+ expect(find.text('usually 15–40 s'), findsOneWidget);
+
+ expect(find.text('Shared · attic'), findsOneWidget);
+ expect(
+ find.text('Nobody was serving here when it went to sleep'),
+ findsOneWidget,
+ );
+
+ expect(find.text('Not answering right now'), findsOneWidget);
+ expect(
+ top(tester, find.text('Not answering right now')) <
+ top(tester, find.text('Gemma-4-12B')),
+ isTrue,
+ );
+
+ expect(find.text('Starting up… usually 15–40 s'), findsOneWidget);
+ expect(
+ find.text(
+ "Couldn't start barn right now — it will start on your next message",
+ ),
+ findsOneWidget,
+ );
+ expect(
+ find.text('Nobody is serving a model here right now'),
+ findsOneWidget,
+ );
+
+ // The offline row: still listed, greyed, and saying why.
+ expect(find.text('Kimi-K2'), findsOneWidget);
+ expect(
+ find.text('Zeus seems offline — its models come back when it does'),
+ findsOneWidget,
+ );
+ Color? ink(String text) =>
+ tester.widget<Text>(find.text(text)).style?.color;
+ expect(ink('Kimi-K2'), AppPalette.textFaint);
+ expect(ink('DeepSeek-V4-Flash'), AppPalette.textPrimary);
+
+ // Counts are models, as they always were.
+ expect(find.text('Shared 3'), findsOneWidget);
+ expect(saysGrid, findsNothing);
+
+ // A search narrows to what matches; a section with nothing matching says nothing.
+ await tester.enterText(
+ find.byKey(const ValueKey('models-search')),
+ 'DeepSeek',
+ );
+ await tester.pump();
+ expect(find.text('Show models'), findsNothing);
+ expect(find.text('Shared · lab'), findsNothing);
+ expect(find.text('DeepSeek-V4-Flash'), findsOneWidget);
+ // …and a section it kept still says what it says about its rows.
+ expect(find.text(subtitle), findsOneWidget);
+ await tester.enterText(
+ find.byKey(const ValueKey('models-search')),
+ 'Gemma',
+ );
+ await tester.pump();
+ expect(find.text('Not answering right now'), findsOneWidget);
+ expect(find.text('Gemma-4-12B'), findsOneWidget);
+ });
+
+ testWidgets('the Shared tab draws a speaking section even with no models', (
+ tester,
+ ) async {
+ await show(tester, [
+ section('home', own: true),
+ section('lab', state: 'asleep'),
+ ], tab: ModelsTab.shared);
+ expect(find.text('No shared models'), findsNothing);
+ expect(find.text('lab'), findsOneWidget);
+ expect(find.text('Show models'), findsOneWidget);
+ });
+
+ testWidgets('Show models wakes just that section, and says it is starting', (
+ tester,
+ ) async {
+ await show(tester, [
+ section('home', own: true),
+ section('lab', state: 'asleep'),
+ ]);
+ daemon.wakeReply = modelsReply([
+ section('home', own: true),
+ section('lab', state: 'waking'),
+ ]);
+ await tester.tap(find.text('Show models'));
+ await tester.pump();
+ await tester.pump();
+ expect(daemon.asks.single, {
+ 'rowState': true,
+ 'wake': ['lab'],
+ });
+ expect(find.text('Show models'), findsNothing);
+ expect(find.text('Starting up… usually 15–40 s'), findsOneWidget);
+ expect(saysGrid, findsNothing);
+
+ // It wakes with its models; the follow-up read finds them, and then stops.
+ app.inventory = GridModels.fromReply(
+ modelsReply([
+ section('home', own: true),
+ section(
+ 'lab',
+ state: 'awake',
+ models: [row('Qwen3.6-35B-A3B', 'lab-box')],
+ ),
+ ]),
+ );
+ await tester.pump(const Duration(seconds: 5));
+ await tester.pump(const Duration(seconds: 10));
+ });
+
+ testWidgets('a model parked while this computer rests says so', (
+ tester,
+ ) async {
+ final local = modelInventory(scenario: 'ready');
+ final qwen = (local['models'] as List).first as Map<String, dynamic>;
+ // What the daemon sends for a parked engine: running, no telemetry, `gridAsleep`.
+ qwen
+ ..remove('tokensPerSecond')
+ ..remove('requests')
+ ..remove('windowSeconds')
+ ..['gridAsleep'] = true;
+ await show(tester, [section('home', own: true)], local: local);
+ expect(
+ find.text('16.2 GB · Running · resting until your next message'),
+ findsOneWidget,
+ );
+ expect(saysGrid, findsNothing);
+ // Still running as far as its controls go: Pause is what it offers.
+ expect(
+ find.byTooltip(
+ 'Pause Qwen3.8-27B and free memory. The download is kept.',
+ ),
+ findsOneWidget,
+ );
+ });
+}