The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Remove the Flash Firmware entries from the desktop app (#1480)
0xken1539f9a40d7cff
diff --git a/desktop/CLAUDE.md b/desktop/CLAUDE.mdindex 8a023e39a..504c5564a 100644--- a/desktop/CLAUDE.md+++ b/desktop/CLAUDE.md@@ -583,7 +583,7 @@ add a kind there, not at the call site.fills the window goes through `FullWindowScreen` (`lib/widgets/window_chrome.dart`) for its dragstrip, and a full-width band at the top edge pads by `trafficLightClearance`.- `macos/Runner/MainFlutterWindow.swift` installs native menu items and calls into Dart over the- `harness/app_menu` MethodChannel (`checkForUpdates`, `flashFirmware`, `showShortcuts`, terminal font+ `harness/app_menu` MethodChannel (`checkForUpdates`, `showShortcuts`, terminal fontsize). Keep the menu in Swift; only the handler lives in `RootShell`.- `macos/Runner/SurfaceCacheGuard.swift` patches Flutter's private macOS back-buffer cache, which canhand a frame a surface of another size after an A → B → A resize or a display replug; Impeller then@@ -868,8 +868,8 @@ add a kind there, not at the call site.`^U` because a ⌘ chord never reaches xterm's input handler at all. The composer answers all fourline-editing chords too: it writes ⌥⏎'s newline itself, binds `^W`/`^U`, and lets Flutter's ownmacOS text-editing shortcuts serve ⌥⌫ and ⌘⌫.-- `lib/flash/` flashes the ESP32-S3 dial through the CLI runner; `SerialPortLease` pauses daemon- supervision while the port is held so `harness start` cannot steal it mid-write.+- The app has no flash UI: the dial is flashed with `harness flash`. `SerialPortLease` sees that+ flash's lease file and pauses daemon supervision so `harness start` cannot steal the port mid-write.- `lib/update/desktop_updater.dart` self-updates from the GCS manifest (sha256-verified, strictlynewer only). Its keys must match what writes the manifest — `_otaKeyMacOS`/`_otaKeyMacOSArm64` thevariant table in `scripts/publish-macos-variant.sh`, `desktop-linux-<arch>` the `OTA_KEY` indiff --git a/desktop/lib/app_shell.dart b/desktop/lib/app_shell.dartindex b4c98a790..38e9dabe0 100644--- a/desktop/lib/app_shell.dart+++ b/desktop/lib/app_shell.dart@@ -34,7 +34,6 @@ import 'widgets/layout_palette.dart';import 'widgets/environment_preflight_screen.dart';import 'widgets/environment_setup_screen.dart';import 'widgets/export_logs_dialog.dart';-import 'widgets/flash_firmware_dialog.dart';import 'widgets/in_window_menu_bar.dart';import 'widgets/setup_tour.dart';import 'widgets/sign_in_step.dart';@@ -292,8 +291,6 @@ class _RootShellState extends ConsumerState<RootShell>case 'checkForUpdates':final app = ref.read(appStateProvider);await _menuDialog(() => checkForUpdatesAndShowResult(context, app));- case 'flashFirmware':- await _menuDialog(() => showFlashFirmwareDialog(context));case 'exportLogs':await _menuDialog(() => showExportLogsDialog(context));case 'showLayout':diff --git a/desktop/lib/core/serial_port_lease.dart b/desktop/lib/core/serial_port_lease.dartindex c5e3a463b..bff76f159 100644--- a/desktop/lib/core/serial_port_lease.dart+++ b/desktop/lib/core/serial_port_lease.dart@@ -1,27 +1,16 @@-import 'dart:async';import 'dart:io';import 'harness_file_store.dart';-/// Held while something outside the daemon needs the dial's USB serial port to itself.+/// Held while `harness flash` needs the dial's USB serial port to itself.///-/// Exists because two parts of this app want that port and neither knew about the other. Flashing-/// runs `harness stop` first — a serial port on macOS is exclusive, so the daemon has to let go — and-/// then writes for the better part of a minute. Meanwhile the app supervises that same daemon on a-/// five-second timer and starts it again the moment it notices it is gone. The daemon comes up,-/// reopens the dial, and esptool loses the port mid-write: the flash dies a few tens of kilobytes in-/// with "No more data to read from the serial port", which reads like broken hardware and is not.-///-/// A counter rather than a boolean so overlapping holders cannot release each other's claim, and-/// [hold] releases in a `finally` so a thrown or cancelled flash cannot leave supervision switched-/// off for the rest of the session — which would be a worse bug than the one this fixes, and a-/// silent one.+/// Flashing runs `harness stop` first — a serial port on macOS is exclusive, so the daemon has to let+/// go — and then writes for the better part of a minute. Meanwhile the app supervises that same+/// daemon on a five-second timer and starts it again the moment it notices it is gone. The daemon+/// comes up, reopens the dial, and esptool loses the port mid-write: the flash dies a few tens of+/// kilobytes in with "No more data to read from the serial port", which reads like broken hardware+/// and is not.abstract final class SerialPortLease {- static int _holders = 0;-- /// True while the daemon must not be started, because it would take the port.- static bool get held => _holders > 0;-/// How long a flag left behind by a flash that could not clean up is believed.////// A write takes a couple of minutes; ten is generous and still bounded. Without a bound, a script@@ -29,7 +18,7 @@ abstract final class SerialPortLease {/// fault than the one this prevents, and a silent one.static const _staleAfter = Duration(minutes: 10);- /// Where the flasher keeps downloads, its `flashing` flag and the Windows `cancel` file.+ /// Where the flasher keeps downloads and its `flashing` flag./// Honours the script's override so both sides look in the same folder.static String flasherDirectory({Map<String, String>? environment}) {final env = environment ?? Platform.environment;@@ -40,20 +29,18 @@ abstract final class SerialPortLease {);}- /// Whether a flash started OUTSIDE this app is holding the port.+ /// Whether a flash is holding the port.///- /// The in-process counter only knows about flashes this app started. Someone running- /// `harness flash` in a terminal while the app is open hits exactly the same collision — the app- /// restarts the daemon underneath them and their flash dies — and that is the case that matters- /// most, because it is how a device already in someone's hands gets updated.+ /// Someone running `harness flash` in a terminal while the app is open would otherwise have the+ /// app restart the daemon underneath them, and their flash dies.////// The flasher writes this file before it stops the daemon and removes it when it starts it again.static bool heldByAnotherProcess({Map<String, String>? environment}) {try {final dir = flasherDirectory(environment: environment);if (_fresh(File('$dir/flashing'))) return true;- // App-started Windows flashes have unique files so a forced stop can retire exactly its- // own lease. Bash and standalone/older PowerShell scripts keep the shared timestamp above.+ // A PowerShell flash given a run id has a unique file so a forced stop can retire exactly its+ // own lease. Bash and other PowerShell runs keep the shared timestamp above.final directory = Directory(dir);if (!directory.existsSync()) return false;final runName = RegExp(r'^flashing\.[0-9a-f]{32}$');@@ -83,13 +70,4 @@ abstract final class SerialPortLease {return false;}}-- static Future<T> hold<T>(Future<T> Function() action) async {- _holders++;- try {- return await action();- } finally {- _holders--;- }- }}diff --git a/desktop/lib/flash/flasher.dart b/desktop/lib/flash/flasher.dartdeleted file mode 100644index c9651248d..000000000--- a/desktop/lib/flash/flasher.dart+++ /dev/null@@ -1,317 +0,0 @@-import 'dart:async';-import 'dart:convert';-import 'dart:io';-import 'dart:math';--import '../core/harness_cli_runner.dart';-import '../core/runtime_platform.dart';-import '../core/serial_port_lease.dart';--/// How the flash dialog names the computer the dial is plugged into.-String flashHostName({bool? windows}) =>- (windows ?? RuntimePlatform.isWindows) ? 'this computer' : 'this Mac';--/// What a line of flasher output is.-///-/// The script prints a flat stream; the shape is carried by the prefix. `>> `-/// opens a step, an indented line details the step in progress, and anything on-/// stderr is trouble. Nothing here re-orders or drops a line — the raw log stays-/// the record, and this only decides what the UI emphasises.-enum FlashLineKind { step, detail, warning, error }--class FlashLine {- final String text;- final FlashLineKind kind;-- const FlashLine(this.text, this.kind);-- /// The step title without its `>> ` marker, for the step list.- String get title => text.startsWith('>> ') ? text.substring(3) : text;-}--/// Outcome of a finished run.-class FlashResult {- final int exitCode;- final bool cancelled;-- const FlashResult({required this.exitCode, this.cancelled = false});-- bool get ok => exitCode == 0 && !cancelled;-}--/// What `--detect-only` found.-class FlashProbe {- /// Ports the script recognised as an ESP32-S3.- final List<String> ports;-- /// Set when it refused for a reason the user can act on.- final String? problem;-- /// Everything it printed, kept for the log pane.- final List<FlashLine> log;-- const FlashProbe({required this.ports, required this.log, this.problem});-- bool get found => ports.isNotEmpty;-}--/// Runs the published flasher through the installed `harness` CLI.-///-/// The app deliberately does NOT fetch or cache `flash-circle.sh` itself.-/// `harness flash` already owns which script to run and how to get it, and the-/// script owns every number that decides whether a board survives the write —-/// the chip, the app offset, the otadata region, the sha256 checks. A second-/// copy of any of that here is a bricked board the day the two disagree. This-/// class owns one thing: turning that command's output into something a window-/// can draw.-class Flasher {- Flasher({- this.startProcess = harnessCliStart,- bool? windows,- this.cancelDirectory,- this.killAfter = const Duration(seconds: 15),- Future<void> Function(int pid)? killTree,- Future<ProcessResult> Function(String, List<String>) runProcess =- Process.run,- }) : _windows = windows ?? RuntimePlatform.isWindows,- _killTree = killTree ?? ((pid) => _taskkillTree(pid, runProcess));-- /// Overridden in tests.- final Future<Process> Function(- List<String> arguments, {- Map<String, String>? environment,- })- startProcess;-- /// How long a cancelled Windows flash has to stop before its process tree is ended.- final Duration killAfter;-- /// Where the Windows cancel file goes; defaults to the flasher's folder.- final String? cancelDirectory;- final bool _windows;- final Future<void> Function(int pid) _killTree;- Timer? _killTimer;- Future<void>? _forcedStop;-- String get scriptName => _windows ? 'flash-circle.ps1' : 'flash-circle.sh';-- static Future<void> _taskkillTree(- int pid,- Future<ProcessResult> Function(String, List<String>) runProcess,- ) async {- // `harness flash` runs PowerShell, which runs esptool; killing only the parent leaves writers alive.- final arguments = ['/PID', '$pid', '/T', '/F'];- final result = await runProcess('taskkill', arguments);- if (result.exitCode != 0) {- throw ProcessException(- 'taskkill',- arguments,- result.stderr.toString().trim(),- result.exitCode,- );- }- }-- Process? _running;- void Function(FlashLine)? _onLine;- bool _cancelled = false;-- bool get isRunning => _running != null;-- /// Looks for a plugged-in board without touching it.- ///- /// `--detect-only` returns before the script would stop the Harness daemon,- /// so opening the dialog costs nothing: no daemon bounce, no write, no- /// download.- Future<FlashProbe> probe() async {- final log = <FlashLine>[];- final ports = <String>[];- String? problem;-- final code = await _run(['flash', '--detect-only'], (line) {- log.add(line);- final text = line.text;- const marker = '>> board: ';- if (text.startsWith(marker)) {- ports.add(text.substring(marker.length).trim());- } else if (text.startsWith('more than one ESP32-S3')) {- problem = 'more than one board is connected';- } else if (text.contains('no permission')) {- problem = 'no permission to open the serial port';- }- });-- if (code != 0 && problem == null) {- problem = _errorFrom(log) ?? 'could not look for a board';- }- return FlashProbe(ports: ports, log: log, problem: problem);- }-- /// Writes the latest release to [port], or to whatever the script picks.- ///- /// `--yes` is not optional. The script asks for confirmation on `/dev/tty`,- /// and an app launched from Finder has none — without it the run dies with- /// "not a terminal" before writing anything. The dialog's Flash button IS- /// that confirmation.- Future<FlashResult> flash({String? port, void Function(FlashLine)? onLine}) {- final command = ['flash', '--yes'];- if (port != null && port.isNotEmpty) command.addAll(['--port', port]);- // Held for the WHOLE run, not just the write. The script stops the daemon itself and starts it- // again at the end; between those two the port belongs to esptool, and the app's own daemon- // supervisor — a five-second timer that restarts anything it finds missing — would otherwise take- // it back and kill the flash a few tens of kilobytes in.- return SerialPortLease.hold(() async {- final code = await _run(command, (line) => onLine?.call(line));- return FlashResult(exitCode: code, cancelled: _cancelled);- });- }-- /// Asks a running flash to stop, and lets it unwind.- ///- /// SIGTERM, never SIGKILL. The script arms- /// `trap start_harness_after_flash EXIT INT TERM`, and that trap is the only- /// thing that brings the Harness daemon back after the script stopped it to- /// free the serial port. Killing it outright leaves the computer with no- /// daemon and the dial dark — worse than never having flashed at all.- ///- /// Windows Process.kill skips flash-circle.ps1's `finally`, its one way of starting Harness- /// again. Ask by file so the script can unwind, then end its tree only after [killAfter].- /// Releasing the lease lets this app's supervision start the daemon on its next tick.- void cancel() {- final process = _running;- if (process == null) return;- _cancelled = true;- if (!_windows) {- process.kill(ProcessSignal.sigterm);- return;- }- try {- final dir = Directory(- cancelDirectory ?? SerialPortLease.flasherDirectory(),- )..createSync(recursive: true);- File('${dir.path}${Platform.pathSeparator}cancel')- .writeAsStringSync('${DateTime.now().millisecondsSinceEpoch}');- } catch (_) {- // A filesystem failure must not skip the script's chance to finish and restart Harness.- }- _killTimer?.cancel();- _killTimer = Timer(killAfter, () {- if (identical(_running, process) && _forcedStop == null) {- _forcedStop = _endTree(process);- }- });- }-- Future<void> _endTree(Process process) async {- try {- await _killTree(process.pid);- await process.exitCode;- // The script's finally could not run. Only this invocation's unguessable lease name is ours;- // a terminal/older script's shared marker and every other app run must be left alone.- final lease = _ownedLease;- if (lease != null && lease.existsSync()) lease.deleteSync();- } catch (error) {- // A failed kill leaves the writer alive: report it without releasing its serial lease.- if (identical(_running, process)) {- _onLine?.call(- FlashLine(- 'error: could not stop the flash: $error',- FlashLineKind.error,- ),- );- }- }- }-- File? _ownedLease;-- Future<int> _run(- List<String> command,- void Function(FlashLine) onLine,- ) async {- if (_running != null) throw StateError('a flash is already running');- _cancelled = false;- _forcedStop = null;- final random = _windows ? Random.secure() : null;- final runId = _windows- ? List.generate(- 16,- (_) => random!.nextInt(256).toRadixString(16).padLeft(2, '0'),- ).join()- : null;- final cache = cancelDirectory ?? SerialPortLease.flasherDirectory();- _ownedLease = runId == null ? null : File('$cache/flashing.$runId');- final process = await startProcess(- command,- environment: runId == null- ? null- : {'HARNESS_FLASH_RUN_ID': runId, 'HARNESS_FLASHER_CACHE': cache},- );- _running = process;- _onLine = onLine;- try {- final pumps = <Future<void>>[- _pump(process.stdout, onLine, stderr: false),- _pump(process.stderr, onLine, stderr: true),- ];- final code = await process.exitCode;- _killTimer?.cancel();- // Parent EOF can arrive while taskkill is still ending descendants. Retire the persisted- // lease and finish that termination attempt before SerialPortLease.hold releases supervision.- await _forcedStop;- // Drain first: the last lines can still be in flight when the process- // has already gone, and losing them loses the reason it failed.- await Future.wait(pumps);- return code;- } finally {- _killTimer?.cancel();- _killTimer = null;- _onLine = null;- _running = null;- _ownedLease = null;- }- }-- Future<void> _pump(- Stream<List<int>> source,- void Function(FlashLine) onLine, {- required bool stderr,- }) {- return source- .transform(utf8.decoder)- .transform(const LineSplitter())- .forEach((raw) => onLine(classifyFlashLine(raw, stderr: stderr)));- }-- static String? _errorFrom(List<FlashLine> log) {- for (final line in log.reversed) {- if (line.kind == FlashLineKind.error) {- return line.text.replaceFirst(RegExp(r'^error:\s*'), '');- }- }- return null;- }-}--/// Decides what a raw output line is.-///-/// Pure, so the rule can be tested without spawning anything.-FlashLine classifyFlashLine(String raw, {required bool stderr}) {- final text = raw.trimRight();- if (text.startsWith('error:')) return FlashLine(text, FlashLineKind.error);- if (text.startsWith('>> ')) return FlashLine(text, FlashLineKind.step);- // Indented lines detail the running step. On stderr they are the script's- // warnings — same shape, but they must not read as routine.- if (stderr) return FlashLine(text, FlashLineKind.warning);- return FlashLine(text, FlashLineKind.detail);-}--/// Starts `harness flash` with the managed runtime. [HarnessCliRunner] also-/// puts the legacy launcher directory on PATH for the child script, so the-/// flasher can stop and restart its daemon reliably without zsh.-Future<Process> harnessCliStart(- List<String> arguments, {- Map<String, String>? environment,-}) =>- HarnessCliRunner(environment: {...Platform.environment, ...?environment})- .start(arguments);diff --git a/desktop/lib/settings/sections/about_section.dart b/desktop/lib/settings/sections/about_section.dartindex 29d8ce599..7ff801e7d 100644--- a/desktop/lib/settings/sections/about_section.dart+++ b/desktop/lib/settings/sections/about_section.dart@@ -9,7 +9,6 @@ import '../../shared/widgets/section_scaffold.dart';import '../../shared/widgets/skeleton.dart';import '../../state/app_state.dart';import '../../update/desktop_updater.dart';-import '../../widgets/flash_firmware_dialog.dart';import '../../widgets/update_notice.dart';/// Settings ▸ About: which build this is, and the way to ask for a newer one.@@ -27,13 +26,6 @@ import '../../widgets/update_notice.dart';/// from both places shares a check and a single result dialog. The card's/// pill is the quiet half of that: the dialog is the answer to a question you/// asked, the pill is the state you can see without asking.-///-/// "Flash dial firmware…" opens the same [showFlashFirmwareDialog] the native-/// macOS "Flash Firmware…" menu item does. It is in the card on every platform-/// rather than only where it is strictly needed, because on Linux and Windows-/// there is no native app menu and this is the ONLY way to reach it — and a-/// control that appears on some machines and not others is the harder thing to-/// support.class AboutSection extends StatefulWidget {const AboutSection({super.key, required this.notifier});@@ -131,8 +123,6 @@ class _AboutCard extends StatelessWidget {Container(height: 1, color: grid.AppPalette.divider),const SizedBox(height: 14),_CheckRow(checking: checking, onCheck: onCheck),- const SizedBox(height: 12),- const _FlashRow(),],],),@@ -376,25 +366,6 @@ class _CheckRow extends StatelessWidget {}}-/// The dial, in the same sentence-then-button shape the update row uses, so the-/// card reads as one object with two things you can ask of it.-class _FlashRow extends StatelessWidget {- const _FlashRow();-- @override- Widget build(BuildContext context) {- grid.AppTheme.watch(context);- return _AboutAction(- description: 'Update your hardware dial over USB.',- action: OutlinedButton(- key: const Key('settings-flash-firmware-button'),- onPressed: () => showFlashFirmwareDialog(context),- child: const Text('Flash dial firmware…'),- ),- );- }-}-/// Put the action below its explanation when larger text needs the full row.class _AboutAction extends StatelessWidget {const _AboutAction({required this.description, required this.action});diff --git a/desktop/lib/shared/theme/app_icons.dart b/desktop/lib/shared/theme/app_icons.dartindex eaf0d4465..9cc5a657d 100644--- a/desktop/lib/shared/theme/app_icons.dart+++ b/desktop/lib/shared/theme/app_icons.dart@@ -189,10 +189,8 @@ abstract final class AppIcons {static const undo2 = LucideIcons.undo2400;static const unlink = LucideIcons.unlink400;static const unplug = LucideIcons.unplug400;- static const usb = LucideIcons.usb400;static const user = LucideIcons.user400;static const users = LucideIcons.users400;static const waypoints = LucideIcons.waypoints400;static const wrapText = LucideIcons.wrapText400;- static const zap = LucideIcons.zap400;}diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex 22324e186..cd9b4a1cf 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -896,9 +896,7 @@ class AppNotifier extends ChangeNotifier {ownPid: pid,// An uninstall at work as well: this restart is a `harness stop` and a start beside it.paused: () =>- SerialPortLease.held ||- SerialPortLease.heldByAnotherProcess() ||- UninstallMarker.held(),+ SerialPortLease.heldByAnotherProcess() || UninstallMarker.held(),restart: () async {final probe = await _discovery.restart();return probe.ready ? probe.pid : null;diff --git a/desktop/lib/widgets/flash_firmware_dialog.dart b/desktop/lib/widgets/flash_firmware_dialog.dartdeleted file mode 100644index 43a55d5a8..000000000--- a/desktop/lib/widgets/flash_firmware_dialog.dart+++ /dev/null@@ -1,788 +0,0 @@-import 'dart:async';--import 'package:harness/shared/theme/app_icons.dart';-import 'package:flutter/material.dart';-import 'package:flutter/services.dart';--import '../flash/flasher.dart';-import '../shared/theme/app_theme.dart' as grid;-import '../shared/widgets/app_dialog.dart';--/// Writes firmware to the plugged-in dial, and shows the flasher's own output-/// while it happens.-Future<void> showFlashFirmwareDialog(BuildContext context, {Flasher? flasher}) {- return showAppDialog<void>(- context: context,- // A half-written image is a board that will not boot. The dialog refuses to- // leave while the write is in flight; PopScope below does the same for the- // Escape key and the window's own close.- barrierDismissible: false,- builder: (context) => _FlashDialog(flasher: flasher ?? Flasher()),- );-}--enum _Phase { probing, ready, noBoard, flashing, done, failed }--class _FlashDialog extends StatefulWidget {- const _FlashDialog({required this.flasher});-- final Flasher flasher;-- @override- State<_FlashDialog> createState() => _FlashDialogState();-}--class _FlashDialogState extends State<_FlashDialog> {- final List<FlashLine> _log = [];- final ScrollController _logScroll = ScrollController();-- _Phase _phase = _Phase.probing;- List<String> _ports = const [];- String? _port;- String? _problem;-- /// Step titles in the order the script announced them, and which one is live.- final List<String> _steps = [];- bool _stepFailed = false;-- Stopwatch? _elapsed;- Timer? _ticker;-- @override- void initState() {- super.initState();- unawaited(_probe());- }-- @override- void dispose() {- _ticker?.cancel();- _logScroll.dispose();- super.dispose();- }-- Future<void> _probe() async {- setState(() {- _phase = _Phase.probing;- _log.clear();- _steps.clear();- _problem = null;- });- final probe = await widget.flasher.probe();- if (!mounted) return;- setState(() {- _log- ..clear()- ..addAll(probe.log);- _ports = probe.ports;- _port = probe.ports.length == 1 ? probe.ports.first : null;- _problem = probe.problem;- _phase = probe.found ? _Phase.ready : _Phase.noBoard;- });- }-- Future<void> _flash() async {- setState(() {- _phase = _Phase.flashing;- _log.clear();- _steps.clear();- _stepFailed = false;- _problem = null;- _elapsed = Stopwatch()..start();- });- _ticker = Timer.periodic(- const Duration(seconds: 1),- (_) => mounted ? setState(() {}) : null,- );-- final result = await widget.flasher.flash(port: _port, onLine: _onLine);- _ticker?.cancel();- _elapsed?.stop();- if (!mounted) return;- setState(() {- if (!result.ok) _stepFailed = true;- _phase = result.ok ? _Phase.done : _Phase.failed;- if (!result.ok) {- _problem = result.cancelled- ? 'Stopped.'- : _lastTrouble() ?? 'The flasher exited with ${result.exitCode}.';- }- });- }-- void _onLine(FlashLine line) {- if (!mounted) return;- setState(() {- _log.add(line);- if (line.kind == FlashLineKind.step) _steps.add(line.title);- });- // Follow the tail the way a terminal does.- WidgetsBinding.instance.addPostFrameCallback((_) {- if (_logScroll.hasClients) {- _logScroll.jumpTo(_logScroll.position.maxScrollExtent);- }- });- }-- String? _lastTrouble() {- for (final line in _log.reversed) {- if (line.kind == FlashLineKind.error ||- line.kind == FlashLineKind.warning) {- return line.text.trim().replaceFirst(RegExp(r'^error:\s*'), '');- }- }- return null;- }-- /// The version the script said it wrote, once it has said so.- String? get _version {- for (final line in _log) {- final match = RegExp(r'^>> release: \S+ (\S+)').firstMatch(line.text);- if (match != null) return match.group(1);- }- return null;- }-- @override- Widget build(BuildContext context) {- grid.AppTheme.watch(context);- return PopScope(- canPop: _phase != _Phase.flashing,- child: Dialog(- // See the note on the other two dialogs: `dialogTheme` owns the- // fill, the radius and the absence of a rim.- child: ConstrainedBox(- constraints: const BoxConstraints(maxWidth: 540),- child: Column(- mainAxisSize: MainAxisSize.min,- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Padding(- padding: const EdgeInsets.fromLTRB(18, 17, 18, 0),- child: _header(),- ),- Flexible(- child: SingleChildScrollView(- padding: const EdgeInsets.fromLTRB(18, 14, 18, 0),- child: _body(),- ),- ),- _actions(),- ],- ),- ),- ),- );- }-- // ---------------------------------------------------------------- header-- Widget _header() {- final (- IconData? icon,- Color tone,- String title,- String sub,- ) = switch (_phase) {- _Phase.probing => (- null,- grid.AppPalette.accentOnSurface,- 'Looking for the dial…',- 'Checking the USB ports on ${flashHostName()}.',- ),- _Phase.ready => (- AppIcons.zap,- grid.AppPalette.accentOnSurface,- 'Flash firmware to the dial',- 'Writes the latest circle release over USB.',- ),- _Phase.noBoard => (- AppIcons.usb,- grid.AppPalette.warn,- 'No dial found',- _problem ??- 'Plug the dial into ${flashHostName()} with a USB cable, then look '- 'again.',- ),- _Phase.flashing => (- null,- grid.AppPalette.accentOnSurface,- _version == null- ? 'Flashing the dial…'- : 'Flashing $_version → ${_port ?? 'the dial'}',- 'Don’t unplug the dial.',- ),- _Phase.done => (- AppIcons.circleCheck,- grid.AppPalette.online,- _version == null- ? 'The dial is flashed'- : 'circle $_version is on the dial',- 'Harness is running again. Your machines are back.',- ),- _Phase.failed => (- AppIcons.triangleAlert,- grid.AppPalette.dangerFill,- 'Flash failed',- _problem ?? 'Nothing else was changed. Harness has been started again.',- ),- };-- return Row(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Container(- width: 34,- height: 34,- decoration: BoxDecoration(- color: tone.withValues(alpha: 0.13),- borderRadius: BorderRadius.circular(grid.AppCard.insetRadius),- ),- alignment: Alignment.center,- child: icon == null- ? SizedBox(- width: 17,- height: 17,- child: CircularProgressIndicator(strokeWidth: 2, color: tone),- )- : Icon(icon, size: 18, color: tone),- ),- const SizedBox(width: 12),- Expanded(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- title,- style: grid.AppType.heading(color: grid.AppPalette.textPrimary),- ),- const SizedBox(height: 3),- Text(- sub,- style: grid.AppType.body(- color: grid.AppPalette.textSecondary,- height: 1.5,- ),- ),- ],- ),- ),- ],- );- }-- // ------------------------------------------------------------------ body-- Widget _body() {- return Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- if (_phase == _Phase.ready) ...[- _facts(),- if (_ports.length > 1) _portPicker(),- _daemonNotice(),- ],- if (_phase == _Phase.done) _facts(),- if (_phase == _Phase.flashing || _phase == _Phase.failed) ...[- _stepList(),- if (_phase == _Phase.flashing) ...[- const SizedBox(height: 13),- // Indeterminate on purpose. esptool prints a percentage, but it is- // the percentage of ONE write — following it would run the bar to- // full and drop it back to zero several times over.- LinearProgressIndicator(- minHeight: 2,- backgroundColor: grid.AppGlass.hair,- color: grid.AppPalette.accentOnSurface,- ),- ],- ],- if (_log.isNotEmpty && _phase != _Phase.ready) _logPane(),- ],- );- }-- Widget _facts() {- final done = _phase == _Phase.done;- return Column(- children: [- _fact('Board', _port ?? 'the dial'),- const SizedBox(height: 7),- if (done) ...[- _fact('Flashed', _version ?? 'circle'),- const SizedBox(height: 7),- _fact('Took', _formatElapsed(), tone: grid.AppPalette.textSecondary),- ] else- // Not a version number: --detect-only returns before the script- // resolves the release, so nothing here knows it yet, and inventing- // one would be a guess presented as a fact.- _fact('Will install', 'circle · latest'),- ],- );- }-- Widget _fact(String label, String value, {Color? tone}) {- grid.AppTheme.watch(context);- return Row(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- SizedBox(- width: 104,- child: Text(- label,- style: grid.AppType.body(color: grid.AppPalette.textFaint),- ),- ),- Expanded(- child: Text(- value,- style: grid.AppType.monoLabel(- fontWeight: FontWeight.w400,- color: tone ?? grid.AppPalette.textSecondary,- ),- ),- ),- ],- );- }-- Widget _portPicker() {- return Padding(- padding: const EdgeInsets.only(top: 13),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- 'More than one board is connected — pick one:',- style: grid.AppType.body(color: grid.AppPalette.textSecondary),- ),- const SizedBox(height: 7),- for (final port in _ports)- _PortChoice(- port: port,- selected: port == _port,- onTap: () => setState(() => _port = port),- ),- ],- ),- );- }-- Widget _daemonNotice() {- return Container(- margin: const EdgeInsets.only(top: 13),- padding: const EdgeInsets.fromLTRB(11, 10, 11, 10),- decoration: BoxDecoration(- color: grid.AppPalette.warn.withValues(alpha: 0.09),- border: Border.all(color: grid.AppPalette.warn.withValues(alpha: 0.24)),- borderRadius: BorderRadius.circular(grid.AppCard.insetRadius),- ),- child: Row(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Icon(AppIcons.triangleAlert, size: 14, color: grid.AppPalette.warn),- const SizedBox(width: 9),- Expanded(- child: RichText(- text: TextSpan(- style: grid.AppType.body(- color: grid.AppPalette.textSecondary,- height: 1.5,- ),- children: [- TextSpan(- text: 'Harness stops while flashing. ',- style: TextStyle(- color: grid.AppPalette.textPrimary,- fontWeight: grid.AppFont.semibold,- ),- ),- const TextSpan(- text:- 'The flasher has to close the serial port, so your '- 'machines go offline for about a minute and come back '- 'on their own.',- ),- ],- ),- ),- ),- ],- ),- );- }-- Widget _stepList() {- return Column(- children: [- for (var i = 0; i < _steps.length; i++)- _StepRow(- label: _steps[i],- state: i < _steps.length - 1- ? _StepState.done- : _stepFailed- ? _StepState.failed- : _phase == _Phase.flashing- ? _StepState.running- : _StepState.done,- ),- ],- );- }-- Widget _logPane() {- return Container(- margin: const EdgeInsets.only(top: 13),- decoration: BoxDecoration(- border: Border.all(color: grid.AppGlass.hair),- borderRadius: BorderRadius.circular(grid.AppCard.insetRadius),- ),- clipBehavior: Clip.antiAlias,- child: Column(- children: [- Container(- padding: const EdgeInsets.fromLTRB(10, 7, 10, 7),- color: grid.AppPalette.windowBg,- child: Row(- children: [- Icon(- AppIcons.squareTerminal,- size: 14,- color: grid.AppPalette.textFaint,- ),- const SizedBox(width: 8),- Text(- 'Output',- style: grid.AppType.caption(- color: grid.AppPalette.textSecondary,- fontWeight: grid.AppFont.medium,- ),- ),- const Spacer(),- Text(- widget.flasher.scriptName,- style: grid.AppType.monoMeta(- color: grid.AppPalette.textFaint,- ),- ),- ],- ),- ),- Container(- constraints: const BoxConstraints(maxHeight: 170),- width: double.infinity,- color: grid.AppPalette.windowBg,- child: SingleChildScrollView(- controller: _logScroll,- padding: const EdgeInsets.fromLTRB(11, 9, 11, 9),- child: SelectableText.rich(- TextSpan(- children: [- for (final line in _log)- TextSpan(- text: '${line.text}\n',- style: TextStyle(color: _inkFor(line.kind)),- ),- ],- ),- style: grid.AppType.monoLabel(- fontWeight: FontWeight.w400,- height: 1.62,- ),- ),- ),- ),- ],- ),- );- }-- Color _inkFor(FlashLineKind kind) => switch (kind) {- FlashLineKind.step => grid.AppPalette.textPrimary,- FlashLineKind.detail => grid.AppPalette.textSecondary,- FlashLineKind.warning => grid.AppPalette.warn,- FlashLineKind.error => grid.AppPalette.dangerFill,- };-- // --------------------------------------------------------------- actions-- Widget _actions() {- final children = <Widget>[];-- if (_log.isNotEmpty && _phase != _Phase.probing) {- children.add(- _DialogButton(- label: 'Copy log',- onPressed: () => unawaited(- Clipboard.setData(- ClipboardData(text: _log.map((l) => l.text).join('\n')),- ),- ),- ),- );- }- children.add(const Spacer());-- switch (_phase) {- case _Phase.probing:- children.add(- _DialogButton(- label: 'Cancel',- onPressed: () => Navigator.pop(context),- ),- );- case _Phase.ready:- children- ..add(- _DialogButton(- label: 'Cancel',- kind: _ButtonKind.ghost,- onPressed: () => Navigator.pop(context),- ),- )- ..add(const SizedBox(width: 8))- ..add(- _DialogButton(- key: const Key('flash-start-button'),- label: 'Flash',- kind: _ButtonKind.primary,- // The script asks for confirmation on a terminal it does not- // have here, so it runs with --yes. THIS is the confirmation.- onPressed: _port == null && _ports.length > 1- ? null- : () => unawaited(_flash()),- ),- );- case _Phase.noBoard:- children- ..add(- _DialogButton(- label: 'Close',- kind: _ButtonKind.ghost,- onPressed: () => Navigator.pop(context),- ),- )- ..add(const SizedBox(width: 8))- ..add(- _DialogButton(- label: 'Look again',- kind: _ButtonKind.primary,- onPressed: () => unawaited(_probe()),- ),- );- case _Phase.flashing:- children.add(- _DialogButton(- key: const Key('flash-stop-button'),- label: 'Stop',- kind: _ButtonKind.ghost,- onPressed: widget.flasher.cancel,- ),- );- case _Phase.done:- children.add(- _DialogButton(- label: 'Done',- kind: _ButtonKind.primary,- onPressed: () => Navigator.pop(context),- ),- );- case _Phase.failed:- children- ..add(- _DialogButton(- label: 'Close',- kind: _ButtonKind.ghost,- onPressed: () => Navigator.pop(context),- ),- )- ..add(const SizedBox(width: 8))- ..add(- _DialogButton(- label: 'Try again',- kind: _ButtonKind.primary,- onPressed: () => unawaited(_flash()),- ),- );- }-- return Container(- margin: const EdgeInsets.only(top: 14),- padding: const EdgeInsets.fromLTRB(18, 12, 18, 12),- decoration: BoxDecoration(- border: Border(top: BorderSide(color: grid.AppGlass.hair)),- ),- child: Row(children: children),- );- }-- String _formatElapsed() {- final seconds = (_elapsed?.elapsed.inSeconds ?? 0);- final minutes = seconds ~/ 60;- return '$minutes:${(seconds % 60).toString().padLeft(2, '0')}';- }-}--enum _StepState { done, running, failed }--class _StepRow extends StatelessWidget {- const _StepRow({required this.label, required this.state});-- final String label;- final _StepState state;-- @override- Widget build(BuildContext context) {- grid.AppTheme.watch(context);- final (Widget mark, Color ink) = switch (state) {- _StepState.done => (- Icon(AppIcons.circleCheck, size: 14, color: grid.AppPalette.online),- grid.AppPalette.textSecondary,- ),- _StepState.running => (- SizedBox(- width: 13,- height: 13,- child: CircularProgressIndicator(- strokeWidth: 2,- color: grid.AppPalette.accentOnSurface,- ),- ),- grid.AppPalette.textPrimary,- ),- _StepState.failed => (- Icon(- AppIcons.triangleAlert,- size: 14,- color: grid.AppPalette.dangerFill,- ),- grid.AppPalette.textPrimary,- ),- };-- return Padding(- padding: const EdgeInsets.symmetric(vertical: 3),- child: Row(- children: [- SizedBox(width: 16, child: Center(child: mark)),- const SizedBox(width: 9),- Expanded(- child: Text(- label,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: grid.AppType.body(color: ink),- ),- ),- ],- ),- );- }-}--enum _ButtonKind { quiet, ghost, primary }--class _DialogButton extends StatelessWidget {- const _DialogButton({- super.key,- required this.label,- required this.onPressed,- this.kind = _ButtonKind.quiet,- });-- final String label;- final VoidCallback? onPressed;- final _ButtonKind kind;-- @override- Widget build(BuildContext context) {- grid.AppTheme.watch(context);- final primary = kind == _ButtonKind.primary;- return TextButton(- onPressed: onPressed,- style: TextButton.styleFrom(- minimumSize: const Size(0, 28),- padding: const EdgeInsets.symmetric(horizontal: 13, vertical: 5),- tapTargetSize: MaterialTapTargetSize.shrinkWrap,- visualDensity: VisualDensity.standard,- backgroundColor: primary- ? grid.AppPalette.accentOnSurface- : Colors.transparent,- foregroundColor: primary- ? grid.AppPalette.windowBg- : grid.AppPalette.textSecondary,- disabledForegroundColor: grid.AppPalette.textFaint,- shape: RoundedRectangleBorder(- borderRadius: BorderRadius.circular(7),- side: kind == _ButtonKind.ghost- ? BorderSide(color: grid.AppGlass.hair)- : BorderSide.none,- ),- textStyle: grid.AppType.label(- fontWeight: primary ? grid.AppFont.semibold : grid.AppFont.regular,- ),- ),- child: Text(label),- );- }-}--/// One selectable serial port, when more than one board is plugged in.-class _PortChoice extends StatelessWidget {- const _PortChoice({- required this.port,- required this.selected,- required this.onTap,- });-- final String port;- final bool selected;- final VoidCallback onTap;-- @override- Widget build(BuildContext context) {- grid.AppTheme.watch(context);- final accent = grid.AppPalette.accentOnSurface;- return InkWell(- onTap: onTap,- borderRadius: BorderRadius.circular(7),- child: Padding(- padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),- child: Row(- children: [- Container(- width: 13,- height: 13,- decoration: BoxDecoration(- shape: BoxShape.circle,- border: Border.all(- color: selected ? accent : grid.AppPalette.textFaint,- width: 1.5,- ),- ),- alignment: Alignment.center,- child: selected- ? Container(- width: 6,- height: 6,- decoration: BoxDecoration(- shape: BoxShape.circle,- color: accent,- ),- )- : null,- ),- const SizedBox(width: 9),- Text(- port,- style: grid.AppType.monoLabel(- fontWeight: FontWeight.w400,- color: grid.AppPalette.textPrimary,- ),- ),- ],- ),- ),- );- }-}diff --git a/desktop/lib/widgets/in_window_menu_bar.dart b/desktop/lib/widgets/in_window_menu_bar.dartindex 123a41196..793592e36 100644--- a/desktop/lib/widgets/in_window_menu_bar.dart+++ b/desktop/lib/widgets/in_window_menu_bar.dart@@ -330,12 +330,6 @@ class _InWindowMenuBarState extends State<InWindowMenuBar> {label: 'Check for Updates…',action: 'checkForUpdates',),- _appRow(- key: 'menu-bar-flash-firmware',- icon: AppIcons.zap,- label: 'Flash Firmware…',- action: 'flashFirmware',- ),const AppMenuDivider(),// The Quit row the Mac's application menu carries. The app's exit// lifecycle (the pane-arrangement flush in didRequestAppExit) runs ondiff --git a/desktop/lib/ws/local_cli_discovery.dart b/desktop/lib/ws/local_cli_discovery.dartindex 179e3c9c9..524e0dce9 100644--- a/desktop/lib/ws/local_cli_discovery.dart+++ b/desktop/lib/ws/local_cli_discovery.dart@@ -265,7 +265,7 @@ class LocalCliDiscovery {if (!last.alive) {// Same reason as the supervisor: while the dial is being flashed the daemon is down on purpose// and its port belongs to esptool. Down is the honest answer here — it really is not running.- if (SerialPortLease.held || SerialPortLease.heldByAnotherProcess()) {+ if (SerialPortLease.heldByAnotherProcess()) {return last;}try {@@ -289,9 +289,7 @@ class LocalCliDiscovery {last = await probe();if (last.ready) return last;if (!last.alive) {- if (spawned ||- SerialPortLease.held ||- SerialPortLease.heldByAnotherProcess()) {+ if (spawned || SerialPortLease.heldByAnotherProcess()) {return last;}spawned = true;@@ -424,7 +422,7 @@ class LocalCliDiscovery {// The daemon is DELIBERATELY down while the dial is being flashed — it was stopped so the// port could be handed over. Starting it here takes the port back mid-write and kills the// flash, which is what made a firmware update fail at a few tens of kilobytes.- if (SerialPortLease.held || SerialPortLease.heldByAnotherProcess()) {+ if (SerialPortLease.heldByAnotherProcess()) {return;}// Down on purpose as well: `harness uninstall` stopped it and is removing its files. Adiff --git a/desktop/macos/Runner/MainFlutterWindow.swift b/desktop/macos/Runner/MainFlutterWindow.swiftindex ba7dba164..359fd5b47 100644--- a/desktop/macos/Runner/MainFlutterWindow.swift+++ b/desktop/macos/Runner/MainFlutterWindow.swift@@ -101,7 +101,7 @@ class MainFlutterWindow: NSWindow {}/// Puts Check for Updates… in the application menu; [HarnessAppMenu.arrange]- /// gives it its place. Keyboard Shortcuts… and Flash Firmware… live in Help.+ /// gives it its place. Keyboard Shortcuts… lives in Help.////// Added here rather than in MainMenu.xib so the whole menu bar keeps coming/// from the nib — declaring it in Dart with PlatformMenuBar would replace the@@ -131,8 +131,7 @@ class MainFlutterWindow: NSWindow {/// and AppKit prints ⌘/ beside it, which is how people learn the chord./// Export Logs… is the bug-report zip, from a menu every build has (Settings/// ▸ Debug carries the same action but is hidden in a shipped app, and the- /// person whose dial got stuck is running a shipped app). Flash Firmware…- /// is that dial's, and is here for the same reason.+ /// person whose dial got stuck is running a shipped app).private func installHelpMenuItems() {guard let helpMenu = NSApp.mainMenu?.item(withTitle: "Help")?.submenu else { return }guard helpMenu.indexOfItem(withTag: exportLogsMenuItemTag) == -1 else { return }@@ -149,7 +148,6 @@ class MainFlutterWindow: NSWindow {),NSMenuItem.separator(),menuItem(title: "Export Logs…", action: #selector(exportLogs(_:)), symbol: "doc.zipper", tag: exportLogsMenuItemTag),- menuItem(title: "Flash Firmware…", action: #selector(flashFirmware(_:)), symbol: "bolt.circle", tag: flashMenuItemTag),NSMenuItem.separator(),]for (index, item) in items.enumerated() { helpMenu.insertItem(item, at: index) }@@ -290,7 +288,6 @@ class MainFlutterWindow: NSWindow {}private var updateMenuItemTag: Int { 7301 }- private var flashMenuItemTag: Int { 7302 }private var shortcutsMenuItemTag: Int { 7303 }private var resetFontMenuItemTag: Int { 7304 }private var biggerFontMenuItemTag: Int { 7305 }@@ -303,10 +300,6 @@ class MainFlutterWindow: NSWindow {menuChannel?.invokeMethod("checkForUpdates", arguments: nil)}- @objc private func flashFirmware(_ sender: Any?) {- menuChannel?.invokeMethod("flashFirmware", arguments: nil)- }-@objc private func exportLogs(_ sender: Any?) {menuChannel?.invokeMethod("exportLogs", arguments: nil)}diff --git a/desktop/test/about_section_test.dart b/desktop/test/about_section_test.dartindex 093864cf6..1fe73123c 100644--- a/desktop/test/about_section_test.dart+++ b/desktop/test/about_section_test.dart@@ -74,18 +74,12 @@ void main() {expect(find.text('1.0.0'), findsOneWidget);expect(find.text('Not checked'), findsOneWidget);expect(find.text('Up to date'), findsNothing);- // Secondary actions, never a filled one — the pane is read, not operated.- // Two of them since the merge with main: the update check, and the dial- // flash, which on Linux and Windows has no native menu item to live in.+ // A secondary action, never a filled one — the pane is read, not operated.expect(find.byKey(const Key('settings-check-updates-button')),findsOneWidget,);- expect(- find.byKey(const Key('settings-flash-firmware-button')),- findsOneWidget,- );- expect(find.byType(OutlinedButton), findsNWidgets(2));+ expect(find.byType(OutlinedButton), findsOneWidget);expect(find.byType(FilledButton), findsNothing);},);diff --git a/desktop/test/app_menu_test.dart b/desktop/test/app_menu_test.dartindex bacc8c7b7..6d5dddd95 100644--- a/desktop/test/app_menu_test.dart+++ b/desktop/test/app_menu_test.dart@@ -91,7 +91,6 @@ void main() {await repeated;expect(find.byType(Dialog), findsOneWidget);await _menu(tester, 'showLayout');- await _menu(tester, 'flashFirmware');expect(find.byType(Dialog), findsOneWidget);Navigator.of(tester.element(find.byType(Dialog))).pop();await tester.pump(const Duration(milliseconds: 300));@@ -184,7 +183,7 @@ void main() {await tester.pump();await tester.pump(const Duration(milliseconds: 300));expect(find.byType(SettingsScreen), findsOneWidget);- for (final method in ['showShortcuts', 'showLayout', 'flashFirmware']) {+ for (final method in ['showShortcuts', 'showLayout']) {await _menu(tester, method);}await tester.pump();diff --git a/desktop/test/flash_firmware_dialog_test.dart b/desktop/test/flash_firmware_dialog_test.dartdeleted file mode 100644index e904bb766..000000000--- a/desktop/test/flash_firmware_dialog_test.dart+++ /dev/null@@ -1,64 +0,0 @@-import 'dart:async';--import 'package:flutter/material.dart';-import 'package:flutter_test/flutter_test.dart';-import 'package:harness/flash/flasher.dart';-import 'package:harness/widgets/flash_firmware_dialog.dart';--class _DialogFlasher extends Flasher {- _DialogFlasher({required super.windows});- final stopped = Completer<FlashResult>();-- @override- Future<FlashProbe> probe() async =>- const FlashProbe(ports: ['COM3'], log: []);-- @override- Future<FlashResult> flash({String? port, void Function(FlashLine)? onLine}) {- onLine?.call(const FlashLine('>> writing firmware', FlashLineKind.step));- return stopped.future;- }-- @override- void cancel() =>- stopped.complete(const FlashResult(exitCode: 130, cancelled: true));-}--void main() {- for (final windows in [true, false]) {- testWidgets(- 'output identifies the ${windows ? 'Windows' : 'Unix'} script and Stop avoids an unverified restart claim',- (tester) async {- final flasher = _DialogFlasher(windows: windows);- await tester.pumpWidget(- MaterialApp(- home: Builder(- builder: (context) => TextButton(- onPressed: () => unawaited(- showFlashFirmwareDialog(context, flasher: flasher),- ),- child: const Text('Open'),- ),- ),- ),- );- await tester.tap(find.text('Open'));- await tester.pumpAndSettle();- await tester.tap(find.byKey(const Key('flash-start-button')));- await tester.pump();- expect(- find.text(windows ? 'flash-circle.ps1' : 'flash-circle.sh'),- findsOneWidget,- );- await tester.tap(find.byKey(const Key('flash-stop-button')));- await tester.pumpAndSettle();- expect(find.text('Stopped.'), findsOneWidget);- expect(- find.textContaining('Harness has been started again.'),- findsNothing,- );- await tester.pumpWidget(const SizedBox());- },- );- }-}diff --git a/desktop/test/flasher_test.dart b/desktop/test/flasher_test.dartdeleted file mode 100644index c6ceca2d2..000000000--- a/desktop/test/flasher_test.dart+++ /dev/null@@ -1,698 +0,0 @@-import 'dart:async';-import 'dart:convert';-import 'dart:io';--import 'package:flutter_test/flutter_test.dart';-import 'package:harness/core/config.dart';-import 'package:harness/core/serial_port_lease.dart';-import 'package:harness/flash/flasher.dart';-import 'package:harness/ws/local_cli_discovery.dart';--// Redirect only the default lease paths; all tested markers remain real files in a private cache.-final class _LeaseIo extends IOOverrides {- _LeaseIo(this.directory) : original = SerialPortLease.flasherDirectory();- final Directory directory;- final String original;-- @override- File createFile(String path) => path == '$original/flashing'- ? super.createFile('${directory.path}/flashing')- : super.createFile(path);-- @override- Directory createDirectory(String path) =>- path == original ? directory : super.createDirectory(path);-}--class _DownDiscovery extends LocalCliDiscovery {- _DownDiscovery(Future<void> Function() spawn)- : super(config: AppConfig.dev, spawnCommand: spawn);-- @override- Future<LocalCliProbe> probe({String? expectedComputerId}) async =>- const LocalCliProbe.down('fixture daemon stopped');-}--/// A process whose output is a script, so the parsing rules can be exercised-/// without a board, a cable, or a shell.-class _FakeProcess implements Process {- _FakeProcess({- required this.out,- this.err = const [],- this.code = 0,- this.waitForKill = false,- });-- final List<String> out;- final List<String> err;- final int code;-- /// Keeps running until something signals it — the only way to exercise a- /// cancel, since a process that has already exited cannot be cancelled.- final bool waitForKill;- final List<ProcessSignal> signals = [];- final Completer<int> _exit = Completer<int>();-- @override- Stream<List<int>> get stdout =>- Stream.value(utf8.encode(out.map((l) => '$l\n').join()));-- @override- Stream<List<int>> get stderr =>- Stream.value(utf8.encode(err.map((l) => '$l\n').join()));-- @override- Future<int> get exitCode => waitForKill ? _exit.future : Future.value(code);-- @override- bool kill([ProcessSignal signal = ProcessSignal.sigterm]) {- signals.add(signal);- if (!_exit.isCompleted) _exit.complete(code);- return true;- }-- @override- int get pid => 4242;-- @override- IOSink get stdin => throw UnimplementedError();-}--void main() {- group('Windows persisted flash ownership', () {- late Directory dir;- late Map<String, String> leaseEnvironment;- setUp(() {- dir = Directory.systemTemp.createTempSync('flasher-owned-');- leaseEnvironment = {'HARNESS_FLASHER_CACHE': dir.path};- });- tearDown(() => dir.deleteSync(recursive: true));-- File mark(String name) => File('${dir.path}/$name')- ..writeAsStringSync('${DateTime.now().millisecondsSinceEpoch ~/ 1000}\n');-- test(- 'forced tree exit retires only its own real lease before resolving',- () async {- final spawned = _FakeProcess(out: [], code: 130, waitForKill: true);- late File owned;- final killFinished = Completer<void>();- final killStarted = Completer<void>();- var finished = false;- final flasher = Flasher(- windows: true,- cancelDirectory: dir.path,- killAfter: const Duration(milliseconds: 1),- startProcess: (_, {Map<String, String>? environment}) async {- final runId =- environment?['HARNESS_FLASH_RUN_ID'] ?? 'missing-owner';- owned = mark('flashing.$runId');- return spawned;- },- killTree: (_) async {- killStarted.complete();- spawned.kill();- await killFinished.future;- },- );- final run = flasher.flash().then((value) {- finished = true;- return value;- });- await Future<void>.delayed(Duration.zero);- try {- expect(SerialPortLease.held, isTrue);- expect(- SerialPortLease.heldByAnotherProcess(environment: leaseEnvironment),- isTrue,- );- flasher.cancel();- await killStarted.future.timeout(const Duration(seconds: 2));- await Future<void>.delayed(Duration.zero);- expect(- finished,- isFalse,- reason: 'parent exit alone is not proof that taskkill finished',- );- expect(SerialPortLease.held, isTrue);- expect(owned.existsSync(), isTrue);- } finally {- if (!killFinished.isCompleted) killFinished.complete();- spawned.kill();- await run;- }- expect(owned.existsSync(), isFalse);- expect(SerialPortLease.held, isFalse);- expect(- SerialPortLease.heldByAnotherProcess(environment: leaseEnvironment),- isFalse,- );- },- );-- test('successful kill still waits for parent exit before retiring the lease', () async {- final spawned = _FakeProcess(out: [], code: 130, waitForKill: true);- late File owned;- final killed = Completer<void>();- final flasher = Flasher(- windows: true,- cancelDirectory: dir.path,- killAfter: const Duration(milliseconds: 1),- startProcess: (_, {Map<String, String>? environment}) async {- owned = mark(- 'flashing.${environment?['HARNESS_FLASH_RUN_ID'] ?? 'missing-owner'}',- );- return spawned;- },- killTree: (_) async {- killed.complete();- },- );-- final run = flasher.flash();- await Future<void>.delayed(Duration.zero);- flasher.cancel();- await killed.future.timeout(const Duration(seconds: 2));- await Future<void>.delayed(Duration.zero);- expect(owned.existsSync(), isTrue);- expect(SerialPortLease.held, isTrue);- spawned.kill();- expect((await run).cancelled, isTrue);- expect(owned.existsSync(), isFalse);- });-- test('a real forced child exit unblocks explicit startup and timed supervision', () async {- await IOOverrides.runWithIOOverrides(() async {- Process? child;- var spawned = 0;- final supervised = Completer<void>();- final discovery = _DownDiscovery(() async {- spawned++;- if (spawned == 2) supervised.complete();- });- final flasher = Flasher(- windows: true,- cancelDirectory: dir.path,- killAfter: const Duration(milliseconds: 1),- startProcess: (_, {Map<String, String>? environment}) async {- mark('flashing.${environment!['HARNESS_FLASH_RUN_ID']}');- return child = await Process.start(- Platform.isWindows ? 'powershell.exe' : '/bin/sleep',- Platform.isWindows- ? ['-NoProfile', '-Command', 'Start-Sleep -Seconds 30']- : ['30'],- );- },- killTree: (pid) async {- if (!Process.killPid(pid, ProcessSignal.sigkill)) {- throw StateError('fixture child did not terminate');- }- },- );- final run = flasher.flash();- while (!flasher.isRunning) {- await Future<void>.delayed(const Duration(milliseconds: 1));- }- Timer? timer;- try {- expect(SerialPortLease.heldByAnotherProcess(), isTrue);- await discovery.ensureRunning(timeout: Duration.zero);- expect(spawned, 0);- timer = discovery.startSupervising(- checkInterval: const Duration(milliseconds: 5),- graceWindow: Duration.zero,- spawnAfter: 1,- spawnAllowedAt: (_) => true,- );- await Future<void>.delayed(const Duration(milliseconds: 25));- expect(spawned, 0);- timer.cancel();- flasher.cancel();- expect((await run).cancelled, isTrue);- expect(SerialPortLease.held, isFalse);- expect(SerialPortLease.heldByAnotherProcess(), isFalse);- await discovery.ensureRunning(timeout: Duration.zero);- expect(spawned, 1);- timer = discovery.startSupervising(- checkInterval: const Duration(milliseconds: 5),- graceWindow: Duration.zero,- spawnAfter: 1,- spawnAllowedAt: (_) => true,- );- await supervised.future.timeout(const Duration(seconds: 2));- expect(spawned, 2);- } finally {- timer?.cancel();- child?.kill();- await run;- }- }, _LeaseIo(dir));- });-- test(- 'a cached older script keeps its unowned shared lease after forced exit',- () async {- final spawned = _FakeProcess(out: [], code: 130, waitForKill: true);- late File legacy;- final flasher = Flasher(- windows: true,- cancelDirectory: dir.path,- killAfter: const Duration(milliseconds: 1),- startProcess: (_, {environment}) async {- legacy = mark('flashing');- return spawned;- },- killTree: (_) async {- spawned.kill();- },- );- final run = flasher.flash();- await Future<void>.delayed(Duration.zero);- flasher.cancel();- await run;- expect(legacy.existsSync(), isTrue);- expect(- SerialPortLease.heldByAnotherProcess(environment: leaseEnvironment),- isTrue,- );- },- );-- for (final foreignName in ['flashing', 'flashing.${'b' * 32}']) {- test('forced cleanup preserves a same-second foreign $foreignName', () async {- final spawned = _FakeProcess(out: [], code: 130, waitForKill: true);- late File owned;- late File foreign;- late String foreignContents;- final flasher = Flasher(- windows: true,- cancelDirectory: dir.path,- killAfter: const Duration(milliseconds: 1),- startProcess: (_, {Map<String, String>? environment}) async {- owned = mark(- 'flashing.${environment?['HARNESS_FLASH_RUN_ID'] ?? 'missing-owner'}',- );- return spawned;- },- killTree: (_) async {- foreign = mark(foreignName);- // Deliberately indistinguishable timestamps: run identity must decide ownership.- foreignContents = owned.readAsStringSync();- foreign.writeAsStringSync(foreignContents);- foreign.setLastModifiedSync(owned.lastModifiedSync());- spawned.kill();- },- );- final run = flasher.flash();- await Future<void>.delayed(Duration.zero);- flasher.cancel();- await run;- expect(owned.existsSync(), isFalse);- expect(foreign.readAsStringSync(), foreignContents);- expect(SerialPortLease.held, isFalse);- expect(- SerialPortLease.heldByAnotherProcess(environment: leaseEnvironment),- isTrue,- );- });- }-- test('failed tree termination preserves its real persisted lease', () async {- final spawned = _FakeProcess(out: [], code: 130, waitForKill: true);- late File owned;- final attempted = Completer<void>();- final lines = <FlashLine>[];- final flasher = Flasher(- windows: true,- cancelDirectory: dir.path,- killAfter: const Duration(milliseconds: 1),- startProcess: (_, {Map<String, String>? environment}) async {- owned = mark(- 'flashing.${environment?['HARNESS_FLASH_RUN_ID'] ?? 'missing-owner'}',- );- return spawned;- },- killTree: (_) async {- attempted.complete();- throw StateError('access denied');- },- );- final run = flasher.flash(onLine: lines.add);- await Future<void>.delayed(Duration.zero);- try {- flasher.cancel();- await attempted.future.timeout(const Duration(seconds: 2));- await Future<void>.delayed(Duration.zero);- expect(SerialPortLease.held, isTrue);- expect(- SerialPortLease.heldByAnotherProcess(environment: leaseEnvironment),- isTrue,- );- expect(owned.existsSync(), isTrue);- expect(lines.single.text, contains('access denied'));- } finally {- spawned.kill();- await run;- }- expect(- owned.existsSync(),- isTrue,- reason: 'a parent exit after failed taskkill does not establish writer exit',- );- expect(- SerialPortLease.heldByAnotherProcess(environment: leaseEnvironment),- isTrue,- );- });-- test('every invocation passes a distinct child-only owner and the chosen cache', () async {- final owners = <String?>[];- final flasher = Flasher(- windows: true,- cancelDirectory: dir.path,- startProcess: (_, {Map<String, String>? environment}) async {- owners.add(environment?['HARNESS_FLASH_RUN_ID']);- expect(environment?['HARNESS_FLASHER_CACHE'], dir.path);- return _FakeProcess(out: []);- },- );- await flasher.flash();- await flasher.flash();- expect(owners, everyElement(matches(RegExp(r'^[0-9a-f]{32}$'))));- expect(owners.toSet(), hasLength(2));- expect(Platform.environment['HARNESS_FLASH_RUN_ID'], isNull);- });- });-- group('classifyFlashLine', () {- test('a >> line opens a step, and loses its marker in the title', () {- final line = classifyFlashLine(- '>> flashing 0.0.39 → /dev/cu.usbmodem',- stderr: false,- );- expect(line.kind, FlashLineKind.step);- expect(line.title, 'flashing 0.0.39 → /dev/cu.usbmodem');- });-- test('an indented line details the step it follows', () {- expect(- classifyFlashLine(' write app (0x10000)', stderr: false).kind,- FlashLineKind.detail,- );- });-- test('error: wins over the stream it arrived on', () {- // The script writes `die` to stderr, but a line that names itself an- // error must read as one from either stream — the prefix is the claim.- expect(- classifyFlashLine('error: cancelled', stderr: true).kind,- FlashLineKind.error,- );- expect(- classifyFlashLine('error: cancelled', stderr: false).kind,- FlashLineKind.error,- );- });-- test('anything else on stderr is a warning, not routine detail', () {- expect(- classifyFlashLine(- ' sha256 mismatch — not installing',- stderr: true,- ).kind,- FlashLineKind.warning,- );- });- });-- group('probe', () {- test('reads the port the script settled on', () async {- final flasher = Flasher(- startProcess: (_, {environment}) async => _FakeProcess(- out: [- '>> probing 2 serial port(s)…',- '>> board: /dev/cu.usbmodem2101',- '>> detect-only: nothing was written.',- ],- ),- );- final probe = await flasher.probe();- expect(probe.found, isTrue);- expect(probe.ports, ['/dev/cu.usbmodem2101']);- expect(probe.problem, isNull);- });-- test('a bare exit 1 still yields a reason to show', () async {- final flasher = Flasher(- startProcess: (_, {environment}) async => _FakeProcess(- out: ['>> probing 1 serial port(s)…'],- err: ['error: no ESP32-S3 found'],- code: 1,- ),- );- final probe = await flasher.probe();- expect(probe.found, isFalse);- // Stripped of the prefix: the dialog puts it under a heading that already- // says something went wrong.- expect(probe.problem, 'no ESP32-S3 found');- });-- test(- 'names the permission case rather than calling it "not found"',- () async {- final flasher = Flasher(- startProcess: (_, {environment}) async => _FakeProcess(- out: ['>> probing 1 serial port(s)…'],- err: [' /dev/cu.usbmodem2101 — no permission'],- code: 1,- ),- );- expect(- (await flasher.probe()).problem,- 'no permission to open the serial port',- );- },- );- });-- test('cancel asks with SIGTERM so the script can run its trap', () async {- // SIGKILL would skip `trap start_harness_after_flash EXIT INT TERM`, which- // is the only thing that restarts the daemon the script stopped.- late _FakeProcess spawned;- final flasher = Flasher(- windows: false,- startProcess: (_, {environment}) async {- spawned = _FakeProcess(- out: ['>> flashing…'],- code: 143,- waitForKill: true,- );- return spawned;- },- );- final run = flasher.flash();- await Future<void>.delayed(Duration.zero);- flasher.cancel();- final result = await run;-- expect(spawned.signals, [ProcessSignal.sigterm]);- expect(result.cancelled, isTrue);- expect(result.ok, isFalse);- });-- test('Windows cancellation writes a file before ending an unresponsive tree', () async {- final dir = Directory.systemTemp.createTempSync('flasher-cancel-');- addTearDown(() => dir.deleteSync(recursive: true));- late _FakeProcess spawned;- final killed = <int>[];- final flasher = Flasher(- windows: true,- cancelDirectory: dir.path,- killAfter: const Duration(milliseconds: 50),- killTree: (pid) async => killed.add(pid),- startProcess: (_, {environment}) async {- spawned = _FakeProcess(- out: ['>> flashing…'],- code: 130,- waitForKill: true,- );- return spawned;- },- );- final run = flasher.flash();- await Future<void>.delayed(Duration.zero);- flasher.cancel();-- expect(spawned.signals, isEmpty);- expect(- File('${dir.path}${Platform.pathSeparator}cancel').existsSync(),- isTrue,- );- expect(killed, isEmpty);- await Future<void>.delayed(const Duration(milliseconds: 120));- expect(killed, [spawned.pid]);- spawned- .kill(); // Simulates the process tree ending, without running taskkill.- final result = await run;- expect(result.cancelled, isTrue);- expect(result.ok, isFalse);- });-- test('a Windows script that stops in time is not killed', () async {- final dir = Directory.systemTemp.createTempSync('flasher-cancel-');- addTearDown(() => dir.deleteSync(recursive: true));- late _FakeProcess spawned;- final killed = <int>[];- final flasher = Flasher(- windows: true,- cancelDirectory: dir.path,- killAfter: const Duration(milliseconds: 50),- killTree: (pid) async => killed.add(pid),- startProcess: (_, {environment}) async {- spawned = _FakeProcess(out: const [], code: 130, waitForKill: true);- return spawned;- },- );- final run = flasher.flash();- await Future<void>.delayed(Duration.zero);- flasher.cancel();- expect(spawned.signals, isEmpty);- spawned.kill(); // Simulates the script seeing the file and exiting itself.- final result = await run;- await Future<void>.delayed(const Duration(milliseconds: 120));- expect(killed, isEmpty);- expect(result.cancelled, isTrue);- });-- test(- 'a Windows cancel-file error still allows the grace period before killing',- () async {- final dir = Directory.systemTemp.createTempSync('flasher-cancel-');- addTearDown(() => dir.deleteSync(recursive: true));- final blocked = File('${dir.path}${Platform.pathSeparator}file')- ..writeAsStringSync('');- late _FakeProcess spawned;- final killed = <int>[];- final flasher = Flasher(- windows: true,- cancelDirectory: blocked.path,- killAfter: const Duration(milliseconds: 50),- killTree: (pid) async => killed.add(pid),- startProcess: (_, {environment}) async {- spawned = _FakeProcess(out: const [], code: 130, waitForKill: true);- return spawned;- },- );- final run = flasher.flash();- await Future<void>.delayed(Duration.zero);- flasher.cancel();- expect(spawned.signals, isEmpty);- expect(killed, isEmpty);- await Future<void>.delayed(const Duration(milliseconds: 120));- expect(killed, [spawned.pid]);- spawned.kill();- expect((await run).cancelled, isTrue);- },- );-- test('a failed Windows tree kill is logged while the flash still holds its lease', () async {- final dir = Directory.systemTemp.createTempSync('flasher-cancel-');- addTearDown(() => dir.deleteSync(recursive: true));- final spawned = _FakeProcess(out: const [], code: 130, waitForKill: true);- final lines = <FlashLine>[];- var finished = false;- final flasher = Flasher(- windows: true,- cancelDirectory: dir.path,- killAfter: const Duration(milliseconds: 10),- killTree: (_) async => throw StateError('tree termination failed'),- startProcess: (_, {environment}) async => spawned,- );- final run = flasher.flash(onLine: lines.add).then((result) {- finished = true;- return result;- });- await Future<void>.delayed(Duration.zero);- try {- flasher.cancel();- await Future<void>.delayed(const Duration(milliseconds: 50));- final errors = lines.where((line) => line.kind == FlashLineKind.error);- expect(errors, hasLength(1));- expect(errors.single.text, contains('tree termination failed'));- expect(flasher.isRunning, isTrue);- expect(SerialPortLease.held, isTrue);- expect(finished, isFalse);- expect(spawned.signals, isEmpty);- } finally {- spawned.kill();- await run;- }- expect(SerialPortLease.held, isFalse);- });-- test(- 'a nonzero taskkill exit is logged and does not release a live flash',- () async {- final dir = Directory.systemTemp.createTempSync('flasher-cancel-');- addTearDown(() => dir.deleteSync(recursive: true));- final spawned = _FakeProcess(out: const [], code: 130, waitForKill: true);- final lines = <FlashLine>[];- String? executable;- List<String>? arguments;- var finished = false;- final flasher = Flasher(- windows: true,- cancelDirectory: dir.path,- killAfter: const Duration(milliseconds: 10),- runProcess: (command, args) async {- executable = command;- arguments = args;- return ProcessResult(7, 5, '', 'Access is denied.');- },- startProcess: (_, {environment}) async => spawned,- );- final run = flasher.flash(onLine: lines.add).then((result) {- finished = true;- return result;- });- await Future<void>.delayed(Duration.zero);- try {- flasher.cancel();- await Future<void>.delayed(const Duration(milliseconds: 50));- expect(executable, 'taskkill');- expect(arguments, ['/PID', '${spawned.pid}', '/T', '/F']);- final errors = lines.where((line) => line.kind == FlashLineKind.error);- expect(errors, hasLength(1));- expect(errors.single.text, contains('Access is denied.'));- expect(flasher.isRunning, isTrue);- expect(SerialPortLease.held, isTrue);- expect(finished, isFalse);- expect(spawned.signals, isEmpty);- } finally {- spawned.kill();- await run;- }- expect(SerialPortLease.held, isFalse);- },- );-- test(- 'the dialog names this computer on Windows and keeps this Mac elsewhere',- () {- expect(flashHostName(windows: true), 'this computer');- expect(flashHostName(windows: false), 'this Mac');- },- );-- test('a port stays one literal argv value', () async {- List<String>? seen;- final flasher = Flasher(- startProcess: (arguments, {environment}) async {- seen = arguments;- return _FakeProcess(out: const []);- },- );- await flasher.flash(port: "/dev/cu.o'dd");- expect(seen, ['flash', '--yes', '--port', "/dev/cu.o'dd"]);- });-}diff --git a/desktop/test/in_window_menu_bar_test.dart b/desktop/test/in_window_menu_bar_test.dartindex a52b92451..2bbd1b29d 100644--- a/desktop/test/in_window_menu_bar_test.dart+++ b/desktop/test/in_window_menu_bar_test.dart@@ -462,10 +462,6 @@ void main() {await tap(tester, 'menu-bar-harness');await tap(tester, 'menu-bar-check-for-updates');expect(appActions.last, 'checkForUpdates');-- await tap(tester, 'menu-bar-harness');- await tap(tester, 'menu-bar-flash-firmware');- expect(appActions.last, 'flashFirmware');});testWidgets('the File menu fires the native action strings', (tester) async {@@ -894,7 +890,6 @@ void main() {'menu-bar-settings Settings…','menu-bar-shortcuts Keyboard Shortcuts…','menu-bar-check-for-updates Check for Updates…',- 'menu-bar-flash-firmware Flash Firmware…','menu-bar-quit Quit Harness',]);expect(await rows('menu-bar-file'), [diff --git a/desktop/test/serial_port_lease_test.dart b/desktop/test/serial_port_lease_test.dartindex 171496fb5..62da84890 100644--- a/desktop/test/serial_port_lease_test.dart+++ b/desktop/test/serial_port_lease_test.dart@@ -1,4 +1,3 @@-import 'dart:async';import 'dart:io';import 'package:flutter_test/flutter_test.dart';@@ -69,37 +68,6 @@ void main() {},);- test('the lease is released even when the work throws', () async {- expect(SerialPortLease.held, isFalse);- await expectLater(- SerialPortLease.hold<void>(() async => throw StateError('flash died')),- throwsStateError,- );- // Leaving it held would switch daemon supervision off for the rest of the- // session — a worse fault than the one it prevents, and a silent one.- expect(SerialPortLease.held, isFalse);- });-- test('overlapping holders do not release each other', () async {- final outer = Completer<void>();- final inner = Completer<void>();- unawaited(SerialPortLease.hold(() => outer.future));- unawaited(SerialPortLease.hold(() => inner.future));- await Future<void>.delayed(Duration.zero);-- inner.complete();- await Future<void>.delayed(Duration.zero);- expect(- SerialPortLease.held,- isTrue,- reason: 'the outer one still holds it',- );-- outer.complete();- await Future<void>.delayed(Duration.zero);- expect(SerialPortLease.held, isFalse);- });-test('a flash started in a terminal also stops the daemon being restarted', () async {// The case that matters most for a device already in someone's hands: they run `harness flash`// themselves while the app is open, and the app's five-second supervisor takes the port back@@ -150,15 +118,23 @@ void main() {spawnCommand: () async => spawned = true,);- await SerialPortLease.hold(() async {- // Flashing stops the daemon first, so discovery finds nothing and the- // old code went straight on to start it again — taking back the port- // esptool was writing through.- final probe = await discovery.ensureRunning();- expect(probe.state, LocalCliProbeState.down);- expect(probe.endpoint, isNull);+ // A run-id lease of its own in the real flasher folder, so a flash the+ // machine may really be running keeps its shared flag untouched.+ final dir = Directory(SerialPortLease.flasherDirectory())+ ..createSync(recursive: true);+ final lease = File('${dir.path}/flashing.${'e' * 32}')+ ..writeAsStringSync('${DateTime.now().millisecondsSinceEpoch ~/ 1000}\n');+ addTearDown(() {+ if (lease.existsSync()) lease.deleteSync();});+ // Flashing stops the daemon first, so discovery finds nothing and the+ // old code went straight on to start it again — taking back the port+ // esptool was writing through.+ final probe = await discovery.ensureRunning();+ expect(probe.state, LocalCliProbeState.down);+ expect(probe.endpoint, isNull);+expect(spawned, isFalse);});}diff --git a/desktop/test/settings_review_render_test.dart b/desktop/test/settings_review_render_test.dartindex de2bca7fe..c5aeadc0b 100644--- a/desktop/test/settings_review_render_test.dart+++ b/desktop/test/settings_review_render_test.dart@@ -212,7 +212,7 @@ void main() {}if (section == SettingsSection.about) {await tester.ensureVisible(- find.byKey(const Key('settings-flash-firmware-button')),+ find.byKey(const Key('settings-check-updates-button')),);await tester.pumpAndSettle();debugDisableShadows = false;