feat(nix): the pausing scenario

A window that opens while the daemon is paused is not managed; after
toggle-pause again the next one is, and every window is where the
layout says. core-e2e passes 248 checks on KDE.
This commit is contained in:
LGUG2Z committed 2026-10-30 12:03:00 -07:00
1 parent 0d8f073dc8
commit 6e111411e7
4 files changed
+69

No files matched your search

@@ -0,0 +1,39 @@
"""A paused daemon leaves new windows alone, and an unpaused one takes them up."""
from komorebi_vm.core.checks import Checks
from komorebi_vm.core.platform import Client, Platform
from komorebi_vm.core.scenarios.layouts import tiled
# how long a daemon that is paused has to leave a window alone for it to count
QUIET = 3
def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
"""Pauses the daemon, opens a window, unpauses it and opens another, with `clients` tiled
on the first workspace. Closes both."""
managed = platform.state().managed()
platform.komorebic("toggle-pause")
paused = platform.spawn("while-paused")
checks.check(
"a window that opens while the daemon is paused is not managed",
not platform.wait_for(lambda: platform.state().managed() > managed, timeout=QUIET),
)
platform.komorebic("toggle-pause")
after = platform.spawn("after-the-pause")
checks.check(
"after 'toggle-pause' again the next window is managed",
platform.wait_for(lambda: platform.state().managed() > managed, timeout=20),
)
checks.check(
"... and every window it had is still tiled where the layout says",
platform.wait_for(lambda: tiled(platform, [*clients, after]), timeout=20),
)
platform.close(paused)
platform.close(after)
checks.check(
"the two windows are closed and the daemon has the ones it had",
platform.wait_for(lambda: platform.state().managed() == managed, timeout=20),
)
+6
View File
@@ -80,6 +80,7 @@ class FakePlatform:
self.display_of: dict[str, int] = {}
self.forgets_displays = False
self.floats: list[str] = []
self.paused = False
self.flipped = False
self.last = 0
self.maximized: str | None = None
@@ -143,6 +144,9 @@ class FakePlatform:
return [stack[0] for stack in self.containers]
def spawn(self, title: str) -> Client:
if self.paused:
self.unmanaged.append(title)
return Client(title)
if title in self.ignored:
self.unmanaged.append(title)
elif title in self.initial_rules:
@@ -421,6 +425,8 @@ class FakePlatform:
case ("flip-layout", "horizontal"):
self.flipped = not self.flipped
self._relayout()
case ("toggle-pause",):
self.paused = not self.paused
case ("toggle-float",):
if self.floats:
self.containers.insert(self.focus, [self.floats.pop()])
@@ -17,6 +17,7 @@ from komorebi_vm.core.scenarios import (
monocle,
moving,
padding,
pausing,
placement,
promoting,
resize,
@@ -339,6 +340,27 @@ def test_a_daemon_that_does_not_flip_fails_flipping() -> None:
assert checks.failed > 0
def test_a_daemon_that_is_right_passes_pausing() -> None:
platform = FakePlatform()
checks = Checks()
clients = opened(platform, checks)
pausing.run(platform, checks, clients)
assert checks.failed == 0, checks.failures
assert checks.passed > 3
def test_a_daemon_that_manages_while_paused_fails_pausing() -> None:
class Stubborn(FakePlatform):
def komorebic(self, *args: str) -> str:
return "" if args == ("toggle-pause",) else super().komorebic(*args)
platform = Stubborn()
checks = Checks()
clients = opened(platform, checks)
pausing.run(platform, checks, clients)
assert checks.failed > 0
def test_a_command_the_port_lacks_is_skipped_by_name() -> None:
platform = FakePlatform()
checks = Checks()
+2
View File
@@ -27,6 +27,7 @@ from komorebi_vm.core.scenarios import (
monocle,
moving,
padding,
pausing,
placement,
promoting,
resize_commands,
@@ -464,6 +465,7 @@ maximizing.run(platform, checks, neutral)
resize_commands.run(platform, checks, neutral)
promoting.run(platform, checks, neutral)
flipping.run(platform, checks, neutral)
pausing.run(platform, checks, neutral)
padding.run(platform, checks, neutral)
monocle.run(platform, checks, neutral)
workspace_moves.run(platform, checks, neutral)