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
Headless setup: factory reset, OpenCode alone after a phone's setup, Wi-Fi page that gives its tab back
bubu-dudu0e5d8d1846a4
diff --git a/os/network.py b/os/network.pyindex 354737e60..76f456d05 100644--- a/os/network.py+++ b/os/network.py@@ -343,12 +343,18 @@ class NetworkPage:value += keydef run(self):- if self.first_use and connected():+ online = connected()+ if self.first_use and online:return 0+ # Opened while offline (hn brings it forward when the network has been gone a while): done+ # once the network is back, however it came back — chosen here, by a phone through setup.py,+ # or a router back on. Left open, it held the first tab and OpenCode never opened there.+ # Opened while online, to change networks, it stays until closed.+ until_online = self.first_use or not onlineself.refresh()checked = time.monotonic()while True:- if self.first_use and time.monotonic() - checked >= 2:+ if until_online and time.monotonic() - checked >= 2:if connected():return 0checked = time.monotonic()diff --git a/os/onboarding.py b/os/onboarding.pyindex 622ce34ea..69ca0a39a 100644--- a/os/onboarding.py+++ b/os/onboarding.py@@ -5,6 +5,9 @@ from pathlib import Pathimport subprocessimport sys+# Written by setup.py when a phone signed this computer in (os/setup.py FROM_PHONE).+FROM_PHONE = Path('/var/lib/harness-os/set-up-from-phone')+def prepare():if Path('/etc/harness-live').is_file() or (Path.home() / '.local/state/harness-os/onboarded').is_file():@@ -24,8 +27,11 @@ def welcome():# Initial networking finished before hn launched. This pane is created only# after hn's shared account gate has opened.pane = os.environ.get('TMUX_PANE', '')+ # Set up from a phone (setup.py): OpenCode alone, without the two starter terminals; nobody+ # was at this screen to start with three panes.+ bare = ['bare'] if FROM_PHONE.is_file() else []try:- result = subprocess.run(['hn', 'os-action', 'ready', pane], check=False, timeout=15)+ result = subprocess.run(['hn', 'os-action', 'ready', pane, *bare], check=False, timeout=15)if result.returncode == 0:state = Path.home() / '.local/state/harness-os'state.mkdir(parents=True, exist_ok=True)diff --git a/os/root/etc/sudoers.d/20-harness-network b/os/root/etc/sudoers.d/20-harness-networkindex 573d83f88..b643fa922 100644--- a/os/root/etc/sudoers.d/20-harness-network+++ b/os/root/etc/sudoers.d/20-harness-network@@ -4,3 +4,5 @@# The daemon switching Wi-Fi for the person's phone (cli services/osDevice.ts): the Wi-Fi comes as JSON# on stdin to the fixed, root-owned setup helper, which goes back to the previous Wi-Fi when it fails.%wheel ALL=(root) NOPASSWD: /usr/bin/python3 /usr/lib/harness-os/setup.py join+# `harness factory-reset`: this computer as just flashed (the reset button's action), from a terminal.+%wheel ALL=(root) NOPASSWD: /usr/bin/python3 /usr/lib/harness-os/setup.py reset, /usr/bin/python3 /usr/lib/harness-os/setup.py reset --keep-wifidiff --git a/os/root/usr/bin/harness b/os/root/usr/bin/harnessindex 1cd5882bf..ce7bb80fd 100644--- a/os/root/usr/bin/harness+++ b/os/root/usr/bin/harness@@ -26,6 +26,13 @@ if [ "${1:-}" = rollback ]; thenshiftexec /usr/bin/python3 /usr/lib/harness-os/runtime_update.py rollback "$@"fi+if [ "${1:-}" = factory-reset ]; then+ # As just flashed: signed out, no harnesses, Wi-Fi forgotten (--keep-wifi keeps it), the setup+ # hotspot open for a phone. The same as the reset button. Not `harness reset`, the CLI's own.+ shift+ [ "$(id -u)" = 0 ] && exec /usr/bin/python3 /usr/lib/harness-os/setup.py reset "$@"+ exec sudo /usr/bin/python3 /usr/lib/harness-os/setup.py reset "$@"+fiif [ "${1:-}" = update ]; then# Everything Super+u updates, from a terminal: the OS package, hn, the CLI and its daemon.# The CLI's own self-update would only race the OS's activation (ADAPTER_UPDATE_DISABLE below).diff --git a/os/setup.py b/os/setup.pyindex 4843e61fa..d469149c3 100644--- a/os/setup.py+++ b/os/setup.py@@ -25,6 +25,7 @@ import jsonfrom pathlib import Pathimport pwdimport queue+import shutilimport socketimport subprocessimport sys@@ -37,6 +38,8 @@ RESULT = STATE / 'setup-result.json'NOW = Path('/run/harness-os/setup-now')# What the radio saw before hosting the hotspot, for the screen's Wi-Fi page (network.py SETUP_NETWORKS).SCREEN_NETWORKS = Path('/run/harness-os/setup-networks.json')+# Signed in from a phone: its first workspace is OpenCode alone, not with two terminals (onboarding.py).+FROM_PHONE = STATE / 'set-up-from-phone'HEADLESS = Path('/etc/harness-os/headless')DRM = Path('/sys/class/drm')USER = 'me'@@ -305,6 +308,19 @@ def forget(ssid):def sign_in(ticket):if signed_in():return True, ''+ # Before the sign-in, not after: the screen's hn opens its first workspace the moment the+ # account is there, and reads this to open OpenCode alone (onboarding.py).+ try:+ FROM_PHONE.touch()+ except OSError:+ pass+ ok, message = run_sign_in(ticket)+ if not ok:+ FROM_PHONE.unlink(missing_ok=True)+ return ok, message+++def run_sign_in(ticket):try:result = subprocess.run(['/usr/bin/runuser', '-u', USER, '--', '/usr/bin/harness', 'login', '--json','--ticket=' + ticket],@@ -608,10 +624,95 @@ def change(request):write_result(run=run, **result)+HN = '/usr/lib/harness/harness-tui'+RESET_UNIT = 'harness-factory-reset'+++def as_user(*command, timeout=30):+ """A command as the person, in their session: their hn, their daemon, their systemd units."""+ uid = pwd.getpwnam(USER).pw_uid+ runtime = f'/run/user/{uid}'+ try:+ return subprocess.run(['/usr/bin/runuser', '-u', USER, '--', *command], capture_output=True, text=True,+ timeout=timeout, env=dict(HOME=str(HOME), USER=USER, LOGNAME=USER,+ PATH='/usr/local/bin:/usr/bin:/bin', XDG_RUNTIME_DIR=runtime,+ DBUS_SESSION_BUS_ADDRESS=f'unix:path={runtime}/bus'))+ except (OSError, subprocess.TimeoutExpired):+ return None+++def wipe(folder, keep):+ """Everything in [folder] but the [keep] names; a kept name may be a folder wiped in turn."""+ for path in folder.iterdir() if folder.is_dir() else []:+ if path.name in keep:+ if isinstance(keep[path.name], dict):+ wipe(path, keep[path.name])+ continue+ if path.is_dir() and not path.is_symlink():+ shutil.rmtree(path, ignore_errors=True)+ else:+ path.unlink(missing_ok=True)+++def factory_reset(keep_wifi=False):+ """This computer as it was just flashed: no account, no harnesses, the first workspace still to come,+ and (unless [keep_wifi]) no Wi-Fi, so it opens its setup hotspot for a phone. It stays the same+ computer: its id and its device key are kept, as a new key for the same computer is refused by the+ account until the old one is removed. The engines' own sign-ins and ~/projects are the person's.+ For the reset button and `harness factory-reset`."""+ log('factory reset')+ # Its windows first, while still signed in: the account keeps the tabs (the desk, the same on+ # every computer), and one left there comes back at the next sign-in in the first workspace's place.+ windows = as_user(HN, 'list-windows', '-F', '#{window_index}')+ for index in sorted((int(n) for n in (windows.stdout.split() if windows else []) if n.isdigit()), reverse=True):+ as_user(HN, 'kill-window', '-t', f':{index}')+ as_user('/usr/bin/harness', 'logout', timeout=60)+ # Every harness and terminal: the daemon, then the tmux server its panes run in.+ as_user('systemctl', '--user', 'stop', 'harness-daemon', timeout=60)+ as_user('tmux', 'kill-server')+ harness = HOME / '.harness'+ wipe(harness, {'computer-id': True, 'cli': {'data': {'e2e': True}}})+ (HOME / '.local/state/harness-os/onboarded').unlink(missing_ok=True)+ for path in (RESULT, FROM_PHONE):+ path.unlink(missing_ok=True)+ as_user('systemctl', '--user', 'start', 'harness-daemon', timeout=60)+ # hn again from its sign-in page. Its server outlives the screen unit (KillMode=process).+ as_user(HN, 'kill-server')+ subprocess.run(['/usr/bin/pkill', '-u', USER, '-x', 'harness-tui'], capture_output=True)+ as_user('systemctl', '--user', 'restart', 'hn-screen', timeout=60)+ if not keep_wifi:+ for row in rows('-f', 'UUID,TYPE', 'connection', 'show'):+ if len(row) == 2 and row[1] == '802-11-wireless':+ nmcli('connection', 'delete', 'uuid', row[0])+ # The watcher opens the hotspot for a phone (headless or not: asked for).+ NOW.parent.mkdir(parents=True, exist_ok=True)+ NOW.touch()+ log('factory reset done')++def main():parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])- parser.add_argument('command', nargs='?', choices=['watch', 'now', 'name', 'join'], default='watch')+ parser.add_argument('command', nargs='?', choices=['watch', 'now', 'name', 'join', 'reset'], default='watch')+ parser.add_argument('--keep-wifi', action='store_true', help='reset: keep the saved Wi-Fi')+ parser.add_argument('--here', action='store_true', help=argparse.SUPPRESS)arguments = parser.parse_args()+ if arguments.command == 'reset':+ if arguments.here:+ factory_reset(keep_wifi=arguments.keep_wifi)+ return+ # In a unit of its own: the computer leaves its Wi-Fi, and whatever asked (an SSH session, the+ # button's handler) may go with it before the reset is done. `journalctl -u harness-factory-reset`.+ command = ['/usr/bin/systemd-run', f'--unit={RESET_UNIT}', '--collect', '--quiet',+ '/usr/bin/python3', str(Path(__file__).resolve()), 'reset', '--here']+ if arguments.keep_wifi:+ command.append('--keep-wifi')+ started = subprocess.run(command, capture_output=True, text=True)+ if started.returncode:+ raise SystemExit('Could not start the reset: ' + (started.stderr.strip() or 'systemd-run failed'))+ print('Resetting this computer. It signs out, closes every harness'+ + ('' if arguments.keep_wifi else ', forgets its Wi-Fi')+ + ' and opens its setup hotspot for a phone in about a minute.')+ returnif arguments.command == 'join':# From the daemon, through sudo: the Wi-Fi as JSON on stdin, never in argv.try:diff --git a/os/tests/test_network.py b/os/tests/test_network.pyindex f59438ff0..94c400338 100644--- a/os/tests/test_network.py+++ b/os/tests/test_network.py@@ -157,6 +157,24 @@ class Network(unittest.TestCase):self.enterContext(patch.object(network, 'nmcli', return_value=result()))return screen, network.NetworkPage(screen, first_use=first_use)+ def test_a_page_opened_offline_closes_once_the_network_is_back(self):+ # hn brought it forward during an outage (a phone's setup hotspot): the network came back+ # some other way, and the page gives its tab back.+ screen, page = self.page([], first_use=False)+ clock = iter(range(0, 1000, 3))+ with patch.object(network, 'connected', side_effect=[False, False, True]), \+ patch.object(network.time, 'monotonic', side_effect=lambda: next(clock)), \+ patch.object(screen, 'get_wch', side_effect=curses.error):+ self.assertEqual(page.run(), 0)++ def test_a_page_opened_online_stays_to_change_networks(self):+ screen, page = self.page(['\x1b'], first_use=False)+ clock = iter(range(0, 1000, 3))+ with patch.object(network, 'connected', return_value=True) as online, \+ patch.object(network.time, 'monotonic', side_effect=lambda: next(clock)):+ self.assertEqual(page.run(), 1)+ self.assertEqual(online.call_count, 1)+def test_first_page_keeps_wifi_above_wired_and_advances_only_after_connection(self):screen, page = self.page(['\x1b', '\x03', 'r', '\n'])with patch.object(network, 'connect', return_value=True):diff --git a/os/tests/test_onboarding.py b/os/tests/test_onboarding.pyindex e09501086..494a454a1 100644--- a/os/tests/test_onboarding.py+++ b/os/tests/test_onboarding.py@@ -32,6 +32,19 @@ class Onboarding(unittest.TestCase):execute.assert_called_once_with('/usr/bin/hn-os', ['hn-os', 'try'])self.assertTrue((Path(temp) / '.local/state/harness-os/onboarded').exists())+ def test_a_computer_set_up_from_a_phone_asks_for_opencode_alone(self):+ with tempfile.TemporaryDirectory() as temp:+ marker = Path(temp) / 'set-up-from-phone'+ marker.touch()+ with patch.object(onboarding, 'FROM_PHONE', marker), \+ patch.object(onboarding.Path, 'home', return_value=Path(temp)), \+ patch.object(onboarding.subprocess, 'run', return_value=result()) as command, \+ patch.object(onboarding.os, 'execv') as execute, \+ patch.dict(os.environ, {'TMUX_PANE': '%4'}):+ onboarding.welcome()+ self.assertEqual(command.call_args_list[0].args[0], ['hn', 'os-action', 'ready', '%4', 'bare'])+ execute.assert_called_once_with('/usr/bin/hn-os', ['hn-os', 'try'])+def test_usb_never_opens_networking_or_an_agent(self):with patch.object(onboarding.Path, 'is_file', return_value=True), \patch.object(onboarding.subprocess, 'run') as command, \diff --git a/os/tests/test_setup.py b/os/tests/test_setup.pyindex c8d628630..2c076b3b9 100644--- a/os/tests/test_setup.py+++ b/os/tests/test_setup.py@@ -200,6 +200,80 @@ class Change(unittest.TestCase):self.assertEqual(setup.read_result()['error'], 'BAD_REQUEST')+class FromPhone(unittest.TestCase):+ def test_the_mark_is_there_before_the_sign_in_and_stays_only_when_it_worked(self):+ with tempfile.TemporaryDirectory() as folder:+ marker = Path(folder) / 'set-up-from-phone'+ with patch.object(setup, 'FROM_PHONE', marker), patch.object(setup, 'signed_in', return_value=False):+ with patch.object(setup, 'run_sign_in', side_effect=lambda t: (marker.exists(), '')):+ self.assertEqual(setup.sign_in('t'), (True, ''))+ self.assertTrue(marker.exists())+ marker.unlink()+ with patch.object(setup, 'run_sign_in', return_value=(False, 'used')):+ self.assertEqual(setup.sign_in('t'), (False, 'used'))+ self.assertFalse(marker.exists())+++class FactoryReset(unittest.TestCase):+ def home(self, folder):+ home = Path(folder)+ for path in ['.harness/computer-id', '.harness/cli/data/e2e/identity.json', '.harness/cli/data/registry.json',+ '.harness/auth/session.json', '.harness/tui/state.json', '.local/state/harness-os/onboarded',+ '.claude/settings.json', 'projects/AGENTS.md']:+ (home / path).parent.mkdir(parents=True, exist_ok=True)+ (home / path).write_text('x')+ return home++ def run_reset(self, home, keep_wifi):+ users, wifi = [], []+ state = home / 'state'+ state.mkdir()+ (state / 'r.json').write_text('{}')+ (state / 'from-phone').touch()+ with patch.object(setup, 'HOME', home), patch.object(setup, 'RESULT', state / 'r.json'), \+ patch.object(setup, 'FROM_PHONE', state / 'from-phone'), patch.object(setup, 'NOW', state / 'now'), \+ patch.object(setup, 'as_user', side_effect=lambda *c, timeout=30: users.append(c) or result(output='2\n1\n')), \+ patch.object(setup.subprocess, 'run', return_value=result()), \+ patch.object(setup, 'rows', return_value=[['u-home', '802-11-wireless'], ['u-lo', 'loopback']]), \+ patch.object(setup, 'nmcli', side_effect=lambda *a, **k: wifi.append(a) or result()):+ setup.factory_reset(keep_wifi=keep_wifi)+ return users, wifi, state++ def test_it_is_as_just_flashed_but_the_same_computer(self):+ with tempfile.TemporaryDirectory() as folder:+ home = self.home(folder)+ users, wifi, state = self.run_reset(home, keep_wifi=False)+ left = sorted(str(p.relative_to(home)) for p in home.rglob('*') if p.is_file())+ self.assertIn('.harness/computer-id', left)+ self.assertIn('.harness/cli/data/e2e/identity.json', left)+ for gone in ['.harness/cli/data/registry.json', '.harness/auth/session.json', '.harness/tui/state.json',+ '.local/state/harness-os/onboarded', 'state/r.json', 'state/from-phone']:+ self.assertNotIn(gone, left)+ # The person's own: the engines' sign-ins and their projects.+ self.assertIn('.claude/settings.json', left)+ self.assertIn('projects/AGENTS.md', left)+ # The account's tabs closed while still signed in, highest first, then the sign-out.+ closes = [c for c in users if 'kill-window' in c]+ self.assertEqual([c[-1] for c in closes], [':2', ':1'])+ self.assertLess(users.index(closes[-1]), next(i for i, c in enumerate(users) if 'logout' in c))+ self.assertEqual(wifi, [('connection', 'delete', 'uuid', 'u-home')])+ self.assertTrue((state / 'now').exists())++ def test_keep_wifi_keeps_it(self):+ with tempfile.TemporaryDirectory() as folder:+ _, wifi, _ = self.run_reset(self.home(folder), keep_wifi=True)+ self.assertEqual(wifi, [])++ def test_the_command_runs_it_in_a_unit_of_its_own(self):+ with patch.object(setup.subprocess, 'run', return_value=result()) as run, \+ patch.object(setup.sys, 'argv', ['setup.py', 'reset', '--keep-wifi']), \+ patch('builtins.print'):+ setup.main()+ command = run.call_args.args[0]+ self.assertEqual(command[:2], ['/usr/bin/systemd-run', '--unit=harness-factory-reset'])+ self.assertEqual(command[-3:], ['reset', '--here', '--keep-wifi'])++class Screen(unittest.TestCase):def test_a_wifi_chosen_on_the_screen_ends_setup_and_its_list_goes(self):class Server:diff --git a/tui/src/app.rs b/tui/src/app.rsindex ee6589947..bb4a67516 100644--- a/tui/src/app.rs+++ b/tui/src/app.rs@@ -5747,6 +5747,8 @@ impl App {// Fill its original tab instead of whichever tab is now active.let tab = self.tab().id.clone();crate::input::new_shell_from(self, None, Placement::Fill(tab), None, Some("/usr/bin/hn-os welcome".into()));+ } else if (self.os_live || self.os_first_use) && crate::os_welcome::welcome_waits_on_wifi(self) {+ // Asked again every tick until the Wi-Fi form gives the tab back.} else { self.shell_asked = true; }return;}@@ -6635,6 +6637,27 @@ mod scroll_settle_tests {mod recovery_tests {use super::*;+ #[tokio::test]+ async fn os_first_workspace_waits_while_the_wifi_form_holds_the_tabs() {+ let (sink, _) = tokio::sync::mpsc::unbounded_channel();+ let mut app = App::new(19789, sink, (80, 24));+ app.handed_over = true;+ app.os_session = true;+ app.os_first_use = true;+ app.desk_answered = true;+ app.new_tab();+ app.open_agent(crate::local::MACHINE, "wifi", Placement::Auto(None));+ let form = app.focused().unwrap();+ app.os_welcome.wifi_pane = Some(form);+ app.maybe_start_shell();+ assert!(!app.shell_asked, "the welcome must not give up while the Wi-Fi form holds the tabs");+ app.close_pane(form);+ app.maybe_start_shell();+ // No local daemon in this test: the welcome is still to come rather than given up on.+ assert!(!app.shell_asked);+ assert_eq!(app.tabs.len(), 1);+ }+#[tokio::test]async fn os_starts_at_the_agent_launcher_without_creating_an_unused_shell() {let (sink, _) = tokio::sync::mpsc::unbounded_channel();diff --git a/tui/src/os_welcome.rs b/tui/src/os_welcome.rsindex 270ed92de..3e5e68f3b 100644--- a/tui/src/os_welcome.rs+++ b/tui/src/os_welcome.rs@@ -14,7 +14,7 @@ pub struct State {starter_tab: Option<String>,welcome_panes: Vec<u64>,install_pane: Option<u64>,- wifi_pane: Option<u64>,+ pub(crate) wifi_pane: Option<u64>,install_tab: Option<String>,wifi_tab: Option<String>,/// The Wi-Fi form was opened for this spell offline; closed, it is not forced on again until the@@ -56,6 +56,15 @@ fn read(path: &str) -> String { std::fs::read_to_string(path).unwrap_or_default(/// Never in the middle of a sign-in, and never before this computer's daemon can run the form.pub fn offer_wifi(app: &mut App, online: bool, now: std::time::Instant) {if online {+ // The form this spell offline brought forward: the network is back, however it came back+ // (chosen there, by a phone through the setup hotspot, a router back on). It closes itself,+ // but one opened before a sign-in belongs to the daemon from before it, which no longer+ // tells its end: left, it would hold its tab and keep the first workspace from opening.+ if app.os_welcome.offline_offered && app.tabs.len() > 1 {+ if let Some(id) = app.os_welcome.wifi_pane.filter(|id| app.tabs.iter().any(|tab| tab.panes().contains(id))) {+ app.close_pane(id);+ }+ }app.os_welcome.offline_offered = false;app.os_welcome.offline_since = None;return@@ -72,6 +81,15 @@ pub fn offer_wifi(app: &mut App, online: bool, now: std::time::Instant) {local_dialog(app, "Wi-Fi", "/usr/bin/hn-os wifi", false);}+/// The first workspace is still to come, and all that holds the first tab is the Wi-Fi form, brought+/// forward while the network was gone (a phone's setup hotspot): the form closes itself once the+/// network is back, and the welcome then fills the tab it leaves (`App::maybe_start_shell`).+pub fn welcome_waits_on_wifi(app: &App) -> bool {+ // The form opens in a tab of its own (local_dialog), beside the empty one the welcome fills.+ app.os_welcome.wifi_pane.is_some_and(|id| app.tabs.iter().any(|tab| tab.panes() == [id])+ && app.tabs.iter().all(|tab| tab.root.is_none() || tab.panes() == [id]))+}+/// The Wi-Fi form is already somewhere in the workspace: offering it again would only steal focus.fn wifi_open(app: &App) -> bool {app.os_welcome.wifi_pane.is_some_and(|id| app.panes.get(&id).is_some_and(|pane| pane.dead.is_none()))@@ -191,7 +209,10 @@ pub fn command(app: &mut App, args: &[String]) {let Some(pane) = pane else { return app.error("That pane is not the welcome on this computer.") };if app.os_welcome.guide_pane == Some(pane) { return }app.os_welcome.guide_pane = Some(pane);- if app.size.0 >= 80 && app.size.1 >= 18 {+ // `bare`: a computer set up from a phone (os/setup.py, no one at its screen) opens OpenCode+ // alone, without the two starter terminals beside it.+ let bare = args.get(2).map(String::as_str) == Some("bare");+ if !bare && app.size.0 >= 80 && app.size.1 >= 18 {if let Some(tab) = app.tabs.iter().find(|tab| tab.panes() == [pane]) {app.os_welcome.starter_tab = Some(tab.id.clone());split_starter(app, pane, Dir::Horizontal, "/usr/bin/hn-os starter upper");@@ -487,6 +508,63 @@ mod tests {assert!(crate::commands::is_command_name("os-action"));}+ #[tokio::test]+ async fn the_wifi_form_brought_forward_offline_goes_when_the_network_is_back() {+ use std::time::Instant;+ for (offered, closes) in [(true, true), (false, false)] {+ let mut app = fixture(120, 40);+ app.new_tab();+ app.open_agent(crate::local::MACHINE, "wifi", Placement::Auto(None));+ let form = app.focused().unwrap();+ app.os_welcome.wifi_pane = Some(form);+ // Opened by hand while online (Super+w) is the person's: it stays.+ app.os_welcome.offline_offered = offered;+ offer_wifi(&mut app, true, Instant::now());+ assert_eq!(!app.panes.contains_key(&form), closes, "offered offline: {offered}");+ assert_eq!(app.tabs.len(), if closes { 1 } else { 2 });+ }+ }++ #[tokio::test]+ async fn the_first_workspace_waits_for_the_wifi_form_to_give_its_tab_back() {+ let mut app = fixture(120, 40);+ // The form, brought forward in a tab of its own beside the empty first one.+ app.new_tab();+ app.open_agent(crate::local::MACHINE, "wifi", Placement::Auto(None));+ let form = app.focused().unwrap();+ app.os_welcome.wifi_pane = Some(form);+ assert_eq!(app.tabs.len(), 2);+ assert!(welcome_waits_on_wifi(&app));+ // Back online: the form closes, its tab goes, and the first tab is the welcome's again.+ app.close_pane(form);+ assert_eq!(app.tabs.len(), 1);+ assert!(app.tabs[0].root.is_none());+ assert!(!welcome_waits_on_wifi(&app));+ // Other work beside the form: that is a workspace already, and no welcome comes.+ let mut busy = fixture(120, 40);+ busy.open_agent(crate::local::MACHINE, "work", Placement::Auto(None));+ busy.new_tab();+ busy.open_agent(crate::local::MACHINE, "wifi", Placement::Auto(None));+ busy.os_welcome.wifi_pane = busy.focused();+ assert!(!welcome_waits_on_wifi(&busy));+ }++ #[tokio::test]+ async fn a_computer_set_up_from_a_phone_opens_without_the_starter_terminals() {+ for (bare, starters) in [(false, true), (true, false)] {+ let mut app = fixture(120, 40);+ app.open_agent(crate::local::MACHINE, "welcome", Placement::Auto(None));+ let pane = app.focused().unwrap();+ app.panes.get_mut(&pane).unwrap().start_command = Some("/usr/bin/hn-os welcome".into());+ shell_created(&mut app, pane);+ let mut args = vec!["ready".to_string(), crate::pane::tag(pane)];+ if bare { args.push("bare".into()); }+ command(&mut app, &args);+ assert_eq!(app.os_welcome.guide_pane, Some(pane));+ assert_eq!(app.os_welcome.starter_tab.is_some(), starters, "bare: {bare}");+ }+ }+#[tokio::test]async fn readiness_maps_the_backend_pane_instead_of_assuming_the_same_number() {let mut app = fixture(120, 40);