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 remote-tracking branch 'origin/feat/harness-grid' into feat/harness-grid-websearch

Kelvin258a3cc5d824
diff --cc cli/src/cli.ts
index 44ae3fdc9,500474878..c4b700042
--- a/cli/src/cli.ts
+++ b/cli/src/cli.ts
@@@ -70,7 -68,8 +71,8 @@@ import { claudeContinuation, findLiveSe
import { TmuxBackend } from './lib/tmuxBackend.js'
import { createAndRegisterPane } from './lib/createAgentPane.js'
import { restoreAgents } from './lib/restoreAgents.js'
-import { buildLaunchOverrides, validateLaunchOverrides, type LaunchOverridesDeps, type LaunchOverridesResult, type LaunchSource } from './lib/launchOverrides.js'
+import { buildLaunchOverrides, validateLaunchOverrides, type LaunchOverrides, type LaunchOverridesDeps, type LaunchOverridesResult, type LaunchSource } from './lib/launchOverrides.js'
+ import { prepareCodexResume } from './engines/codex/portableHistory.js'
import { buildHarnessSessionLabel } from './lib/harnessSessionLabel.js'
import { basename } from 'node:path'
import {
@@@ -3370,18 -3375,17 +3373,29 @@@ async function runForeground(session: A
const relaunchOverrides = (session: RegisteredSession, source: LaunchSource = session): Promise<LaunchOverridesResult> =>
buildLaunchOverrides(launchOverridesDeps, session.engine, source, session.agentId)
+ /**
+ * A restart or a post-reboot restore rebuilds the ROW's own launch, and the machine may decide
+ * differently about web search this time than it did when the row was written (an administrator
+ * pinned `/etc/hermes` since, or unpinned it). The override is the row's already; what is
+ * refreshed is the decision, so the frame describes the pane that actually came up. Retarget
+ * does not go through here — its override is new, and it records the pair itself once the move
+ * has succeeded.
+ */
+ const refreshGridWebSearch = (agentId: string, overrides: LaunchOverrides): void => {
+ if (overrides.gridLaunchRecord) registry.setGridLaunch(agentId, overrides.gridLaunchRecord)
+ }
+
+ const prepareSessionResume = (session: RegisteredSession): void => {
+ const repair = prepareCodexResume(session)
+ if (repair.repairedItems) {
+ // The rollout we tail was just shrunk in place. Move the tail to the repaired length now, before
+ // the resumed engine appends, or the watcher would read the whole repaired history as new lines
+ // and the live normalizer would replay the conversation into web/device. See Watcher.setTail.
+ if (repair.repairedBytes !== undefined) watcher.setTail(session.sessionId, repair.repairedBytes)
+ console.log(`[resume] repaired ${repair.repairedItems} Codex reasoning items · backup: ${repair.backupPath}`)
+ }
+ }
+
watcher.start()
await cursorDiscovery.start()
// Panes that died while the daemon was down (a reboot takes the whole tmux server with it) are
@@@ -3404,9 -3408,11 +3418,14 @@@
// own shell.
const built = await relaunchOverrides(entry)
if (!built.ok) return { error: built.error, detail: built.detail }
+ if (opts.resumeSessionId) {
+ try { prepareSessionResume(entry) } catch (error) {
+ return { error: 'RESUME_PREPARATION_FAILED', detail: error instanceof Error ? error.message : String(error) }
+ }
+ }
+ // Before the pane comes up rather than after: restore has no later hook per agent, and a
+ // pane that fails to come up is reported failed by the frame regardless of this field.
+ refreshGridWebSearch(entry.agentId, built.overrides)
const { env: launchEnv, extraArgs, clearEnv } = built.overrides
const argv = buildEngineLaunchArgv(entry.engine, {
...opts,
diff --cc desktop/lib/widgets/grid_model_picker.dart
index 1d30f416e,6f08c8a98..224b8b9cf
--- a/desktop/lib/widgets/grid_model_picker.dart
+++ b/desktop/lib/widgets/grid_model_picker.dart
@@@ -36,16 -36,9 +36,16 @@@ class GridModelPicker extends StatefulW
final VoidCallback? onUseOwnLogin;
/// The grid model this agent is on right now, or null when it is on its own login. Drives the
-- /// checkmark, so the menu answers "where am I" as well as "where could I go".
++ /// filled row, so the menu answers "where am I" as well as "where could I go".
final String? currentModel;
+ /// Whether the agent can search the web on [currentModel], as the daemon decided when it built
+ /// the launch. Shown as a subtitle under the current Local row and in the control's tooltip —
+ /// only for the two degraded values; `on` and null (nothing said) show nothing. Read only when
+ /// [currentModel] is set: it is a fact about a Local-model launch, and the Subscription row has
+ /// its own web tools.
+ final GridWebSearch? webSearch;
+
/// The agent's engine, for the subscription row's icon and label.
final String? engineLabel;
@@@ -67,24 -59,34 +67,45 @@@
class _GridModelPickerState extends State<GridModelPicker> {
bool _loading = false;
ModelsMenuController? _usage;
+ GridModels? _last;
+
+ @override
+ void initState() {
+ super.initState();
+ // Warm the answer as soon as the control exists, so a click lands on a memo rather than on two
+ // subprocess spawns and two network round trips — measured at ~1.4s, which is a person watching
+ // a header do nothing. Fire-and-forget: nothing here waits on it, and a failure just means the
+ // first open pays what it used to.
+ unawaited(_prefetch());
+ }
+
+ Future<void> _prefetch() async {
+ // Created here, not only on the cold path: a warm open reads `_usage.rows` for the subscription
+ // row's provider name and percentage, and skipping it left that row falling back to the bare
+ // engine label with no status beside it.
+ _usage ??= ModelsMenuController(remote: widget.notifier.readRemoteUsage);
+ unawaited(_usage!.refresh().catchError((_) {}));
+ final answer = await widget.notifier.gridModels(widget.machineId);
+ if (mounted) _last = answer;
+ }
+
+ @override
+ void dispose() {
+ _usage?.dispose();
+ super.dispose();
+ }
+ /// The sentence about web search on the current Local model, or null when there is none to
+ /// 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;
+
+ /// 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;
+
- @override
- void dispose() {
- _usage?.dispose();
- super.dispose();
- }
-
/// The subscription reading for THIS agent's engine, or null when there is none to show.
///
/// Built from the same controller the window's own Models menu uses, so the percentage here and
@@@ -160,11 -179,10 +198,12 @@@
PopupMenuItem<_Choice>(
enabled: false,
height: 30,
+ padding: const EdgeInsets.only(left: _menuInset + _rowPadding),
child: Text(
+ // "Local models", in the user's own vocabulary: the grid is how a Local model is
+ // served, not a thing this menu asks anyone to know about.
answer.gridName == null
- ? 'No grid on this account yet — sign in again to set one up.'
+ ? 'No local models on this account yet — sign in again to set them up.'
: 'Nothing is being served yet.',
style: TextStyle(fontSize: 11, color: AppColors.textSoft),
),
@@@ -172,9 -190,8 +211,10 @@@
for (final model in answer.models)
PopupMenuItem<_Choice>(
value: _Choice.model(model),
- height: 32,
+ // Taller only for the current row carrying a sentence; every other row keeps its height
+ // so the menu does not grow for a fact about one agent.
+ height: _subtitleFor(model) != null ? 46 : 32,
+ padding: EdgeInsets.zero,
child: _Row(
selected: widget.currentModel == model.id,
title: model.id,
@@@ -256,9 -270,8 +297,10 @@@
}
}
--/// One menu row: tick, optional engine mark, title, a quiet detail beside it, and a right-aligned
- /// status. The same column order in both sections, so the eye can run straight down the menu. A
- /// [subtitle], when there is one, sits under the title in the same column.
-/// status. The same column order in both sections, so the eye can run straight down the menu.
++/// One menu row: optional engine mark, title, a quiet detail beside it, and a right-aligned
++/// status — filled when it is the current one. The same column order in both sections, so the eye
++/// can run straight down the menu. A [subtitle], when there is one, sits under the title inside
++/// the same fill.
class _Row extends StatelessWidget {
final bool selected;
final String? engine;
@@@ -278,65 -289,55 +320,74 @@@
@override
Widget build(BuildContext context) {
+ final row = Row(
+ children: [
- // A fixed tick column, so every row's label starts at the same x whether or not it is the
- // active one — a menu whose text shifts between rows reads as misaligned. Section headers
- // carry the same inset, which is what lines a header up with the rows under it.
- SizedBox(
- width: _tickColumn,
- child: selected ? Icon(Icons.check, size: 12, color: AppColors.accent) : null,
- ),
+ if (engine != null) ...[
+ EngineMark(engine: engine, size: 14),
+ const SizedBox(width: 7),
+ ],
+ // ⚠️ Expanded on the TITLE, not on the status. The status is a handful of characters and
+ // wants only what it needs; giving it the flexible half truncated
+ // `Qwen3.6-35B-A3B-UD-Q5_K_XL` to `Qwen3.6-35B-A3B-UD-Q5_K…` while empty space sat beside
+ // it. The long string here is the model id, so the model id is what gets the room.
+ Expanded(
+ child: Text(
+ title,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(
+ fontSize: 12.5,
+ // Stated rather than inherited: a PopupMenuItem's default text style is heavier than
+ // this menu wants, which read as every row being emphasised.
+ fontWeight: FontWeight.w400,
+ color: AppColors.text,
+ ),
+ ),
+ ),
+ if (detail.isNotEmpty) ...[
+ const SizedBox(width: 6),
+ Text(detail, style: TextStyle(fontSize: 11, color: AppColors.mutedStrong)),
+ ],
+ if (status != null) ...[
+ const SizedBox(width: 14),
+ Text(
+ status!,
+ style: TextStyle(fontSize: 11, color: AppColors.mutedStrong),
+ ),
+ ],
+ ],
+ );
- if (subtitle == null) return row;
- return Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- row,
- Padding(
- // Behind the tick column, so the sentence starts under the title it is about.
- padding: const EdgeInsets.only(left: _tickColumn, top: 2),
- child: Text(
- subtitle!,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(fontSize: 10.5, color: AppColors.textSoft),
- ),
- ),
- ],
+ return Container(
+ // The highlight is the row, so it needs the row's own inset rather than the item's padding —
+ // which is why the `PopupMenuItem`s around these set `padding: EdgeInsets.zero`.
+ margin: const EdgeInsets.symmetric(horizontal: _menuInset),
+ padding: const EdgeInsets.symmetric(horizontal: _rowPadding, vertical: 5),
+ decoration: selected
+ // Subtle on purpose: one row in the menu is already the current one, and a mark loud
+ // enough to announce that would compete with the thing a person opened the menu to read.
+ ? BoxDecoration(
+ color: AppColors.selected,
+ borderRadius: BorderRadius.circular(5),
+ )
+ : null,
- child: Row(
- children: [
- if (engine != null) ...[
- EngineMark(engine: engine, size: 14),
- const SizedBox(width: 7),
- ],
- // ⚠️ Expanded on the TITLE, not on the status. The status is a handful of characters and
- // wants only what it needs; giving it the flexible half truncated
- // `Qwen3.6-35B-A3B-UD-Q5_K_XL` to `Qwen3.6-35B-A3B-UD-Q5_K…` while empty space sat beside
- // it. The long string here is the model id, so the model id is what gets the room.
- Expanded(
- child: Text(
- title,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: 12.5,
- // Stated rather than inherited: a PopupMenuItem's default text style is heavier than
- // this menu wants, which read as every row being emphasised.
- fontWeight: FontWeight.w400,
- color: AppColors.text,
- ),
- ),
- ),
- if (detail.isNotEmpty) ...[
- const SizedBox(width: 6),
- Text(detail, style: TextStyle(fontSize: 11, color: AppColors.mutedStrong)),
- ],
- if (status != null) ...[
- const SizedBox(width: 14),
- Text(
- status!,
- style: TextStyle(fontSize: 11, color: AppColors.mutedStrong),
++ // The subtitle sits INSIDE the fill, under the title: it is about this row, and a sentence
++ // hanging below the highlight would read as belonging to the next one.
++ child: subtitle == null
++ ? row
++ : Column(
++ mainAxisSize: MainAxisSize.min,
++ crossAxisAlignment: CrossAxisAlignment.start,
++ children: [
++ row,
++ Padding(
++ padding: const EdgeInsets.only(top: 2),
++ child: Text(
++ subtitle!,
++ overflow: TextOverflow.ellipsis,
++ style: TextStyle(fontSize: 10.5, color: AppColors.textSoft),
++ ),
++ ),
++ ],
+ ),
- ],
- ],
- ),
);
}
}
diff --cc desktop/tool/swarm_titlebar_checks.swift
index 7f9fae26b,c92a299bf..232c91cf9
--- a/desktop/tool/swarm_titlebar_checks.swift
+++ b/desktop/tool/swarm_titlebar_checks.swift
@@@ -11,25 -11,10 +11,30 @@@ private func checkTitlebar(_ condition
titlebarCheckCount += 1
}
+private final class TitlebarMouseUpProbe: NSResponder {
+ var mouseUps = 0
+ override func mouseUp(with event: NSEvent) { mouseUps += 1 }
+}
+
+private extension SwarmActionButton {
+ func renderedPixels() -> Data {
+ let bitmap = NSBitmapImageRep(bitmapDataPlanes: nil,
+ pixelsWide: Int(bounds.width), pixelsHigh: Int(bounds.height),
+ bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false,
+ colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0)!
+ let count = bitmap.bytesPerRow * bitmap.pixelsHigh
+ bitmap.bitmapData!.initialize(repeating: 0, count: count)
+ NSGraphicsContext.saveGraphicsState()
+ NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: bitmap)
+ draw(bounds)
+ NSGraphicsContext.restoreGraphicsState()
+ return Data(bytes: bitmap.bitmapData!, count: count)
+ }
++
+ private extension SwarmSubscriptionView {
+ // `icon` is private to the row view; a same-file extension reads it without widening the app API.
+ var iconImage: NSImage? { icon.image }
+ var iconTint: NSColor? { icon.contentTintColor }
}
private extension SwarmTabButton {