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.

Refine harness tabs, creation placement, and invention wallpapers

dee0042513027b5
diff --git a/desktop/assets/welcome/README.md b/desktop/assets/welcome/README.md
new file mode 100644
index 000000000..5eca9720d
--- /dev/null
+++ b/desktop/assets/welcome/README.md
@@ -0,0 +1,92 @@
+# New Tab invention wallpapers
+
+Three original Leonardo-inspired still illustrations, generated with the built-in OpenAI image generation tool on 2026-09-21. These are decorative interpretations of invention studies, not reproductions or historically exact diagrams.
+
+Each Cmd-T selects a random bundled wallpaper, avoiding an immediate repeat. That choice is stored on the tab and does not change during filtering, form editing, resizing, or rebuilding. All images load offline. The app draws the live tagline separately at the center of the full tab; the dock overlays the wallpaper without moving the caption. There is no animation.
+
+The selected set contains flight and mechanical studies only. It contains no anatomical artwork.
+
+## References
+
+- [User-selected notebook collage](https://miro.medium.com/v2/1*ieFE-OttOL_h7F_R4GgOAg.jpeg), used only for mechanical sketch themes.
+- User-provided framed invention montage, used as a subject reference for the flight variant.
+- [Museo Leonardiano: flight studies](https://museoleonardiano.it/en/collezione/flight-studies/).
+- [Museo Leonardiano: aerial screw](https://museoleonardiano.it/en/opera/aerial-screw/).
+- [Victoria and Albert Museum: Leonardo’s notebooks](https://www.vam.ac.uk/articles/leonardo-da-vincis-notebooks), including hydraulic machinery studies.
+
+No third-party photographs, thumbnails, book covers, or notebook scans are bundled. The reference images are not loaded by the app.
+
+## Final assets and prompts
+
+The generated PNGs are copied unchanged from the tool outputs. Runtime BoxFit.cover and a subtle center shade adapt them to the viewport.
+
+### leonardo-flight.png
+
+Generation: exec-546bf8b2-c3df-480e-a0fc-376aa43a7c0c
+
+SHA-256: `7baf5469bc5bc6c0f567ad023ba19017afa88469e21bf8d035d5d892391ebabb`
+
+Final prompt:
+
+```text
+Use case: style-transfer.
+Asset type: a still wallpaper for a charcoal developer desktop app, the third member of a quiet Leonardo-inspired polymath wallpaper set.
+Input image 1 sets the exact mood and palette: wide 16:9 canvas, deep neutral charcoal #171717, very restrained warm graphite and stone-gray engraved lines, abundant negative space.
+Input image 2 is a theme reference only: a collection of Renaissance mechanical invention sketches. Create a new original arrangement inspired by these ideas, without the picture frame, paper, handwriting or crowded montage.
+Composition: an elegant, airy study of a small Renaissance spiral aerial screw/flying machine around the upper-center, balanced by an almost-erased gear-and-linkage study to one side and a light architectural perspective fragment on the other. All subjects stay within the middle half of the canvas and upper 55% of its height. They should connect flight, engineering and spatial imagination through delicate construction lines, not look like an infographic.
+Scale and restraint: the main flying-machine study is about 28% of canvas height; peripheral studies are smaller and much fainter. Sketches should merge naturally into the background. Low contrast throughout; no line brighter than muted medium gray around #6c6860. No blue cast, bright orange, paper tan, neon, white highlights or glow.
+Keep a broad empty central band at 65–80% of image height for the app's separately rendered "Follow your curiosity." tagline. DO NOT draw any text, writing, labels, logo, watermark, border, frame, screen, card or UI control. Lower fifth and outer quarters are nearly empty charcoal. No humans, weapons, motion blur, animation effects, dense collage or dramatic lighting.
+The final result should feel like a beautiful, quiet still wallpaper that supports thought and leaves the brighter command dock as the primary focus.
+```
+
+### leonardo-wings.png
+
+Generation: exec-1f1ccb5b-9fe7-453d-863d-f6df96fcc827
+
+SHA-256: `17c74cc85038532c6220e4f7f4e40f45ee92902975b73b67bbe497a303880728`
+
+Final prompt:
+
+```text
+Use case: style-transfer.
+Asset type: a full-screen still wallpaper for a developer desktop app's New Tab page.
+Create an original Leonardo da Vinci-inspired invention notebook composition. Reference image 1 supplies ONLY the mechanical invention and engineering sketch themes, not its central human figure. Reference image 2 supplies the palette and fine engraved line technique.
+Palette and finish: almost uniform neutral charcoal #171717, beautifully delicate low-contrast graphite and warm stone-gray lines. No light line brighter than #6c6860. No blue, orange, neon, glow, tan paper or white highlights. Refined old-master hatching, a few almost-erased compass/construction arcs, no noisy grain. Blend all sketches softly into the full-bleed background, no rectangles or frames.
+Layout: landscape 16:9. An artful asymmetric arrangement around the upper left and upper right, with faint smaller studies toward the side edges. Keep the central 42% of the image width and the vertical band from 43% to 58% completely quiet dark charcoal: the app renders a fixed, centered tagline there. Lower quarter stays very dark and nearly empty behind the command dock. Reward a glance, not attention. Subject details can be visible toward the edges but remain muted.
+Text: none. Do not render the tagline, handwriting, labels, words, logos or watermarks.
+Strict exclusions: no people, no figures, no anatomical studies, no faces, no body parts, no weapons, no armor, no screens or UI, no motion effects. This is machinery and invention drawings only.
+Subject: flight mechanisms — an elegant jointed wooden mechanical wing and an ornithopter study in the upper-left, balanced by a small exploded pulley-and-linkage assembly and flight-control geometry in the upper-right. Show engineering sketches, not a living bird. Plenty of breathing room. Distinct from an aerial screw wallpaper.
+```
+
+### leonardo-mechanisms.png
+
+Generation: exec-72a1ef1c-c5cb-4e15-9ae3-75a5dc17e6e9
+
+SHA-256: `6824c25371bbd6471fec19a6fa925450a5715933a88c2ac45120bac08673e8ca`
+
+Final prompt:
+
+```text
+Use case: style-transfer.
+Asset type: a full-screen still wallpaper for a developer desktop app's New Tab page.
+Create an original Leonardo da Vinci-inspired invention notebook composition. Reference image 1 supplies ONLY the mechanical invention and engineering sketch themes, not its central human figure. Reference image 2 supplies the palette and fine engraved line technique.
+Palette and finish: almost uniform neutral charcoal #171717, beautifully delicate low-contrast graphite and warm stone-gray lines. No light line brighter than #6c6860. No blue, orange, neon, glow, tan paper or white highlights. Refined old-master hatching, a few almost-erased compass/construction arcs, no noisy grain. Blend all sketches softly into the full-bleed background, no rectangles or frames.
+Layout: landscape 16:9. An artful asymmetric arrangement around the upper left and upper right, with faint smaller studies toward the side edges. Keep the central 42% of the image width and the vertical band from 43% to 58% completely quiet dark charcoal: the app renders a fixed, centered tagline there. Lower quarter stays very dark and nearly empty behind the command dock. Reward a glance, not attention. Subject details can be visible toward the edges but remain muted.
+Text: none. Do not render the tagline, handwriting, labels, words, logos or watermarks.
+Strict exclusions: no people, no figures, no anatomical studies, no faces, no body parts, no weapons, no armor, no screens or UI, no motion effects. This is machinery and invention drawings only.
+Subject: hydraulic engineering and mechanisms — a beautifully drawn Renaissance water-lifting screw with a geared wooden water wheel on the upper-left, balanced by smaller interlocking cog, shaft and hoist sketches on the upper-right. Suggest fluid engineering with a few faint curving construction lines, not realistic water. Quiet broad composition with a clean dark center.
+```
+
+## Shared style reference
+
+The flight variant used an earlier generated charcoal geometric study as its style reference. Wings and mechanisms used the final flight variant as their palette reference. The geometric study is not part of the shipped rotation. Its generating prompt is retained here for reproducibility:
+
+```text
+Use case: stylized-concept.
+Asset type: a still wallpaper for the empty New Tab page of OpenHarness, a developer desktop app for people who build across code, design, engineering and art.
+Create an exceptionally restrained, refined dark charcoal wallpaper inspired by Leonardo da Vinci's open-frame geometric studies in Divina proportione. One small, elegant skeletal rhombicuboctahedron with believable perspective and delicate engraved hatching suggests the intersection of art, mathematics and engineering. This is a new original artwork, not a book cover or a UI mockup.
+Composition: wide landscape 16:9. The geometric object is centered horizontally and sits at about 38% of image height, occupying only about 17% of image width. Around it, a few extremely faint compass arcs and geometric construction lines fade smoothly into the empty background. Keep the lower third and the outer quarters almost entirely empty. The app will add the live text "Follow your curiosity." below the artwork; DO NOT render any words.
+Palette: almost uniform neutral charcoal #171717, ink in muted graphite and warm stone gray with a subtle bronze undertone. Low contrast: the lightest engraved lines around #6c6860, most details much darker. No blue cast, orange glow, neon or white. Very slight tonal depth around the object, no visible horizon, no paper rectangle or border, no heavy vignette, no noisy texture.
+Mood: timeless, thoughtful, quiet, beautifully crafted. It should reward a glance without competing with the brighter command dock below it.
+Constraints: static artwork only. No text, letters, logos, watermark, people, extra pictorial objects, screens, cards, controls, symbols or labels. Preserve abundant negative space. No animation or motion effect.
+```
diff --git a/desktop/assets/welcome/leonardo-flight.png b/desktop/assets/welcome/leonardo-flight.png
new file mode 100644
index 000000000..3e2993dbb
Binary files /dev/null and b/desktop/assets/welcome/leonardo-flight.png differ
diff --git a/desktop/assets/welcome/leonardo-mechanisms.png b/desktop/assets/welcome/leonardo-mechanisms.png
new file mode 100644
index 000000000..081f1fd7c
Binary files /dev/null and b/desktop/assets/welcome/leonardo-mechanisms.png differ
diff --git a/desktop/assets/welcome/leonardo-wings.png b/desktop/assets/welcome/leonardo-wings.png
new file mode 100644
index 000000000..75c4708e6
Binary files /dev/null and b/desktop/assets/welcome/leonardo-wings.png differ
diff --git a/desktop/design/agent-lifecycle-map.md b/desktop/design/agent-lifecycle-map.md
index c2da27b8b..916e4c1ba 100644
--- a/desktop/design/agent-lifecycle-map.md
+++ b/desktop/design/agent-lifecycle-map.md
@@ -1,8 +1,8 @@
# Harness requests and Claude Code / Codex actions
-Implementation review: `worktree-agent-resume`, [WIP PR #168](https://github.com/autonomous-ai/openharness/pull/168).
+Implementation review: `worktree-agent-resume`, [PR #168](https://github.com/autonomous-ai/openharness/pull/168).
The original proposal and pre-change mapping are preserved in [issue #167](https://github.com/autonomous-ai/openharness/issues/167).
-The command dock and welcome screen were merged separately in #165. This branch adds CLI/daemon lifecycle behavior and remains unmerged for team review.
+The original command dock and welcome screen were merged in #165. This branch adds CLI/daemon lifecycle behavior and the follow-up desktop changes described below. It remains unmerged for team review.
Commands below omit existing profile, permissions, provider, installer and shell-wrapper arguments.
## Three identities
@@ -57,8 +57,7 @@ allocates a replacement tmux session.
`agent_pause` is not implemented. No native pause operation is wired here.
Request dispatch lives in [`backendSocket.ts`](../../cli/src/backendSocket.ts).
-The daemon callbacks live in [`cli.ts`](../../cli/src/cli.ts). Exact resume and
-fork argv are in [`engineLaunch.ts`](../../cli/src/lib/engineLaunch.ts).
+The daemon wires its callbacks in [`cli.ts`](../../cli/src/cli.ts). The production Stop and Resume handlers are [`stopAgentService.ts`](../../cli/src/lib/stopAgentService.ts) and [`resumeAgentService.ts`](../../cli/src/lib/resumeAgentService.ts); the native acceptance fixture uses these same handlers. Exact resume and fork argv are in [`engineLaunch.ts`](../../cli/src/lib/engineLaunch.ts).
Process replacement and fallback are in
[`restartAgent.ts`](../../cli/src/lib/restartAgent.ts); strict stopped resume is
in [`resumeStoppedAgent.ts`](../../cli/src/lib/resumeStoppedAgent.ts).
@@ -121,11 +120,17 @@ Natural engine exit sends `agent_synced` with `status: stopped` and no terminal
## Cmd-P/T contract
+- Cmd-T immediately opens a temporary tab with a full-tab Leonardo-inspired invention wallpaper, **Follow your curiosity.** fixed at the center, and the dock. Each new tab randomly selects one of three bundled still illustrations, avoiding an immediate repeat; filtering and editing do not move the tagline or change the artwork. Escape cancels an untouched draft and returns to its previous tab; if that tab has since closed, the final empty workspace returns to onboarding with its dock. The full diagram is reserved for onboarding.
+- Cmd-P opens the dock over the current tab. Both pickers show up to ten recent sessions plus New Harness, with a smaller visible viewport on short windows; typing searches the full catalog.
+- The New Harness form has **Open in** after Task and before Start. Cmd-N and Cmd-P default to New Pane; Cmd-T defaults to New Tab and fills the tab already created. Enter or a click toggles directly between the two destinations. Creation in flight or awaiting its receipt keeps its destination.
+- Stop closes tabs emptied by that harness and its owned viewers. Occupied tabs, other machines' panes, unrelated tabs, presets and pending creation destinations are preserved. If no tabs remain, one onboarding page opens with the dock.
+- Pane menus and corresponding dialogs call the whole session a **Harness**. Agent remains the engine choice inside New Harness.
- All retained harnesses use the same row, Enter glyph and **Open** action. No Stopped badge, separate Resume action or confirmation dialog.
- Running sessions keep their existing process and conversation; opening multiple app views was already supported.
- Stopped Claude Code and Codex sessions use native resume with the exact saved conversation. Required cwd, Codex profile, permission mode, DSH and provider configuration are preserved. Missing history, project, DSH or provider credentials produce explicit errors.
- Pane allocation publishes `launch: starting`. Process discovery alone does not mark strict resume ready. A verified native hook must bind the requested conversation and the readiness poll must observe that same process. A different session ID fails instead of rebinding to a new conversation.
-- Resume does not submit a prompt, restore process memory or promise to continue an interrupted tool call.
+- Desktop can open the newly allocated terminal while its receipt is pending, so native login, trust review and input remain usable. The terminal must match the selected machine, Harness ID and saved conversation; a mismatched or failed launch cannot replace the selected view.
+- **Codex 0.154.0 defers its SessionStart hook until the first submitted message.** Native history is visible before that input, but daemon confirmation remains pending until the exact hook arrives. After ten minutes without confirmation, the receipt reports `RESUME_UNCONFIRMED` and retains the runtime/reservation; it does not launch a replacement. The acceptance fixture verifies this order. Production does not submit a prompt, restore process memory or promise to continue an interrupted tool call.
- An explicit **Start New Conversation** action remains available after failure; it is never invoked automatically.
## Concurrency and recovery
@@ -143,7 +148,22 @@ Natural engine exit sends `agent_synced` with `status: stopped` and no terminal
- The catalog contains histories retained by this daemon, not vendor conversations that Harness never recorded. Previously deleted histories are not imported.
- `agent_recent` works from the archive. Other file/model/edit RPCs still use a live row; open the harness before using them.
- Unknown tmux allocation is intentionally conservative. If the daemon died before any runtime was registered and no native hook later confirms it, the reservation remains blocked for operator investigation. There is no automatic force-clear, destructive retry or terminal takeover in this PR.
-- Unit, protocol, persistence and desktop tests use isolated fixture state. Native Claude/Codex login, trust prompts, and resume hooks across installed vendor versions still need team acceptance testing before merge. The running user daemon is not replaced by verification.
+- Native acceptance passed with Claude Code 2.1.278 and Codex 0.154.0 on macOS/tmux. Login with real accounts, other vendor versions and Linux remain team acceptance checks. Verification uses isolated profiles and a separate tmux server; it does not replace the running user daemon.
+
+## Repeatable verification
+
+From `cli/`:
+
+```sh
+npm run test:resume
+npm run test:resume-native
+```
+
+`test:resume` runs 109 tests and enforces **100% lines, statements, branches and functions** for four production modules: `resumeAgentService.ts`, `resumeStoppedAgent.ts`, `stopAgentService.ts` and `stoppedAgents.ts`. This is measured coverage of those modules, not a claim of 100% coverage of the repository or every runtime environment. The complete CLI suite passed **3,757 tests, with 63 skipped**. TypeScript checking and the normal `build.mjs` build passed.
+
+`test:resume-native` requires installed Claude Code, Codex and tmux. It launches the real vendor CLIs against synthetic saved conversations using the production BackendSocket, Stop/Resume handlers, registry/archive, launch arguments and native hook server. It verifies visible saved history, exact conversation IDs, live attach without process replacement, operation receipts, Stop persistence across a registry reload, new tmux runtimes on resume, and preservation of a surviving shell after engine exit. It uses a separate tmux socket, isolated data/config directories and unavailable loopback model endpoints, without real credentials or paid model calls. Only after restored Codex history is visible does the fixture submit a harmless test message to trigger its deferred native hook. No such message is submitted by production resume.
+
+Desktop regression coverage includes Cmd-P/T selection of retained sessions, pending native terminals, receipt and identity races, creation placement, repeated Cmd-T, Escape from search and creation, occupied-tab preservation, and the last-tab onboarding exception. The final full desktop suite passed **2,671 tests, with 10 skipped**. The analyzer reported no errors or warnings, with 17 existing informational findings. The three wallpapers were visually reviewed with the real dock at 1280×800 and 960×640; a widget regression verifies the full-tab artwork and centered tagline remain fixed during filtering and form editing. Artwork, sources, and generation prompts are recorded in [assets/welcome/README.md](../assets/welcome/README.md).
## Suggested manual acceptance checks
diff --git a/desktop/lib/core/agent_names.dart b/desktop/lib/core/agent_names.dart
index 769f07475..6434a3355 100644
--- a/desktop/lib/core/agent_names.dart
+++ b/desktop/lib/core/agent_names.dart
@@ -1,6 +1,6 @@
/// The names a derived agent starts with, before the engine reports a title.
/// One place so a fork and a clone read as siblings in the rail: `<source> - fork`,
-/// `<source> - clone`. A blank source name falls back to "Agent".
+/// `<source> - clone`. A blank source name falls back to "Harness".
library;
String forkNameFor(String name) => '${_baseName(name)} - fork';
@@ -8,4 +8,4 @@ String forkNameFor(String name) => '${_baseName(name)} - fork';
/// Clone (⌘⇧N): another agent of the same kind with a fresh conversation.
String cloneNameFor(String name) => '${_baseName(name)} - clone';
-String _baseName(String name) => name.trim().isEmpty ? 'Agent' : name.trim();
+String _baseName(String name) => name.trim().isEmpty ? 'Harness' : name.trim();
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 78d386421..0d51df926 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -202,9 +202,10 @@ class _SwarmScreenState extends State<SwarmScreen> {
bool _firstLaunchScheduled = false;
String? _emptyEntryTab;
+ final _newTabSources = <String, TerminalPane>{};
bool get _isWelcomeEntry =>
- app.activeSwarm.isEmptyStarter ||
+ (app.activeSwarm.isEmptyStarter && !app.activeSwarm.isNewTabPage) ||
(app.activeSwarm.kind == 'harness' &&
app.activeSwarm.name == 'Welcome' &&
app.activeSwarm.panes.isEmpty &&
@@ -280,8 +281,9 @@ class _SwarmScreenState extends State<SwarmScreen> {
});
}
- Widget _startGuide() =>
- WorkspaceStartGuide(onShortcuts: _showKeyboardShortcuts);
+ Widget _startGuide() => app.activeSwarm.isNewTabPage
+ ? NewTabStartPage(wallpaper: app.activeSwarm.wallpaper)
+ : WorkspaceStartGuide(onShortcuts: _showKeyboardShortcuts);
void _reviewOnboarding() {
if (_newHarness?.requestDismiss() == false) return;
@@ -1331,7 +1333,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
final focused =
source == _NewHarnessSource.workspace &&
(newHarnessOpensInBox || requestedSplit != null)
- ? app.focusedPane
+ ? app.focusedPane ?? _newTabSources[target]
: null;
final machine = focused == null ? null : app.stateOf(focused.machineId);
final agent = machine?.agents
@@ -1410,6 +1412,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
required String swarmId,
PaneSplitRequest? split,
HarnessPlacement? placement,
+ HarnessPlacement? returnedPlacement,
String? task,
NewHarnessDraft? initialDraft,
_NewHarnessContext? draftContext,
@@ -1446,13 +1449,14 @@ class _SwarmScreenState extends State<SwarmScreen> {
draftContext: draftContext,
swarmId: swarmId,
split: split,
- placement: placement,
+ placement: returnedPlacement ?? placement,
);
return;
}
if (returning != null && draftContext != null) {
_rememberNewHarnessDraft(draftContext, returning!);
}
+ app.cancelSwarmDraft(swarmId);
await _ensureEmptyEntry();
}
@@ -1552,7 +1556,11 @@ class _SwarmScreenState extends State<SwarmScreen> {
final content = NewHarnessBox(
docked: true,
controller: box,
- onClose: _closeNewHarness,
+ onClose: () {
+ final target = box.swarmId ?? app.activeSwarmId;
+ _closeNewHarness();
+ app.cancelSwarmDraft(target);
+ },
onCreated: () {
_closeNewHarness(restoreFocus: false, keepDraft: false);
unawaited(_focusCreatedPane());
@@ -1575,7 +1583,8 @@ class _SwarmScreenState extends State<SwarmScreen> {
returnToPrompt: true,
swarmId: swarmId,
split: split,
- placement: placement,
+ placement: box.effectivePlacement,
+ returnedPlacement: box.placement,
),
);
},
@@ -1588,7 +1597,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
listenable: box,
builder: (context, child) => LayoutBuilder(
builder: (context, constraints) {
- if (onWelcome) {
+ if (onWelcome && !app.activeSwarm.isNewTabPage) {
return Padding(
padding: EdgeInsets.only(top: _native ? 0 : _tabBarHeight),
child: FocusScope(
@@ -1622,13 +1631,19 @@ class _SwarmScreenState extends State<SwarmScreen> {
key: const ValueKey('new-harness-dismiss'),
behavior: HitTestBehavior.opaque,
onTap: () {
- if (box.requestDismiss()) _closeNewHarness();
+ if (box.requestDismiss()) {
+ final target = box.swarmId ?? app.activeSwarmId;
+ _closeNewHarness();
+ app.cancelSwarmDraft(target);
+ }
},
),
),
),
CommandDock(
- topClearance: _native ? 0 : _tabBarHeight,
+ topClearance: app.activeSwarm.isBlankNewTab
+ ? constraints.maxHeight * .56
+ : (_native ? 0 : _tabBarHeight),
expanded: box.field == NewHarnessField.projectMenu,
child: content,
),
@@ -2071,7 +2086,11 @@ class _SwarmScreenState extends State<SwarmScreen> {
}
}
- void _dismissSearch() => _closeSearch();
+ void _dismissSearch() {
+ final target = _search?.targetId;
+ _closeSearch();
+ if (target != null) app.cancelSwarmDraft(target);
+ }
Future<void> _ensureEmptyEntry() async {
if (!mounted || app.panes.isNotEmpty) return;
@@ -2099,7 +2118,19 @@ class _SwarmScreenState extends State<SwarmScreen> {
return;
}
_closeSearch(restoreFocus: choice.destination.isCommand);
- await _activateSearch(choice, target, split: split, placement: placement);
+ // Cmd-T allocated its visible destination before the picker opened. Pin
+ // selection to that tab, including while an exact resume is still pending.
+ final targetTab = app.swarms.where((tab) => tab.id == target).firstOrNull;
+ await _activateSearch(
+ choice,
+ target,
+ split: split,
+ placement:
+ placement == HarnessPlacement.newTab &&
+ targetTab?.isBlankNewTab == true
+ ? HarnessPlacement.currentTab
+ : placement,
+ );
if (mounted) {
if (app.activeSwarmId != target) app.cancelSwarmDraft(target);
await _ensureEmptyEntry();
@@ -2228,7 +2259,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
onRefocus: _focusSearch,
child: scoped,
);
- if (_searchOnWelcome) {
+ if (_searchOnWelcome && !app.activeSwarm.isNewTabPage) {
return Padding(
padding: EdgeInsets.only(top: _native ? 0 : _tabBarHeight),
child: BlockSemantics(
@@ -2264,7 +2295,12 @@ class _SwarmScreenState extends State<SwarmScreen> {
),
),
CommandDock(
- topClearance: _native ? 0 : _tabBarHeight,
+ expanded: true,
+ topClearance: (_native ? 0.0 : _tabBarHeight).clamp(
+ constraints.maxHeight *
+ (app.activeSwarm.isBlankNewTab ? .56 : .35),
+ double.infinity,
+ ),
child: contents,
),
],
@@ -2295,12 +2331,47 @@ class _SwarmScreenState extends State<SwarmScreen> {
_openPlacementPicker(HarnessPlacement.currentTab);
}
- void _newTab() => _openPlacementPicker(HarnessPlacement.newTab);
+ void _newTab() {
+ if (!mounted || _dialogOpen || _spokenPaletteOpen || !_routeIsCurrent) {
+ return;
+ }
+ if (_newHarness case final box?) {
+ if (box.busy || box.checking) {
+ box.warn('Check the pending creation before opening another picker.');
+ return;
+ }
+ if (!box.requestDismiss()) return;
+ }
+ final source = app.focusedPane ?? _newTabSources[app.activeSwarmId];
+ final draft = _search?.adding == true && _search?.isCommandMode == false
+ ? _search?.draft
+ : null;
+ final editing = _searchText.value;
+ _closeNewHarness(restoreFocus: false);
+ _closeSearch(restoreFocus: false);
+ _closeCommandBar(restoreFocus: false);
+ dismissTransientMenus();
+ _preparePaneFocus();
+ app.newSwarm(newTabPage: true, draft: true);
+ _newTabSources.removeWhere(
+ (id, _) => !app.swarms.any((tab) => tab.id == id),
+ );
+ if (source != null) _newTabSources[app.activeSwarmId] = source;
+ _openSearch(adding: true, placement: HarnessPlacement.newTab);
+ if (draft != null) {
+ _search?.restoreDraft(draft, newTab: true);
+ _searchText.value = editing;
+ }
+ }
void _openPlacementPicker(HarnessPlacement requested) {
- final placement = app.activeSwarm.isStore || app.activeSwarm.isOrchestrator
- ? HarnessPlacement.newTab
- : requested;
+ if (requested == HarnessPlacement.newTab ||
+ app.activeSwarm.isStore ||
+ app.activeSwarm.isOrchestrator) {
+ _newTab();
+ return;
+ }
+ final placement = requested;
if (_search?.changePlacement(placement) == true) {
_focusSearch();
return;
@@ -2590,7 +2661,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
?mode('terminal.new', 'New terminal', 'A shell where you are'),
?mode(
'agent.clone',
- 'Clone Agent',
+ 'Clone Harness',
'Another of this one, fresh conversation',
),
?mode('navigation.needs_input', 'Agents needing input', 'Who is waiting'),
@@ -2940,7 +3011,10 @@ class _SwarmScreenState extends State<SwarmScreen> {
!app
.activeSwarm
.isOrchestrator
- ? newHarnessOpensInBox
+ ? newHarnessOpensInBox ||
+ app
+ .activeSwarm
+ .isNewTabPage
? _startGuide()
: HarnessStartPage(
key: ValueKey(
diff --git a/desktop/lib/shortcuts/keyboard_practice.dart b/desktop/lib/shortcuts/keyboard_practice.dart
index c47016144..7aa1fd0d2 100644
--- a/desktop/lib/shortcuts/keyboard_practice.dart
+++ b/desktop/lib/shortcuts/keyboard_practice.dart
@@ -41,7 +41,7 @@ class KeyboardLesson {
'[agent 1]\nThe second view closes. Its agent keeps running.',
'swarm.close' =>
'[previous tab]\nThe view closes. Its agents keep running.',
- 'navigation.commands' => '> rename\nRename Agent\nRename Tab',
+ 'navigation.commands' => '> rename\nRename Harness\nRename Tab',
'terminal.find' => 'find > timeout\n1/3 matches in this terminal’s output',
'picker.complete' => 'project ~/work/payments\nTab completes the current argument; Enter accepts it.',
'picker.complete_back' =>
@@ -69,12 +69,11 @@ class KeyboardLesson {
'more options\nPermissions · Codex profile · repository',
'picker.toggle_preview' =>
'results │ preview\nToggle again to hide the preview.',
- 'agent.stop' => 'Stop Agent?\n> Cancel Stop\nStopping ends the agent; closing a pane only closes a view.',
- 'agent.restart' =>
- 'Restart Agent\nA fresh conversation starts in the same project.',
+ 'agent.stop' => 'Stop Harness?\n> Cancel Stop\nStopping ends the running harness; its saved conversation is kept. Closing a pane only closes a view.',
+ 'agent.restart' => 'Restart Harness\nRestarts the harness in the same pane and tries to resume its conversation.',
'agent.fork' =>
- 'Fork Agent\nChoose a name and first task. The source stays open.',
- 'agent.clone' => 'Clone Agent\nAnother of this one opens beside it: same folder and settings, fresh conversation.',
+ 'Fork Harness\nChoose a name and first task. The source stays open.',
+ 'agent.clone' => 'Clone Harness\nAnother of this one opens beside it: same folder and settings, fresh conversation.',
'app.store' =>
'[Harness Store]\nFind a harness for the kind of work you want to do.',
'pane.focus_left' ||
diff --git a/desktop/lib/shortcuts/keymap_commands.dart b/desktop/lib/shortcuts/keymap_commands.dart
index 65a4d205d..2f234ddbf 100644
--- a/desktop/lib/shortcuts/keymap_commands.dart
+++ b/desktop/lib/shortcuts/keymap_commands.dart
@@ -299,18 +299,18 @@ final harnessCommands = <HarnessCommand>[
action: ShortcutAction.newAgent,
nativeAction: 'newAgent',
),
- const HarnessCommand('agent.rename', 'Rename Agent', ShortcutGroup.actions),
- const HarnessCommand('agent.stop', 'Stop Agent', ShortcutGroup.actions),
- const HarnessCommand('agent.fork', 'Fork Agent', ShortcutGroup.actions),
+ const HarnessCommand('agent.rename', 'Rename Harness', ShortcutGroup.actions),
+ const HarnessCommand('agent.stop', 'Stop Harness', ShortcutGroup.actions),
+ const HarnessCommand('agent.fork', 'Fork Harness', ShortcutGroup.actions),
const HarnessCommand(
'agent.clone',
- 'Clone Agent',
+ 'Clone Harness',
ShortcutGroup.actions,
action: ShortcutAction.cloneAgent,
nativeAction: 'cloneAgent',
keywords: ['duplicate', 'another', 'fresh'],
),
- const HarnessCommand('agent.restart', 'Restart Agent', ShortcutGroup.actions),
+ const HarnessCommand('agent.restart', 'Restart Harness', ShortcutGroup.actions),
const HarnessCommand(
'terminal.new',
'New Terminal',
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dart
index f3662ff64..2257f7976 100644
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@ -51,6 +51,7 @@ import 'harness_placement.dart';
import 'pane_layout_store.dart';
import 'terminal_pane.dart';
import 'swarm.dart';
+import 'new_tab_wallpaper.dart';
import '../terminal/terminal_binary.dart';
import '../update/desktop_updater.dart';
import '../update/manual_update_check.dart';
@@ -805,7 +806,10 @@ class AppNotifier extends ChangeNotifier {
final _draftSwarmReturns = <String, String>{};
bool isDraftSwarm(String id) {
- if (!_draftSwarmReturns.containsKey(id)) return false;
+ if (!_draftSwarmReturns.containsKey(id) ||
+ _activeAgentCreations.any((attempt) => attempt._targetId == id)) {
+ return false;
+ }
final swarm = swarms.where((swarm) => swarm.id == id).firstOrNull;
return swarm != null &&
swarm.panes.isEmpty &&
@@ -813,11 +817,18 @@ class AppNotifier extends ChangeNotifier {
swarm.presets.isEmpty;
}
- void newSwarm({String name = Swarm.defaultName, bool draft = false}) {
+ final _wallpaperRandom = Random();
+ NewTabWallpaper? _lastNewTabWallpaper;
+
+ void newSwarm({
+ String name = Swarm.defaultName,
+ bool draft = false,
+ bool newTabPage = false,
+ }) {
name = Swarm.normalizeName(name);
- // Every New Tab entry point reuses the existing start page, including
- // when another tab is selected or the tab limit has been reached.
- if (name == Swarm.defaultName) {
+ // Reuse onboarding for ordinary destinations. Explicit Cmd-T opens a
+ // temporary minimal page, removed when the user cancels or leaves it.
+ if (name == Swarm.defaultName && !newTabPage) {
final starter = activeSwarm.isEmptyStarter
? activeSwarm
: swarms.where((swarm) => swarm.isEmptyStarter).firstOrNull;
@@ -829,7 +840,18 @@ class AppNotifier extends ChangeNotifier {
while (swarms.any((s) => s.id == 'swarm-$_nextSwarmId')) {
_nextSwarmId++;
}
- final swarm = Swarm(id: 'swarm-${_nextSwarmId++}', name: name);
+ final swarm = Swarm(
+ id: 'swarm-${_nextSwarmId++}',
+ name: name,
+ isNewTabPage: newTabPage,
+ );
+ if (newTabPage) {
+ final choices = NewTabWallpaper.values
+ .where((wallpaper) => wallpaper != _lastNewTabWallpaper)
+ .toList(growable: false);
+ swarm.wallpaper = choices[_wallpaperRandom.nextInt(choices.length)];
+ _lastNewTabWallpaper = swarm.wallpaper;
+ }
if (draft) {
_draftSwarmReturns[swarm.id] =
_draftSwarmReturns[activeSwarmId] ?? activeSwarmId;
@@ -913,21 +935,24 @@ class AppNotifier extends ChangeNotifier {
}
/// Cancel an untouched New Tab without closing a session or recording
- /// Recently Closed. A sole workspace remains the app's starting screen.
+ /// Recently Closed. If its return tab disappeared, restore onboarding.
bool cancelSwarmDraft(String id) {
final returnId = _draftSwarmReturns[id];
final target = swarms.where((swarm) => swarm.id == id).firstOrNull;
if (returnId == null ||
+ !isDraftSwarm(id) ||
target == null ||
target.panes.isNotEmpty ||
target.name != Swarm.defaultName ||
- target.presets.isNotEmpty ||
- swarms.length == 1) {
+ target.presets.isNotEmpty) {
return false;
}
final wasActive = activeSwarmId == id;
swarms.remove(target);
_draftSwarmReturns.remove(id);
+ if (swarms.isEmpty) {
+ swarms.add(Swarm(id: 'swarm-${_nextSwarmId++}'));
+ }
if (wasActive) {
selectSwarm(
swarms.any((swarm) => swarm.id == returnId) ? returnId : swarms.last.id,
@@ -5432,6 +5457,36 @@ class AppNotifier extends ChangeNotifier {
_syncAgentName(machine, machine.agents[index]);
}
+ // Creation can be in flight while a Stop reply removes the old final pane.
+ final _activeAgentCreations = <AgentCreationAttempt>{};
+
+ void _closeTabsEmptiedByStop(Set<Swarm> affected) {
+ final activeIndex = swarms.indexWhere((tab) => tab.id == _activeSwarmId);
+ final removable = affected.where(
+ (tab) =>
+ tab.kind == 'harness' &&
+ tab.panes.isEmpty &&
+ tab.presets.isEmpty &&
+ !_activeAgentCreations.any((attempt) => attempt._targetId == tab.id),
+ );
+ final ids = removable.map((tab) => tab.id).toSet();
+ if (ids.isEmpty) return;
+ swarms.removeWhere((tab) => ids.contains(tab.id));
+ for (final id in ids) {
+ _draftSwarmReturns.remove(id);
+ }
+ if (swarms.isEmpty) {
+ // A fresh start page gets the normal welcome/dock behavior. Never reuse
+ // the stopped harness's name, which would suppress that entry behavior.
+ swarms.add(Swarm(id: 'swarm-${_nextSwarmId++}'));
+ }
+ if (ids.contains(_activeSwarmId)) {
+ _activeSwarmId = swarms[activeIndex.clamp(0, swarms.length - 1)].id;
+ selectedMachineId = focusedPane?.machineId;
+ _paneFocusRequest++;
+ }
+ }
+
Future<void> _removeAgent(MachineState machine, String agentId) async {
final stop = _agentStops[(machine.machine.machineId, agentId)];
final confirmedStop = stop != null && _agentStopCurrent(stop) ? stop : null;
@@ -5455,6 +5510,7 @@ class AppNotifier extends ChangeNotifier {
// already destroyed.
final machineId = machine.machine.machineId;
final closing = <Future<void>>[];
+ final affected = <Swarm>{};
for (final pane in allPanes.toList()) {
final owned =
pane.machineId == machineId &&
@@ -5462,10 +5518,14 @@ class AppNotifier extends ChangeNotifier {
(pane.isWeb && pane.ownerAgentId == agentId));
if (!owned) continue;
for (final swarm in swarms) {
- swarm.remove(pane);
+ if (swarm.panes.contains(pane)) {
+ affected.add(swarm);
+ swarm.remove(pane);
+ }
}
closing.add(_detachSession(pane, sendClose: false));
}
+ _closeTabsEmptiedByStop(affected);
_dismissedViewers.remove(_viewerKey(machineId, agentId));
_persistLayout();
_announceAppFocus();
@@ -6055,9 +6115,15 @@ class AppNotifier extends ChangeNotifier {
creation._split = split;
creation._placement = placement;
}
+ _activeAgentCreations.add(creation);
final work = _createAgentWithReceipt(creation);
creation._inFlight = work;
- return work.whenComplete(() => creation._inFlight = null);
+ return work.whenComplete(() {
+ creation._inFlight = null;
+ if (!creation.awaitingConfirmation) {
+ _activeAgentCreations.remove(creation);
+ }
+ });
}
String? _creationPlacementError(
@@ -6563,7 +6629,7 @@ class AppNotifier extends ChangeNotifier {
final trimmed = name.trim();
if (trimmed.isEmpty) return Future.value('Name cannot be empty');
if (machine.machine.isShared) {
- return Future.value('Shared agents are view-only.');
+ return Future.value('Shared harnesses are view-only.');
}
if (pendingAgentStop(machineId, agentId) != null) {
return Future.value('The agent is stopping.');
@@ -6668,7 +6734,7 @@ class AppNotifier extends ChangeNotifier {
final machine = machineStates[machineId];
if (machine == null) return Future.value('Machine not found');
if (machine.machine.isShared) {
- return Future.value('Shared agents are view-only.');
+ return Future.value('Shared harnesses are view-only.');
}
if (pendingAgentStop(machineId, agentId) case final pending?) {
return pending;
@@ -6863,7 +6929,7 @@ class AppNotifier extends ChangeNotifier {
}
if (machine.machine.isShared) {
return const RestartAgentResult(
- error: 'Shared agents are view-only.',
+ error: 'Shared harnesses are view-only.',
retryable: false,
);
}
@@ -7217,35 +7283,34 @@ class AppNotifier extends ChangeNotifier {
if (machine.machine.machineId != machineId ||
attempt.source?.id != agentId) {
return const ForkAgentResult(
- error: 'The source agent is no longer available.',
+ error: 'The source harness is no longer available.',
);
}
if (!_machineWorkCurrent(machine, attempt._authRevision)) {
return const ForkAgentResult(
- error: 'This fork is no longer active. Reopen Fork Agent.',
+ error: 'This fork is no longer active. Reopen Fork Harness.',
);
}
if (machine.machine.isShared) {
- return const ForkAgentResult(error: 'Shared agents are view-only.');
+ return const ForkAgentResult(error: 'Shared harnesses are view-only.');
}
if (!attempt.awaitingConfirmation) {
if (!_forkSourceCurrent(attempt)) {
return const ForkAgentResult(
- error: 'The source agent changed. Close this prompt and reopen Fork Agent.',
+ error: 'The source harness changed. Close this prompt and reopen Fork Harness.',
);
}
if (pendingAgentStop(machineId, agentId) != null) {
- return const ForkAgentResult(error: 'The source agent is stopping.');
+ return const ForkAgentResult(error: 'The source harness is stopping.');
}
if (attempt.source?.canFork != true) {
return const ForkAgentResult(
- error: 'This agent does not support forking.',
+ error: 'This harness does not support forking.',
);
}
if (agentIsProcessing(machineId, agentId)) {
return const ForkAgentResult(
- error:
- 'This agent is working. Wait for its turn to finish, then fork.',
+ error: 'This harness is working. Wait for its turn to finish, then fork.',
);
}
if (attempt.name.characters.length > 80) {
@@ -7402,7 +7467,7 @@ class AppNotifier extends ChangeNotifier {
'UNSUPPORTED_ON_REMOTE' || 'UNSUPPORTED' =>
'Update the harness CLI on this machine to fork an agent.',
'AGENT_BUSY' =>
- 'This agent is working. Wait for its turn to finish, then fork.',
+ 'This harness is working. Wait for its turn to finish, then fork.',
_ => 'Fork failed: $code',
};
@@ -8501,6 +8566,8 @@ class AppNotifier extends ChangeNotifier {
..orchestratorMachineId = raw['orchestratorMachineId'] is String
? raw['orchestratorMachineId'] as String
: null;
+ swarm.isNewTabPage = raw['newTabPage'] == true;
+ swarm.wallpaper = NewTabWallpaper.fromName(raw['newTabWallpaper']);
swarm.titleMachineId = raw['titleMachineId'] as String?;
swarm.titleAgentId = raw['titleAgentId'] as String?;
swarm.nameIsCustom =
@@ -8561,7 +8628,9 @@ class AppNotifier extends ChangeNotifier {
if (restored.isNotEmpty) {
// Older builds saved multiple unused start pages. Retain the selected
// one when possible; custom names, presets and real work stay intact.
- final starters = restored.where((swarm) => swarm.isEmptyStarter);
+ final starters = restored.where(
+ (swarm) => swarm.isEmptyStarter && !swarm.isNewTabPage,
+ );
final starter =
starters
.where((swarm) => swarm.id == saved['activeId'])
@@ -8570,7 +8639,8 @@ class AppNotifier extends ChangeNotifier {
final hadDuplicateStarters = starters.length > 1;
if (hadDuplicateStarters) {
restored.removeWhere(
- (swarm) => swarm.isEmptyStarter && swarm != starter,
+ (swarm) =>
+ swarm.isEmptyStarter && !swarm.isNewTabPage && swarm != starter,
);
}
swarms
diff --git a/desktop/lib/state/harness_placement.dart b/desktop/lib/state/harness_placement.dart
index d87da8734..2ecdd616f 100644
--- a/desktop/lib/state/harness_placement.dart
+++ b/desktop/lib/state/harness_placement.dart
@@ -1,5 +1,5 @@
-/// A requested destination, not an allocated tab or pane. Resolving it waits
-/// until an existing harness is chosen or a new harness is successfully made.
+/// Where a harness should open. Cmd-T allocates a temporary destination first;
+/// other entry points allocate a new tab only when a harness is ready.
enum HarnessPlacement {
currentTab,
newTab;
diff --git a/desktop/lib/state/new_harness.dart b/desktop/lib/state/new_harness.dart
index 38bbeb43c..c6157dcab 100644
--- a/desktop/lib/state/new_harness.dart
+++ b/desktop/lib/state/new_harness.dart
@@ -187,11 +187,17 @@ class NewHarnessController extends ChangeNotifier {
NewHarnessDraft? draft,
this.swarmId,
this.split,
- this.placement,
+ HarnessPlacement? placement,
this.offersStore = false,
this.firstRun = false,
String? home,
- }) : _machineId = draft?.machineId ?? machineId,
+ }) : placement =
+ placement ?? (split == null ? HarnessPlacement.currentTab : null),
+ _targetId = swarmId ?? app.activeSwarmId,
+ _usesNewTabPage = app.swarms.any(
+ (tab) => tab.id == (swarmId ?? app.activeSwarmId) && tab.isBlankNewTab,
+ ),
+ _machineId = draft?.machineId ?? machineId,
_autoProject = autoProject || draft?.project.generated != null,
_now = now ?? DateTime.now,
_home = home ?? Platform.environment['HOME'] {
@@ -263,7 +269,20 @@ class NewHarnessController extends ChangeNotifier {
final AppNotifier app;
final String? swarmId;
final PaneSplitRequest? split;
- final HarnessPlacement? placement;
+ HarnessPlacement? placement;
+ final String _targetId;
+ final bool _usesNewTabPage;
+ HarnessPlacement? get effectivePlacement =>
+ placement == HarnessPlacement.newTab && _usesNewTabPage
+ ? HarnessPlacement.currentTab
+ : placement;
+
+ void changePlacement(HarnessPlacement value) {
+ if (locked || split != null || placement == value) return;
+ placement = value;
+ notifyListeners();
+ }
+
final bool firstRun;
final bool _autoProject;
final DateTime Function() _now;
@@ -2034,9 +2053,9 @@ class NewHarnessController extends ChangeNotifier {
engine: base,
folder: terminal ? folder : folder ?? '',
projectFolder: projectFolderRequest,
- swarmId: swarmId,
+ swarmId: _targetId,
split: split,
- placement: placement,
+ placement: effectivePlacement,
bypassPermission: bypass,
permissionMode: permissionMode,
codexHome: base == 'codex' ? _profile?.path : null,
diff --git a/desktop/lib/state/new_tab_wallpaper.dart b/desktop/lib/state/new_tab_wallpaper.dart
new file mode 100644
index 000000000..cd744c912
--- /dev/null
+++ b/desktop/lib/state/new_tab_wallpaper.dart
@@ -0,0 +1,12 @@
+/// Bundled, still artwork. Each New Tab chooses once, independently of builds.
+enum NewTabWallpaper {
+ flight('assets/welcome/leonardo-flight.png'),
+ wings('assets/welcome/leonardo-wings.png'),
+ mechanisms('assets/welcome/leonardo-mechanisms.png');
+
+ const NewTabWallpaper(this.asset);
+ final String asset;
+
+ static NewTabWallpaper fromName(Object? name) =>
+ values.where((wallpaper) => wallpaper.name == name).firstOrNull ?? flight;
+}
diff --git a/desktop/lib/state/swarm.dart b/desktop/lib/state/swarm.dart
index 2fe6706e5..8f78c01f3 100644
--- a/desktop/lib/state/swarm.dart
+++ b/desktop/lib/state/swarm.dart
@@ -1,6 +1,7 @@
import 'dart:ui' show Size;
import '../core/models.dart' show isAutomaticHarnessName;
+import 'new_tab_wallpaper.dart';
import 'pane_preset.dart';
import 'pane_arrangement.dart';
import 'terminal_pane.dart';
@@ -13,6 +14,8 @@ class Swarm {
required this.id,
String name = defaultName,
this.kind = 'harness',
+ this.isNewTabPage = false,
+ this.wallpaper = NewTabWallpaper.flight,
bool? nameIsCustom,
}) : name = nameIsCustom == true ? name : normalizeName(name),
nameIsCustom = nameIsCustom ?? (normalizeName(name) != defaultName);
@@ -23,6 +26,12 @@ class Swarm {
/// just is not somewhere a pane can land. Mutable because the store takes
/// over the New Tab it was opened from, the way a first agent does.
String kind;
+
+ /// A deliberately opened tab has a minimal landing page, separate from onboarding.
+ bool isNewTabPage;
+ NewTabWallpaper wallpaper;
+ bool get isBlankNewTab =>
+ isNewTabPage && kind == 'harness' && panes.isEmpty && presets.isEmpty;
bool get isStore => kind == 'store';
bool get isOrchestrator =>
kind == 'orchestrator' &&
@@ -118,6 +127,8 @@ class Swarm {
'id': id,
'name': name,
if (nameIsCustom) 'nameIsCustom': true,
+ if (isNewTabPage) 'newTabPage': true,
+ if (isNewTabPage) 'newTabWallpaper': wallpaper.name,
if (titleMachineId != null) 'titleMachineId': titleMachineId,
if (titleAgentId != null) 'titleAgentId': titleAgentId,
if (kind != 'harness') 'kind': kind,
diff --git a/desktop/lib/state/swarm_navigation.dart b/desktop/lib/state/swarm_navigation.dart
index 94ff2030b..1173538be 100644
--- a/desktop/lib/state/swarm_navigation.dart
+++ b/desktop/lib/state/swarm_navigation.dart
@@ -349,9 +349,41 @@ Future<void> _resumeStoppedDestination(
.where((agent) => agent.id == agentId)
.firstOrNull;
if (agent?.isStopped != true) return;
- final result = await app.resumeAgent(machineId, agentId);
- if (result.error case final error?) {
- throw SwarmResumeFailure(destination, error);
+ final machine = app.stateOf(machineId);
+ final terminalReady = Completer<void>();
+ void observeRuntime() {
+ if (terminalReady.isCompleted ||
+ !identical(machine, app.stateOf(machineId)) ||
+ app.pendingAgentStop(machineId, agentId) != null) {
+ return;
+ }
+ final current = app
+ .stateOf(machineId)
+ ?.agents
+ .where((row) => row.id == agentId)
+ .firstOrNull;
+ // This opens a view of the allocated terminal, not a claim that history
+ // has loaded. The native CLI may need login or hook review before it can
+ // confirm the conversation; the receipt keeps verifying in the background.
+ if (current?.terminalAvailable == true &&
+ current?.sessionId == agent!.sessionId &&
+ current?.launchState != 'failed' &&
+ current?.isStopped == false) {
+ terminalReady.complete();
+ }
+ }
+
+ app.addListener(observeRuntime);
+ try {
+ final confirmed = app.resumeAgent(machineId, agentId).then((result) {
+ if (result.error case final error?) {
+ throw SwarmResumeFailure(destination, error);
+ }
+ });
+ observeRuntime();
+ await Future.any([confirmed, terminalReady.future]);
+ } finally {
+ app.removeListener(observeRuntime);
}
}
@@ -732,8 +764,8 @@ Future<bool> activateSwarmSearchSelection(
return false;
}
} else {
- // Validate and resume before allocation, so a stale row or a failed
- // resume cannot leave an empty tab behind.
+ // Validate the saved target and wait for its terminal before allocating
+ // a tab, so a refusal cannot leave an empty tab behind.
app.newSwarm();
target = app.activeSwarm;
}
diff --git a/desktop/lib/state/swarm_search.dart b/desktop/lib/state/swarm_search.dart
index abaf7c370..2bdf01114 100644
--- a/desktop/lib/state/swarm_search.dart
+++ b/desktop/lib/state/swarm_search.dart
@@ -17,9 +17,15 @@ const kSwarmCreateRowId = 'create:harness';
/// Search text and selection retained while the start-page picker is dismissed.
/// Membership and availability are revalidated against a fresh catalog on return.
class SwarmSearchDraft {
- const SwarmSearchDraft._(this.targetId, this.query, this.selectedId);
+ const SwarmSearchDraft._(
+ this.targetId,
+ this.query,
+ this.selectedId,
+ this.groupScope,
+ );
final String targetId, query;
final String? selectedId;
+ final ({String id, String name, String query})? groupScope;
}
/// One search session, shared by the native/Flutter input and its results.
@@ -189,11 +195,12 @@ class SwarmSearchController extends ChangeNotifier {
bool? _splitCurrent;
Set<String> _presentIds = const {};
SwarmSearchDraft get draft =>
- SwarmSearchDraft._(targetId, query, selected?.id);
+ SwarmSearchDraft._(targetId, query, selected?.id, _groupScope);
- void restoreDraft(SwarmSearchDraft draft) {
- if (!adding || draft.targetId != targetId) return;
+ void restoreDraft(SwarmSearchDraft draft, {bool newTab = false}) {
+ if (!adding || (!newTab && draft.targetId != targetId)) return;
query = draft.query;
+ _groupScope = draft.groupScope;
_selectedId = draft.selectedId;
cursor = 0;
_filter();
diff --git a/desktop/lib/widgets/delete_agent_dialog.dart b/desktop/lib/widgets/delete_agent_dialog.dart
index 0e271c994..e9db57f64 100644
--- a/desktop/lib/widgets/delete_agent_dialog.dart
+++ b/desktop/lib/widgets/delete_agent_dialog.dart
@@ -118,7 +118,7 @@ class _StopAgentPromptState extends State<_StopAgentPrompt> {
try {
error = await request;
} catch (_) {
- error = 'Could not stop the agent. Try again.';
+ error = 'Could not stop the harness. Try again.';
}
if (!mounted) return;
if (error == null) {
@@ -154,7 +154,7 @@ class _StopAgentPromptState extends State<_StopAgentPrompt> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
- widget.terminal ? 'Stop Terminal' : 'Stop Agent',
+ widget.terminal ? 'Stop Terminal' : 'Stop Harness',
style: boxMonoStyle(size: 12, color: kBoxFaint),
),
const SizedBox(height: 12),
@@ -177,7 +177,7 @@ class _StopAgentPromptState extends State<_StopAgentPrompt> {
Text(
widget.terminal
? 'End this shell and anything running in it? Files are kept.'
- : 'End the running agent? Project files and saved conversation history are kept.',
+ : 'Stop this harness? Project files and saved conversation history are kept.',
style: boxMonoStyle(size: 12, color: Colors.white70),
),
const SizedBox(height: 8),
diff --git a/desktop/lib/widgets/fork_agent_dialog.dart b/desktop/lib/widgets/fork_agent_dialog.dart
index 63e157226..2bd4e8650 100644
--- a/desktop/lib/widgets/fork_agent_dialog.dart
+++ b/desktop/lib/widgets/fork_agent_dialog.dart
@@ -176,8 +176,7 @@ class _ForkAgentPromptState extends State<_ForkAgentPrompt> {
result = await request;
} catch (_) {
result = const ForkAgentResult(
- error:
- 'Could not confirm the fork. Check agents before starting another.',
+ error: 'Could not confirm the fork. Check harnesses before starting another.',
);
}
if (!mounted) return;
@@ -347,7 +346,7 @@ class _ForkAgentPromptState extends State<_ForkAgentPrompt> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
- 'Fork Agent',
+ 'Fork Harness',
style: boxMonoStyle(size: 12, color: kBoxFaint),
),
const SizedBox(height: 10),
diff --git a/desktop/lib/widgets/machine_rail.dart b/desktop/lib/widgets/machine_rail.dart
index a93eb5648..6c13b393c 100644
--- a/desktop/lib/widgets/machine_rail.dart
+++ b/desktop/lib/widgets/machine_rail.dart
@@ -1229,7 +1229,7 @@ class _AgentRowState extends State<_AgentRow> {
icon: LucideIcons.refreshCw300,
label: isTerminalEngine(agent.engine)
? 'Restart Terminal'
- : 'Restart Agent',
+ : 'Restart Harness',
onPressed: () {
_agentMenu.close();
_restartAgent();
@@ -1238,7 +1238,7 @@ class _AgentRowState extends State<_AgentRow> {
if (agent.canFork)
AppMenuItem(
icon: LucideIcons.gitFork300,
- label: 'Fork Agent',
+ label: 'Fork Harness',
onPressed: () {
_agentMenu.close();
_forkAgent();
@@ -1247,7 +1247,7 @@ class _AgentRowState extends State<_AgentRow> {
const AppMenuDivider(),
AppMenuItem(
icon: Icons.stop_rounded,
- label: 'Stop Agent',
+ label: 'Stop Harness',
danger: true,
onPressed: () {
_agentMenu.close();
diff --git a/desktop/lib/widgets/new_harness_box.dart b/desktop/lib/widgets/new_harness_box.dart
index e51b41148..6dc7e7b71 100644
--- a/desktop/lib/widgets/new_harness_box.dart
+++ b/desktop/lib/widgets/new_harness_box.dart
@@ -9,11 +9,12 @@ import '../shared/theme/app_theme.dart' as grid;
import '../shortcuts/app_keymap.dart';
import '../shortcuts/keymap.dart';
import '../state/new_harness.dart';
+import '../state/harness_placement.dart';
import 'box_chrome.dart';
import 'pane_menu.dart';
import 'terminal_prompt.dart';
-enum _LaunchChoice { agent, machine, project, task, create }
+enum _LaunchChoice { agent, machine, project, task, placement, create }
/// A launch menu and focused completion prompts with shared arrow navigation.
/// Create is selected initially; arrows and Enter edit a displayed default.
@@ -73,6 +74,7 @@ class _NewHarnessBoxState extends State<NewHarnessBox> {
_LaunchChoice.machine,
_LaunchChoice.project,
_LaunchChoice.task,
+ if (box.split == null) _LaunchChoice.placement,
_LaunchChoice.create,
];
String get _launchCreateLabel => box.checking
@@ -98,12 +100,25 @@ class _NewHarnessBoxState extends State<NewHarnessBox> {
box.focusField(NewHarnessField.projectMenu);
case _LaunchChoice.task:
_editTask();
+ case _LaunchChoice.placement:
+ _togglePlacement();
case _LaunchChoice.create:
unawaited(_finish(box.create()));
}
_requestFocus();
}
+ void _togglePlacement() {
+ if (box.locked || box.split != null) return;
+ _selectLaunchChoice(_LaunchChoice.placement);
+ box.changePlacement(
+ box.placement == HarnessPlacement.newTab
+ ? HarnessPlacement.currentTab
+ : HarnessPlacement.newTab,
+ );
+ _requestFocus();
+ }
+
void _requestFocus() => (_hasInput ? _focus : _launchFocus).requestFocus();
final _scroll = ScrollController();
final _announcer = BoxAnnouncer();
@@ -208,6 +223,7 @@ class _NewHarnessBoxState extends State<NewHarnessBox> {
box.status,
box.error,
box.task,
+ box.placement,
box.query.trim().isEmpty,
box.matchCount,
box.total,
@@ -276,6 +292,8 @@ class _NewHarnessBoxState extends State<NewHarnessBox> {
(_launching
? _launchChoice == _LaunchChoice.create
? _summaryText()
+ : _launchChoice == _LaunchChoice.placement
+ ? 'Open in ${box.placement!.title}. Enter to switch.'
: '${_launchChoice.name}. Enter to edit.'
: box.field == NewHarnessField.task
// No row to read here: read what Return will do instead.
@@ -844,7 +862,7 @@ class _NewHarnessBoxState extends State<NewHarnessBox> {
? 'Codex profile on ${box.machineLabel}'
: box.field == NewHarnessField.mode
? 'Permissions for ${box.agentSettingsLabel}'
- : 'New Harness${box.placement == null ? '' : ' / ${box.placement!.title}'}',
+ : 'New Harness',
style: boxMonoStyle(size: 12, color: kBoxFaint),
),
),
@@ -875,6 +893,12 @@ class _NewHarnessBoxState extends State<NewHarnessBox> {
muted: !box.takesTask,
onTap: _editTask,
),
+ if (_launching && box.split == null)
+ _default(
+ 'placement',
+ box.placement!.title,
+ onTap: _togglePlacement,
+ ),
if (_launching) ...[
const SizedBox(height: 8),
_default(
@@ -922,7 +946,9 @@ class _NewHarnessBoxState extends State<NewHarnessBox> {
final disabled = name == 'create'
? box.busy || box.detectingAgent
: box.locked;
- final fieldLabel = '${name[0].toUpperCase()}${name.substring(1)}';
+ final fieldLabel = name == 'placement'
+ ? 'Open in'
+ : '${name[0].toUpperCase()}${name.substring(1)}';
return MouseRegion(
onHover: (event) {
if (choice != null && _pointer.moved(event)) {
@@ -1466,7 +1492,9 @@ class _NewHarnessBoxState extends State<NewHarnessBox> {
_ => 'use project',
}
: _launching && _launchChoice != _LaunchChoice.create
- ? 'edit ${_launchChoice.name}'
+ ? _launchChoice == _LaunchChoice.placement
+ ? 'switch'
+ : 'edit ${_launchChoice.name}'
: _launching && box.needsProject
? 'choose project'
: box.returnCreates
diff --git a/desktop/lib/widgets/pane_header_actions.dart b/desktop/lib/widgets/pane_header_actions.dart
index aeaecc9a6..d2a103663 100644
--- a/desktop/lib/widgets/pane_header_actions.dart
+++ b/desktop/lib/widgets/pane_header_actions.dart
@@ -33,7 +33,7 @@ class PaneHeaderActions extends StatelessWidget {
final bool zoomed, composerVisible;
/// The pane is a shell, not a harness: Restart and Stop say so, because
- /// "Stop Agent" over a terminal reads as a button for something else.
+ /// "Stop Harness" over a terminal reads as a button for something else.
final bool terminal;
final bool compact;
final VoidCallback? onShare;
@@ -138,13 +138,13 @@ class PaneHeaderActions extends StatelessWidget {
if (onShare != null)
(label: 'Share harness', callback: onShare),
(
- label: terminal ? 'Restart Terminal' : 'Restart Agent',
+ label: terminal ? 'Restart Terminal' : 'Restart Harness',
callback: onRestart,
),
- if (onFork != null) (label: 'Fork Agent', callback: onFork),
+ if (onFork != null) (label: 'Fork Harness', callback: onFork),
(label: 'Close Pane', callback: onClose),
(
- label: terminal ? 'Stop Terminal' : 'Stop Agent',
+ label: terminal ? 'Stop Terminal' : 'Stop Harness',
callback: onDelete,
),
],
@@ -176,17 +176,17 @@ class PaneHeaderActions extends StatelessWidget {
),
const SizedBox(width: 2),
action(
- terminal ? 'Restart Terminal' : 'Restart Agent',
+ terminal ? 'Restart Terminal' : 'Restart Harness',
LucideIcons.refreshCw,
onRestart,
),
const SizedBox(width: 2),
if (onFork != null) ...[
- action('Fork Agent', LucideIcons.gitFork, onFork),
+ action('Fork Harness', LucideIcons.gitFork, onFork),
const SizedBox(width: 2),
],
action(
- terminal ? 'Stop Terminal' : 'Stop Agent',
+ terminal ? 'Stop Terminal' : 'Stop Harness',
Icons.stop_rounded,
onDelete,
),
diff --git a/desktop/lib/widgets/rename_agent_dialog.dart b/desktop/lib/widgets/rename_agent_dialog.dart
index 04d020661..9c57cf0f0 100644
--- a/desktop/lib/widgets/rename_agent_dialog.dart
+++ b/desktop/lib/widgets/rename_agent_dialog.dart
@@ -19,11 +19,11 @@ Future<void> showAgentRenameDialog(
context,
keymap: keymap,
builder: (_) => TerminalNamePrompt(
- title: 'Rename Agent',
+ title: 'Rename Harness',
detail: notifier.stateOf(machineId)?.machine.displayName,
name: notifier.pendingAgentName(machineId, agentId) ?? currentName,
fieldKey: const Key('agent-rename-input'),
- fieldLabel: 'Agent name',
+ fieldLabel: 'Harness name',
pending: notifier.pendingAgentRename(machineId, agentId),
save: (name) => notifier.renameAgent(machineId, agentId, name),
),
diff --git a/desktop/lib/widgets/restart_agent_action.dart b/desktop/lib/widgets/restart_agent_action.dart
index 67a166fec..e1af104a0 100644
--- a/desktop/lib/widgets/restart_agent_action.dart
+++ b/desktop/lib/widgets/restart_agent_action.dart
@@ -204,7 +204,7 @@ class _RestartAgentPromptState extends State<_RestartAgentPrompt> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
- _terminal ? 'Restart Terminal' : 'Restart Agent',
+ _terminal ? 'Restart Terminal' : 'Restart Harness',
style: boxMonoStyle(size: 12, color: kBoxFaint),
),
const SizedBox(height: 12),
@@ -224,7 +224,7 @@ class _RestartAgentPromptState extends State<_RestartAgentPrompt> {
if (!_confirmAgain) ...[
const SizedBox(height: 10),
Text(
- _terminal ? 'Starts a fresh shell in the same pane.' : 'Relaunches the agent in the same pane and tries to resume its conversation.',
+ _terminal ? 'Starts a fresh shell in the same pane.' : 'Restarts the harness in the same pane and tries to resume its conversation.',
style: boxMonoStyle(size: 12, color: Colors.white70),
),
if (_busy) ...[
diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dart
index 0abb98278..cb6c7e88e 100644
--- a/desktop/lib/widgets/swarm_switcher.dart
+++ b/desktop/lib/widgets/swarm_switcher.dart
@@ -399,8 +399,10 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
final capacity = ((available - chrome) / _rowHeight).floor();
// A window too short for one row can only scroll a partial row.
if (capacity < 1) return constraints.maxHeight;
+ // Ten recent sessions plus the pinned New Harness row on a roomy screen.
+ // The measured capacity below still reduces this for smaller windows.
final maxRows = search.resultsFromBottom
- ? 6
+ ? 11
: widget.terminal
? 9
: 12;
diff --git a/desktop/lib/widgets/workspace_start_guide.dart b/desktop/lib/widgets/workspace_start_guide.dart
index cf5269e12..12229e470 100644
--- a/desktop/lib/widgets/workspace_start_guide.dart
+++ b/desktop/lib/widgets/workspace_start_guide.dart
@@ -1,12 +1,75 @@
import 'package:flutter/material.dart';
import '../shared/theme/app_theme.dart' as grid;
+import '../state/new_tab_wallpaper.dart';
import '../shortcuts/app_keymap.dart';
import '../shortcuts/keymap.dart';
import '../shortcuts/keymap_commands.dart';
import 'box_chrome.dart';
import 'welcome_project_example.dart';
+/// The everyday New Tab page leaves the dock as the only action surface.
+class NewTabStartPage extends StatelessWidget {
+ const NewTabStartPage({super.key, required this.wallpaper});
+
+ final NewTabWallpaper wallpaper;
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ return ColoredBox(
+ key: const ValueKey('new-tab-start-page'),
+ color: grid.AppPalette.swarmWelcome,
+ child: Stack(
+ fit: StackFit.expand,
+ children: [
+ IgnorePointer(
+ child: ExcludeSemantics(
+ child: Image.asset(
+ wallpaper.asset,
+ fit: BoxFit.cover,
+ filterQuality: FilterQuality.medium,
+ ),
+ ),
+ ),
+ // Preserve a quiet center even when a narrow window crops the art.
+ const IgnorePointer(
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ gradient: RadialGradient(
+ colors: [Color(0x99171717), Color(0x00171717)],
+ stops: [.1, 1],
+ radius: .65,
+ ),
+ ),
+ ),
+ ),
+ Center(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 32),
+ child: Text(
+ 'Follow your curiosity.',
+ key: const ValueKey('new-tab-tagline'),
+ textAlign: TextAlign.center,
+ style:
+ boxMonoStyle(
+ size: 24,
+ color: const Color(0xffd3d0ca),
+ weight: FontWeight.w600,
+ ).copyWith(
+ shadows: [
+ const Shadow(color: Color(0xaa171717), blurRadius: 18),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
+
/// A quiet, live keyboard map for an empty workspace. The drawing illustrates
/// tabs and panes. Only the full shortcuts link is interactive.
class WorkspaceStartGuide extends StatelessWidget {
diff --git a/desktop/pubspec.yaml b/desktop/pubspec.yaml
index c7170b23a..4c2683c74 100644
--- a/desktop/pubspec.yaml
+++ b/desktop/pubspec.yaml
@@ -111,6 +111,9 @@ flutter:
- assets/store/
- assets/store/projects/
- assets/store/covers/
+ - assets/welcome/leonardo-flight.png
+ - assets/welcome/leonardo-wings.png
+ - assets/welcome/leonardo-mechanisms.png
# The real app icon, shown in Settings ▸ About. Copied from the macOS
# icon set (`macos/Runner/Assets.xcassets/AppIcon.appiconset`) rather than
# loaded from the bundle: Flutter can't read an .icns, and About should show
diff --git a/desktop/test/clone_agent_test.dart b/desktop/test/clone_agent_test.dart
index 7b12058d9..d66d7aaa9 100644
--- a/desktop/test/clone_agent_test.dart
+++ b/desktop/test/clone_agent_test.dart
@@ -132,7 +132,7 @@ void main() {
test('a clone is named after its source the way a fork is', () {
expect(cloneNameFor('Reviewer'), 'Reviewer - clone');
- expect(cloneNameFor(' '), 'Agent - clone');
+ expect(cloneNameFor(' '), 'Harness - clone');
expect(forkNameFor('Reviewer'), 'Reviewer - fork');
});
diff --git a/desktop/test/command_dock_interaction_test.dart b/desktop/test/command_dock_interaction_test.dart
index e54c06754..61041a7d8 100644
--- a/desktop/test/command_dock_interaction_test.dart
+++ b/desktop/test/command_dock_interaction_test.dart
@@ -75,6 +75,8 @@ void main() {
highlighted('create');
}
await key(tester, LogicalKeyboardKey.arrowUp);
+ highlighted('placement');
+ await key(tester, LogicalKeyboardKey.arrowUp);
highlighted('task');
expect(
find.byKey(const ValueKey('new-harness-field-options')),
@@ -483,6 +485,56 @@ void main() {
},
);
+ for (final size in [const Size(1440, 1000), const Size(900, 560)]) {
+ testWidgets('recent sessions fill the available dock at $size', (
+ tester,
+ ) async {
+ final app = createApp();
+ addTearDown(app.dispose);
+ final map = MemoryKeymap();
+ addTearDown(map.dispose);
+ app.adoptSessionForTest(terminal('a69', []));
+ await configured.mount(tester, app, map);
+ tester.view.physicalSize = size;
+ await tester.pump();
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ final results = tester.widget<SwarmSearchResults>(
+ find.byType(SwarmSearchResults),
+ );
+ final list = tester.getRect(
+ find.byKey(const ValueKey('swarm-search-result-list')),
+ );
+ final visible = results.search.rows.where((row) {
+ if (row.isCreate) return false;
+ final finder = find.byKey(ValueKey(row.id));
+ if (finder.evaluate().isEmpty) return false;
+ final bounds = tester.getRect(finder);
+ return bounds.top >= list.top - 1 && bounds.bottom <= list.bottom + 1;
+ }).length;
+ if (size.height >= 1000) {
+ expect(visible, 10);
+ } else {
+ expect(visible, inInclusiveRange(1, 10));
+ }
+ expect(
+ find.byKey(const ValueKey('swarm-search-input')).hitTestable(),
+ findsOneWidget,
+ );
+ expect(
+ find.byKey(const ValueKey('create:harness')).hitTestable(),
+ findsOneWidget,
+ );
+ expect(
+ find.byKey(const ValueKey('swarm-search-hints')).hitTestable(),
+ findsOneWidget,
+ );
+ expect(tester.takeException(), isNull);
+ await tester.pump(const Duration(milliseconds: 100));
+ await tester.pumpWidget(const SizedBox());
+ await tester.pump(const Duration(milliseconds: 100));
+ });
+ }
+
for (final size in [const Size(1280, 800), const Size(600, 700)]) {
testWidgets(
'dock pins creation beside its input while matches filter at $size',
@@ -532,7 +584,7 @@ void main() {
tester
.getSize(find.byKey(const ValueKey('swarm-search-results')))
.height,
- lessThan(size.height * .4),
+ lessThan(size.height * .65),
);
}
await key(tester, LogicalKeyboardKey.slash, ctrl: true);
diff --git a/desktop/test/fork_agent_test.dart b/desktop/test/fork_agent_test.dart
index fdd60ec68..7e35446a0 100644
--- a/desktop/test/fork_agent_test.dart
+++ b/desktop/test/fork_agent_test.dart
@@ -195,7 +195,7 @@ void main() {
);
await tester.tap(find.text('open'));
await tester.pumpAndSettle();
- expect(find.text('Fork Agent'), findsOneWidget);
+ expect(find.text('Fork Harness'), findsOneWidget);
expect(find.textContaining('same project folder'), findsOneWidget);
final name = tester.widget<TextField>(
find.byKey(const ValueKey('fork-name')),
@@ -241,6 +241,6 @@ void main() {
test('forkNameFor is the source name with " - fork"', () {
expect(forkNameFor('Kinh Te'), 'Kinh Te - fork');
- expect(forkNameFor(' '), 'Agent - fork');
+ expect(forkNameFor(' '), 'Harness - fork');
});
}
diff --git a/desktop/test/harness_command_bar_test.dart b/desktop/test/harness_command_bar_test.dart
index eb7d1a047..e8a2598ee 100644
--- a/desktop/test/harness_command_bar_test.dart
+++ b/desktop/test/harness_command_bar_test.dart
@@ -360,7 +360,8 @@ void main() {
tester.testTextInput.enterText('Open a fresh tab');
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pumpAndSettle();
- expect(app.activeSwarmId, previousTab);
+ expect(app.activeSwarmId, isNot(previousTab));
+ expect(app.activeSwarm.isBlankNewTab, isTrue);
final picker = find.byKey(const ValueKey('swarm-search-input'));
expect(picker, findsOneWidget);
expect(tester.widget<TextField>(picker).focusNode!.hasFocus, isTrue);
diff --git a/desktop/test/harness_placement_test.dart b/desktop/test/harness_placement_test.dart
index ef5871ac4..dde7aa399 100644
--- a/desktop/test/harness_placement_test.dart
+++ b/desktop/test/harness_placement_test.dart
@@ -244,7 +244,8 @@ void main() {
'New harness launch',
);
expect(connection.requests, isEmpty);
- expect(app.swarms, [original]);
+ expect(app.swarms, contains(original));
+ expect(app.swarms, hasLength(2));
// Returning to advanced options preserves an explicit Default choice,
// even when discovery finds one profile and would normally select it.
@@ -375,7 +376,8 @@ void main() {
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pump();
expect(box.task, 'Keep this first task');
- expect(app.swarms, [original]);
+ expect(app.swarms, contains(original));
+ expect(app.swarms, hasLength(2));
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
expect(connection.requests, hasLength(2));
@@ -474,7 +476,8 @@ void main() {
find.descendant(of: mode, matching: find.text('Read only')),
findsOneWidget,
);
- expect(app.swarms, [original]);
+ expect(app.swarms, contains(original));
+ expect(app.swarms, hasLength(2));
final create = find.byKey(const ValueKey('create-agent-submit'));
await tester.ensureVisible(create);
await tester.tap(create);
@@ -806,7 +809,8 @@ void main() {
tester.widget<NewHarnessBox>(find.byType(NewHarnessBox)).controller,
same(box),
);
- expect(app.swarms, [original]);
+ expect(app.swarms, contains(original));
+ expect(app.swarms, hasLength(2));
}
await tester.tapAt(const Offset(12, 650));
await tester.pump();
@@ -939,7 +943,8 @@ void main() {
: LogicalKeyboardKey.keyP;
await chord(tester, key);
await tester.pump();
- expect(app.swarms, [original]);
+ expect(app.swarms, contains(original));
+ expect(app.swarms.length, placement == HarnessPlacement.newTab ? 2 : 1);
expect(find.text(placement.title), findsWidgets);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
@@ -955,7 +960,8 @@ void main() {
expect(box.engine, 'codex');
expect(box.machineId, 'm');
expect(box.project.folder, '/work/project');
- expect(app.swarms, [original]);
+ expect(app.swarms, contains(original));
+ expect(app.swarms.length, placement == HarnessPlacement.newTab ? 2 : 1);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
expect(app.activeSwarm, same(original));
diff --git a/desktop/test/keyboard_practice_test.dart b/desktop/test/keyboard_practice_test.dart
index 3cecb6042..cbcb3d06f 100644
--- a/desktop/test/keyboard_practice_test.dart
+++ b/desktop/test/keyboard_practice_test.dart
@@ -124,13 +124,13 @@ void main() {
await key(tester, LogicalKeyboardKey.keyT, cmd: true);
expect(find.text('[x] New Tab'), findsOneWidget);
await key(tester, LogicalKeyboardKey.escape);
- await openLesson(tester, 'Stop Agent');
+ await openLesson(tester, 'Stop Harness');
await tester.enterText(
find.byKey(const ValueKey('practice-command')),
- 'Stop Agent',
+ 'Stop Harness',
);
await key(tester, LogicalKeyboardKey.enter);
- expect(find.text('[x] Stop Agent'), findsOneWidget);
+ expect(find.text('[x] Stop Harness'), findsOneWidget);
expect(app.swarms, [original]);
expect(original.panes, panes);
expect(input, isEmpty);
diff --git a/desktop/test/keymap_runtime_test.dart b/desktop/test/keymap_runtime_test.dart
index e48a18efa..e6b09c2a5 100644
--- a/desktop/test/keymap_runtime_test.dart
+++ b/desktop/test/keymap_runtime_test.dart
@@ -200,8 +200,8 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
await key(tester, LogicalKeyboardKey.keyT, cmd: true);
- expect(app.swarms, hasLength(1));
- expect(app.activeSwarm, same(original));
+ expect(app.swarms, hasLength(2));
+ expect(app.activeSwarm, isNot(same(original)));
expect(
tester
.widget<TextField>(find.byKey(const ValueKey('swarm-search-input')))
@@ -748,7 +748,7 @@ void main() {
tester.testTextInput.updateEditingValue(TextEditingValue.empty);
await tester.pump();
await key(tester, LogicalKeyboardKey.keyT, cmd: true);
- expect(app.swarms, hasLength(1));
+ expect(app.swarms, hasLength(2));
expect(find.byKey(const ValueKey('swarm-search-input')), findsOneWidget);
await tester.pumpWidget(const SizedBox());
app.dispose();
diff --git a/desktop/test/new_harness_entry_rules_test.dart b/desktop/test/new_harness_entry_rules_test.dart
index f47ebbd21..bbdad77a5 100644
--- a/desktop/test/new_harness_entry_rules_test.dart
+++ b/desktop/test/new_harness_entry_rules_test.dart
@@ -167,6 +167,83 @@ void main() {
await key(tester, LogicalKeyboardKey.enter);
}
+ for (final shortcut in [
+ LogicalKeyboardKey.keyN,
+ LogicalKeyboardKey.keyP,
+ LogicalKeyboardKey.keyT,
+ ]) {
+ testWidgets(
+ '${shortcut.keyLabel} defaults Open in correctly and lets users change it',
+ (tester) async {
+ await mount(tester, store: false);
+ final origin = app.activeSwarm;
+ await key(tester, shortcut, cmd: true);
+ if (shortcut != LogicalKeyboardKey.keyN) {
+ await key(tester, LogicalKeyboardKey.enter);
+ }
+ final controller = box(tester);
+ final initial = shortcut == LogicalKeyboardKey.keyT
+ ? HarnessPlacement.newTab
+ : HarnessPlacement.currentTab;
+ expect(controller.placement, initial);
+ final placement = find.byKey(
+ const ValueKey('new-harness-field-placement'),
+ );
+ expect(placement.hitTestable(), findsOneWidget);
+ expect(
+ tester.getTopLeft(placement).dy,
+ greaterThan(
+ tester
+ .getTopLeft(
+ find.byKey(const ValueKey('new-harness-field-task')),
+ )
+ .dy,
+ ),
+ );
+ expect(
+ tester.getTopLeft(placement).dy,
+ lessThan(
+ tester
+ .getTopLeft(
+ find.byKey(const ValueKey('new-harness-field-create')),
+ )
+ .dy,
+ ),
+ );
+ final choice = initial == HarnessPlacement.newTab
+ ? HarnessPlacement.currentTab
+ : HarnessPlacement.newTab;
+ await key(tester, LogicalKeyboardKey.arrowUp);
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(controller.placement, choice);
+ expect(
+ find.descendant(of: placement, matching: find.text(choice.title)),
+ findsOneWidget,
+ );
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(controller.placement, initial);
+ await tester.tap(placement);
+ await tester.pump();
+ expect(controller.placement, choice);
+ expect(
+ find.descendant(of: placement, matching: find.text(choice.title)),
+ findsOneWidget,
+ );
+ expect(connections['m']!.starts, isEmpty);
+ await key(tester, LogicalKeyboardKey.arrowDown);
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(connections['m']!.starts, hasLength(1));
+ connections['m']!.created();
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 200));
+ expect(app.swarms.length, 2);
+ expect(origin.panes.single.agentId, 'a0');
+ expect(app.activeSwarm.panes.single.agentId, 'created-1');
+ await tester.pumpWidget(const SizedBox());
+ },
+ );
+ }
+
for (final closeFirst in [false, true]) {
for (final task in [null, 'Model a reading nook']) {
testWidgets(
@@ -376,8 +453,9 @@ void main() {
expect(updated.selected?.agentId, 'a1');
await key(tester, LogicalKeyboardKey.enter);
expect(app.focusedPane?.agentId, 'a1');
- expect(app.activeSwarm == origin, !newTab);
- expect(app.swarms.length, newTab ? 2 : 1);
+ // Cmd-P operates on the visible tab, including a tab just opened by Cmd-T.
+ expect(app.activeSwarm, isNot(same(origin)));
+ expect(app.swarms.length, 2);
expect(connections.values.expand((c) => c.starts), isEmpty);
await tester.pumpWidget(const SizedBox());
},
@@ -418,7 +496,8 @@ void main() {
);
expect(updated.focusNode.hasFocus, isTrue);
expect(find.text(nextTab ? 'New Tab' : 'New Pane'), findsOneWidget);
- expect(app.swarms, [origin]);
+ expect(app.swarms.first, same(origin));
+ expect(app.swarms.length, newTab || nextTab ? 2 : 1);
await key(tester, LogicalKeyboardKey.enter);
expect(box(tester).task, 'Check the keyboard workflow');
expect(
@@ -433,7 +512,7 @@ void main() {
connections['m']!.created();
await tester.pump();
await tester.pump(const Duration(milliseconds: 200));
- expect(app.swarms.length, nextTab ? 2 : 1);
+ expect(app.swarms.length, newTab || nextTab ? 2 : 1);
expect(app.focusedPane?.agentId, 'created-1');
await tester.pumpWidget(const SizedBox());
},
@@ -494,13 +573,16 @@ void main() {
expect(draft.engine, 'codex');
expect(draft.machineId, 'm');
expect(draft.project.folder, '/work/openharness');
- expect(app.swarms, [origin]);
+ expect(app.swarms.first, same(origin));
+ expect(app.swarms.length, newTab ? 2 : 1);
draft.focusField(NewHarnessField.task);
await tester.pump();
await tester.enterText(input, 'Check keyboard focus');
await key(tester, LogicalKeyboardKey.escape);
await nameProject(tester, 'keyboard-review');
await dismiss(tester);
+ expect(app.swarms, [origin]);
+ expect(app.activeSwarm, same(origin));
await key(
tester,
newTab ? LogicalKeyboardKey.keyP : LogicalKeyboardKey.keyT,
diff --git a/desktop/test/pane_restart_test.dart b/desktop/test/pane_restart_test.dart
index eea6cdb68..b9309fa3d 100644
--- a/desktop/test/pane_restart_test.dart
+++ b/desktop/test/pane_restart_test.dart
@@ -62,7 +62,7 @@ void main() {
await tester.tap(
find.descendant(
of: controls,
- matching: find.byTooltip('Restart Agent'),
+ matching: find.byTooltip('Restart Harness'),
),
);
await tester.pumpAndSettle();
@@ -90,7 +90,7 @@ void main() {
of: controls,
matching: find.byWidgetPredicate(
(widget) =>
- widget is IconButton && widget.tooltip == 'Restart Agent',
+ widget is IconButton && widget.tooltip == 'Restart Harness',
),
),
);
diff --git a/desktop/test/quick_access_test.dart b/desktop/test/quick_access_test.dart
index 5347c7c8e..81cb2fb9d 100644
--- a/desktop/test/quick_access_test.dart
+++ b/desktop/test/quick_access_test.dart
@@ -125,8 +125,8 @@ void main() {
final map = MemoryKeymap();
addTearDown(map.dispose);
await configured.mount(tester, app, map);
- final tabs = app.swarms.length;
await key(tester, entry, cmd: true);
+ final tabs = app.swarms.length;
final input = find.byKey(const ValueKey('swarm-search-input'));
final field = tester.widget<TextField>(input);
final search = tester
diff --git a/desktop/test/rename_agent_dialog_test.dart b/desktop/test/rename_agent_dialog_test.dart
index 5a12416aa..03378df09 100644
--- a/desktop/test/rename_agent_dialog_test.dart
+++ b/desktop/test/rename_agent_dialog_test.dart
@@ -52,14 +52,14 @@ void main() {
);
await tester.tap(find.text('rename'));
await tester.pumpAndSettle();
- expect(find.text('Rename Agent'), findsOneWidget);
+ expect(find.text('Rename Harness'), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
// Pumped through the WHOLE exit transition, which is the window the bug
// lived in: one pump would settle before the rebuild that threw.
await tester.pumpAndSettle();
- expect(find.text('Rename Agent'), findsNothing);
+ expect(find.text('Rename Harness'), findsNothing);
expect(
tester.takeException(),
isNull,
diff --git a/desktop/test/stop_keyboard_test.dart b/desktop/test/stop_keyboard_test.dart
index 2dd535a6c..3e32d075d 100644
--- a/desktop/test/stop_keyboard_test.dart
+++ b/desktop/test/stop_keyboard_test.dart
@@ -82,7 +82,7 @@ void main() {
app.adoptSessionForTest(terminal('a1', input));
await mount(tester);
await open(tester);
- expect(find.text('Stop Agent'), findsOneWidget);
+ expect(find.text('Stop Harness'), findsOneWidget);
expect(
find.textContaining('Close Pane keeps it running.'),
findsOneWidget,
@@ -90,7 +90,7 @@ void main() {
// The default action must leave the agent running.
await key(tester, LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
- expect(find.text('Stop Agent'), findsNothing);
+ expect(find.text('Stop Harness'), findsNothing);
expect(connection.stops, isEmpty);
await open(tester);
await key(tester, LogicalKeyboardKey.tab);
@@ -102,7 +102,7 @@ void main() {
expect(connection.stops, hasLength(1));
await key(tester, LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
- expect(find.text('Stop Agent'), findsNothing);
+ expect(find.text('Stop Harness'), findsNothing);
await open(tester);
expect(find.text('Stopping…'), findsOneWidget);
expect(connection.stops, hasLength(1));
@@ -117,14 +117,14 @@ void main() {
LogicalKeyboardKey.enter,
); // Retry still starts on Cancel.
await tester.pumpAndSettle();
- expect(find.text('Stop Agent'), findsNothing);
+ expect(find.text('Stop Harness'), findsNothing);
expect(connection.stops, hasLength(1));
await open(tester);
await key(tester, LogicalKeyboardKey.tab);
await key(tester, LogicalKeyboardKey.enter);
connection.stopReplies.last.complete({'deleted': true});
await tester.pumpAndSettle();
- expect(find.text('Stop Agent'), findsNothing);
+ expect(find.text('Stop Harness'), findsNothing);
expect(app.allPanes, [retained]);
expect(app.focusedPane, same(retained));
expect(input, isEmpty);
@@ -152,7 +152,7 @@ void main() {
await open(tester, accept: LogicalKeyboardKey.f8);
expect(find.text('F8 select'), findsOneWidget);
await key(tester, LogicalKeyboardKey.escape);
- expect(find.text('Stop Agent'), findsOneWidget);
+ expect(find.text('Stop Harness'), findsOneWidget);
await key(tester, LogicalKeyboardKey.f6);
await key(tester, LogicalKeyboardKey.f8);
expect(connection.stops, ['a0']);
@@ -163,10 +163,10 @@ void main() {
await tester.pump();
expect(find.text('F4 close'), findsOneWidget);
await key(tester, LogicalKeyboardKey.escape);
- expect(find.text('Stop Agent'), findsOneWidget);
+ expect(find.text('Stop Harness'), findsOneWidget);
await key(tester, LogicalKeyboardKey.f4);
await tester.pumpAndSettle();
- expect(find.text('Stop Agent'), findsNothing);
+ expect(find.text('Stop Harness'), findsNothing);
connection.stopReplies.single.complete({'error': 'REFUSED'});
await tester.pumpAndSettle();
expect(app.stateOf('m')!.agents.any((agent) => agent.id == 'a0'), isTrue);
@@ -261,7 +261,7 @@ void main() {
LogicalKeyboardKey.enter,
); // Cancel retains focus on error.
await tester.pumpAndSettle();
- expect(find.text('Stop Agent'), findsNothing);
+ expect(find.text('Stop Harness'), findsNothing);
await tester.pumpWidget(const SizedBox());
});
}
diff --git a/desktop/test/stopped_harness_test.dart b/desktop/test/stopped_harness_test.dart
index aa31776e0..600b9efbe 100644
--- a/desktop/test/stopped_harness_test.dart
+++ b/desktop/test/stopped_harness_test.dart
@@ -11,13 +11,14 @@ import 'package:harness/state/swarm_search.dart';
import 'support/restart_connection.dart';
import 'swarm_interactions_test.dart' show chord;
-import 'swarm_screen_test.dart' show mount;
+import 'swarm_screen_test.dart' show mount, terminal;
import 'swarm_state_test.dart' show createApp;
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
late AppNotifier app;
late RestartConnection connection;
+ var disposed = false;
const stopped = Agent(
id: 'saved',
name: 'Saved work',
@@ -27,11 +28,14 @@ void main() {
project: AgentProject(name: 'Project', cwd: '/work/project'),
);
setUp(() {
+ disposed = false;
connection = RestartConnection();
app = createApp(connectionForTest: (_) => connection);
app.machineStates['m']!.agents.add(stopped);
});
- tearDown(() => app.dispose());
+ tearDown(() {
+ if (!disposed) app.dispose();
+ });
SwarmDestination row() =>
swarmDestinations(app).firstWhere((row) => row.agentId == stopped.id);
@@ -184,6 +188,74 @@ void main() {
},
);
+ test('native login or hook review is visible while conversation confirmation is pending', () async {
+ final opening = activateSwarmSearchSelection(
+ app,
+ SwarmSearchSelection(row()),
+ destinationSwarmId: app.activeSwarmId,
+ placement: HarnessPlacement.currentTab,
+ );
+ await app.handleEventForTest('m', {
+ 'type': 'agent_synced',
+ 'payload': {
+ 'agent': {
+ 'id': 'saved',
+ 'name': 'Saved work',
+ 'engine': 'codex',
+ 'sessionId': 'original-conversation',
+ 'launch': {'state': 'starting'},
+ 'terminal': {'available': true},
+ },
+ },
+ });
+ expect(await opening, isTrue);
+ expect(app.allPanes.single.agentId, 'saved');
+ expect(connection.restartReplies.single.isCompleted, isFalse);
+ connection.restartReplies.single.complete(
+ restartReceipt(
+ connection.requests.single['creationId'] as String,
+ agentId: 'saved',
+ sessionId: 'original-conversation',
+ ),
+ );
+ await Future<void>.delayed(Duration.zero);
+ expect(connection.types, ['agent_resume']);
+ });
+
+ test(
+ 'a different conversation push cannot open an unconfirmed resume',
+ () async {
+ final opening = activateSwarmSearchSelection(
+ app,
+ SwarmSearchSelection(row()),
+ destinationSwarmId: app.activeSwarmId,
+ placement: HarnessPlacement.newTab,
+ );
+ final failed = expectLater(opening, throwsA(isA<SwarmResumeFailure>()));
+ await app.handleEventForTest('m', {
+ 'type': 'agent_synced',
+ 'payload': {
+ 'agent': {
+ 'id': 'saved',
+ 'name': 'Different work',
+ 'engine': 'codex',
+ 'sessionId': 'other-conversation',
+ 'launch': {'state': 'starting'},
+ 'terminal': {'available': true},
+ },
+ },
+ });
+ expect(app.allPanes, isEmpty);
+ connection.restartReplies.single.complete({
+ 'creationId': connection.requests.single['creationId'],
+ 'state': 'failed',
+ 'failure': {'code': 'RESUME_SESSION_MISMATCH'},
+ });
+ await failed;
+ expect(app.allPanes, isEmpty);
+ },
+ );
+
test('never accepts a fresh conversation as a successful resume', () async {
final opening = app.resumeAgent('m', 'saved');
connection.restartReplies.single.complete(
@@ -222,6 +294,48 @@ void main() {
},
);
+ for (final key in [LogicalKeyboardKey.keyP, LogicalKeyboardKey.keyT]) {
+ testWidgets(
+ '${key.keyLabel} opens retained work with Enter and preserves other panes',
+ (tester) async {
+ final existing = app.adoptSessionForTest(terminal('a0', []));
+ final originalTab = app.activeSwarmId;
+ await mount(tester, app);
+ await chord(tester, key);
+ await tester.pump();
+ await tester.enterText(
+ find.byKey(const ValueKey('swarm-search-input')),
+ 'Saved work',
+ );
+ await tester.pump();
+ expect(find.textContaining('Stopped'), findsNothing);
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ expect(connection.types, ['agent_resume']);
+ expect(find.byType(AlertDialog), findsNothing);
+ connection.restartReplies.single.complete(
+ restartReceipt(
+ connection.requests.single['creationId'] as String,
+ agentId: 'saved',
+ sessionId: 'original-conversation',
+ ),
+ );
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 100));
+ expect(app.allPanes.any((pane) => pane.agentId == 'saved'), isTrue);
+ expect(app.allPanes.contains(existing), isTrue);
+ expect(
+ app.activeSwarmId == originalTab,
+ key == LogicalKeyboardKey.keyP,
+ );
+ expect(connection.types, ['agent_resume']);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ disposed = true;
+ },
+ );
+ }
+
testWidgets('Enter submits resume immediately with no confirmation dialog', (
tester,
) async {
diff --git a/desktop/test/stopped_tab_cleanup_test.dart b/desktop/test/stopped_tab_cleanup_test.dart
new file mode 100644
index 000000000..96c7fb4c3
--- /dev/null
+++ b/desktop/test/stopped_tab_cleanup_test.dart
@@ -0,0 +1,215 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+import 'package:flutter/services.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/pane_preset.dart';
+import 'package:harness/state/swarm.dart';
+import 'package:harness/state/terminal_pane.dart';
+import 'package:harness/state/new_harness.dart';
+
+import 'support/stop_connection.dart';
+import 'swarm_state_test.dart' show createApp;
+import 'swarm_interactions_test.dart' show chord;
+import 'swarm_screen_test.dart' show terminal, mount;
+
+class _Connection extends StopConnection {
+ final create = Completer<Map<String, dynamic>>();
+ @override
+ Future<Map<String, dynamic>> request(
+ String type, {
+ Map<String, dynamic> payload = const {},
+ Duration timeout = const Duration(seconds: 20),
+ }) => type == 'agent_create'
+ ? create.future
+ : super.request(type, payload: payload, timeout: timeout);
+}
+
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+ late AppNotifier app;
+ late _Connection connection;
+ setUp(() {
+ newHarnessOpensInBox = true;
+ connection = _Connection();
+ app = createApp(connectionForTest: (_) => connection);
+ });
+ tearDown(() {
+ newHarnessOpensInBox = false;
+ app.dispose();
+ });
+ Future<void> stopped([String machine = 'm', String agent = 'a0']) =>
+ app.handleEventForTest(machine, {
+ 'type': 'agent_deleted',
+ 'payload': {'agentId': agent},
+ });
+
+ test(
+ 'stopping a store harness closes only its emptied tab and owned viewer',
+ () async {
+ final other = app.adoptSessionForTest(terminal('a1', []));
+ final otherTab = app.activeSwarm;
+ app.newSwarm(name: 'Blender');
+ final closing = app.activeSwarm;
+ app.adoptSessionForTest(terminal('a0', []));
+ closing.panes.add(
+ TerminalPane(
+ id: 900,
+ machineId: 'm',
+ kind: PaneKind.web,
+ ownerAgentId: 'a0',
+ url: 'http://fixture.invalid',
+ ),
+ );
+ final stop = app.deleteAgent('m', 'a0');
+ connection.stopReplies.single.complete({'deleted': true});
+ expect(await stop, isNull);
+ expect(app.swarms, [otherTab]);
+ expect(app.activeSwarm, same(otherTab));
+ expect(app.allPanes, [other]);
+ },
+ );
+ test('a background stop does not switch the tab the user is using', () async {
+ app.adoptSessionForTest(terminal('a0', []));
+ final closing = app.activeSwarm;
+ app.newSwarm(name: 'Working');
+ final current = app.activeSwarm;
+ final kept = app.adoptSessionForTest(terminal('a1', []));
+ await stopped();
+ expect(app.swarms.contains(closing), isFalse);
+ expect(app.activeSwarm, same(current));
+ expect(app.focusedPane, same(kept));
+ });
+ test('all affected empty tabs close while a shared tab with another pane survives', () async {
+ final shared = app.adoptSessionForTest(terminal('a0', []));
+ final one = app.activeSwarm;
+ app.newSwarm(name: 'Second');
+ final two = app.activeSwarm;
+ two.panes.add(shared);
+ app.newSwarm(name: 'Mixed');
+ final mixed = app.activeSwarm;
+ mixed.panes.add(shared);
+ final kept = app.adoptSessionForTest(terminal('a1', []));
+ await stopped();
+ expect(app.swarms.contains(one), isFalse);
+ expect(app.swarms.contains(two), isFalse);
+ expect(app.swarms, [mixed]);
+ expect(app.allPanes, [kept]);
+ });
+ test(
+ 'does not sweep unrelated empty, store, orchestrator, or draft tabs',
+ () async {
+ app.adoptSessionForTest(terminal('a0', []));
+ final blank = Swarm(id: 'blank');
+ final store = Swarm(id: 'store', kind: 'store');
+ final orchestrator = Swarm(id: 'orchestrator', kind: 'orchestrator');
+ app.swarms.addAll([blank, store, orchestrator]);
+ app.newSwarm(draft: true);
+ final selected = app.activeSwarm;
+ await stopped();
+ expect(app.swarms, containsAll([blank, store, orchestrator]));
+ expect(app.activeSwarm, same(selected));
+ },
+ );
+ for (final keep in [
+ 'other machine',
+ 'unowned viewer',
+ 'placeholder',
+ 'preset',
+ ]) {
+ test('preserves a tab containing $keep', () async {
+ app.adoptSessionForTest(terminal('a0', []));
+ final tab = app.activeSwarm;
+ if (keep == 'preset') {
+ tab.presets[2] = PanePreset.columns;
+ } else {
+ tab.panes.add(
+ TerminalPane(
+ id: 901,
+ machineId: keep == 'other machine' ? 'other' : 'm',
+ agentId: keep == 'other machine' ? 'a0' : null,
+ ownerAgentId: keep == 'unowned viewer' ? 'a1' : null,
+ kind: keep == 'unowned viewer' ? PaneKind.web : PaneKind.terminal,
+ ),
+ );
+ }
+ await stopped();
+ expect(app.swarms.single, same(tab));
+ });
+ }
+ test('a late Stop reply cannot close a reused identity or its tab', () async {
+ app.adoptSessionForTest(terminal('a0', []));
+ final tab = app.activeSwarm;
+ final stop = app.deleteAgent('m', 'a0');
+ app.stateOf('m')!.agents[0] = const Agent(
+ id: 'a0',
+ name: 'Replacement',
+ sessionId: 'new-session',
+ );
+ connection.stopReplies.single.complete({'deleted': true});
+ expect(await stop, isNotNull);
+ expect(app.swarms.single, same(tab));
+ expect(tab.panes, hasLength(1));
+ });
+ test('creation already in flight keeps its destination even when the old final pane stops', () async {
+ app.adoptSessionForTest(terminal('a0', []));
+ final tab = app.activeSwarm;
+ app.stateOf('m')!.nodeOnline = true;
+ final creation = app.createAgent(
+ 'm',
+ engine: 'codex',
+ folder: '/tmp',
+ swarmId: tab.id,
+ );
+ await Future<void>.delayed(Duration.zero);
+ await stopped();
+ expect(app.swarms.single, same(tab));
+ connection.create.complete({'error': 'FIXTURE_FAILURE'});
+ await creation;
+ });
+ testWidgets('Escape restores onboarding if the draft return tab stopped', (
+ tester,
+ ) async {
+ app.status = AppStatus.authenticated;
+ app.adoptSessionForTest(terminal('a0', []));
+ await mount(tester, app);
+ await chord(tester, LogicalKeyboardKey.keyT);
+ final draft = app.activeSwarmId;
+ expect(app.swarms, hasLength(2));
+ await stopped();
+ await tester.pump();
+ expect(app.swarms, hasLength(1));
+ expect(app.activeSwarmId, draft);
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 200));
+ expect(app.swarms, hasLength(1));
+ expect(app.activeSwarmId, isNot(draft));
+ expect(app.activeSwarm.isNewTabPage, isFalse);
+ expect(app.activeSwarm.isEmptyStarter, isTrue);
+ expect(find.byKey(const ValueKey('swarm-search-input')), findsOneWidget);
+ await tester.pumpWidget(const SizedBox());
+ });
+ testWidgets('last stopped tab becomes one welcome page with its dock open', (
+ tester,
+ ) async {
+ // The same entry condition as an authenticated, connected workspace.
+ app.status = AppStatus.authenticated;
+ app.adoptSessionForTest(terminal('a0', []));
+ app.renameSwarm(app.activeSwarmId, 'Blender');
+ final oldId = app.activeSwarmId;
+ await mount(tester, app);
+ await stopped();
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 200));
+ expect(app.swarms, hasLength(1));
+ expect(app.activeSwarmId, isNot(oldId));
+ expect(app.activeSwarm.isEmptyStarter, isTrue);
+ expect(find.byKey(const ValueKey('swarm-search-input')), findsOneWidget);
+ await stopped();
+ expect(app.swarms, hasLength(1));
+ await tester.pumpWidget(const SizedBox());
+ });
+}
diff --git a/desktop/test/swarm_entry_picker_test.dart b/desktop/test/swarm_entry_picker_test.dart
index 248ed8611..00f9150a0 100644
--- a/desktop/test/swarm_entry_picker_test.dart
+++ b/desktop/test/swarm_entry_picker_test.dart
@@ -182,7 +182,7 @@ void main() {
for (final dismissal in ['outside', 'escape']) {
testWidgets(
- 'New Tab has a usable page after $dismissal (native=$native)',
+ 'New Tab discards its empty draft after $dismissal (native=$native)',
(tester) async {
final app = createApp();
final frames = <TerminalBinaryFrame>[];
@@ -191,7 +191,8 @@ void main() {
await mount(tester, app, nativeTabs: native);
await chord(tester, LogicalKeyboardKey.keyT);
await tester.pump();
- expect(app.activeSwarmId, original);
+ expect(app.activeSwarmId, isNot(original));
+ expect(app.activeSwarm.isNewTabPage, isTrue);
expect(_results, findsOneWidget);
expect(_startInput, findsNothing);
if (dismissal == 'outside') {
diff --git a/desktop/test/swarm_immediate_input_test.dart b/desktop/test/swarm_immediate_input_test.dart
index 49da4d5d2..fec4d5b5b 100644
--- a/desktop/test/swarm_immediate_input_test.dart
+++ b/desktop/test/swarm_immediate_input_test.dart
@@ -103,8 +103,9 @@ void main() {
await tester.pump(const Duration(milliseconds: 10));
expect(secondInput, isEmpty, reason: 'The old agent owns no input');
if (action == 'new tab') {
- expect(app.panes, [first, second]);
- expect(app.swarms, hasLength(1));
+ expect(app.panes, isEmpty);
+ expect(app.swarms.first.panes, [first, second]);
+ expect(app.swarms, hasLength(2));
expect(firstInput, isEmpty);
expect(
tester
diff --git a/desktop/test/swarm_interactions_test.dart b/desktop/test/swarm_interactions_test.dart
index 2efb43524..4ab647fe6 100644
--- a/desktop/test/swarm_interactions_test.dart
+++ b/desktop/test/swarm_interactions_test.dart
@@ -70,7 +70,7 @@ Future<void> chord(
void main() {
for (final native in [false, true]) {
testWidgets(
- 'New Tab actions defer placement until selection (native: $native)',
+ 'New Tab opens a minimal draft and Escape removes only that draft (native: $native)',
(tester) async {
const channel = MethodChannel('harness/swarm_tabs');
const codec = StandardMethodCodec();
@@ -114,6 +114,7 @@ void main() {
expect(replied, isTrue);
}
+ Object? previousWallpaper;
for (final action in <Future<void> Function()>[
() => chord(tester, LogicalKeyboardKey.keyT),
newFromChrome,
@@ -131,12 +132,29 @@ void main() {
await tester.pumpAndSettle();
await action();
await tester.pumpAndSettle();
- expect(app.activeSwarmId, work);
- expect(app.swarms, hasLength(2));
+ expect(app.activeSwarmId, isNot(work));
+ expect(app.activeSwarm.isNewTabPage, isTrue);
+ final wallpaper = app.activeSwarm.wallpaper;
+ if (previousWallpaper != null) {
+ expect(wallpaper, isNot(previousWallpaper));
+ }
+ previousWallpaper = wallpaper;
+ expect(app.swarms, hasLength(3));
+ expect(find.text('Follow your curiosity.'), findsWidgets);
+ expect(
+ find.text('Follow your curiosity. Build across disciplines.'),
+ findsNothing,
+ );
final input = find.byKey(const ValueKey('swarm-search-input'));
expect(tester.widget<TextField>(input).focusNode!.hasFocus, isTrue);
await tester.enterText(input, 'Agent 1');
await tester.pump();
+ expect(app.activeSwarm.wallpaper, wallpaper);
+ await chord(tester, LogicalKeyboardKey.keyT);
+ expect(app.activeSwarm.wallpaper, isNot(wallpaper));
+ previousWallpaper = app.activeSwarm.wallpaper;
+ expect(app.swarms, hasLength(3));
+ expect(tester.widget<TextField>(input).controller!.text, 'Agent 1');
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
expect(input, findsNothing);
@@ -152,9 +170,13 @@ void main() {
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
- expect(app.activeSwarmId, starter);
- expect(app.swarms, hasLength(2));
+ expect(app.activeSwarmId, isNot(starter));
+ expect(app.swarms, hasLength(3));
expect(app.panes.single.agentId, 'a0');
+ expect(
+ app.swarms.firstWhere((tab) => tab.id == work).panes.single.agentId,
+ 'a0',
+ );
await tester.pumpWidget(const SizedBox());
app.dispose();
projects.dispose();
@@ -243,13 +265,13 @@ void main() {
'Share harness',
'Show message composer',
'Zoom Pane',
- 'Restart Agent',
- 'Fork Agent',
- 'Stop Agent',
+ 'Restart Harness',
+ 'Fork Harness',
+ 'Stop Harness',
'Close Pane',
]),
);
- expect(find.byTooltip('Stop Agent').first.hitTestable(), findsNothing);
+ expect(find.byTooltip('Stop Harness').first.hitTestable(), findsNothing);
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
await mouse.addPointer(location: const Offset(1, 1));
Future<void> hover() async {
@@ -276,10 +298,10 @@ void main() {
await hover();
await tester.tap(
- find.descendant(of: controls, matching: find.byTooltip('Stop Agent')),
+ find.descendant(of: controls, matching: find.byTooltip('Stop Harness')),
);
await tester.pumpAndSettle();
- expect(find.text('Stop Agent'), findsOneWidget);
+ expect(find.text('Stop Harness'), findsOneWidget);
expect(find.text('Stop'), findsOneWidget);
expect(app.panes, contains(pane));
expect(original.panes.single.session, same(session));
@@ -398,6 +420,10 @@ void main() {
);
final starter = app.activeSwarmId;
await activate('new');
+ expect(app.swarms, hasLength(2));
+ expect(app.activeSwarmId, isNot(starter));
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
expect(app.swarms, hasLength(1));
expect(app.activeSwarmId, starter);
expect(input, hasLength(2));
diff --git a/desktop/test/swarm_screen_test.dart b/desktop/test/swarm_screen_test.dart
index 99bb63c4d..f7b458ab1 100644
--- a/desktop/test/swarm_screen_test.dart
+++ b/desktop/test/swarm_screen_test.dart
@@ -163,7 +163,7 @@ void main() {
}
await tester.pump();
await tester.pump(const Duration(milliseconds: 300));
- expect(app.swarms, hasLength(30));
+ expect(app.swarms, hasLength(31));
final input = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(input, 'Agent 1');
await tester.pump();
diff --git a/desktop/test/swarm_switcher_test.dart b/desktop/test/swarm_switcher_test.dart
index 66de8d713..90fa83fc7 100644
--- a/desktop/test/swarm_switcher_test.dart
+++ b/desktop/test/swarm_switcher_test.dart
@@ -57,7 +57,11 @@ void main() {
await tester.tap(find.byKey(const ValueKey('swarm-new-tab-button')));
await tester.pump();
}
- expect(app.activeSwarm, same(original));
+ final draft = app.activeSwarm;
+ expect(draft, isNot(same(original)));
+ expect(draft.isBlankNewTab, isTrue);
+ expect(app.swarms, hasLength(2));
+ expect(original.panes, [pane]);
expect(find.byType(AlertDialog), findsNothing);
final field = find.byKey(const ValueKey('swarm-search-input'));
expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
@@ -66,7 +70,7 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
final opened = app.activeSwarm;
- expect(opened, isNot(same(original)));
+ expect(opened, same(draft));
expect(opened.panes, [pane]);
expect(original.panes, [pane]);
expect(app.focusedPane, same(pane));
@@ -121,8 +125,9 @@ void main() {
await tester.pump();
await tester.tap(find.byKey(const ValueKey('command:swarm.new')));
await tester.pump();
- expect(app.panes, [pane]);
- expect(app.swarms, hasLength(1));
+ expect(app.activeSwarm.isBlankNewTab, isTrue);
+ expect(app.panes, isEmpty);
+ expect(app.swarms, hasLength(2));
expect(app.allPanes, contains(pane));
expect(jumpField, findsOneWidget);
final search = tester
diff --git a/desktop/test/terminal_panel_presentation_test.dart b/desktop/test/terminal_panel_presentation_test.dart
index a01535fc6..e3948a299 100644
--- a/desktop/test/terminal_panel_presentation_test.dart
+++ b/desktop/test/terminal_panel_presentation_test.dart
@@ -57,8 +57,8 @@ void main() {
await tester.pump(const Duration(milliseconds: 120));
await tester.tap(find.byTooltip('Show message composer'));
await tester.tap(find.byTooltip('Zoom Pane'));
- await tester.tap(find.byTooltip('Restart Agent'));
- await tester.tap(find.byTooltip('Stop Agent'));
+ await tester.tap(find.byTooltip('Restart Harness'));
+ await tester.tap(find.byTooltip('Stop Harness'));
await tester.tap(find.byTooltip('Close Pane'));
await tester.pump();
expect(closed, [1]);
@@ -177,7 +177,7 @@ void main() {
tester.getRect(find.text('main')).left,
greaterThan(tester.getRect(find.text('harness')).right),
);
- expect(find.byTooltip('Stop Agent').hitTestable(), findsNothing);
+ expect(find.byTooltip('Stop Harness').hitTestable(), findsNothing);
expect(
find.descendant(of: controls, matching: find.byType(IconButton)),
findsNWidgets(local ? 5 : 6),
@@ -186,7 +186,7 @@ void main() {
await mouse.addPointer(location: tester.getCenter(title));
await tester.pump(const Duration(milliseconds: 120));
expect(tester.widget<AnimatedOpacity>(details).opacity, 0);
- expect(find.byTooltip('Stop Agent').hitTestable(), findsOneWidget);
+ expect(find.byTooltip('Stop Harness').hitTestable(), findsOneWidget);
expect(find.byTooltip('Share harness').hitTestable(), findsOneWidget);
expect(tester.getRect(title), titleBounds);
expect(
@@ -196,11 +196,11 @@ void main() {
await mouse.moveTo(const Offset(300, 200));
await tester.pump(const Duration(milliseconds: 120));
expect(tester.widget<AnimatedOpacity>(details).opacity, 1);
- expect(find.byTooltip('Stop Agent').hitTestable(), findsNothing);
+ expect(find.byTooltip('Stop Harness').hitTestable(), findsNothing);
// Keyboard users can reveal and reach the same actions without a mouse.
- Focus.of(tester.element(find.byTooltip('Stop Agent'))).nextFocus();
+ Focus.of(tester.element(find.byTooltip('Stop Harness'))).nextFocus();
await tester.pump(const Duration(milliseconds: 120));
- expect(find.byTooltip('Stop Agent').hitTestable(), findsOneWidget);
+ expect(find.byTooltip('Stop Harness').hitTestable(), findsOneWidget);
await mouse.removePointer();
await tester.pumpWidget(const SizedBox());
session.dispose();
@@ -270,8 +270,8 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('Zoom Pane'), findsOneWidget);
expect(find.text('Show viewer'), findsOneWidget);
- expect(find.text('Fork Agent'), findsOneWidget);
- expect(find.text('Stop Agent'), findsOneWidget);
+ expect(find.text('Fork Harness'), findsOneWidget);
+ expect(find.text('Stop Harness'), findsOneWidget);
expect(tester.getRect(title), titleBefore);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
diff --git a/desktop/test/web_pane_test.dart b/desktop/test/web_pane_test.dart
index 9adceb73f..221367a96 100644
--- a/desktop/test/web_pane_test.dart
+++ b/desktop/test/web_pane_test.dart
@@ -336,7 +336,7 @@ void main() {
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
- expect(find.text('Stop Agent'), findsOneWidget);
+ expect(find.text('Stop Harness'), findsOneWidget);
expect(find.text('Hide viewer'), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
diff --git a/desktop/test/workspace_start_guide_test.dart b/desktop/test/workspace_start_guide_test.dart
index 892ffb18a..b9d5cf478 100644
--- a/desktop/test/workspace_start_guide_test.dart
+++ b/desktop/test/workspace_start_guide_test.dart
@@ -20,6 +20,7 @@ import 'package:harness/state/app_state.dart';
import 'package:harness/state/first_harness_launch.dart';
import 'package:harness/state/harness_placement.dart';
import 'package:harness/state/new_harness.dart';
+import 'package:harness/state/new_tab_wallpaper.dart';
import 'package:harness/state/pane_arrangement.dart';
import 'package:harness/widgets/new_harness_box.dart';
import 'package:harness/widgets/workspace_start_guide.dart';
@@ -57,6 +58,11 @@ class _FirstApp extends AppNotifier {
..nodeOnline = true
..agentLoadStatus = AgentLoadStatus.loaded;
}
+ void reviewWallpaper(NewTabWallpaper wallpaper) {
+ activeSwarm.wallpaper = wallpaper;
+ notifyListeners();
+ }
+
Completer<void>? detection;
List<String> installed = ['codex'];
final launches =
@@ -187,7 +193,8 @@ void main() {
await tester.pump(const Duration(milliseconds: 150));
expect(box.engine, 'codex');
expect(find.text('Start'), findsOneWidget);
- expect(find.text('New Harness / New Tab'), findsOneWidget);
+ expect(find.text('New Harness'), findsOneWidget);
+ expect(find.text('New Tab'), findsOneWidget);
await key(tester, LogicalKeyboardKey.enter);
await tester.pump();
expect(app.launches, hasLength(1));
@@ -562,6 +569,45 @@ void main() {
},
);
+ testWidgets(
+ 'New Tab artwork and caption stay fixed while filtering and editing the dock',
+ (tester) async {
+ final app = _FirstApp();
+ addTearDown(app.dispose);
+ app.machineStates['m']!.agents = [
+ Agent(id: 'saved', name: 'Robot arm', engine: 'claude'),
+ ];
+ await _mount(tester, app, FirstHarnessLaunch());
+ await key(tester, LogicalKeyboardKey.keyT, cmd: true);
+ await tester.pumpAndSettle();
+ final page = find.byKey(const ValueKey('new-tab-start-page'));
+ final tagline = find.byKey(const ValueKey('new-tab-tagline'));
+ final wallpaper = app.activeSwarm.wallpaper;
+ final bounds = tester.getRect(page);
+ final center = tester.getCenter(tagline);
+ expect(center, bounds.center);
+
+ final search = find.byKey(const ValueKey('swarm-search-input'));
+ await tester.enterText(search, 'nothing matches');
+ await tester.pumpAndSettle();
+ expect(tester.getRect(page), bounds);
+ expect(tester.getCenter(tagline), center);
+ expect(app.activeSwarm.wallpaper, wallpaper);
+
+ await key(tester, LogicalKeyboardKey.keyN, cmd: true);
+ await tester.pumpAndSettle();
+ expect(find.byType(NewHarnessBox), findsOneWidget);
+ expect(tester.getRect(page), bounds);
+ expect(tester.getCenter(tagline), center);
+ expect(app.activeSwarm.wallpaper, wallpaper);
+ expect(
+ tester.getRect(find.byType(NewHarnessBox)).top,
+ greaterThan(tester.getRect(tagline).bottom),
+ );
+ await tester.pumpWidget(const SizedBox());
+ },
+ );
+
final output = Platform.environment['GUIDE_RENDER_DIR'];
testWidgets('render first entry guide', skip: output == null, (tester) async {
await tester.runAsync(() async {
@@ -603,6 +649,32 @@ void main() {
find.byType(MaterialApp),
matchesGoldenFile(Uri.file('$output/$name-compact.png')),
);
+ if (hasHarnesses) {
+ await key(tester, LogicalKeyboardKey.keyT, cmd: true);
+ for (final wallpaper in NewTabWallpaper.values) {
+ app.reviewWallpaper(wallpaper);
+ await tester.pump();
+ await tester.runAsync(
+ () => precacheImage(
+ AssetImage(wallpaper.asset),
+ tester.element(find.byType(NewTabStartPage).first),
+ ),
+ );
+ for (final (size, name) in [
+ (const Size(1280, 800), 'new-tab'),
+ (const Size(960, 640), 'new-tab-compact'),
+ ]) {
+ tester.view.physicalSize = size;
+ await tester.pumpAndSettle();
+ await expectLater(
+ find.byType(MaterialApp),
+ matchesGoldenFile(
+ Uri.file('$output/$name-${wallpaper.name}.png'),
+ ),
+ );
+ }
+ }
+ }
await tester.pumpWidget(const SizedBox());
}
});