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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
desktop: the model picker becomes a panel, and its tick keeps up with the click
bitcoinbuilder6b7cbfc9ae55
diff --git a/desktop/lib/theme/app_theme.dart b/desktop/lib/theme/app_theme.dartindex 2eec6b546..757608d17 100644--- a/desktop/lib/theme/app_theme.dart+++ b/desktop/lib/theme/app_theme.dart@@ -35,6 +35,11 @@ abstract final class AppColors {static Color get hover => grid.AppPalette.cardBgHover;static Color get selected => grid.AppSurface.selectedFill;+ /// The row under the pointer. Deliberately WEAKER than [selected]: a menu that+ /// paints both the same makes two rows look chosen at once, and the one the+ /// pointer happens to rest on is not the one the agent is on.+ static Color get rowHover => grid.AppSurface.hoverFill;+/// A hairline between blocks, and the stronger one that has to hold a shape.static Color get border => grid.AppPalette.divider;static Color get borderStrong => grid.AppPalette.guide;diff --git a/desktop/lib/usage/models_menu_controller.dart b/desktop/lib/usage/models_menu_controller.dartindex a9e12d936..d88fe6477 100644--- a/desktop/lib/usage/models_menu_controller.dart+++ b/desktop/lib/usage/models_menu_controller.dart@@ -95,11 +95,16 @@ class ModelsMenuController extends ChangeNotifier {windows.every((w) => w.usedPercent.isFinite);final String status;final details = <String>[];+ // The figure behind the sentence, for a meter the words alone cannot draw. Null whenever the+ // sentence is not a figure ("Usage unavailable", "Checking usage…"), so a caller cannot mistake+ // "we could not read it" for "nothing left".+ double? remainingPercent;if (valid) {// Show the limit that will stop work first. Weekly-only summaries can// look healthy while a shorter window is already exhausted.final limiting = reading.tightest!;status = '${_remaining(limiting)} remaining';+ remainingPercent = (100 - limiting.usedPercent).clamp(0, 100).toDouble();details.add('Limiting window: ${limiting.label}');for (final window in windows) {final reset = window.resetsInLabel(now: now);@@ -126,6 +131,7 @@ class ModelsMenuController extends ChangeNotifier {'title': provider,'account': _accountLabel(reading),'status': status,+ 'remainingPercent': remainingPercent,'details': details,'engine': reading.provider.engineId,'iconAsset': engineIdentity(reading.provider.engineId).asset,diff --git a/desktop/lib/widgets/grid_model_picker.dart b/desktop/lib/widgets/grid_model_picker.dartindex 4aecf6b11..ad755d7f1 100644--- a/desktop/lib/widgets/grid_model_picker.dart+++ b/desktop/lib/widgets/grid_model_picker.dart@@ -10,6 +10,7 @@ import '../shared/theme/app_type.dart';import '../theme/app_theme.dart';import '../usage/models_menu_controller.dart';import 'engine_identity.dart';+import 'model_picker_chrome.dart';import 'pane_menu.dart';/// The engines whose panes carry a model picker.@@ -126,6 +127,85 @@ class _GridModelPickerState extends State<GridModelPicker> {/// Closes the menu this control has open, if any. Set while one is showing.void Function()? _close;+ /// The model this picker has just been told to move to, before the machine has confirmed it.+ ///+ /// A retarget RESPAWNS the pane, so the authoritative answer — `agent.gridModel`, which is what+ /// [GridModelPicker.currentModel] carries — only arrives once the daemon has done the work and+ /// sent a frame, seconds later. Until then the menu reopened with the tick still on the row the+ /// person had just moved off, which reads as the click having done nothing.+ ///+ /// `_expecting` is what tells "moving to the engine's own login" (a deliberate null) apart from+ /// "nothing pending", which null alone cannot.+ bool _expecting = false;+ String? _expected;+ Timer? _expiry;++ /// What the menu should tick: the guess while there is one, else what the machine says.+ String? get _effectiveModel => _expecting ? _expected : widget.currentModel;++ /// Take the choice as made, and say so at once.+ void _expect(String? model) {+ _expiry?.cancel();+ setState(() {+ _expecting = true;+ _expected = model;+ });+ // A refused retarget never produces a frame to correct this, so the guess expires on its own.+ // The request's own budget is 30s; outliving it would leave a tick on a row the agent never+ // reached.+ _expiry = Timer(const Duration(seconds: 30), () {+ if (!mounted) return;+ setState(() {+ _expecting = false;+ _expected = null;+ });+ _redrawOpenMenu();+ });+ _redrawOpenMenu();+ }++ @override+ void didUpdateWidget(GridModelPicker oldWidget) {+ super.didUpdateWidget(oldWidget);+ if (widget.currentModel == oldWidget.currentModel) return;+ if (_expecting && _settles(widget.currentModel)) {+ _expiry?.cancel();+ _expecting = false;+ _expected = null;+ }+ // A menu open while this lands redraws, rather than waiting to be reopened.+ //+ // ⚠️ AFTER the frame, never inside it. `didUpdateWidget` runs while the framework is building,+ // and marking an overlay entry dirty from there throws "setState() or markNeedsBuild() called+ // during build" across the window — the entry belongs to a different subtree that this build+ // pass has already gone past.+ _redrawOpenMenu();+ }++ /// Does what the machine now reports END the guess?+ ///+ /// NOT simply "the answer changed". A retarget respawns the pane, and a pane that is restarting+ /// reports no model at all for a moment — so the first frame after a click is usually a null on+ /// its way to the model that was asked for. Dropping the guess there put the tick back on the+ /// Subscription row mid-move, and the row the person clicked only claimed it once the respawn+ /// finished: a visible flicker between two different answers.+ ///+ /// So a null settles nothing while a MODEL is expected — the timer is what bounds that wait. Any+ /// other model does settle it: the agent went somewhere other than where this menu asked, and+ /// what the machine says beats what this menu hoped. Expecting the engine's own login is the+ /// mirror image, where null IS the confirmation.+ bool _settles(String? reported) =>+ _expected == null ? reported == null : reported != null;++ /// Ask an open menu to rebuild, safely from anywhere — including mid-build.+ void _redrawOpenMenu() {+ final entry = _entry;+ if (entry == null) return;+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (mounted && _entry == entry) entry.markNeedsBuild();+ });+ }+/// The answer the OPEN menu is drawing, and the overlay entry drawing it. Both set only while a/// menu is showing. A refresh that lands while the menu is open swaps the first and rebuilds/// the second, so a model that came up since the last open appears in THIS one rather than the@@ -136,6 +216,7 @@ class _GridModelPickerState extends State<GridModelPicker> {@overridevoid dispose() {+ _expiry?.cancel();// A pane can go away under an open menu — closed, moved, or its swarm switched — and an overlay// entry outlives the State that inserted it._close?.call();@@ -147,12 +228,12 @@ class _GridModelPickerState extends State<GridModelPicker> {/// show. Null off a grid whatever the daemon said: a frame can lag a move home by a beat, and/// the Subscription row must never wear a sentence about a launch it was no part of.String? get _webSearchSentence =>- widget.currentModel == null ? null : widget.webSearch?.sentence;+ _effectiveModel == null ? null : widget.webSearch?.sentence;/// The subtitle under one Local row: the sentence for the CURRENT model only. The status is about/// this agent's launch, and the other rows are places it could go, about which nothing is known.String? _subtitleFor(GridModel model) =>- widget.currentModel == model.id ? _webSearchSentence : null;+ _effectiveModel == model.id ? _webSearchSentence : null;/// The subscription reading for THIS agent's engine, or null when there is none to show.///@@ -219,81 +300,16 @@ class _GridModelPickerState extends State<GridModelPicker> {final subscription = _subscriptionRow();final chosen = await _showMenu(position: position,- children: (close) => [- paneMenuHeader('Subscription'),- paneMenuItem(- onTap: () => close(const _Choice.ownLogin()),- child: PaneMenuRow(- selected: widget.currentModel == null,- engine: widget.engineLabel,- title:- (subscription?['title'] as String?) ??- engineIdentity(widget.engineLabel).label,- detail: (subscription?['account'] as String?) ?? '',- // Absent rather than "unknown": a row that cannot say how much is left says nothing,- // which reads as "no figure" instead of as a figure that happens to be missing.- status: subscription?['status'] as String?,- ),- ),- Divider(height: 9, thickness: 1, color: AppColors.border),- // One section per grid with something to offer, the account's own first as "Local"- // (its rows are the user's own computers), the shared ones by name — the same shape as- // Subscription above, so a model on a team's grid is one row away like any other.- // With no grid at all there is still a "Local" heading, so the sentence under it has a- // place to be. Each heading carries a few words saying what the group is: a grid's name- // alone ("autonomous.ai") over a model's id read as two entries of the same kind.- for (final (index, section) in _sectionsToDraw(_shown!).indexed) ...[- if (index > 0) const SizedBox(height: 4),- // Own: one plain sentence, nothing under it — "your machines" was a second half of the- // same fact and read oddly split onto its own clause. Shared: the general fact as the- // heading, the specific grid as the name under it — the two are different kinds of- // information (why the rows are here vs. which fleet they are), not one sentence.- section.own- ? paneMenuHeader('Local models on your machines')- : paneMenuHeader('Models shared with you', caption: section.name),- // An engine with no way onto a Local model (Cursor talks only to its own API; the- // daemon refuses the move) is told so here, instead of being offered rows whose click- // would do nothing. The daemon names the capable engines beside the list; an older- // daemon names none, and then every row is offered as before.- if (!_shown!.canRunLocally(widget.engineLabel))- paneMenuEmpty(- '${engineIdentity(widget.engineLabel).label} can only run on its own login.',- )- // Two different facts, two sentences. "We could not ask" and "this account has no- // grid" send a person to two different places, and the one that used to cover both- // told a signed-in user to sign in again. "The grid is serving nothing" is NOT a- // sentence here: the "Open Grid" row that ends the menu is the answer, and a line- // saying the list is empty above an empty list is noise.- else if (section.models.isEmpty &&- _emptySentence(_shown!, section) != null)- paneMenuEmpty(_emptySentence(_shown!, section)!),- if (_shown!.canRunLocally(widget.engineLabel))- for (final model in section.models)- paneMenuItem(- onTap: () => close(_Choice.model(model)),- child: PaneMenuRow(- selected: widget.currentModel == model.id,- title: model.id,- // Which machine answers it — on the own grid one of the user's own computers,- // which is the useful part of the answer.- status: model.node.isEmpty ? null : model.node,- subtitle: _subtitleFor(model),- ),- ),- ],- // The way to GET a Local model, under the ones there are and behind a rule of its own.- //- // Not a row among the models: those are places this agent can go, and this starts something- // instead. Not on the section's own line either — that put a button beside a heading, two- // different kinds of thing sharing a line and competing for the same glance. A captioned- // rule says plainly that what follows answers a different question, and the button spans- // the menu so it reads as the section's one action rather than as a wider row.- //- // Offered whatever THIS pane's engine can do: it opens a new pane, on an engine that can.- _ManagerInvitation(- onPressed: () => close(const _Choice.runLocalModel()),- ),- ],+ body: (close) => _ModelPickerPanel(+ answer: _shown!,+ engineLabel: widget.engineLabel,+ currentModel: _effectiveModel,+ subscription: subscription,+ sections: _sectionsToDraw(_shown!),+ subtitleFor: _subtitleFor,+ emptySentence: (section) => _emptySentence(_shown!, section),+ close: close,+ ),);if (chosen == null) return;if (chosen.runLocalModel) {@@ -302,10 +318,14 @@ class _GridModelPickerState extends State<GridModelPicker> {}// Selecting what is already selected respawns the pane for no reason — do nothing instead.if (chosen.model == null) {- if (widget.currentModel != null) widget.onUseOwnLogin?.call();+ if (_effectiveModel != null) {+ _expect(null);+ widget.onUseOwnLogin?.call();+ }return;}- if (chosen.model!.id != widget.currentModel) {+ if (chosen.model!.id != _effectiveModel) {+ _expect(chosen.model!.id);widget.onSelected?.call(chosen.model!);}}@@ -358,11 +378,13 @@ class _GridModelPickerState extends State<GridModelPicker> {/// open menu can take the menu with it.Future<_Choice?> _showMenu({required RelativeRect position,- required List<Widget> Function(void Function(_Choice?) close) children,+ required Widget Function(void Function(_Choice?) close) body,}) => showPaneMenu<_Choice>(context: context,position: position,- children: children,+ body: body,+ minWidth: kModelPickerWidth,+ maxWidth: kModelPickerWidth,onOpen: (entry, close) {_entry = entry;_close = close;@@ -384,7 +406,9 @@ class _GridModelPickerState extends State<GridModelPicker> {if (!mounted || entry == null || fresh == null || shown == null) return;if (_sameAnswer(fresh, shown)) return;_shown = fresh;- entry.markNeedsBuild();+ // One safe path for every redraw — see [_redrawOpenMenu]. This one arrives off an async read+ // and so is usually clear of the build phase, but "usually" is what the crash was.+ _redrawOpenMenu();}static bool _sameAnswer(GridModels a, GridModels b) {@@ -490,93 +514,212 @@ class _GridModelPickerState extends State<GridModelPicker> {}}-/// The invitation that closes the Local section: a captioned rule, then the one ACTION in this menu.-///-/// Everything above is a destination — pick it and the agent moves. This starts something instead,-/// and the rule is what says so before the button is read: a line that names a different question,-/// so the button under it is not scanned as one more place to go.+/// The picker's panel: a search field that stays put, the sections scrolling under it, and a+/// footer that stays put below.///-/// The spacing is the point as much as the parts. A rule tight against the last model reads as a-/// separator between two rows rather than the end of a list, and a button pressed against its own-/// caption reads as one block of chrome; both were tried. The gaps here are deliberately larger-/// than the row rhythm above, because this is where the menu stops listing and starts offering.-class _ManagerInvitation extends StatefulWidget {- const _ManagerInvitation({required this.onPressed});+/// Stateful because the query is: the menu is an overlay entry the picker rebuilds whenever a+/// refresh lands, and a query held by the picker would be rebuilt away mid-typing.+class _ModelPickerPanel extends StatefulWidget {+ const _ModelPickerPanel({+ required this.answer,+ required this.engineLabel,+ required this.currentModel,+ required this.subscription,+ required this.sections,+ required this.subtitleFor,+ required this.emptySentence,+ required this.close,+ });- final VoidCallback onPressed;+ final GridModels answer;+ final String? engineLabel;+ final String? currentModel;+ final Map<String, Object?>? subscription;+ final List<GridSection> sections;+ final String? Function(GridModel) subtitleFor;+ final String? Function(GridSection) emptySentence;+ final void Function(_Choice?) close;@override- State<_ManagerInvitation> createState() => _ManagerInvitationState();+ State<_ModelPickerPanel> createState() => _ModelPickerPanelState();}-class _ManagerInvitationState extends State<_ManagerInvitation> {- bool _hovered = false;+class _ModelPickerPanelState extends State<_ModelPickerPanel> {+ final _query = TextEditingController();+ String _needle = '';++ @override+ void dispose() {+ _query.dispose();+ super.dispose();+ }++ /// Models matching the query. The MACHINE counts as well as the model: "which of these is on+ /// zeus" is the same question as "where is DeepSeek", and a search that read only ids would+ /// answer one of them.+ List<GridModel> _matching(GridSection section) {+ if (_needle.isEmpty) return section.models;+ final needle = _needle.toLowerCase();+ return section.models+ .where(+ (m) =>+ m.id.toLowerCase().contains(needle) ||+ m.node.toLowerCase().contains(needle),+ )+ .toList();+ }++ bool get _subscriptionMatches {+ if (_needle.isEmpty) return true;+ final title =+ (widget.subscription?['title'] as String?) ??+ engineIdentity(widget.engineLabel).label;+ final account = (widget.subscription?['account'] as String?) ?? '';+ final needle = _needle.toLowerCase();+ return title.toLowerCase().contains(needle) ||+ account.toLowerCase().contains(needle);+ }++ /// Amber once the tightest window is nearly out, so the bar and the figure agree.+ static const _lowWater = 20.0;@overrideWidget build(BuildContext context) {- return Padding(- // Wider than a row's inset on purpose: this block is not one of them.- padding: const EdgeInsets.fromLTRB(- kPaneMenuInset + kPaneMenuRowPadding,- 12,- kPaneMenuInset + kPaneMenuRowPadding,- 4,- ),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- Row(- mainAxisAlignment: MainAxisAlignment.center,- children: [- Container(width: 12, height: 1, color: AppColors.border),- const SizedBox(width: 8),- Flexible(- child: Text(- 'Manage the models on your machines',- textAlign: TextAlign.center,- style: AppType.caption(color: AppColors.mutedStrong),- ),- ),- const SizedBox(width: 8),- Container(width: 12, height: 1, color: AppColors.border),- ],+ final canRunLocally = widget.answer.canRunLocally(widget.engineLabel);+ final sections = widget.sections;+ final total = sections.fold<int>(0, (n, s) => n + _matching(s).length);+ final rows = <Widget>[];++ if (_subscriptionMatches) {+ rows+ ..add(const ModelPickerSectionHeader(label: 'Subscription'))+ ..add(_subscriptionRowWidget());+ }+ for (final section in sections) {+ final models = canRunLocally ? _matching(section) : const <GridModel>[];+ // A section a search has emptied says nothing: the query is the reason, and repeating+ // "nothing here" under every heading turns one empty result into a wall of them.+ if (_needle.isNotEmpty && models.isEmpty) continue;+ rows.add(+ ModelPickerSectionHeader(+ label: section.own ? 'On your machines' : 'Shared · ${section.name}',+ count: models.length,+ ),+ );+ if (!canRunLocally) {+ rows.add(+ _panelSentence(+ '${engineIdentity(widget.engineLabel).label} can only run on its own login.',),- const SizedBox(height: 9),- MouseRegion(- cursor: SystemMouseCursors.click,- onEnter: (_) => setState(() => _hovered = true),- onExit: (_) => setState(() => _hovered = false),- child: InkWell(- onTap: widget.onPressed,- child: Container(- // Full width, so it reads as the section's one action rather than as a wider row.- width: double.infinity,- alignment: Alignment.center,- padding: const EdgeInsets.symmetric(vertical: 8),- decoration: BoxDecoration(- color: _hovered ? AppColors.selected : Colors.transparent,- border: Border.all(color: AppColors.border),- borderRadius: BorderRadius.circular(6),- ),- child: Text(- 'Open Grid',- style: AppType.label(- color: _hovered ? AppColors.text : AppColors.textSoft,- ),- ),- ),+ );+ continue;+ }+ if (models.isEmpty) {+ final sentence = widget.emptySentence(section);+ if (sentence != null) rows.add(_panelSentence(sentence));+ continue;+ }+ for (final model in models) {+ rows.add(+ Padding(+ padding: const EdgeInsets.only(bottom: 2),+ child: ModelPickerRow(+ title: model.id,+ subtitle: model.node,+ selected: widget.currentModel == model.id,+ avatar: ModelAvatar(label: model.id),+ note: null,+ onTap: () => widget.close(_Choice.model(model)),),),- ],+ );+ }+ }+ if (rows.isEmpty) rows.add(_panelSentence('Nothing matches “$_needle”.'));++ return Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Padding(+ padding: const EdgeInsets.fromLTRB(12, 12, 12, 2),+ child: ModelPickerSearch(+ controller: _query,+ onChanged: (value) => setState(() => _needle = value.trim()),+ ),+ ),+ Flexible(+ child: SingleChildScrollView(+ padding: const EdgeInsets.fromLTRB(12, 0, 12, 10),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: rows,+ ),+ ),+ ),+ ModelPickerFooter(+ summary: total == 1 ? '1 model available' : '$total models available',+ actionLabel: 'Manage in Grid',+ onAction: () => widget.close(const _Choice.runLocalModel()),+ ),+ ],+ );+ }++ Widget _subscriptionRowWidget() {+ final percent = widget.subscription?['remainingPercent'];+ final low = percent is double && percent <= _lowWater;+ final status = widget.subscription?['status'] as String?;+ final account = (widget.subscription?['account'] as String?) ?? '';+ return ModelPickerRow(+ title:+ (widget.subscription?['title'] as String?) ??+ engineIdentity(widget.engineLabel).label,+ // The account, said as what it is. A bare `7f0c59` under a provider's name read as part of+ // the name rather than as the key it identifies.+ subtitle: account.isEmpty ? '' : 'key ···$account',+ selected: widget.currentModel == null,+ avatar: ModelAvatar(+ label: widget.engineLabel ?? '',+ child: EngineMark(engine: widget.engineLabel, size: 17),),+ // Absent rather than "unknown": a row that cannot say how much is left says nothing, which+ // reads as "no figure" instead of as a figure that happens to be missing.+ trailing: status == null+ ? null+ : Column(+ crossAxisAlignment: CrossAxisAlignment.end,+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ percent is double ? '${percent.floor()}% left' : status,+ style: AppType.body(+ color: low ? AppColors.warning : AppColors.textSoft,+ ).copyWith(fontSize: 12.5, fontWeight: FontWeight.w600),+ ),+ if (percent is double) ...[+ const SizedBox(height: 2),+ Text(+ low ? 'Running low' : 'Healthy',+ style: AppType.body(+ color: AppColors.muted,+ ).copyWith(fontSize: 11),+ ),+ ],+ ],+ ),+ meter: percent is double ? percent / 100 : null,+ note: low ? AppColors.warning : AppColors.accent,+ onTap: () => widget.close(const _Choice.ownLogin()),);}++ Widget _panelSentence(String text) => Padding(+ padding: const EdgeInsets.fromLTRB(9, 4, 9, 8),+ child: Text(text, style: AppType.body(color: AppColors.textSoft)),+ );}-/// One row's meaning: a grid model, the engine's own login, or the action that starts a local-/// model. A sealed set rather than a nullable `GridModel`, because `null` already means "the menu-/// was dismissed" in `showMenu`'s own result — and the action is neither a model nor a login, so-/// it carries its own flag rather than borrowing `model == null` from the login row.class _Choice {final GridModel? model;final bool runLocalModel;diff --git a/desktop/lib/widgets/model_picker_chrome.dart b/desktop/lib/widgets/model_picker_chrome.dartnew file mode 100644index 000000000..6ccdbc554--- /dev/null+++ b/desktop/lib/widgets/model_picker_chrome.dart@@ -0,0 +1,374 @@+/// The model picker's own furniture: the search field, the section headings, the rows and the+/// footer that closes the panel.+///+/// Kept here rather than in `pane_menu.dart` because this is ONE menu's look, not the shape every+/// pane menu shares. The find bar and the New Harness box draw their rows from `PaneMenuRow`, and+/// a model picker that wanted an avatar, a second line and a quota meter would have dragged all of+/// them somewhere they never asked to go.+///+/// Everything here is presentation and nothing here decides: what a row means, whether it can be+/// chosen, and what happens when it is are all the picker's ([GridModelPicker]).+library;++import 'package:flutter/material.dart';++import '../shared/theme/app_type.dart';+import '../theme/app_theme.dart';++/// The panel's own width. Narrower than a row list, because every row here is two lines and the+/// eye reads a column better than a stripe.+const double kModelPickerWidth = 376;++/// The avatar's side, and the gutter its column occupies on every row.+const double kModelAvatarSize = 34;++/// One tile per model, lettered and tinted.+///+/// The tint is DERIVED from the id rather than assigned, so the same model wears the same colour+/// in every section and on every machine — the point of a coloured tile is that it is recognisable+/// before it is read, which an arbitrary per-list colour would defeat.+class ModelAvatar extends StatelessWidget {+ const ModelAvatar({super.key, required this.label, this.child});++ /// What the tile is lettered with. The first letter or digit of the model's id.+ final String label;++ /// Drawn instead of the letter — a subscription's own logo.+ final Widget? child;++ /// The tints, in the order [_tintFor] walks them. Low-alpha so they read as a surface rather+ /// than as a badge, with the letter carrying the saturated version of the same hue.+ static const _tints = <(Color, Color)>[+ (Color(0xFF6D5BD0), Color(0xFFC3B9F5)), // violet+ (Color(0xFF2F5BEA), Color(0xFFAFC4FA)), // blue+ (Color(0xFF1F8A5B), Color(0xFFA9E2C7)), // green+ (Color(0xFFC77A16), Color(0xFFF2D19B)), // amber+ (Color(0xFFB84A6A), Color(0xFFF1B3C4)), // rose+ (Color(0xFF1B8A99), Color(0xFFA6DFE6)), // teal+ ];++ static (Color, Color) _tintFor(String seed) {+ if (seed.isEmpty) return _tints.first;+ var hash = 0;+ for (final unit in seed.codeUnits) {+ hash = (hash * 31 + unit) & 0x7FFFFFFF;+ }+ return _tints[hash % _tints.length];+ }++ /// The one character a model is lettered with: its first letter or digit, so `Qwen/Qwen3.8` and+ /// `qwen3.8` letter the same and a leading slash or dash letters as nothing.+ static String initialOf(String id) {+ for (final rune in id.runes) {+ final ch = String.fromCharCode(rune);+ if (RegExp(r'[A-Za-z0-9]').hasMatch(ch)) return ch.toUpperCase();+ }+ return '?';+ }++ @override+ Widget build(BuildContext context) {+ final (fill, ink) = _tintFor(label);+ return Container(+ width: kModelAvatarSize,+ height: kModelAvatarSize,+ alignment: Alignment.center,+ decoration: BoxDecoration(+ color: child != null ? AppColors.surface : fill.withValues(alpha: 0.30),+ borderRadius: BorderRadius.circular(9),+ ),+ child:+ child ??+ Text(+ initialOf(label),+ style: AppType.body(+ color: ink,+ ).copyWith(fontWeight: FontWeight.w600, fontSize: 13),+ ),+ );+ }+}++/// The field that narrows the list. Its own widget so the panel can keep the query and rebuild+/// only the rows under it.+class ModelPickerSearch extends StatelessWidget {+ const ModelPickerSearch({+ super.key,+ required this.controller,+ required this.onChanged,+ });++ final TextEditingController controller;+ final ValueChanged<String> onChanged;++ @override+ Widget build(BuildContext context) => Container(+ height: 44,+ padding: const EdgeInsets.symmetric(horizontal: 12),+ decoration: BoxDecoration(+ color: AppColors.surface,+ borderRadius: BorderRadius.circular(10),+ border: Border.all(color: AppColors.border),+ ),+ child: Row(+ children: [+ Icon(Icons.search, size: 16, color: AppColors.mutedStrong),+ const SizedBox(width: 9),+ Expanded(+ child: TextField(+ controller: controller,+ onChanged: onChanged,+ autofocus: true,+ style: AppType.body(color: AppColors.text),+ cursorColor: AppColors.text,+ decoration: InputDecoration(+ isCollapsed: true,+ border: InputBorder.none,+ hintText: 'Search models or machines',+ hintStyle: AppType.body(color: AppColors.muted),+ ),+ ),+ ),+ ],+ ),+ );+}++/// A section's heading: what the group is, in small caps, with how many rows are under it.+///+/// The count is on the right and quiet. It answers "is the thing I want even here" before the eye+/// walks the list, which matters most in the section a search has just emptied.+class ModelPickerSectionHeader extends StatelessWidget {+ const ModelPickerSectionHeader({+ super.key,+ required this.label,+ this.count,+ });++ final String label;+ final int? count;++ @override+ Widget build(BuildContext context) => Padding(+ padding: const EdgeInsets.fromLTRB(4, 14, 4, 8),+ child: Row(+ children: [+ Expanded(+ child: Text(+ label.toUpperCase(),+ style: AppType.body(color: AppColors.mutedStrong).copyWith(+ fontSize: 11,+ fontWeight: FontWeight.w700,+ letterSpacing: 0.9,+ ),+ ),+ ),+ if (count != null)+ Text(+ '$count',+ style: AppType.body(color: AppColors.muted).copyWith(fontSize: 11),+ ),+ ],+ ),+ );+}++/// One model, as two lines beside its tile.+///+/// The id leads because it is what the person is choosing; the machine or account under it is how+/// they tell two copies of the same model apart. Both were one line and one weight before, which+/// made a row of `DeepSeek-V4-Flash-0731 scholes-60001` read as a single compound name.+class ModelPickerRow extends StatelessWidget {+ const ModelPickerRow({+ super.key,+ required this.title,+ required this.subtitle,+ required this.selected,+ required this.onTap,+ this.avatar,+ this.trailing,+ this.meter,+ this.note,+ });++ final String title;+ final String subtitle;+ final bool selected;+ final VoidCallback onTap;+ final Widget? avatar;++ /// The right-hand column — a quota, a state, whatever the row is worth saying.+ final Widget? trailing;++ /// 0..1, drawn as a bar under the row. Only the subscription has one.+ final double? meter;++ /// The colour the meter runs in; ignored when [meter] is null.+ final Color? note;++ @override+ Widget build(BuildContext context) {+ final row = Row(+ crossAxisAlignment: CrossAxisAlignment.center,+ children: [+ if (avatar != null) ...[avatar!, const SizedBox(width: 11)],+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ title,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppType.body(+ color: AppColors.text,+ ).copyWith(fontWeight: FontWeight.w600, fontSize: 13.5),+ ),+ if (subtitle.isNotEmpty) ...[+ const SizedBox(height: 2),+ Text(+ subtitle,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppType.mono(color: AppColors.mutedStrong),+ ),+ ],+ ],+ ),+ ),+ if (trailing != null) ...[const SizedBox(width: 10), trailing!],+ // The tick's gutter, reserved on every row so a row becoming the chosen one does not+ // shuffle the column beside it.+ SizedBox(+ width: 20,+ child: selected+ ? Icon(+ Icons.check,+ size: 16,+ color: AppColors.accent,+ semanticLabel: 'Selected',+ )+ : null,+ ),+ ],+ );+ return MouseRegion(+ cursor: SystemMouseCursors.click,+ child: InkWell(+ onTap: onTap,+ mouseCursor: SystemMouseCursors.click,+ borderRadius: BorderRadius.circular(11),+ hoverColor: AppColors.rowHover,+ // Focus is a keyboard position, not a decision, and the panel focuses something the moment+ // it opens; painting it would light a row the person never pointed at.+ focusColor: Colors.transparent,+ splashColor: Colors.transparent,+ highlightColor: Colors.transparent,+ child: Container(+ padding: const EdgeInsets.fromLTRB(9, 9, 9, 9),+ decoration: BoxDecoration(+ color: selected ? AppColors.selected : null,+ borderRadius: BorderRadius.circular(11),+ border: selected+ ? Border.all(color: AppColors.accent.withValues(alpha: 0.45))+ : null,+ ),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ row,+ if (meter != null) ...[+ const SizedBox(height: 9),+ ClipRRect(+ borderRadius: BorderRadius.circular(3),+ child: LinearProgressIndicator(+ value: meter!.clamp(0, 1),+ minHeight: 5,+ backgroundColor: AppColors.border,+ valueColor: AlwaysStoppedAnimation(+ note ?? AppColors.accent,+ ),+ ),+ ),+ ],+ ],+ ),+ ),+ ),+ );+ }+}++/// The bar that closes the panel: what the list adds up to, and the one action that is not a+/// choice among the rows.+class ModelPickerFooter extends StatelessWidget {+ const ModelPickerFooter({+ super.key,+ required this.summary,+ required this.actionLabel,+ required this.onAction,+ });++ final String summary;+ final String actionLabel;+ final VoidCallback onAction;++ @override+ Widget build(BuildContext context) => Container(+ padding: const EdgeInsets.fromLTRB(14, 10, 12, 12),+ decoration: BoxDecoration(+ border: Border(top: BorderSide(color: AppColors.border)),+ ),+ child: Row(+ children: [+ Expanded(+ child: Text(+ summary,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppType.body(color: AppColors.muted).copyWith(fontSize: 12),+ ),+ ),+ MouseRegion(+ cursor: SystemMouseCursors.click,+ child: InkWell(+ onTap: onAction,+ mouseCursor: SystemMouseCursors.click,+ borderRadius: BorderRadius.circular(9),+ hoverColor: AppColors.rowHover,+ focusColor: Colors.transparent,+ splashColor: Colors.transparent,+ highlightColor: Colors.transparent,+ child: Container(+ padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 9),+ decoration: BoxDecoration(+ color: AppColors.surface,+ borderRadius: BorderRadius.circular(9),+ border: Border.all(color: AppColors.border),+ ),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ Icon(+ Icons.grid_view_rounded,+ size: 15,+ color: AppColors.textSoft,+ ),+ const SizedBox(width: 8),+ Text(+ actionLabel,+ style: AppType.body(color: AppColors.text).copyWith(+ fontSize: 12.5,+ fontWeight: FontWeight.w600,+ ),+ ),+ ],+ ),+ ),+ ),+ ),+ ],+ ),+ );+}diff --git a/desktop/lib/widgets/pane_menu.dart b/desktop/lib/widgets/pane_menu.dartindex 51de2c0ec..6641e03c3 100644--- a/desktop/lib/widgets/pane_menu.dart+++ b/desktop/lib/widgets/pane_menu.dart@@ -32,12 +32,17 @@ import 'transient_menus.dart';Future<T?> showPaneMenu<T>({required BuildContext context,required RelativeRect position,- required List<Widget> Function(void Function(T?) close) children,+ List<Widget> Function(void Function(T?) close)? children,+ Widget Function(void Function(T?) close)? body,void Function(OverlayEntry entry, void Function() close)? onOpen,VoidCallback? onClose,double minWidth = 340,double maxWidth = 540,}) {+ assert(+ (children == null) != (body == null),+ 'a pane menu is either a list of rows or one body widget, never both',+ );final overlayState = Overlay.of(context);final completer = Completer<T?>();final previousFocus = FocusManager.instance.primaryFocus;@@ -75,20 +80,25 @@ Future<T?> showPaneMenu<T>({delegate: _PaneMenuPosition(position, minWidth, maxWidth),child: _PaneMenuFocus(close: () => close(null),- child: IntrinsicWidth(- child: TerminalBox(- child: SingleChildScrollView(- child: Padding(- padding: const EdgeInsets.symmetric(vertical: 6),- child: Column(- mainAxisSize: MainAxisSize.min,- crossAxisAlignment: CrossAxisAlignment.stretch,- children: children(close),+ // A row list sizes itself to its widest row ([IntrinsicWidth]) and scrolls as one+ // column. A BODY does neither: it is handed the menu's box and lays itself out, which+ // is what a panel with something pinned above and below a scrolling middle needs.+ child: body != null+ ? TerminalBox(child: body(close))+ : IntrinsicWidth(+ child: TerminalBox(+ child: SingleChildScrollView(+ child: Padding(+ padding: const EdgeInsets.symmetric(vertical: 6),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: children!(close),+ ),+ ),+ ),),),- ),- ),- ),),),],@@ -202,6 +212,12 @@ class _PaneMenuFocusState extends State<_PaneMenuFocus> {/// InkWell around the whole item painted edge to edge and square, over a selected fill that was/// neither, and the two reading as different shapes made the current row look like the odd one/// out.+///+/// Same SHAPE, one fill. The fill belongs to the CHOSEN row and to nothing else: focus paints+/// none at all (it is a keyboard position, not a decision) and hover paints the weaker+/// [AppColors.rowHover], which moves with the pointer and so can never be mistaken for where the+/// agent is. A tick was tried and taken out again — the fill is the whole signal, and a second one+/// beside it was a column every row paid for./// ⚠️ The cursor is STATED, in both places that can answer for it. A pane menu is drawn in an/// overlay above a terminal, and what a person sees while hovering a row was whatever the surface/// underneath asked for — an arrow over rows that are the whole point of the menu. `InkWell` carries@@ -218,6 +234,21 @@ Widget paneMenuItem({required VoidCallback onTap, required Widget child}) =>onTap: onTap,mouseCursor: SystemMouseCursors.click,borderRadius: BorderRadius.circular(kPaneMenuRowRadius),+ // ⚠️ STATED, all three. Left to the Material default the hover landed close enough to+ // the selected fill to be indistinguishable, so the row under the pointer and the row+ // the agent is actually on looked equally chosen — two highlights, one menu. The+ // palette has always had a weaker tone for exactly this ([AppColors.rowHover]); the+ // menu simply never asked for it. Splash and highlight go transparent because an ink+ // ripple is a THIRD fill on the same rectangle, and it lingers after the tap.+ hoverColor: AppColors.rowHover,+ splashColor: Colors.transparent,+ highlightColor: Colors.transparent,+ // ⚠️ The one that actually put two highlights on screen. The menu moves focus to its+ // FIRST row as it opens (`_PaneMenuFocus`, so Enter activates something), and an InkWell+ // paints focus with a fill of its own — so the top row was lit before the pointer moved+ // and the agent's real row was lit too. Focus is a keyboard position, not a choice; only+ // the chosen row is filled.+ focusColor: Colors.transparent,child: child,),),@@ -301,17 +332,34 @@ class PaneMenuRow extends StatelessWidget {@overrideWidget build(BuildContext context) {+ // Trailing metadata, as its own bounded column. Bounded rather than flexible: a `Flexible`+ // here has a flex of ONE, so the row's spare width was split evenly between the title and+ // every metadata field beside it — which put the account column a third of the way across a+ // subscription row and a machine column halfway across a model row, three columns at three+ // different offsets down one menu. What each field actually wants is its own width, at the+ // right-hand edge, with the title absorbing the slack.+ Widget meta(String text) => ConstrainedBox(+ constraints: const BoxConstraints(maxWidth: kPaneMenuMetaMaxWidth),+ child: Text(+ text,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppType.mono(color: AppColors.mutedStrong),+ ),+ );final row = Row(children: [+ // The mark is the row's own, and rows without one do NOT reserve its width. A gutter on+ // every row would line up the handful of rows that carry a logo by indenting every row+ // that does not — the same trade the tick column was removed for, and the same answer.if (engine != null) ...[- EngineMark(engine: engine, size: 14),+ EngineMark(engine: engine, size: kPaneMenuMarkSize),const SizedBox(width: 7),] else if (leading != null) ...[leading!,const SizedBox(width: 7),],- // The title gets spare width; trailing metadata may ellipsize when- // the combined line is too wide.+ // The title takes the slack, so every metadata column lands at the right-hand edge.Expanded(child: Text(title,@@ -321,28 +369,8 @@ class PaneMenuRow extends StatelessWidget {style: AppType.mono(color: AppColors.text),),),- if (detail.isNotEmpty) ...[- const SizedBox(width: 6),- Flexible(- child: Text(- detail,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppType.mono(color: AppColors.mutedStrong),- ),- ),- ],- if (status != null) ...[- const SizedBox(width: 14),- Flexible(- child: Text(- status!,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppType.mono(color: AppColors.mutedStrong),- ),- ),- ],+ if (detail.isNotEmpty) ...[const SizedBox(width: 12), meta(detail)],+ if (status != null) ...[const SizedBox(width: 12), meta(status!)],],);return Container(@@ -386,5 +414,15 @@ class PaneMenuRow extends StatelessWidget {const double kPaneMenuInset = 6;const double kPaneMenuRowPadding = 8;+/// A row's leading mark, when it has one. Not reserved on rows that do not.+const double kPaneMenuMarkSize = 14;++/// How wide one trailing metadata column may grow before it ellipsizes.+///+/// A cap rather than a flex share: the menu itself is capped, and a field allowed to take half of+/// it would crowd out the thing the row is actually named after. Past this the account, the+/// machine or the quota loses its tail — never the model's id.+const double kPaneMenuMetaMaxWidth = 168;+/// One radius for the hover and the selected fill: they are the same shape.const double kPaneMenuRowRadius = 5;diff --git a/desktop/test/grid_model_picker_test.dart b/desktop/test/grid_model_picker_test.dartindex 45697f0aa..6b5d7fba9 100644--- a/desktop/test/grid_model_picker_test.dart+++ b/desktop/test/grid_model_picker_test.dart@@ -9,7 +9,10 @@ import 'package:harness/auth/auth_session.dart';import 'package:harness/core/config.dart';import 'package:harness/core/models.dart';import 'package:harness/state/app_state.dart';+import 'package:harness/theme/app_theme.dart';import 'package:harness/widgets/grid_model_picker.dart';+import 'package:harness/widgets/model_picker_chrome.dart';+import 'package:harness/widgets/pane_menu.dart';import 'package:harness/ws/ws_conn.dart';/// A connection that answers the picker's one RPC immediately. Without it the menu waits out the@@ -567,11 +570,12 @@ void main() {});testWidgets(- 'the current row is marked by a highlight, not by a tick column',+ 'the current row is marked by a highlight, and nothing else is',(tester) async {- // The tick reserved a fixed column at the start of EVERY row to keep labels aligned, which cost- // every row that indent for one row's sake. Filling the current row instead says the same thing- // and gives the space back.+ // A tick was tried twice and dropped twice: it costs a column on every row to say what the+ // fill already says. What actually lit two rows at once was FOCUS — the menu focuses its+ // first row as it opens so Enter has a target, and an InkWell paints focus with a fill.+ // Focus paints nothing now, so the fill means exactly one thing.build(models: [{'id': 'Qwen3.6-35B-A3B-UD-Q5_K_XL', 'node': 'macbook-m1max'},@@ -955,4 +959,265 @@ void main() {},);});++ // ── two rows highlighted at once ──────────────────────────────────────────────────────────────+ //+ // The subscription row and a model row appeared equally chosen. Neither was wrong about itself:+ // one was SELECTED and the other was merely under the pointer, and both were painted the same+ // fill, so the menu said "you are here" twice.++ testWidgets('hover is its own colour, weaker than the selected fill', (tester) async {+ build(models: [{'id': 'Qwen-Test', 'node': 'macbook'}]);+ await open(tester, currentModel: 'Qwen-Test');++ // The ROW items specifically — the menu also holds a button, which is its own shape and has no+ // business wearing a row's hover.+ final wells = tester+ .widgetList<InkWell>(+ find.ancestor(of: find.byType(PaneMenuRow), matching: find.byType(InkWell)),+ )+ .toList();+ expect(wells, isNotEmpty);+ for (final well in wells) {+ // Stated, not inherited: the Material default sat close enough to the selected fill to be+ // indistinguishable, which is the whole of the reported bug.+ expect(well.hoverColor, AppColors.rowHover);+ // An ink ripple is a THIRD fill on the same rectangle and it lingers past the tap.+ expect(well.splashColor, Colors.transparent);+ expect(well.highlightColor, Colors.transparent);+ // The one that lit the top row before the pointer had moved: the menu focuses its first row+ // on open, and an InkWell paints focus with a fill unless told otherwise.+ expect(well.focusColor, Colors.transparent);+ }+ expect(AppColors.rowHover, isNot(AppColors.selected));+ expect(AppColors.rowHover.a, lessThan(AppColors.selected.a));+ });++ testWidgets('exactly one row wears the selected fill', (tester) async {+ build(models: [+ {'id': 'Qwen-Test', 'node': 'macbook'},+ {'id': 'DeepSeek-Test', 'node': 'zeus'},+ ]);+ await open(tester, currentModel: 'Qwen-Test');++ BoxDecoration? fillOf(String text) => tester+ .widget<Container>(find.ancestor(of: find.text(text), matching: find.byType(Container)).first)+ .decoration as BoxDecoration?;+ expect(fillOf('Qwen-Test')?.color, AppColors.selected);+ expect(fillOf('DeepSeek-Test')?.color, isNull);+ expect(fillOf('Anthropic')?.color, isNull);+ expect(find.byIcon(Icons.check), findsNothing);+ });++ testWidgets('the subscription row is the selected one when no model is set', (tester) async {+ build(models: [{'id': 'Qwen-Test', 'node': 'macbook'}]);+ await open(tester);++ BoxDecoration? fillOf(String text) => tester+ .widget<Container>(find.ancestor(of: find.text(text), matching: find.byType(Container)).first)+ .decoration as BoxDecoration?;+ expect(fillOf('Anthropic')?.color, AppColors.selected);+ expect(fillOf('Qwen-Test')?.color, isNull);+ expect(find.byIcon(Icons.check), findsNothing);+ });++ // ── the metadata columns ──────────────────────────────────────────────────────────────────────+ //+ // Every trailing field was a `Flexible`, whose flex is ONE — so the row's spare width was split+ // evenly between the title and each field beside it. A subscription row with two fields put them+ // a third and two thirds across; a model row with one put it halfway. Three columns, three+ // offsets, one menu.++ testWidgets('trailing metadata shares one right edge, whatever the row', (tester) async {+ build(models: [+ {'id': 'Qwen-Test', 'node': 'a'},+ {'id': 'DeepSeek-V4-Flash-0731-Vision', 'node': 'firmware-engineer-daniel'},+ ]);+ await open(tester, currentModel: 'Qwen-Test');++ final short = tester.getRect(find.text('a')).right;+ final long = tester.getRect(find.text('firmware-engineer-daniel')).right;+ // Node names of wildly different lengths, one right edge.+ expect((short - long).abs(), lessThan(0.5));++ // And the subscription row's own trailing field lands on that same edge, though its row is+ // built from different parts.+ final subscription = tester.getRect(find.textContaining('usage')).right;+ expect((subscription - short).abs(), lessThan(0.5));+ });++ testWidgets('a long machine name ellipsizes rather than crowding out the model id', (tester) async {+ build(models: [+ {'id': 'Qwen-Test', 'node': 'a-machine-name-far-longer-than-any-column-should-ever-be-allowed-to-grow'},+ ]);+ await open(tester, currentModel: 'Qwen-Test');++ final node = tester.getRect(+ find.text('a-machine-name-far-longer-than-any-column-should-ever-be-allowed-to-grow'),+ );+ expect(node.width, lessThanOrEqualTo(kPaneMenuMetaMaxWidth + 0.5));+ // The row is named after its model, so that is the text that keeps its width.+ expect(tester.getRect(find.text('Qwen-Test')).width, greaterThan(0));+ expect(tester.takeException(), isNull);+ });++ // ── the selection has to land before the machine confirms it ──────────────────────────────────+ //+ // Picking a model RESPAWNS the pane, so `agent.gridModel` — what `currentModel` carries — only+ // changes once the daemon has done the work. The menu reopened with the tick still on the row+ // the person had just left, which reads as the click having done nothing.++ testWidgets('a fresh currentModel while the menu is open does not crash the frame', (tester) async {+ // The first attempt at this redrew the overlay from `didUpdateWidget`, which runs mid-build:+ // "setState() or markNeedsBuild() called during build" across the whole window.+ build(models: [+ {'id': 'Qwen-Test', 'node': 'macbook'},+ {'id': 'DeepSeek-Test', 'node': 'zeus'},+ ]);++ Widget app(String? current) => MaterialApp(+ home: Scaffold(+ body: Center(+ child: GridModelPicker(+ notifier: notifier,+ machineId: 'local',+ engineLabel: 'claude',+ currentModel: current,+ ),+ ),+ ),+ );++ tester.view.physicalSize = const Size(1200, 900);+ tester.view.devicePixelRatio = 1;+ addTearDown(tester.view.reset);+ await tester.pumpWidget(app(null));+ await tester.tap(find.text('Model'));+ await tester.pumpAndSettle();+ expect(find.text('Qwen-Test'), findsOneWidget);++ // The daemon's frame lands while the menu is still open.+ await tester.pumpWidget(app('Qwen-Test'));+ await tester.pumpAndSettle();+ expect(tester.takeException(), isNull);+ });++ /// Open the picker as a rebuildable host, so a test can change `currentModel` under it the way+ /// the daemon's frames do.+ Future<void Function(String?)> openLive(+ WidgetTester tester, {+ String? currentModel,+ ValueChanged<GridModel>? onSelected,+ VoidCallback? onOwnLogin,+ }) async {+ var current = currentModel;+ late StateSetter setHost;+ tester.view.physicalSize = const Size(1200, 900);+ tester.view.devicePixelRatio = 1;+ addTearDown(tester.view.reset);+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: Center(+ child: StatefulBuilder(+ builder: (context, setState) {+ setHost = setState;+ return GridModelPicker(+ notifier: notifier,+ machineId: 'local',+ engineLabel: 'claude',+ currentModel: current,+ onSelected: onSelected,+ onUseOwnLogin: onOwnLogin,+ );+ },+ ),+ ),+ ),+ ),+ );+ await tester.tap(find.text('Model'));+ await tester.pumpAndSettle();+ return (String? next) => setHost(() => current = next);+ }++ bool ticked(WidgetTester tester, String title) => tester+ .widgetList<ModelPickerRow>(find.byType(ModelPickerRow))+ .any((r) => r.title == title && r.selected);++ testWidgets('the tick stays on the picked model through the respawn', (tester) async {+ // A retarget restarts the pane, and a restarting pane reports NO model for a moment. Taking+ // that null as the answer put the tick back on Subscription mid-move, and the row the person+ // clicked only claimed it once the respawn finished — the flicker between two answers.+ build(models: [+ {'id': 'gemma-4-31B-it', 'node': '3d-artist-diego'},+ ]);+ final report = await openLive(tester, currentModel: 'Qwen-Old');++ await tester.tap(find.text('gemma-4-31B-it'));+ await tester.pumpAndSettle();+ await tester.tap(find.text('Model'));+ await tester.pumpAndSettle();+ expect(ticked(tester, 'gemma-4-31B-it'), isTrue);++ // The pane goes down: no model at all.+ report(null);+ await tester.pumpAndSettle();+ expect(ticked(tester, 'gemma-4-31B-it'), isTrue, reason: 'a restarting pane is not an answer');+ expect(ticked(tester, 'Anthropic'), isFalse);++ // And comes back up on what was asked for.+ report('gemma-4-31B-it');+ await tester.pumpAndSettle();+ expect(ticked(tester, 'gemma-4-31B-it'), isTrue);+ });++ testWidgets('a model the menu did not ask for wins over the guess', (tester) async {+ build(models: [+ {'id': 'gemma-4-31B-it', 'node': '3d-artist-diego'},+ {'id': 'Qwen-Test', 'node': 'macbook'},+ ]);+ // Starts on the engine's own login, so the report below is a real CHANGE. A daemon that+ // re-sends the value it already held is not a new answer, and the guess then waits out its+ // own timer rather than being contradicted.+ final report = await openLive(tester, currentModel: null);++ await tester.tap(find.text('gemma-4-31B-it'));+ await tester.pumpAndSettle();+ await tester.tap(find.text('Model'));+ await tester.pumpAndSettle();+ expect(ticked(tester, 'gemma-4-31B-it'), isTrue);++ // The machine says the agent ended up somewhere else. What it says beats what this menu hoped.+ report('Qwen-Test');+ await tester.pumpAndSettle();+ expect(ticked(tester, 'Qwen-Test'), isTrue);+ expect(ticked(tester, 'gemma-4-31B-it'), isFalse);+ });++ testWidgets('choosing the own login is confirmed BY a null, not broken by one', (tester) async {+ build(models: [+ {'id': 'gemma-4-31B-it', 'node': '3d-artist-diego'},+ ]);+ final report = await openLive(tester, currentModel: 'gemma-4-31B-it');++ await tester.tap(find.text('Anthropic'));+ await tester.pumpAndSettle();+ await tester.tap(find.text('Model'));+ await tester.pumpAndSettle();+ expect(ticked(tester, 'Anthropic'), isTrue);++ report(null);+ await tester.pumpAndSettle();+ expect(ticked(tester, 'Anthropic'), isTrue);+ expect(ticked(tester, 'gemma-4-31B-it'), isFalse);++ // And the guess is RELEASED by that confirmation, not merely agreed with: the next thing the+ // machine says has to land. A guess that only ever expired on its clock would hold the tick on+ // Subscription for another half minute after the agent had moved on.+ report('gemma-4-31B-it');+ await tester.pumpAndSettle();+ expect(ticked(tester, 'gemma-4-31B-it'), isTrue);+ expect(ticked(tester, 'Anthropic'), isFalse);+ });}