Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Harness OS: an update no longer stops the screen it is showing

bubu-dudua9bb8e64cfd8
diff --git a/os/root/usr/lib/systemd/user/harness-os.target b/os/root/usr/lib/systemd/user/harness-os.target
index 10ecf5b21..a8c0d0212 100644
--- a/os/root/usr/lib/systemd/user/harness-os.target
+++ b/os/root/usr/lib/systemd/user/harness-os.target
@@ -1,6 +1,12 @@
[Unit]
Description=The hn screen
-BindsTo=graphical-session.target
+# Requires + PartOf, not BindsTo: starting the screen starts the graphical session, and stopping
+# that session stops the screen. BindsTo also stops the screen whenever the session is merely
+# inactive, and an update from preview 14 (whose session never started it) reloaded systemd into
+# exactly that: "Stopped target The hn screen", hn-screen and harness-idle stopped mid-update, a
+# black screen with the Restart button out of sight.
+Requires=graphical-session.target
+PartOf=graphical-session.target
# Portals can keep the standard target needed after our screen stops.
PropagatesStopTo=graphical-session.target
Wants=hn-screen.service harness-install.service harness-idle.service harness-update.timer harness-gpu-check.timer
diff --git a/os/tests/test_graphical_session.py b/os/tests/test_graphical_session.py
index a551c0b9d..c0bd4b149 100644
--- a/os/tests/test_graphical_session.py
+++ b/os/tests/test_graphical_session.py
@@ -46,6 +46,15 @@ class GraphicalSession(unittest.TestCase):
self.assertTrue(events.exists(), f'{result.returncode}: {result.stderr}')
return result, events.read_text().splitlines()
+ def test_an_update_reload_cannot_stop_the_running_screen(self):
+ # BindsTo stops the screen whenever graphical-session.target is inactive, which a session
+ # from before that target (preview 14) is when an update reloads systemd.
+ target = (ROOT / 'os/root/usr/lib/systemd/user/harness-os.target').read_text().splitlines()
+ self.assertFalse([line for line in target if line.startswith('BindsTo=')])
+ for line in ['Requires=graphical-session.target', 'PartOf=graphical-session.target',
+ 'PropagatesStopTo=graphical-session.target']:
+ self.assertIn(line, target)
+
def test_success_stops_graphical_services_without_stopping_agents(self):
result, events = self.exercise(0)
self.assertEqual(result.returncode, 0, result.stderr)
diff --git a/os/tests/update_guest.py b/os/tests/update_guest.py
index 6d9a90ca5..1fe484600 100644
--- a/os/tests/update_guest.py
+++ b/os/tests/update_guest.py
@@ -102,8 +102,11 @@ while True:
receipt['apply_seconds'] = round(time.monotonic() - started, 3)
assert version() == 'harness-os ' + manifest['package']['version']
assert json.loads(Path('/usr/share/harness-os/runtime.json').read_text()) == manifest['runtime']
+ # The screen showing "Restart when ready" is still there after the package's systemd reload,
+ # before anything restarts it: 0.1.1's BindsTo stopped it mid-update from preview 14.
+ run('systemctl', '--user', 'is-active', '--quiet', 'harness-os.target', 'hn-screen')
alive()
- receipt['checks'].append('Package and cached dependencies installed offline and verified without restarting the existing terminal process')
+ receipt['checks'].append('Package and cached dependencies installed offline and verified without restarting the existing terminal process or stopping the screen')
run('sudo', 'harness', 'upgrade', str(bundle))
alive()
receipt['checks'].append('Repeated apply recognizes the installed build without another transaction')