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.

Show what a harness install is doing, step by step, in the New Agent dialog

0xdiego2527218bdddd95
diff --git a/cli/src/cli.ts b/cli/src/cli.ts
index 9756e4555..ed97c4802 100644
--- a/cli/src/cli.ts
+++ b/cli/src/cli.ts
@@ -2110,12 +2110,40 @@ async function runForeground(session: AuthSession): Promise<void> {
backend.onDshInstall = async ({ id, url, ref }, progress) => {
const resolved = id ? resolveInstallSource(id) : url ? { source: url, ref } : null
if (!resolved) return { ok: false, error: 'INVALID_DSH', detail: `${id ?? url} is not a known harness` }
+ // NARRATE THE LINES, NOT ONLY THE PHASES. A toolchain setup is minutes of npm and uv output, and
+ // a dialog that says "Setting up…" for all of it looks hung; the line the command is on is what
+ // says it is alive and what it is doing. Throttled: a setup can print hundreds of lines a second
+ // (`Updating files: 39%…` arrives as carriage returns on ONE line), and the window redraws on
+ // each push. The doctor's own ok/miss/warn lines go out at once — they are the ones a person
+ // reads, and there are seven of them.
+ let last: import('./dsh/install.js').DshInstallProgress | null = null
+ let pendingLine: string | null = null
+ let timer: NodeJS.Timeout | null = null
+ const flushLine = (): void => {
+ timer = null
+ if (last && pendingLine !== null && last.phase !== 'done' && last.phase !== 'failed') progress({ ...last, line: pendingLine })
+ pendingLine = null
+ }
const result = await installDsh({
source: resolved.source,
ref: ref ?? resolved.ref,
- onProgress: progress,
- onLine: (line) => console.log(`[dsh] install · ${line}`),
+ onProgress: (p) => {
+ if (timer) { clearTimeout(timer); timer = null }
+ pendingLine = null
+ last = p
+ progress(p)
+ },
+ onLine: (raw) => {
+ console.log(`[dsh] install · ${raw}`)
+ // The last carriage-return segment is the line as a terminal would show it.
+ const line = raw.split('\r').filter((s) => s.trim()).pop()?.trim() ?? ''
+ if (!line) return
+ pendingLine = line.slice(0, 200)
+ if (/^(ok|miss|warn)\s/.test(line)) { if (timer) clearTimeout(timer); flushLine(); return }
+ if (!timer) timer = setTimeout(flushLine, 300)
+ },
})
+ if (timer) { clearTimeout(timer); timer = null }
if (!result.ok) {
console.warn(`[dsh] install of ${id ?? url} failed · ${result.error} · ${result.detail}`)
return { ok: false, error: result.error, detail: result.detail }
diff --git a/cli/src/dsh/install.ts b/cli/src/dsh/install.ts
index d2ef891c8..a763dce26 100644
--- a/cli/src/dsh/install.ts
+++ b/cli/src/dsh/install.ts
@@ -8,7 +8,7 @@
* manifest's own id — which we cannot know until the clone exists. A manifest that fails to parse
* leaves nothing behind.
*/
-import { execFile } from 'node:child_process'
+import { execFile, spawn } from 'node:child_process'
import { existsSync, lstatSync, mkdirSync, realpathSync, renameSync, rmSync, symlinkSync } from 'node:fs'
import { randomUUID } from 'node:crypto'
import { dirname, isAbsolute, join, resolve } from 'node:path'
@@ -30,6 +30,12 @@ export interface DshInstallProgress {
id: string | null
phase: DshInstallPhase
detail?: string
+ /**
+ * The latest line the phase's command printed — what the install is ON right now, for a dialog
+ * that would otherwise say "Setting up…" for three minutes. Sent by the daemon's narrator, not by
+ * installDsh itself (which reports lines through `onLine`), throttled to a few a second.
+ */
+ line?: string
}
export interface DshInstallOptions {
@@ -91,14 +97,13 @@ async function cloneInstall(
const root = dshRootDir()
mkdirSync(root, { recursive: true, mode: 0o700 })
const tmpDir = join(root, `.tmp-${randomUUID()}`)
- const args = ['clone', '--depth', '1', ...(ref ? ['--branch', ref] : []), '--', source, tmpDir]
- try {
- const { stderr } = await execFileAsync('git', args, { timeout: 10 * 60_000, maxBuffer: 8 * 1024 * 1024 })
- for (const line of stderr.split('\n')) if (line.trim()) onLine?.(line)
- } catch (error) {
+ // `--progress` because stderr is not a tty here and git would otherwise stay silent until the end;
+ // streamed, not collected, so "Receiving objects: 39%" reaches the dialog while it is true.
+ const args = ['clone', '--depth', '1', '--progress', ...(ref ? ['--branch', ref] : []), '--', source, tmpDir]
+ const clone = await streamGit(args, onLine)
+ if (!clone.ok) {
rmSync(tmpDir, { recursive: true, force: true })
- const detail = error instanceof Error ? error.message : String(error)
- return { ok: false, error: 'CLONE_FAILED', detail: detail.slice(0, 2000) }
+ return { ok: false, error: 'CLONE_FAILED', detail: clone.detail.slice(0, 2000) }
}
const manifest = readDshManifest(tmpDir)
if (!manifest.ok) {
@@ -108,6 +113,35 @@ async function cloneInstall(
return { ok: true, tmpDir, manifest: manifest.manifest, commit: await gitHead(tmpDir) }
}
+/** Run git, handing each stderr line (and each carriage-return progress segment) to `onLine` as it lands. */
+function streamGit(args: string[], onLine: ((line: string) => void) | undefined): Promise<{ ok: true } | { ok: false; detail: string }> {
+ return new Promise((resolve) => {
+ const child = spawn('git', args, { stdio: ['ignore', 'ignore', 'pipe'] })
+ const tail: string[] = []
+ let rest = ''
+ const timer = setTimeout(() => child.kill('SIGTERM'), 10 * 60_000)
+ child.stderr?.on('data', (chunk: Buffer) => {
+ rest += chunk.toString('utf8')
+ let at: number
+ while ((at = rest.search(/[\r\n]/)) >= 0) {
+ const line = rest.slice(0, at).trim()
+ rest = rest.slice(at + 1)
+ if (!line) continue
+ onLine?.(line)
+ tail.push(line)
+ if (tail.length > 20) tail.shift()
+ }
+ })
+ child.on('error', (error) => { clearTimeout(timer); resolve({ ok: false, detail: error.message }) })
+ child.on('exit', (code) => {
+ clearTimeout(timer)
+ if (rest.trim()) { onLine?.(rest.trim()); tail.push(rest.trim()) }
+ if (code === 0) resolve({ ok: true })
+ else resolve({ ok: false, detail: `git ${args[0]} exited ${code}: ${tail.filter((l) => !/^(Receiving|Resolving|Updating|remote:)/.test(l)).slice(-3).join(' · ') || tail.slice(-1).join('')}` })
+ })
+ })
+}
+
/** Put the clone (or the link) at its final path, replacing whatever an earlier install left there. */
function placeAt(id: string, from: { tmpDir: string } | { linkTo: string }): string {
const dir = dshInstallDir(id)
diff --git a/desktop/lib/core/dsh_catalog.dart b/desktop/lib/core/dsh_catalog.dart
index 41a869cf1..4f3167bca 100644
--- a/desktop/lib/core/dsh_catalog.dart
+++ b/desktop/lib/core/dsh_catalog.dart
@@ -82,12 +82,18 @@ class DshInstallProgress {
required this.id,
required this.phase,
this.detail,
+ this.line,
});
final String id;
final String phase;
final String? detail;
+ /// The line the phase's command is on right now, as the machine narrates it
+ /// (throttled there). What turns "Setting up…" for three minutes into
+ /// "Installed 61 packages".
+ final String? line;
+
bool get done => phase == 'done';
bool get failed => phase == 'failed';
bool get inProgress => !done && !failed;
@@ -110,17 +116,82 @@ class DshInstallProgress {
return null;
}
final detail = raw['detail'];
+ final line = raw['line'];
return DshInstallProgress(
id: id,
phase: phase,
detail: detail is String && detail.trim().isNotEmpty
- ? detail
- .replaceAll(RegExp(r'[\x00-\x1f\x7f]'), ' ')
- .trim()
- .substring(0, detail.trim().length.clamp(0, 500))
+ ? _clean(detail, 500)
: null,
+ line: line is String && line.trim().isNotEmpty ? _clean(line, 200) : null,
);
}
+
+ static String _clean(String raw, int max) {
+ final text = raw.replaceAll(RegExp(r'[\x00-\x1f\x7f]'), ' ').trim();
+ return text.length > max ? text.substring(0, max) : text;
+ }
+}
+
+/// One install as the dialog watches it: every phase the machine reported,
+/// when each began, and the lines it printed on the way — the material for a
+/// panel that says what is happening rather than that something is.
+///
+/// Kept beside [MachineDsh.installs] (the latest phase, which older callers
+/// read) rather than replacing it.
+class DshInstallRun {
+ DshInstallRun(this.id, {DateTime? startedAt})
+ : startedAt = startedAt ?? DateTime.now();
+
+ final String id;
+ final DateTime startedAt;
+
+ /// Phases in the order they began, with when. `done`/`failed` close the run.
+ final List<({String phase, DateTime at})> phases = [];
+
+ /// What the phases printed, oldest first, bounded.
+ final List<String> log = [];
+ static const int maxLog = 40;
+
+ String? line;
+ String? detail;
+
+ String get phase => phases.isEmpty ? 'clone' : phases.last.phase;
+ bool get done => phase == 'done';
+ bool get failed => phase == 'failed';
+ bool get inProgress => !done && !failed;
+
+ /// The doctor's verdict lines (`ok …`, `miss …`, `warn …`) seen so far.
+ List<String> get checks => log
+ .where((l) => RegExp(r'^(ok|miss|warn)\s').hasMatch(l))
+ .toList(growable: false);
+
+ /// How long [phase] took, once the next one began.
+ Duration? took(String phase) {
+ for (var i = 0; i < phases.length; i++) {
+ if (phases[i].phase != phase) continue;
+ if (i + 1 < phases.length) {
+ return phases[i + 1].at.difference(phases[i].at);
+ }
+ return null;
+ }
+ return null;
+ }
+
+ bool reached(String phase) => phases.any((p) => p.phase == phase);
+
+ void apply(DshInstallProgress progress, {DateTime? now}) {
+ final at = now ?? DateTime.now();
+ if (phases.isEmpty || phases.last.phase != progress.phase) {
+ phases.add((phase: progress.phase, at: at));
+ }
+ if (progress.detail != null) detail = progress.detail;
+ if (progress.line != null && progress.line != line) {
+ line = progress.line;
+ log.add(progress.line!);
+ if (log.length > maxLog) log.removeAt(0);
+ }
+ }
}
/// One machine's answers, with the same "still asking" versus "asked, and it
@@ -146,6 +217,22 @@ class MachineDsh {
/// Installs the user asked for, by harness id, at their latest reported phase.
final Map<String, DshInstallProgress> installs = {};
+ /// The same installs with their history — see [DshInstallRun].
+ final Map<String, DshInstallRun> runs = {};
+
+ /// Record a progress push against both views. A push for a run nobody here
+ /// started (another window asked) opens one, so it can still be watched.
+ void applyInstall(DshInstallProgress progress, {DateTime? now}) {
+ installs[progress.id] = progress;
+ var run = runs[progress.id];
+ // A fresh push after a closed run is a new attempt.
+ if (run == null || run.done || run.failed) {
+ run = DshInstallRun(progress.id, startedAt: now);
+ runs[progress.id] = run;
+ }
+ run.apply(progress, now: now);
+ }
+
DshEntry? operator [](String id) => byId[id];
/// Every harness the machine named, installed or not, in the order it gave.
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dart
index d65a46750..bc3ec52a4 100644
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@ -3580,7 +3580,10 @@ class AppNotifier extends ChangeNotifier {
final machine = machineStates[machineId];
if (machine == null) return 'Machine not found';
final machineName = machine.machine.displayName;
- machine.dsh.installs[id] = DshInstallProgress(id: id, phase: 'clone');
+ // A new run every time the button is pressed: a retry after a failure is
+ // its own attempt, with its own clock.
+ machine.dsh.runs.remove(id);
+ machine.dsh.applyInstall(DshInstallProgress(id: id, phase: 'clone'));
notifyListeners();
try {
final result = await _conn(machineId).request(
@@ -3616,7 +3619,7 @@ class AppNotifier extends ChangeNotifier {
} catch (_) {
return _finishInstall(machine, id, 'Install failed on $machineName');
}
- machine.dsh.installs[id] = DshInstallProgress(id: id, phase: 'done');
+ machine.dsh.applyInstall(DshInstallProgress(id: id, phase: 'done'));
notifyListeners();
// The stored answer just became stale by the dialog's own hand.
await probeDsh(machineId, force: true);
@@ -3624,10 +3627,8 @@ class AppNotifier extends ChangeNotifier {
}
String _finishInstall(MachineState machine, String id, String error) {
- machine.dsh.installs[id] = DshInstallProgress(
- id: id,
- phase: 'failed',
- detail: error,
+ machine.dsh.applyInstall(
+ DshInstallProgress(id: id, phase: 'failed', detail: error),
);
notifyListeners();
return error;
@@ -6102,7 +6103,7 @@ class AppNotifier extends ChangeNotifier {
// Only ever advances a known install: a phase for an id nobody here
// asked about is still worth showing, so it is recorded either way.
final progress = DshInstallProgress.fromJson(payload);
- if (progress != null) machine.dsh.installs[progress.id] = progress;
+ if (progress != null) machine.dsh.applyInstall(progress);
break;
case 'commander_question':
final agentId = _eventAgentId(machine, event, payload);
diff --git a/desktop/lib/widgets/dsh_install_panel.dart b/desktop/lib/widgets/dsh_install_panel.dart
new file mode 100644
index 000000000..ea7dc966a
--- /dev/null
+++ b/desktop/lib/widgets/dsh_install_panel.dart
@@ -0,0 +1,487 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+
+import '../core/dsh_catalog.dart';
+import '../core/test_run.dart';
+import '../shared/theme/app_theme.dart' as grid;
+
+/// What the New Agent dialog shows while a harness installs on a machine
+/// (mockup/dsh-install-progress.html).
+///
+/// The daemon narrates three phases — fetch, set up, check — and, throttled,
+/// the line each one is on. This draws them as steps with the current line
+/// under the active one, a small tail of the log, the elapsed time, and, when
+/// it fails, the machine's own `miss` line turned into a sentence with the
+/// fix it names. Before this the button said "Installing Solid…" for one to
+/// five minutes and nothing else.
+class DshInstallPanel extends StatefulWidget {
+ const DshInstallPanel({
+ super.key,
+ required this.run,
+ required this.harnessName,
+ required this.machineName,
+ });
+
+ final DshInstallRun run;
+ final String harnessName;
+ final String machineName;
+
+ @override
+ State<DshInstallPanel> createState() => _DshInstallPanelState();
+}
+
+class _DshInstallPanelState extends State<DshInstallPanel> {
+ Timer? _tick;
+
+ @override
+ void initState() {
+ super.initState();
+ // The elapsed clock. Not under test: a periodic timer is a pumpAndSettle
+ // that never settles, and the tests drive the run by hand.
+ if (!kUnderTest) {
+ _tick = Timer.periodic(const Duration(seconds: 1), (_) {
+ if (mounted && widget.run.inProgress) setState(() {});
+ });
+ }
+ }
+
+ @override
+ void dispose() {
+ _tick?.cancel();
+ super.dispose();
+ }
+
+ static String _clock(Duration d) {
+ final m = d.inMinutes;
+ final s = d.inSeconds % 60;
+ return '$m:${s.toString().padLeft(2, '0')}';
+ }
+
+ static String _short(Duration d) =>
+ d.inSeconds < 60 ? '${d.inSeconds}s' : _clock(d);
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ final run = widget.run;
+ final elapsed =
+ (run.phases.isEmpty
+ ? DateTime.now()
+ : run.inProgress
+ ? DateTime.now()
+ : run.phases.last.at)
+ .difference(run.startedAt);
+ final steps = [
+ _Step('clone', 'Fetch ${widget.harnessName}'),
+ _Step('setup', 'Set up the toolchain'),
+ _Step('doctor', 'Check this machine'),
+ ];
+ // Which step failed: the last real phase before `failed`.
+ final failedPhase = run.failed && run.phases.length >= 2
+ ? run.phases[run.phases.length - 2].phase
+ : null;
+ final failure = run.failed
+ ? describeInstallFailure(run, widget.harnessName)
+ : null;
+
+ return Container(
+ key: const Key('dsh-install-panel'),
+ padding: const EdgeInsets.fromLTRB(14, 12, 14, 12),
+ decoration: BoxDecoration(
+ color: grid.AppSurface.recess,
+ border: Border.all(color: grid.AppGlass.hair),
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ children: [
+ Expanded(
+ child: Text(
+ run.done
+ ? '${widget.harnessName} installed on ${widget.machineName}'
+ : 'Installing ${widget.harnessName} on ${widget.machineName}',
+ style: TextStyle(
+ fontSize: 13.5,
+ fontWeight: grid.AppFont.semibold,
+ color: grid.AppPalette.textPrimary,
+ ),
+ ),
+ ),
+ Text(
+ _clock(elapsed),
+ style: TextStyle(
+ fontSize: 12,
+ color: grid.AppPalette.textFaint,
+ fontFeatures: const [FontFeature.tabularFigures()],
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(height: 10),
+ for (final step in steps) ...[
+ _StepRow(
+ step: step,
+ state: run.failed && failedPhase == step.phase
+ ? _StepState.failed
+ : run.done || run.took(step.phase) != null
+ ? (run.reached(step.phase)
+ ? _StepState.done
+ : _StepState.pending)
+ : run.phase == step.phase
+ ? _StepState.active
+ : _StepState.pending,
+ sub: _subFor(run, step.phase),
+ took: run.took(step.phase),
+ ),
+ const SizedBox(height: 7),
+ ],
+ // The tail of what the install printed, whenever there is one. It
+ // was behind a "Show log" toggle; the toggle read as a button that
+ // did nothing, and the lines are the part that says the install is
+ // alive.
+ if (run.log.isNotEmpty && !run.done) ...[
+ const SizedBox(height: 4),
+ _LogTail(lines: run.log),
+ ],
+ if (failure != null) ...[
+ const SizedBox(height: 6),
+ _FailureCard(failure: failure),
+ ],
+ const SizedBox(height: 6),
+ Row(
+ children: [
+ Expanded(
+ child: Text(
+ run.failed
+ ? 'The download and the toolchain are kept; Retry runs the check again.'
+ : run.done
+ ? 'Starting the agent…'
+ : 'The first install takes a few minutes. You can keep using Harness.',
+ style: TextStyle(
+ fontSize: 12,
+ color: grid.AppPalette.textFaint,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ );
+ }
+
+ /// The line under a step: the current output for the active step, the
+ /// doctor's verdicts for the check step, nothing for the rest.
+ String? _subFor(DshInstallRun run, String phase) {
+ if (phase == 'doctor' && (run.reached('doctor'))) {
+ final checks = run.checks;
+ if (checks.isNotEmpty) {
+ final oks = checks.where((c) => c.startsWith('ok')).length;
+ final misses = checks.where((c) => c.startsWith('miss')).length;
+ if (run.failed) return '$oks of ${checks.length} checks passed';
+ return checks
+ .map(
+ (c) =>
+ '${c.replaceFirst(RegExp(r'^\w+\s+'), '').split(' (').first} ${c.startsWith('ok')
+ ? '✓'
+ : c.startsWith('miss')
+ ? '✗'
+ : '!'}',
+ )
+ .join(' · ')
+ .replaceAll(RegExp(r'\s+'), ' ') +
+ (misses == 0 && run.inProgress ? ' …' : '');
+ }
+ }
+ if (run.phase != phase || !run.inProgress) return null;
+ if (run.line != null) return run.line;
+ return switch (phase) {
+ 'clone' => run.detail ?? 'Fetching…',
+ 'setup' => 'Setting up the toolchain…',
+ 'doctor' => 'Checking the machine…',
+ _ => null,
+ };
+ }
+}
+
+/// What a failed install means for the person, from the machine's `miss` line.
+///
+/// The doctor's lines name the missing tool and a URL; this turns the common
+/// ones into a sentence and the command that fixes it. Anything it does not
+/// know is shown as the machine wrote it.
+class InstallFailure {
+ const InstallFailure({required this.title, this.body, this.command});
+ final String title;
+ final String? body;
+ final String? command;
+}
+
+InstallFailure describeInstallFailure(DshInstallRun run, String harnessName) {
+ final miss =
+ run.checks.where((c) => c.startsWith('miss')).firstOrNull ??
+ run.detail?.split(' · ').where((p) => p.startsWith('miss')).firstOrNull;
+ final text = (miss ?? run.detail ?? 'Install failed').replaceFirst(
+ RegExp(r'^miss\s+'),
+ '',
+ );
+ final lower = text.toLowerCase();
+ if (lower.startsWith('codex')) {
+ return InstallFailure(
+ title: 'Codex is not installed on this machine.',
+ body: '$harnessName runs on Codex. Install it, then retry.',
+ command: 'npm install -g @openai/codex',
+ );
+ }
+ if (lower.startsWith('claude')) {
+ return InstallFailure(
+ title: 'Claude Code is not installed on this machine.',
+ body: '$harnessName runs on Claude Code. Install it, then retry.',
+ command: 'npm install -g @anthropic-ai/claude-code',
+ );
+ }
+ if (lower.startsWith('uv')) {
+ return const InstallFailure(
+ title: 'uv is not installed on this machine.',
+ body: 'The toolchain is a Python environment that uv builds. Install it, then retry.',
+ command: 'curl -LsSf https://astral.sh/uv/install.sh | sh',
+ );
+ }
+ if (lower.startsWith('node')) {
+ return InstallFailure(
+ title: 'Node.js is missing or too old.',
+ body: text,
+ command: 'brew install node@22',
+ );
+ }
+ if (lower.contains('doctor still running')) {
+ return InstallFailure(
+ title: 'The check is taking longer than five minutes.',
+ body: 'Usually the first load of a large toolchain. Retry runs only the check again.',
+ );
+ }
+ if (lower.contains('clone') || lower.contains('git ')) {
+ return InstallFailure(
+ title: 'Could not download $harnessName.',
+ body: text,
+ );
+ }
+ return InstallFailure(title: text);
+}
+
+class _Step {
+ const _Step(this.phase, this.name);
+ final String phase;
+ final String name;
+}
+
+enum _StepState { pending, active, done, failed }
+
+class _StepRow extends StatelessWidget {
+ const _StepRow({
+ required this.step,
+ required this.state,
+ required this.sub,
+ required this.took,
+ });
+
+ final _Step step;
+ final _StepState state;
+ final String? sub;
+ final Duration? took;
+
+ @override
+ Widget build(BuildContext context) {
+ final muted = state == _StepState.pending;
+ return Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SizedBox(
+ width: 18,
+ height: 18,
+ child: switch (state) {
+ _StepState.done => Container(
+ decoration: BoxDecoration(
+ color: grid.AppPalette.online,
+ shape: BoxShape.circle,
+ ),
+ child: const Icon(Icons.check, size: 12, color: Colors.black),
+ ),
+ _StepState.failed => Container(
+ decoration: BoxDecoration(
+ color: grid.AppPalette.dangerFill,
+ shape: BoxShape.circle,
+ ),
+ child: const Icon(
+ Icons.priority_high,
+ size: 12,
+ color: Colors.white,
+ ),
+ ),
+ _StepState.active => Padding(
+ padding: const EdgeInsets.all(1.5),
+ child: CircularProgressIndicator(
+ strokeWidth: 1.5,
+ color: grid.AppPalette.accentOnSurface,
+ ),
+ ),
+ _StepState.pending => Container(
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ border: Border.all(
+ color: grid.AppPalette.textFaint,
+ width: 1.5,
+ ),
+ ),
+ ),
+ },
+ ),
+ const SizedBox(width: 10),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ step.name,
+ style: TextStyle(
+ fontSize: 13,
+ fontWeight: grid.AppFont.medium,
+ color: muted
+ ? grid.AppPalette.textFaint
+ : grid.AppPalette.textPrimary,
+ ),
+ ),
+ if (sub != null)
+ Padding(
+ padding: const EdgeInsets.only(top: 2),
+ child: Text(
+ sub!,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(
+ fontSize: 12,
+ color: state == _StepState.active
+ ? grid.AppPalette.textSecondary
+ : grid.AppPalette.textFaint,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ if (took != null) ...[
+ const SizedBox(width: 10),
+ Text(
+ _DshInstallPanelState._short(took!),
+ style: TextStyle(
+ fontSize: 12,
+ color: grid.AppPalette.textFaint,
+ fontFeatures: const [FontFeature.tabularFigures()],
+ ),
+ ),
+ ],
+ ],
+ );
+ }
+}
+
+class _LogTail extends StatelessWidget {
+ const _LogTail({required this.lines});
+ final List<String> lines;
+
+ @override
+ Widget build(BuildContext context) {
+ final tail = lines.length > 6 ? lines.sublist(lines.length - 6) : lines;
+ return Container(
+ width: double.infinity,
+ padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
+ decoration: BoxDecoration(
+ color: grid.AppTheme.pick(
+ const Color(0xFFF2F2F1),
+ const Color(0xFF0F0F0F),
+ ),
+ border: Border.all(color: grid.AppGlass.hair),
+ borderRadius: BorderRadius.circular(8),
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ for (var i = 0; i < tail.length; i++)
+ Text(
+ tail[i],
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(
+ fontFamily: grid.AppFont.mono,
+ fontFamilyFallback: grid.AppFont.monoFallback,
+ fontSize: 11.5,
+ height: 1.5,
+ color: i == tail.length - 1
+ ? grid.AppPalette.textSecondary
+ : grid.AppPalette.textFaint,
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
+
+class _FailureCard extends StatelessWidget {
+ const _FailureCard({required this.failure});
+ final InstallFailure failure;
+
+ @override
+ Widget build(BuildContext context) {
+ final danger = grid.AppPalette.dangerFill;
+ return Container(
+ key: const Key('dsh-install-failure'),
+ width: double.infinity,
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
+ decoration: BoxDecoration(
+ color: danger.withValues(alpha: 0.10),
+ border: Border.all(color: danger.withValues(alpha: 0.35)),
+ borderRadius: BorderRadius.circular(8),
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ failure.title,
+ style: TextStyle(
+ fontSize: 12.5,
+ fontWeight: grid.AppFont.semibold,
+ color: grid.AppPalette.textPrimary,
+ ),
+ ),
+ if (failure.body != null)
+ Padding(
+ padding: const EdgeInsets.only(top: 2),
+ child: Text(
+ failure.body!,
+ style: TextStyle(
+ fontSize: 12,
+ color: grid.AppPalette.textSecondary,
+ ),
+ ),
+ ),
+ if (failure.command != null)
+ Padding(
+ padding: const EdgeInsets.only(top: 6),
+ child: SelectableText(
+ failure.command!,
+ style: TextStyle(
+ fontFamily: grid.AppFont.mono,
+ fontFamilyFallback: grid.AppFont.monoFallback,
+ fontSize: 11.5,
+ color: grid.AppPalette.textPrimary,
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/desktop/lib/widgets/new_agent_dialog.dart b/desktop/lib/widgets/new_agent_dialog.dart
index ebe0af9f2..725503d77 100644
--- a/desktop/lib/widgets/new_agent_dialog.dart
+++ b/desktop/lib/widgets/new_agent_dialog.dart
@@ -24,6 +24,7 @@ import 'codex_profile_field.dart';
import 'agent_picker.dart';
import 'remote_folder_picker.dart';
import 'new_agent_project_picker.dart';
+import 'dsh_install_panel.dart';
/// Mirrors the harness CLI's `BYPASS_PERMISSION_FLAGS`
/// (autonomous-harness/cli/src/lib/engineLaunch.ts) 1:1 — this is UI-only display + gating, the CLI
@@ -250,10 +251,15 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
/// The one-line install status while a harness install is running, read off
/// the machine's own narration (`dsh_install_status`), or null.
- String? get _installStatus {
- if (!_installing) return null;
- final progress = widget.notifier.stateOf(_machineId)?.dsh.installs[_engine];
- return progress?.label ?? 'Installing…';
+ /// The install this dialog is watching for the chosen harness: the one in
+ /// flight, or the one that just failed (kept on screen so its verdict and
+ /// the fix it names stay readable under the Retry). Null otherwise.
+ DshInstallRun? get _installRun {
+ final run = widget.notifier.stateOf(_machineId)?.dsh.runs[_engine];
+ if (run == null) return null;
+ if (_installing) return run;
+ if (run.failed && _willInstallHarness(_engine)) return run;
+ return null;
}
Future<void> _loadAgentPreference() async {
@@ -411,8 +417,13 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
// A harness the machine does not have yet is installed FIRST, as its own
// step with its own words: minutes of clone and toolchain under a button
// that said "Creating agent…" would read as a create that hung. The
- // machine's catalog decides "has it"; wait for its answer if it is out.
- if (harness != null && !_confirmationPending && _harness(harness) == null) {
+ // machine's catalog decides "has it" — asked AGAIN at this moment, not
+ // read from the answer the dialog opened with: a harness removed or
+ // installed in the meantime (`harness dsh remove` in a terminal, another
+ // window) made the stale answer send a create for a harness the machine
+ // no longer had, and the create failed with "not installed" instead of
+ // installing. The answer is an index read on the machine; it is cheap.
+ if (harness != null && !_confirmationPending) {
await _probeHarnesses();
if (!mounted) return;
// A machine whose Harness CLI predates harnesses refuses `dsh_list`
@@ -577,6 +588,23 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
child: _choices(),
),
),
+ // Under everything chosen, and OUTSIDE the AbsorbPointer
+ // above: the choices lock while the install runs, and a
+ // panel inside that lock cannot be clicked (owner,
+ // 2026-09-16: "Show log bấm không được"). The install is
+ // what happens after the choices, and reads that way here.
+ if (!_confirmationPending && _installRun != null) ...[
+ const SizedBox(height: _gapBlock),
+ Semantics(
+ liveRegion: true,
+ child: DshInstallPanel(
+ key: const Key('new-agent-install-status'),
+ run: _installRun!,
+ harnessName: _labelOf(_engine),
+ machineName: _machineName,
+ ),
+ ),
+ ],
if (_error != null) ...[
const SizedBox(height: _gapBlock),
Semantics(
@@ -608,7 +636,15 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
spacing: 8,
runSpacing: 8,
children: [
- if (_confirmationPending)
+ // Close belongs to the UNCERTAIN state — a create whose
+ // reply was lost, where the person may leave and check
+ // later. `awaitingConfirmation` is set the moment the
+ // request goes out, so on its own it also covered every
+ // ordinary create in flight, and a disabled Close sat
+ // beside "Creating agent…" meaning nothing (owner,
+ // 2026-09-16). Same gate as Find an agent below.
+ if (_confirmationPending &&
+ (!_submitting || _checkingCreation))
TextButton(
onPressed: _submitting
? null
@@ -683,7 +719,11 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
),
)
: Text(
- _confirmationPending ? 'Check status' : 'Create',
+ _confirmationPending
+ ? 'Check status'
+ : _installRun?.failed == true
+ ? 'Retry'
+ : 'Create',
),
),
],
@@ -800,19 +840,6 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
if (isHarnessId(value)) unawaited(_probeHarnesses());
},
),
- if (!_confirmationPending && _installStatus != null) ...[
- const SizedBox(height: 6),
- Semantics(
- liveRegion: true,
- child: Text(
- key: const Key('new-agent-install-status'),
- 'Installing ${_labelOf(_engine)} on $_machineName… '
- '$_installStatus',
- style: Theme.of(context).textTheme.bodySmall
- ?.copyWith(color: grid.AppPalette.textSecondary),
- ),
- ),
- ],
if (!_confirmationPending && _engineCheckFailed) ...[
const SizedBox(height: 6),
Row(
diff --git a/desktop/test/new_agent_dsh_test.dart b/desktop/test/new_agent_dsh_test.dart
index f1784d67e..5c0ac345d 100644
--- a/desktop/test/new_agent_dsh_test.dart
+++ b/desktop/test/new_agent_dsh_test.dart
@@ -77,7 +77,7 @@ class _Notifier extends AppNotifier {
Future<String?> installDsh(String machineId, String id) {
installs.add(id);
final machine = machineStates[machineId]!;
- machine.dsh.installs[id] = DshInstallProgress(id: id, phase: 'setup');
+ machine.dsh.applyInstall(DshInstallProgress(id: id, phase: 'setup'));
notifyListeners();
final pending = pendingInstall;
if (pending == null) {