fix(tauri): make game-directory changes observable

Game-directory selection could reach update_game_directory and then fail before
peer startup, while the frontend only logged the rejected invoke. Preserve the
last accepted root until peer acknowledgement, surface backend rejection in
the settings and main-window UI, and avoid holding the published control lock
across runtime replies. Startup preflight remains fail-closed; synchronous
setup stays lexically owned through scoped_blocking so cancellation cannot
strand a partially published runtime.

Add peer-cli scenario S50 to verify invalid changes preserve the existing
library and valid changes acknowledge and refresh the library in both
directions. Modernize the fixed-size hex decoders to satisfy the current
workspace Clippy lint without changing their behavior.

Test Plan:
- `just fmt` -- passed
- `just clippy` -- passed
- `just test` -- passed
- `just frontend-test` -- passed
- `deno task build` -- passed
- `just peer-cli-tests S50` -- passed
- `just build` -- passed
- `git diff --cached --check` -- passed
This commit is contained in:
ddidderr committed 2026-08-25 00:10:01 +02:00
1 parent 3bbfe919d2
commit a49b51d3d8
9 files changed
+118 -8

No files matched your search

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Run the peer-cli scenarios S1-S49 through Docker."""
"""Run the peer-cli scenarios S1-S50 through Docker."""
from __future__ import annotations
@@ -425,6 +425,7 @@ class Runner:
("S47", self.s47_multi_archive_streams_in_sorted_order),
("S48", self.s48_call_to_play_replication_and_late_join),
("S49", self.s49_terminal_call_to_play_late_join),
("S50", self.s50_game_directory_acknowledgement),
]
for scenario_id, scenario in scenarios:
@@ -2983,6 +2984,61 @@ class Runner:
"departure removed the complete call despite the live participant author"
)
def s50_game_directory_acknowledgement(self) -> str:
initial_games_dir = self.fixture_root / "s50-initial"
copy_game("ggoo", initial_games_dir)
peer = self.peer("s50-client", games_dir=initial_games_dir)
wait_local_game(peer, "ggoo", downloaded=True, installed=False)
rejected = peer.send(
{"cmd": "set-game-dir", "path": "/games/does-not-exist"},
expect_error=True,
)
error = rejected.get("error")
if not isinstance(error, str) or "game directory" not in error.lower():
raise ScenarioError(f"invalid game-directory rejection was not explicit: {rejected}")
if {
game["id"]
for game in peer.list_games()["local"]
if game.get("downloaded") or game.get("installed")
} != {"ggoo"}:
raise ScenarioError("rejected game-directory change altered the previous library")
peer.docker_exec("mkdir", "-p", "/games/alternate")
peer.docker_exec("cp", "-a", "/games/ggoo", "/games/alternate/ggoo")
alternate_start = len(peer.output)
accepted = peer.send(
{"cmd": "set-game-dir", "path": "/games/alternate"}
)
if accepted.get("data") != {
"accepted": True,
"path": "/games/alternate",
}:
raise ScenarioError(f"valid game-directory acknowledgement was not exact: {accepted}")
peer.wait_for(
event_is("local-library-changed"),
timeout=20,
description="alternate local-library-changed",
waiter=LineWaiter(alternate_start),
)
wait_local_game(peer, "ggoo", downloaded=True, installed=False)
original_start = len(peer.output)
restored = peer.send({"cmd": "set-game-dir", "path": "/games"})
if restored.get("data") != {"accepted": True, "path": "/games"}:
raise ScenarioError(f"original game-directory acknowledgement was not exact: {restored}")
peer.wait_for(
event_is("local-library-changed"),
timeout=20,
description="original local-library-changed",
waiter=LineWaiter(original_start),
)
wait_local_game(peer, "ggoo", downloaded=True, installed=False)
return (
"invalid directory changes were rejected without mutation, then valid directory "
"changes acknowledged and refreshed the local library in both directions"
)
def run(command: list[str], description: str) -> subprocess.CompletedProcess[str]:
result = subprocess.run(