feat(nix): a crashed daemon leaves nothing hidden, as a shared scenario

Platform.crash kills the daemon abruptly. lifecycle_hidden.crash turns a
monocle on, crashes, starts the daemon again, and checks that it manages
every window, that none is left out of sight, and that a monocle works
again. The KDE extra parking keeps the stale parking desktop checks.
This commit is contained in:
LGUG2Z committed 2026-10-30 12:53:28 -07:00
1 parent cb134e7908
commit 86cf814f92
9 files changed
+109 -13

No files matched your search

+1 -1
View File
@@ -94,7 +94,7 @@ make. They are gone; what only KDE can read stayed, as `kde_core` steps after th
| 8, close, the others share the screen, the daemon manages the rest | shared `closing` |
| 8, KWin carried out every command | extra `bridge_did_everything` |
| 9, a clean stop undoes what a monocle did | extra `parking` (opens two windows of its own) |
| 10, a crash with a monocle on leaves nothing stuck | extra `parking` |
| 10, a crash with a monocle on leaves nothing stuck | shared `lifecycle_hidden.crash` (every window is managed and in view after the restart, and a monocle works again); extra `parking` keeps the KDE half: the stale parking desktop is there after the kill and the next start removes it |
| 11, KWin restarts under the daemon | extra `kwin_restart` (the `kwin-restart` suite also covers it) |
| 13, `komorebic stop`: the socket, the script, the window stays | extra `stopped` |
@@ -109,6 +109,12 @@ class Platform(Protocol):
"""Starts the daemon from a clean state and waits until it answers."""
...
def crash(self) -> None:
"""Kills the daemon abruptly, as a crash does, and returns when it is gone. Nothing of
what it had set up is put back: a window it hid is as it left it, until a daemon starts
again and finds it."""
...
def restart_with(self, config: dict[str, Any]) -> None:
"""Stops the daemon if it runs, and starts it from a clean state with `config` as its
`komorebi.json`, and waits until it answers.
@@ -48,3 +48,66 @@ def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
"... and not on each other",
not any(a.overlaps(b) for i, a in enumerate(frames) for b in frames[i + 1 :]),
)
def crash(platform: Platform, checks: Checks, clients: list[Client]) -> None:
"""Turns a monocle on, which puts the other windows away, kills the daemon, and starts it
again: nothing is left out of sight for the new daemon to find, and it manages every window.
`clients` are two tiled windows or more of the first workspace, each in a container of its own.
The monocle is off at the end.
"""
target, other = clients[-1], clients[0]
def in_front() -> None:
# a window that already has the focus gives the daemon no event: another one first
platform.activate(other)
platform.activate(target)
platform.wait_for(lambda: focus_agrees(platform, clients, target.title))
def only_target_in_view() -> bool:
return all(platform.hidden(c) for c in clients if c != target) and not platform.hidden(
target
)
in_front()
platform.komorebic("toggle-monocle")
checks.check(
"with a monocle on, the other windows are out of sight",
platform.wait_for(only_target_in_view, timeout=20),
)
platform.crash()
checks.check(
"the killed daemon no longer answers",
platform.wait_for(lambda: platform.komorebic_status("state")[0] != 0, timeout=20),
)
platform.start_komorebi()
checks.check(
"the next daemon manages every window",
platform.wait_for(lambda: platform.state().managed() >= len(clients), timeout=30),
)
checks.check(
"... and none is left out of sight",
platform.wait_for(lambda: not any(platform.hidden(c) for c in clients), timeout=20),
)
area = platform.work_area()
frames = [w.frame for c in clients if (w := platform.os_window(c)) is not None]
checks.check(
"... inside the work area and not on each other",
len(frames) == len(clients)
and all(f.inside(area) for f in frames)
and not any(a.overlaps(b) for i, a in enumerate(frames) for b in frames[i + 1 :]),
)
in_front()
platform.komorebic("toggle-monocle")
checks.check(
"after a crash and a restart a monocle still puts the other windows away",
platform.wait_for(only_target_in_view, timeout=20),
)
platform.komorebic("toggle-monocle")
checks.check(
"... and turned off, nothing is out of sight",
platform.wait_for(lambda: not any(platform.hidden(c) for c in clients), timeout=20),
)
@@ -71,6 +71,9 @@ class KdePlatform:
tail = "\n".join(self.kde.komorebi_log().splitlines()[-30:])
raise AssertionError(f"the daemon did not answer komorebic; its log ends:\n{tail}")
def crash(self) -> None:
self.kde.kill_komorebi()
def restart_with(self, config: dict[str, Any]) -> None:
if self.kde.komorebi_running():
self.kde.komorebic("stop")
@@ -240,18 +240,6 @@ def parking(platform: KdePlatform, checks: Checks, clients: list[Client]) -> Non
"and brought the parked window back",
kde.wait_for(lambda: _on_a_workspace_desktop(platform, two)),
)
checks.check("it manages the two windows again", kde.wait_for(lambda: _managed(platform, two)))
_focus(platform, two[1], two[0])
kde.komorebic("toggle-monocle")
checks.check(
"after a crash and a restart a monocle still hides the other window",
kde.wait_for(lambda: len(_parked(platform, two)) == 1),
)
kde.komorebic("toggle-monocle")
checks.check(
"and turned off, nothing is out of sight",
kde.wait_for(lambda: _parked(platform, two) == []),
)
for client in two:
platform.close(client)
+11
View File
@@ -93,6 +93,7 @@ class FakePlatform:
resizable: bool = True,
follows_modes: bool = True,
keeps_fullscreen: bool = True,
leaves_hidden_on_crash: bool = False,
ignores_commands_when_maximized: bool = True,
) -> None:
self.panel = panel
@@ -103,6 +104,9 @@ class FakePlatform:
self.second = second
"""The rectangle of the second display, when it is not one of the first's size."""
self.keeps_fullscreen = keeps_fullscreen
self.leaves_hidden_on_crash = leaves_hidden_on_crash
self.stuck: set[str] = set()
"""The windows a daemon that crashed left out of sight, which no daemon found again."""
self.ignores_commands_when_maximized = ignores_commands_when_maximized
self.fullscreened: str | None = None
self.max_home: tuple[int, int] | None = None
@@ -194,6 +198,11 @@ class FakePlatform:
a = self.tiled_area
return [Rect(i * a.w // 3, 0, a.w // 3, a.h) for i in range(3)]
def crash(self) -> None:
if self.leaves_hidden_on_crash:
self.stuck = {t for stack in self.containers for t in stack if self.hidden(Client(t))}
self.running = False
def has(self, feature: str) -> bool:
return feature == "lock" or (feature == "pointer" and self.has_pointer)
@@ -474,6 +483,8 @@ class FakePlatform:
return self._find(title)[1]
def hidden(self, client: Client) -> bool:
if client.title in self.stuck:
return True
if client.title in self.floats or client.title in self.minimized:
return False
if client.title in self.unmanaged:
+20
View File
@@ -9,6 +9,7 @@ from komorebi_vm.core.scenarios import (
fullscreen,
handover,
hotplug,
lifecycle_hidden,
maximizing,
monocle,
placement,
@@ -312,3 +313,22 @@ def test_a_daemon_that_obeys_commands_when_maximized_fails_user_maximize() -> No
platform.activate(clients[-1])
maximizing.user(platform, checks, clients)
assert any("what is asked of the layout does nothing" in f for f in checks.failures)
def test_a_daemon_that_leaves_nothing_hidden_when_it_crashes_passes() -> None:
platform = FakePlatform()
checks = Checks()
clients = opened(platform, checks)
base = checks.passed
lifecycle_hidden.crash(platform, checks, clients)
assert checks.failed == 0, checks.failures
assert checks.passed - base == 7
assert platform.monocle is None
def test_a_crash_that_leaves_a_window_hidden_fails() -> None:
platform = FakePlatform(leaves_hidden_on_crash=True)
checks = Checks()
clients = opened(platform, checks)
lifecycle_hidden.crash(platform, checks, clients)
assert any("none is left out of sight" in f for f in checks.failures), checks.failures
+3
View File
@@ -79,6 +79,9 @@ class FakePlatform:
def restart_with(self, config: dict) -> None:
pass
def crash(self) -> None:
pass
def komorebic(self, *args: str) -> str:
return ""
+2
View File
@@ -168,6 +168,8 @@ run_suite(
lifecycle_hidden.run, platform, checks, [Client("afterwards"), Client("beside")]
),
platform_only("kde", kde_core.start, platform, checks, []),
shared(lifecycle_hidden.crash, platform, checks, [Client("afterwards"), Client("beside")]),
platform_only("kde", kde_core.start, platform, checks, []),
)
platform.close(Client("after-the-restart"))
platform.close(Client("beside"))