mirror of
https://github.com/kuhyx/steam-backlog-enforcer.git
synced 2026-11-26 11:07:21 +01:00
Compare commits
3 Commits
f804a4987f
...
5990b46f5d
| Author | SHA1 | Date | |
|---|---|---|---|
| 5990b46f5d | |||
| 9ed4725d45 | |||
| 4424a26dbe |
@ -60,7 +60,7 @@ mirror is `web/src/api/contract.ts`; change both together or neither.
|
||||
| GET | `/api/jobs/{id}` | – | `Job` |
|
||||
| GET | `/api/jobs/{id}/events` | `?token=&after=<seq>` | SSE stream of `JobEvent` |
|
||||
| POST | `/api/jobs/{id}/answer` | `PromptAnswer` | `204` |
|
||||
| POST | `/api/jobs/{id}/cancel` | – | `204` (only if `CommandSpec.cancellable`) |
|
||||
| POST | `/api/jobs/{id}/cancel` | – | `204` (only if `CommandSpec.cancellable`, or while the job's `cancel_window` is open) |
|
||||
| POST | `/api/pending/{id}/heartbeat` | – | `PendingAction` |
|
||||
| POST | `/api/pending/{id}/commit` | `{confirm_phrase}` | `Job` |
|
||||
| DELETE | `/api/pending/{id}` | – | `204` |
|
||||
@ -134,7 +134,14 @@ with explicit params, a `Progress` reporter and a `Prompter`.
|
||||
`result.json`. The server only tails files, so jobs survive both page
|
||||
reloads and server restarts (including `_serve_stale` retirement).
|
||||
- At most **one mutating job** at a time (`busy` otherwise). Read-only jobs
|
||||
(`check`, `stats`, `list`, …) may run alongside.
|
||||
(`stats`, `list`) may run alongside. `check` is mutating, like `done`: a
|
||||
new achievement releases the game and assigns the next one.
|
||||
- `done`, `check`, `pick`, `pick-manual` and `hide` cannot be cancelled,
|
||||
except while they hide games in the Steam library (the `cancel_window`
|
||||
event below; `check` has the flag but no hide step today, so it never
|
||||
opens a window). That phase can wait on a Steam launch, and the job holds
|
||||
the mutating lock throughout. Cancelling there skips the hide; the job then carries on and ends normally, so the
|
||||
lock drops.
|
||||
- History: last 50 job dirs kept, older ones pruned at job start. Job ids
|
||||
are `<UTC yyyymmddThhmmss + microseconds>Z-<6 hex>`, so sorting by id is
|
||||
creation order even within one second.
|
||||
@ -157,6 +164,14 @@ with explicit params, a `Progress` reporter and a `Prompter`.
|
||||
- `progress` — `{step, total, label, item?, eta_seconds?}`; `total` may be
|
||||
`null` for indeterminate phases. Any operation over 2 s must emit
|
||||
determinate progress.
|
||||
- `cancel_window` — `{open}`, only from commands flagged `cancel_window` in
|
||||
`jobs/_specs.py` (`done`, `check`, `pick`, `pick-manual`, `hide`):
|
||||
`open: true` when the job starts hiding games in the Steam library,
|
||||
`open: false` when it stops (also after a cancel). The job installs its SIGTERM handler before it
|
||||
writes `open: true` and restores the previous one before `open: false`.
|
||||
`POST /api/jobs/{id}/cancel` is accepted exactly while the latest
|
||||
`cancel_window` event says `open`, else `not_cancellable`; the UI shows
|
||||
its Cancel button on the same condition. Declared in `jobContract.ts`.
|
||||
- `prompt` — `{prompt_id, kind, message, options?, phrase?, default?,
|
||||
app_ids?}`; `kind` is `choice` (pick one of `options`), `confirm`
|
||||
(yes/no), `phrase` (type `phrase` exactly), `text` or `game`. The job
|
||||
|
||||
@ -76,6 +76,9 @@ unfixable = []
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"**/tests/**/*.py" = ["ARG", "D", "PLC0415", "PLR2004", "S101", "SLF001"]
|
||||
"**/test_*.py" = ["ARG", "D", "PLC0415", "PLR2004", "S101", "SLF001"]
|
||||
# libX11 puts local display sockets in /tmp/.X11-unix; the path is not ours to
|
||||
# move to a private temp dir (and `# noqa` is banned by pre-commit).
|
||||
"steam_backlog_enforcer/_desktop_env.py" = ["S108"]
|
||||
|
||||
[tool.ruff.lint.pydocstyle]
|
||||
convention = "google"
|
||||
|
||||
@ -4,14 +4,14 @@
|
||||
aiohttp==3.14.5
|
||||
bandit==1.9.4
|
||||
codespell==2.4.3
|
||||
coverage==7.17.2
|
||||
coverage==7.17.3
|
||||
earned-time @ git+https://github.com/kuhyx/utils@earned-time-v0.21.0#subdirectory=earned_time
|
||||
howlongtobeatpy==1.0.24
|
||||
leisure-watch @ git+https://github.com/kuhyx/leisure-watch@leisure-watch-v0.2.7
|
||||
mcp==2.3.0
|
||||
mypy==2.4.1
|
||||
pre-commit==4.7.0
|
||||
pylint==4.1.3
|
||||
pylint==4.1.4
|
||||
pytest==9.2.0
|
||||
pytest-cov==7.1.0
|
||||
pytest-randomly==5.1.0
|
||||
@ -19,6 +19,6 @@ pytest-sugar==1.1.1
|
||||
pytest-timeout==2.4.0
|
||||
pytest-xdist==3.8.0
|
||||
requests==2.34.2
|
||||
ruff==0.17.4
|
||||
ruff==0.17.5
|
||||
types-requests==2.33.0.20261030
|
||||
websockets==17.4
|
||||
|
||||
39
steam_backlog_enforcer/_cancel_window.py
Normal file
39
steam_backlog_enforcer/_cancel_window.py
Normal file
@ -0,0 +1,39 @@
|
||||
"""A stretch of a command during which a web job may be cancelled.
|
||||
|
||||
Most commands cannot be stopped midway, but the library-hiding phase of
|
||||
``done`` and ``check`` can: it only drives Steam, and a hide that is aborted is
|
||||
already a skip. The command code marks that phase with :func:`cancel_window`;
|
||||
*who* acts on the mark is decided by the caller, exactly like
|
||||
:mod:`steam_backlog_enforcer._progress`. The CLI and the root daemon install
|
||||
nothing, so for them the window is a no-op; a web job installs one that
|
||||
announces it to the server and turns SIGTERM into a skipped hide.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from contextlib import AbstractContextManager, contextmanager, nullcontext
|
||||
from contextvars import ContextVar
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Callable, Iterator
|
||||
|
||||
WindowFactory = Callable[[], AbstractContextManager[None]]
|
||||
|
||||
_ACTIVE: ContextVar[WindowFactory | None] = ContextVar("cancel_window", default=None)
|
||||
|
||||
|
||||
def cancel_window() -> AbstractContextManager[None]:
|
||||
"""Return the context manager that brackets a cancellable phase."""
|
||||
factory = _ACTIVE.get()
|
||||
return nullcontext() if factory is None else factory()
|
||||
|
||||
|
||||
@contextmanager
|
||||
def use_cancel_window(factory: WindowFactory) -> Iterator[None]:
|
||||
"""Make *factory* build the cancel windows for the duration of the context."""
|
||||
token = _ACTIVE.set(factory)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
_ACTIVE.reset(token)
|
||||
@ -28,6 +28,39 @@ from __future__ import annotations
|
||||
import os
|
||||
from pathlib import Path
|
||||
import pwd
|
||||
import re
|
||||
|
||||
# Where local X servers put their sockets: fixed by libX11, not a scratch file
|
||||
# (pyproject waives S108 for this module). A module constant so tests (and
|
||||
# repro scripts) can point it at a scratch directory.
|
||||
X_SOCKET_DIR = "/tmp/.X11-unix"
|
||||
# ``:0``, ``:1.0`` and ``unix:0`` are local; ``host:0`` is not.
|
||||
_LOCAL_DISPLAY = re.compile(r"(?:unix)?:(\d+)(?:\.\d+)?")
|
||||
|
||||
|
||||
def desktop_display() -> str:
|
||||
"""The X display for the desktop session: inherited, else the usual ``:0``."""
|
||||
return os.environ.get("DISPLAY") or ":0"
|
||||
|
||||
|
||||
def x_display_error() -> str | None:
|
||||
"""Why a program launched now has no X display to open, or ``None``.
|
||||
|
||||
A Steam started without a reachable display logs "Unable to open X11
|
||||
display" and exits within seconds, so launching it is pointless. A web
|
||||
job (a user unit with no ``DISPLAY``) hit exactly that. Only local
|
||||
displays are checked, by their socket: a ``host:N`` display cannot be
|
||||
probed without connecting, so it is assumed up.
|
||||
"""
|
||||
display = desktop_display()
|
||||
match = _LOCAL_DISPLAY.fullmatch(display)
|
||||
if match is None:
|
||||
return None
|
||||
socket = Path(X_SOCKET_DIR) / f"X{match[1]}"
|
||||
if socket.exists():
|
||||
return None
|
||||
origin = "DISPLAY" if os.environ.get("DISPLAY") else "DISPLAY unset, default"
|
||||
return f"No X display for Steam: {origin} {display} is not up ({socket} missing)"
|
||||
|
||||
|
||||
def desktop_runtime_dir(uid: int) -> str:
|
||||
@ -66,7 +99,7 @@ def desktop_env_args(user: str, uid: int) -> list[str]:
|
||||
dbus_addr = os.environ.get("DBUS_SESSION_BUS_ADDRESS", dbus_default)
|
||||
xauth = os.environ.get("XAUTHORITY", f"/home/{user}/.Xauthority")
|
||||
return [
|
||||
f"DISPLAY={os.environ.get('DISPLAY', ':0')}",
|
||||
f"DISPLAY={desktop_display()}",
|
||||
f"XAUTHORITY={xauth}",
|
||||
f"DBUS_SESSION_BUS_ADDRESS={dbus_addr}",
|
||||
f"XDG_RUNTIME_DIR={runtime_dir}",
|
||||
@ -112,23 +145,41 @@ def resolve_desktop_user() -> str | None:
|
||||
)
|
||||
|
||||
|
||||
def desktop_user_cmd(cmd: list[str], user: str | None) -> list[str]:
|
||||
"""Wrap *cmd* so it runs as *user* when the caller is root.
|
||||
def _process_owner() -> str | None:
|
||||
"""The user this process runs as, or ``None`` without a passwd entry."""
|
||||
try:
|
||||
return pwd.getpwuid(os.geteuid()).pw_name
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
Returns *cmd* unchanged when already unprivileged or when no desktop user
|
||||
resolves; otherwise prefixes ``sudo -u <user> env <session vars>``.
|
||||
|
||||
def desktop_user_cmd(cmd: list[str], user: str | None) -> list[str]:
|
||||
"""Wrap *cmd* so it runs in the desktop session as *user*.
|
||||
|
||||
As root: prefixes ``sudo -u <user> env <session vars>``, or returns *cmd*
|
||||
unchanged when no desktop user resolves. Unprivileged (a web job): there
|
||||
is no one to switch to, but the session vars are still prefixed with a
|
||||
plain ``env`` — a user unit has no ``DISPLAY``, and a bare ``steam`` then
|
||||
dies with "Unable to open X11 display". The uid comes from the process
|
||||
itself, not from the lookup that falls back to 1000.
|
||||
|
||||
This is argv construction only — deliberately no ``subprocess`` call, so
|
||||
every spawn site stays in a module covered by the test suite's
|
||||
``_no_subprocess`` guard.
|
||||
"""
|
||||
if os.geteuid() == 0 and user and user != "root":
|
||||
return [
|
||||
"sudo",
|
||||
"-u",
|
||||
user,
|
||||
"env",
|
||||
*desktop_env_args(user, desktop_uid(user)),
|
||||
*cmd,
|
||||
]
|
||||
return cmd
|
||||
euid = os.geteuid()
|
||||
if euid == 0:
|
||||
if user and user != "root":
|
||||
return [
|
||||
"sudo",
|
||||
"-u",
|
||||
user,
|
||||
"env",
|
||||
*desktop_env_args(user, desktop_uid(user)),
|
||||
*cmd,
|
||||
]
|
||||
return cmd
|
||||
owner = user or _process_owner()
|
||||
if owner is None:
|
||||
return cmd
|
||||
return ["env", *desktop_env_args(owner, euid), *cmd]
|
||||
|
||||
@ -9,7 +9,9 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from steam_backlog_enforcer._steam_launch import _resolve_desktop_user
|
||||
from steam_backlog_enforcer._desktop_env import (
|
||||
resolve_desktop_user as _resolve_desktop_user,
|
||||
)
|
||||
from steam_backlog_enforcer._steam_process import _run_as_user
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -60,3 +60,13 @@ class FastInstallInProgressError(SteamUnavailableError):
|
||||
underneath it discards the manifest the installer is about to write and
|
||||
resumes the slow client download - so every launch path defers instead.
|
||||
"""
|
||||
|
||||
|
||||
class HidingCancelledError(SteamUnavailableError):
|
||||
"""Raised inside a job's library-hiding phase when the user cancels it.
|
||||
|
||||
Subclasses :class:`SteamUnavailableError` so ``try_hide_other_games``
|
||||
already turns it into a skipped hide: the job carries on and ends
|
||||
normally, releasing the one-mutating-job lock, instead of waiting out a
|
||||
Steam launch that may never finish.
|
||||
"""
|
||||
|
||||
@ -24,6 +24,10 @@ from steam_backlog_enforcer._desktop_env import (
|
||||
desktop_runtime_dir,
|
||||
desktop_session_ready,
|
||||
desktop_uid,
|
||||
x_display_error,
|
||||
)
|
||||
from steam_backlog_enforcer._desktop_env import (
|
||||
resolve_desktop_user as _resolve_desktop_user,
|
||||
)
|
||||
from steam_backlog_enforcer._steam_errors import (
|
||||
DesktopSessionNotReadyError,
|
||||
@ -78,11 +82,21 @@ def _steam_has_debug_port() -> bool:
|
||||
return _get_shared_js_ws_url() is not None
|
||||
|
||||
|
||||
def _wait_for_cdp_ready() -> bool:
|
||||
"""Wait up to *_STEAM_STARTUP_WAIT* seconds for CDP to become ready."""
|
||||
def _wait_for_cdp_ready(launched: subprocess.Popen[bytes] | None = None) -> bool:
|
||||
"""Wait up to *_STEAM_STARTUP_WAIT* seconds for CDP to become ready.
|
||||
|
||||
Raises:
|
||||
SteamUnavailableError: *launched* exited and no Steam is left to open
|
||||
the port. A live client keeps the wait going: ``steam`` may fork
|
||||
the real client and exit.
|
||||
"""
|
||||
for _ in range(_STEAM_STARTUP_WAIT):
|
||||
if _get_shared_js_ws_url() is not None:
|
||||
return True
|
||||
code = None if launched is None else launched.poll()
|
||||
if code is not None and not _is_steam_running():
|
||||
msg = f"Steam exited during startup (exit code {code})"
|
||||
raise SteamUnavailableError(msg)
|
||||
time.sleep(1)
|
||||
return False
|
||||
|
||||
@ -109,21 +123,6 @@ def _wait_for_collections_ready() -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def _resolve_desktop_user() -> str | None:
|
||||
"""Resolve which desktop user owns the Steam/X11 session.
|
||||
|
||||
Prefers the explicit STEAM_ENFORCER_DESKTOP_USER (set by the systemd
|
||||
unit, which has no SUDO_USER/USER of its own since it is started
|
||||
directly by systemd rather than via `sudo`), then falls back to
|
||||
SUDO_USER/USER for interactive `sudo` invocations.
|
||||
"""
|
||||
return (
|
||||
os.environ.get("STEAM_ENFORCER_DESKTOP_USER")
|
||||
or os.environ.get("SUDO_USER")
|
||||
or os.environ.get("USER")
|
||||
)
|
||||
|
||||
|
||||
def _shutdown_steam() -> None:
|
||||
"""Send ``steam -shutdown`` and wait for the process to exit."""
|
||||
real_user = _resolve_desktop_user()
|
||||
@ -144,10 +143,10 @@ def _shutdown_steam() -> None:
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
def _launch_steam_with_debug() -> None:
|
||||
"""Launch Steam with CEF debugging enabled."""
|
||||
def _launch_steam_with_debug() -> subprocess.Popen[bytes] | None:
|
||||
"""Launch Steam with CEF debugging enabled; return the process if started."""
|
||||
real_user = _resolve_desktop_user()
|
||||
_run_as_user(
|
||||
return _run_as_user(
|
||||
[
|
||||
"steam",
|
||||
"-cef-enable-debugging",
|
||||
@ -193,14 +192,18 @@ def ensure_steam_debug_port() -> None:
|
||||
logger.info(msg)
|
||||
raise DesktopSessionNotReadyError(msg)
|
||||
|
||||
# Before the shutdown: never close Steam only to find nowhere to restart it.
|
||||
if (no_display := x_display_error()) is not None:
|
||||
raise SteamUnavailableError(no_display)
|
||||
|
||||
logger.info("Steam CDP port not available — (re)starting Steam...")
|
||||
if _is_steam_running():
|
||||
assert_safe_to_restart()
|
||||
_shutdown_steam()
|
||||
|
||||
_launch_steam_with_debug()
|
||||
launched = _launch_steam_with_debug()
|
||||
|
||||
if not _wait_for_cdp_ready():
|
||||
if not _wait_for_cdp_ready(launched):
|
||||
msg = "Timed out waiting for Steam CDP port to become ready"
|
||||
raise SteamUnavailableError(msg)
|
||||
logger.info("Steam CDP port ready.")
|
||||
|
||||
@ -53,13 +53,17 @@ def _reap_spawned() -> None:
|
||||
_SPAWNED[:] = [proc for proc in _SPAWNED if proc.poll() is None]
|
||||
|
||||
|
||||
def _run_as_user(cmd: list[str], user: str | None) -> None:
|
||||
def _run_as_user(cmd: list[str], user: str | None) -> subprocess.Popen[bytes] | None:
|
||||
"""Run a command, dropping to *user* if currently root.
|
||||
|
||||
Refuses to run at all when root and no desktop user resolves: the command
|
||||
would otherwise execute *as root* on the user's session, which is how the
|
||||
enforcer put a root Steam ("Cannot run as root user") on screen.
|
||||
Failing closed costs one skipped pass; failing open costs a modal.
|
||||
|
||||
Returns:
|
||||
The started process, so a caller that waits on it can notice it died;
|
||||
``None`` when the launch was refused.
|
||||
"""
|
||||
_reap_spawned()
|
||||
if os.geteuid() == 0 and (not user or user == "root"):
|
||||
@ -68,7 +72,7 @@ def _run_as_user(cmd: list[str], user: str | None) -> None:
|
||||
"(is STEAM_ENFORCER_DESKTOP_USER set?)",
|
||||
cmd[0] if cmd else "<empty>",
|
||||
)
|
||||
return
|
||||
full_cmd = desktop_user_cmd(cmd, user)
|
||||
|
||||
_SPAWNED.append(spawn_detached(full_cmd))
|
||||
return None
|
||||
proc = spawn_detached(desktop_user_cmd(cmd, user))
|
||||
_SPAWNED.append(proc)
|
||||
return proc
|
||||
|
||||
@ -119,7 +119,7 @@ def answer_view(request: Request) -> Reply:
|
||||
|
||||
|
||||
def cancel_view(request: Request) -> Reply:
|
||||
"""``POST /api/jobs/{id}/cancel`` — only for cancellable commands."""
|
||||
"""``POST /api/jobs/{id}/cancel`` — cancellable, or inside a cancel window."""
|
||||
try:
|
||||
cancel(request.args[0])
|
||||
except JobError as exc:
|
||||
|
||||
61
steam_backlog_enforcer/jobs/_cancel_window.py
Normal file
61
steam_backlog_enforcer/jobs/_cancel_window.py
Normal file
@ -0,0 +1,61 @@
|
||||
"""The job side of a cancel window: announce it, and turn SIGTERM into a skip.
|
||||
|
||||
``done`` and ``check`` cannot be stopped midway, except while they hide games
|
||||
in the Steam library (see :mod:`steam_backlog_enforcer._cancel_window`). While
|
||||
a window is open the job writes ``cancel_window`` events (``open: true`` then
|
||||
``open: false``), which the server reads to accept a cancel and the UI reads
|
||||
to show its button, and a SIGTERM raises :class:`HidingCancelledError`. The hide
|
||||
turns that into a skip, so the job finishes normally and drops the lock.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from contextlib import contextmanager
|
||||
import signal
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from steam_backlog_enforcer._steam_errors import HidingCancelledError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterator
|
||||
from types import FrameType
|
||||
|
||||
from steam_backlog_enforcer.jobs._events import EventWriter
|
||||
|
||||
CANCEL_WINDOW_EVENT = "cancel_window"
|
||||
|
||||
|
||||
def _raise_cancelled(_signum: int, _frame: FrameType | None) -> None:
|
||||
"""SIGTERM inside the window: abort the hide, once. No I/O, as in the runner.
|
||||
|
||||
Ignoring further SIGTERMs first means a second cancel cannot interrupt the
|
||||
cleanup that restores the previous handler and closes the window.
|
||||
"""
|
||||
signal.signal(signal.SIGTERM, signal.SIG_IGN)
|
||||
msg = "Cancelled"
|
||||
raise HidingCancelledError(msg)
|
||||
|
||||
|
||||
class JobCancelWindow:
|
||||
"""Builds the context manager that brackets one cancellable phase."""
|
||||
|
||||
def __init__(self, writer: EventWriter) -> None:
|
||||
"""Bind to the job's event writer."""
|
||||
self._writer = writer
|
||||
|
||||
@contextmanager
|
||||
def __call__(self) -> Iterator[None]:
|
||||
"""Open the window for the body, then close it, however it ends.
|
||||
|
||||
The handler goes in before ``open`` is written and the previous one
|
||||
comes back before ``close``, so the server only ever sees a window
|
||||
the job can act on. The previous handler is restored rather than
|
||||
assumed to be "ignore": a cancellable command already had its own.
|
||||
"""
|
||||
previous = signal.signal(signal.SIGTERM, _raise_cancelled)
|
||||
try:
|
||||
self._writer.emit(CANCEL_WINDOW_EVENT, open=True)
|
||||
yield
|
||||
finally:
|
||||
signal.signal(signal.SIGTERM, previous)
|
||||
self._writer.emit(CANCEL_WINDOW_EVENT, open=False)
|
||||
@ -35,6 +35,13 @@ def _open_prompt_id(job_id: str) -> str | None:
|
||||
return None if latest in answered else latest
|
||||
|
||||
|
||||
def _cancel_window_open(job_id: str) -> bool:
|
||||
"""Whether the job's latest ``cancel_window`` event says it is open."""
|
||||
path = _store.job_dir(job_id)
|
||||
windows = [e for e in read_events(path) if e.get("type") == "cancel_window"]
|
||||
return bool(windows) and bool(windows[-1].get("open"))
|
||||
|
||||
|
||||
def write_answer(job_id: str, prompt_id: str, value: str) -> None:
|
||||
"""Deliver the user's answer to the prompt the job is waiting on.
|
||||
|
||||
@ -60,7 +67,11 @@ def write_answer(job_id: str, prompt_id: str, value: str) -> None:
|
||||
def cancel(job_id: str) -> None:
|
||||
"""Ask a job to stop: any job waiting on a prompt, else cancellable ones.
|
||||
|
||||
A cancellable job gets SIGTERM, to its own process only.
|
||||
A cancellable job gets SIGTERM, to its own process only. So does a
|
||||
cancel-window job (``done``, ``check``, ``pick``, ``pick-manual``,
|
||||
``hide``), but only while its ``cancel_window`` is open (it is hiding
|
||||
games in the Steam library); the runner turns that SIGTERM into a skipped
|
||||
hide and the job finishes normally.
|
||||
|
||||
Only the job's pid is signalled, never its process group: a job may
|
||||
have started Steam, and cancelling a scan must not take Steam down.
|
||||
@ -77,7 +88,9 @@ def cancel(job_id: str) -> None:
|
||||
(_store.job_dir(job_id) / CANCEL_NAME).touch()
|
||||
return
|
||||
flags = JOB_FLAGS.get(job["command"])
|
||||
if flags is None or not flags.cancellable:
|
||||
if flags is None or not (
|
||||
flags.cancellable or (flags.cancel_window and _cancel_window_open(job_id))
|
||||
):
|
||||
msg = f"{job['command']} cannot be cancelled once started."
|
||||
raise JobError(msg, code="not_cancellable")
|
||||
if job["state"] in TERMINAL_STATES:
|
||||
|
||||
@ -18,6 +18,7 @@ import os
|
||||
import signal
|
||||
from typing import TYPE_CHECKING, Any, Final
|
||||
|
||||
from steam_backlog_enforcer._cancel_window import use_cancel_window
|
||||
from steam_backlog_enforcer._command_gate import lock_reason
|
||||
from steam_backlog_enforcer._echo import routed_echo
|
||||
from steam_backlog_enforcer._fail_safe import FAIL_SAFE_ERRORS
|
||||
@ -25,6 +26,7 @@ from steam_backlog_enforcer._progress import use_progress
|
||||
from steam_backlog_enforcer._prompter import PromptAbortedError, use_prompter
|
||||
from steam_backlog_enforcer.config import Config, State, _atomic_write
|
||||
from steam_backlog_enforcer.jobs import _spawn, _store
|
||||
from steam_backlog_enforcer.jobs._cancel_window import JobCancelWindow
|
||||
from steam_backlog_enforcer.jobs._errors import (
|
||||
JobCancelledError,
|
||||
JobError,
|
||||
@ -156,6 +158,8 @@ def _run_command(
|
||||
stack.callback(logging.getLogger().removeHandler, handler)
|
||||
_on_sigterm(cancellable=flags.cancellable)
|
||||
stack.callback(signal.signal, signal.SIGTERM, signal.SIG_IGN)
|
||||
if flags.cancel_window:
|
||||
stack.enter_context(use_cancel_window(JobCancelWindow(writer)))
|
||||
|
||||
config = Config.load()
|
||||
try:
|
||||
|
||||
@ -24,27 +24,34 @@ class JobFlags:
|
||||
mutating: Takes the one-mutating-job lock.
|
||||
cancellable: SIGTERM cancels it (only where stopping midway is safe).
|
||||
privileged: Runs in the root daemon; never spawned as a job.
|
||||
cancel_window: Cancellable only while the job reports an open
|
||||
``cancel_window`` (hiding games in the Steam library); the work
|
||||
before it cannot be stopped midway.
|
||||
"""
|
||||
|
||||
mutating: bool = True
|
||||
cancellable: bool = False
|
||||
privileged: bool = False
|
||||
cancel_window: bool = False
|
||||
|
||||
|
||||
_PRIVILEGED = JobFlags(privileged=True)
|
||||
|
||||
JOB_FLAGS: Final[dict[str, JobFlags]] = {
|
||||
# check is mutating: a new achievement releases the game and assigns
|
||||
# the next one, exactly like done.
|
||||
"check": JobFlags(),
|
||||
# the next one, exactly like done. Every command that hides games in the
|
||||
# Steam library (try_hide_other_games, which may wait on a Steam launch)
|
||||
# can be stopped only during that step. do_check never hides today, so
|
||||
# check's window is inert until it gains one.
|
||||
"check": JobFlags(cancel_window=True),
|
||||
"scan": JobFlags(cancellable=True),
|
||||
"done": JobFlags(),
|
||||
"pick": JobFlags(),
|
||||
"pick-manual": JobFlags(),
|
||||
"done": JobFlags(cancel_window=True),
|
||||
"pick": JobFlags(cancel_window=True),
|
||||
"pick-manual": JobFlags(cancel_window=True),
|
||||
"abandon-pick": JobFlags(),
|
||||
"install": JobFlags(),
|
||||
"uninstall": JobFlags(),
|
||||
"hide": JobFlags(),
|
||||
"hide": JobFlags(cancel_window=True),
|
||||
"unhide": JobFlags(),
|
||||
"add-exception": JobFlags(),
|
||||
"reset": JobFlags(),
|
||||
|
||||
@ -22,6 +22,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from steam_backlog_enforcer._achievement_skip import zero_achievement_ids
|
||||
from steam_backlog_enforcer._actions import allowed_app_ids as _allowed_ids_of
|
||||
from steam_backlog_enforcer._cancel_window import cancel_window
|
||||
from steam_backlog_enforcer._cdp import _cdp_result_value, _evaluate_js
|
||||
from steam_backlog_enforcer._echo import _echo
|
||||
from steam_backlog_enforcer._owned_apps_cache import get_all_owned_app_ids
|
||||
@ -186,7 +187,10 @@ def try_hide_other_games(
|
||||
progress = current_progress()
|
||||
progress.phase("Hiding games in the Steam library", 1)
|
||||
try:
|
||||
return hide_other_games(owned_app_ids, allowed_app_ids), None
|
||||
# A web job may be cancelled here (the Steam launch can wait a while);
|
||||
# the cancel raises a SteamUnavailableError, handled just below.
|
||||
with cancel_window():
|
||||
return hide_other_games(owned_app_ids, allowed_app_ids), None
|
||||
except SteamUnavailableError as exc:
|
||||
return 0, str(exc)
|
||||
finally:
|
||||
|
||||
30
steam_backlog_enforcer/tests/_x_display_up.py
Normal file
30
steam_backlog_enforcer/tests/_x_display_up.py
Normal file
@ -0,0 +1,30 @@
|
||||
"""Autouse: the host's X display never decides a Steam-launch test.
|
||||
|
||||
``ensure_steam_debug_port`` refuses to launch when the X socket for ``DISPLAY``
|
||||
(default ``:0``) is missing. That is a fact about the machine - a headless CI
|
||||
box has none - so every test that reaches a launch would pass or fail by host.
|
||||
Pinned "up" here; ``test_desktop_display`` tests the check itself and
|
||||
``test_steam_launch_failfast`` patches it down for the refusal cases.
|
||||
|
||||
Split out of ``conftest.py`` like ``_no_systemd_run``; ``conftest`` imports the
|
||||
fixture by name to register it.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Iterator
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _x_display_up() -> Iterator[None]:
|
||||
"""Report the X display as up to ``_steam_launch`` for one test."""
|
||||
with patch(
|
||||
"steam_backlog_enforcer._steam_launch.x_display_error", return_value=None
|
||||
):
|
||||
yield
|
||||
@ -42,6 +42,7 @@ from steam_backlog_enforcer.tests._no_subprocess import _block_real_subprocesses
|
||||
from steam_backlog_enforcer.tests._no_systemd_run import _no_systemd_run
|
||||
from steam_backlog_enforcer.tests._no_workout_http import _no_workout_http
|
||||
from steam_backlog_enforcer.tests._research_fixtures import tm
|
||||
from steam_backlog_enforcer.tests._x_display_up import _x_display_up
|
||||
|
||||
# Re-exported so ruff --fix does not delete the imports above: pytest
|
||||
# registers autouse fixtures by name, so they look unused to the linter.
|
||||
@ -63,6 +64,7 @@ __all__ = [
|
||||
"_no_real_effects",
|
||||
"_no_systemd_run",
|
||||
"_no_workout_http",
|
||||
"_x_display_up",
|
||||
"tm",
|
||||
]
|
||||
|
||||
|
||||
109
steam_backlog_enforcer/tests/test_desktop_display.py
Normal file
109
steam_backlog_enforcer/tests/test_desktop_display.py
Normal file
@ -0,0 +1,109 @@
|
||||
"""Tests for the X display Steam is launched on, and the env it gets.
|
||||
|
||||
A web job (a user unit with no DISPLAY) used to run a bare ``steam`` that died
|
||||
with "Unable to open X11 display". Every launch now carries the desktop env,
|
||||
root or not, and no launch is attempted when the display is not up.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from steam_backlog_enforcer import _desktop_env
|
||||
from steam_backlog_enforcer._desktop_env import desktop_user_cmd, x_display_error
|
||||
from steam_backlog_enforcer.tests._desktop_launch_patches import (
|
||||
DESKTOP_ENV_PKG,
|
||||
env_value,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@pytest.fixture(name="x_dir")
|
||||
def _x_socket_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
||||
"""An empty X socket dir, with DISPLAY unset."""
|
||||
monkeypatch.setattr(_desktop_env, "X_SOCKET_DIR", str(tmp_path))
|
||||
monkeypatch.delenv("DISPLAY", raising=False)
|
||||
return tmp_path
|
||||
|
||||
|
||||
class TestXDisplayError:
|
||||
"""x_display_error: why Steam has no display to open, or None."""
|
||||
|
||||
def test_default_display_is_up(self, x_dir: Path) -> None:
|
||||
"""Unset DISPLAY falls back to :0, whose socket exists."""
|
||||
(x_dir / "X0").touch()
|
||||
assert x_display_error() is None
|
||||
|
||||
def test_default_display_missing_names_it(self, x_dir: Path) -> None:
|
||||
"""No socket for the default :0: the error names the display."""
|
||||
message = x_display_error()
|
||||
assert message is not None
|
||||
assert ":0" in message
|
||||
assert str(x_dir / "X0") in message
|
||||
|
||||
def test_explicit_display_with_screen_suffix(
|
||||
self, x_dir: Path, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""DISPLAY=:1.0 checks the X1 socket and is named in the error."""
|
||||
monkeypatch.setenv("DISPLAY", ":1.0")
|
||||
message = x_display_error()
|
||||
assert message is not None
|
||||
assert ":1.0" in message
|
||||
(x_dir / "X1").touch()
|
||||
assert x_display_error() is None
|
||||
|
||||
def test_remote_display_is_not_checked(
|
||||
self, x_dir: Path, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""A host-qualified display has no local socket to look for."""
|
||||
monkeypatch.setenv("DISPLAY", "localhost:10.0")
|
||||
assert x_dir.is_dir()
|
||||
assert x_display_error() is None
|
||||
|
||||
|
||||
class TestNonRootGetsTheDesktopEnv:
|
||||
"""desktop_user_cmd prefixes the session env even without sudo."""
|
||||
|
||||
def _cmd(self, user: str | None = "kuhy") -> list[str]:
|
||||
owner = MagicMock(pw_name="kuhy")
|
||||
with (
|
||||
patch(f"{DESKTOP_ENV_PKG}.os.geteuid", return_value=1234),
|
||||
patch(f"{DESKTOP_ENV_PKG}.pwd.getpwuid", return_value=owner),
|
||||
):
|
||||
return desktop_user_cmd(["steam", "-silent"], user)
|
||||
|
||||
def test_adds_env_without_sudo(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""The command runs under ``env`` with DISPLAY and the runtime dir."""
|
||||
monkeypatch.delenv("DISPLAY", raising=False)
|
||||
cmd = self._cmd()
|
||||
assert cmd[0] == "env"
|
||||
assert "sudo" not in cmd
|
||||
assert cmd[-2:] == ["steam", "-silent"]
|
||||
assert env_value(cmd, "DISPLAY") == ":0"
|
||||
assert env_value(cmd, "XDG_RUNTIME_DIR") == "/run/user/1234"
|
||||
|
||||
def test_keeps_an_inherited_display(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""An explicit DISPLAY in the job's environment still wins."""
|
||||
monkeypatch.setenv("DISPLAY", ":7")
|
||||
assert env_value(self._cmd(), "DISPLAY") == ":7"
|
||||
|
||||
def test_nobody_to_name_leaves_the_command_alone(self) -> None:
|
||||
"""No desktop user and no passwd entry for the process: no env prefix."""
|
||||
with (
|
||||
patch(f"{DESKTOP_ENV_PKG}.os.geteuid", return_value=1234),
|
||||
patch(f"{DESKTOP_ENV_PKG}.pwd.getpwuid", side_effect=KeyError),
|
||||
):
|
||||
assert desktop_user_cmd(["steam"], None) == ["steam"]
|
||||
|
||||
def test_unresolved_user_is_the_process_owner(
|
||||
self, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
"""With no desktop user named, the job's own user is the desktop user."""
|
||||
monkeypatch.delenv("XAUTHORITY", raising=False)
|
||||
cmd = self._cmd(user=None)
|
||||
assert env_value(cmd, "XAUTHORITY") == "/home/kuhy/.Xauthority"
|
||||
@ -70,10 +70,18 @@ class TestResolveDesktopUser:
|
||||
class TestDesktopUserCmd:
|
||||
"""Tests for desktop_user_cmd — all four branches."""
|
||||
|
||||
def test_non_root_returns_cmd_unchanged(self) -> None:
|
||||
"""A non-root caller runs the command as is."""
|
||||
def test_non_root_gets_the_env_without_sudo(self) -> None:
|
||||
"""A non-root caller runs the command under the session env, no sudo.
|
||||
|
||||
The web server is a user unit with no DISPLAY; a bare ``steam`` from
|
||||
a job died with "Unable to open X11 display".
|
||||
"""
|
||||
with patch(f"{ENV_PKG}.os.geteuid", return_value=1000):
|
||||
assert desktop_user_cmd(["steam"], "kuhy") == ["steam"]
|
||||
result = desktop_user_cmd(["steam"], "kuhy")
|
||||
assert result[0] == "env"
|
||||
assert result[-1] == "steam"
|
||||
assert "sudo" not in result
|
||||
assert _env_value(result, "XDG_RUNTIME_DIR") == "/run/user/1000"
|
||||
|
||||
def test_root_with_user_wraps_in_sudo(self) -> None:
|
||||
"""Root with a desktop user wraps the command in sudo with the user env."""
|
||||
|
||||
250
steam_backlog_enforcer/tests/test_jobs_cancel_window.py
Normal file
250
steam_backlog_enforcer/tests/test_jobs_cancel_window.py
Normal file
@ -0,0 +1,250 @@
|
||||
"""Tests for the cancel window: hiding jobs stop only while hiding games.
|
||||
|
||||
A ``done`` job once sat 90+ s in the Steam launch wait holding the one
|
||||
mutating-job lock, and could not be cancelled. Cancelling is now accepted
|
||||
only inside the library-hiding phase: the job announces the phase with
|
||||
``cancel_window`` events, the server signals it only while open, and the
|
||||
runner turns the SIGTERM into a skipped hide so the job ends normally.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from contextlib import contextmanager, suppress
|
||||
import signal
|
||||
from typing import TYPE_CHECKING
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from steam_backlog_enforcer._cancel_window import cancel_window, use_cancel_window
|
||||
from steam_backlog_enforcer._steam_errors import (
|
||||
HidingCancelledError,
|
||||
SteamUnavailableError,
|
||||
)
|
||||
from steam_backlog_enforcer.jobs import _control, _runner
|
||||
from steam_backlog_enforcer.jobs._cancel_window import JobCancelWindow
|
||||
from steam_backlog_enforcer.jobs._errors import JobError
|
||||
from steam_backlog_enforcer.jobs._events import EventWriter, read_events
|
||||
from steam_backlog_enforcer.jobs._job_io import JobLogSink
|
||||
from steam_backlog_enforcer.jobs._registry import HANDLERS
|
||||
from steam_backlog_enforcer.jobs._runner import _run_command
|
||||
from steam_backlog_enforcer.jobs._specs import JOB_FLAGS
|
||||
from steam_backlog_enforcer.library_hider import try_hide_other_games
|
||||
from steam_backlog_enforcer.tests._jobs_helpers import JOB_ID, make_job
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Callable, Iterator
|
||||
from contextlib import AbstractContextManager
|
||||
from pathlib import Path
|
||||
|
||||
_PID_ALIVE = "steam_backlog_enforcer.jobs._view._pid_alive"
|
||||
_ALIVE = "steam_backlog_enforcer.jobs._control.pid_of"
|
||||
_KILL = "steam_backlog_enforcer.jobs._control.os.kill"
|
||||
_WINDOW_SIGNAL = "steam_backlog_enforcer.jobs._cancel_window.signal"
|
||||
_GATE = "steam_backlog_enforcer.jobs._runner.enforce_gate"
|
||||
_HIDE = "steam_backlog_enforcer.library_hider.hide_other_games"
|
||||
|
||||
|
||||
def _window_events(path: Path) -> list[bool]:
|
||||
"""The ``open`` flag of every cancel_window event, in order."""
|
||||
return [bool(e["open"]) for e in read_events(path) if e["type"] == "cancel_window"]
|
||||
|
||||
|
||||
# Every command whose job reaches try_hide_other_games, which opens the window.
|
||||
_WINDOWED = ("done", "check", "pick", "pick-manual", "hide")
|
||||
|
||||
|
||||
class TestFlags:
|
||||
"""Which commands have a cancel window."""
|
||||
|
||||
@pytest.mark.parametrize("command", _WINDOWED)
|
||||
def test_hiding_commands_have_a_window(self, command: str) -> None:
|
||||
"""Each is mutating, not generally cancellable, but has the window."""
|
||||
flags = JOB_FLAGS[command]
|
||||
assert flags.mutating
|
||||
assert not flags.cancellable
|
||||
assert flags.cancel_window
|
||||
|
||||
def test_nothing_else_has_one(self) -> None:
|
||||
"""Every other command keeps its old cancel rules."""
|
||||
others = {k for k, f in JOB_FLAGS.items() if f.cancel_window}
|
||||
assert others == set(_WINDOWED)
|
||||
|
||||
|
||||
class TestControlCancel:
|
||||
"""_control.cancel honours the window for the commands that have one."""
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _alive(self) -> Iterator[None]:
|
||||
with patch(_PID_ALIVE, return_value=True):
|
||||
yield
|
||||
|
||||
def test_accepted_while_the_window_is_open(self) -> None:
|
||||
"""Inside the window, ``done`` gets SIGTERM on its own pid."""
|
||||
path = make_job("done", pid="5\n")
|
||||
EventWriter(path).emit("cancel_window", open=True)
|
||||
with patch(_ALIVE, return_value=5), patch(_KILL) as kill:
|
||||
_control.cancel(JOB_ID)
|
||||
kill.assert_called_once_with(5, signal.SIGTERM)
|
||||
|
||||
def test_refused_before_the_window_opens(self) -> None:
|
||||
"""A windowed job stays uncancellable until its window opens."""
|
||||
make_job("done", pid="5\n")
|
||||
with patch(_KILL) as kill, pytest.raises(JobError) as info:
|
||||
_control.cancel(JOB_ID)
|
||||
assert info.value.code == "not_cancellable"
|
||||
kill.assert_not_called()
|
||||
|
||||
def test_refused_after_the_window_closes(self) -> None:
|
||||
"""Once hiding is over the job can no longer be stopped."""
|
||||
path = make_job("check", pid="5\n")
|
||||
writer = EventWriter(path)
|
||||
writer.emit("cancel_window", open=True)
|
||||
writer.emit("cancel_window", open=False)
|
||||
with patch(_KILL) as kill, pytest.raises(JobError) as info:
|
||||
_control.cancel(JOB_ID)
|
||||
assert info.value.code == "not_cancellable"
|
||||
kill.assert_not_called()
|
||||
|
||||
def test_window_event_does_not_open_other_commands(self) -> None:
|
||||
"""A command without the flag ignores any window event."""
|
||||
path = make_job("abandon-pick", pid="5\n")
|
||||
EventWriter(path).emit("cancel_window", open=True)
|
||||
with patch(_KILL) as kill, pytest.raises(JobError) as info:
|
||||
_control.cancel(JOB_ID)
|
||||
assert info.value.code == "not_cancellable"
|
||||
kill.assert_not_called()
|
||||
|
||||
|
||||
class TestJobCancelWindow:
|
||||
"""JobCancelWindow: the SIGTERM handler and the events, in order."""
|
||||
|
||||
@staticmethod
|
||||
def _body(*, fail: bool) -> None:
|
||||
"""The hide inside the window: fine, or aborted by a cancel."""
|
||||
if fail:
|
||||
raise HidingCancelledError
|
||||
|
||||
def _enter(self, *, fail: bool = False) -> MagicMock:
|
||||
"""Run one window against mocks; return the recorded calls."""
|
||||
path = make_job("done")
|
||||
writer = MagicMock(wraps=EventWriter(path))
|
||||
calls = MagicMock()
|
||||
calls.attach_mock(writer.emit, "emit")
|
||||
fake_signal = MagicMock()
|
||||
fake_signal.SIGTERM = signal.SIGTERM
|
||||
fake_signal.signal.return_value = "previous"
|
||||
calls.attach_mock(fake_signal.signal, "signal")
|
||||
with (
|
||||
patch(_WINDOW_SIGNAL, fake_signal),
|
||||
suppress(HidingCancelledError),
|
||||
JobCancelWindow(writer)(),
|
||||
):
|
||||
self._body(fail=fail)
|
||||
return calls
|
||||
|
||||
def test_handler_is_installed_before_open_and_restored_before_close(
|
||||
self,
|
||||
) -> None:
|
||||
"""The marker is only visible while a handler can act on it."""
|
||||
calls = self._enter()
|
||||
names = [c[0] for c in calls.mock_calls]
|
||||
assert names == ["signal", "emit", "signal", "emit"]
|
||||
assert calls.mock_calls[1].kwargs == {"open": True}
|
||||
assert calls.mock_calls[2].args == (signal.SIGTERM, "previous")
|
||||
assert calls.mock_calls[3].kwargs == {"open": False}
|
||||
|
||||
def test_window_closes_when_the_body_raises(self) -> None:
|
||||
"""An aborted hide still restores the handler and closes the window."""
|
||||
names = [c[0] for c in self._enter(fail=True).mock_calls]
|
||||
assert names == ["signal", "emit", "signal", "emit"]
|
||||
|
||||
def test_sigterm_handler_raises_a_hide_skip_once(self) -> None:
|
||||
"""SIGTERM inside the window raises an error ``try_hide`` turns to a skip.
|
||||
|
||||
The handler also ignores any later SIGTERM, so a second cancel cannot
|
||||
interrupt the cleanup. Called under a mocked ``signal``: a real call
|
||||
would change the test process's own SIGTERM disposition.
|
||||
"""
|
||||
handler = self._enter().mock_calls[0].args[1]
|
||||
fake_signal = MagicMock()
|
||||
with patch(_WINDOW_SIGNAL, fake_signal), pytest.raises(HidingCancelledError):
|
||||
handler(signal.SIGTERM, None)
|
||||
fake_signal.signal.assert_called_once_with(
|
||||
fake_signal.SIGTERM, fake_signal.SIG_IGN
|
||||
)
|
||||
assert issubclass(HidingCancelledError, SteamUnavailableError)
|
||||
|
||||
|
||||
class TestHideUsesTheWindow:
|
||||
"""try_hide_other_games runs the hide inside whatever window is installed."""
|
||||
|
||||
@staticmethod
|
||||
def _recorder(seen: list[str]) -> Callable[[], AbstractContextManager[None]]:
|
||||
@contextmanager
|
||||
def window() -> Iterator[None]:
|
||||
seen.append("open")
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
seen.append("close")
|
||||
|
||||
return window
|
||||
|
||||
def test_no_window_installed_is_a_noop(self) -> None:
|
||||
"""The CLI and the daemon have no window; hiding is unchanged."""
|
||||
with cancel_window():
|
||||
pass
|
||||
with patch(_HIDE, return_value=2):
|
||||
assert try_hide_other_games([1], {2}) == (2, None)
|
||||
|
||||
def test_hide_runs_between_open_and_close(self) -> None:
|
||||
"""The window brackets exactly the hide."""
|
||||
seen: list[str] = []
|
||||
|
||||
def hide(*_args: object) -> int:
|
||||
seen.append("hide")
|
||||
return 3
|
||||
|
||||
with use_cancel_window(self._recorder(seen)), patch(_HIDE, side_effect=hide):
|
||||
assert try_hide_other_games([1], {2}) == (3, None)
|
||||
assert seen == ["open", "hide", "close"]
|
||||
|
||||
def test_cancel_during_hide_is_a_skip_not_a_failure(self) -> None:
|
||||
"""A cancel mid-hide is reported as a skipped hide; the window closes."""
|
||||
seen: list[str] = []
|
||||
with (
|
||||
use_cancel_window(self._recorder(seen)),
|
||||
patch(_HIDE, side_effect=HidingCancelledError("Cancelled")),
|
||||
):
|
||||
assert try_hide_other_games([1], {2}) == (0, "Cancelled")
|
||||
assert seen == ["open", "close"]
|
||||
|
||||
|
||||
class TestRunnerWiring:
|
||||
"""The runner installs the window only for commands that have one."""
|
||||
|
||||
def _run(self, command: str) -> list[bool]:
|
||||
path = make_job(command)
|
||||
writer = EventWriter(path)
|
||||
|
||||
def handler(*_args: object) -> None:
|
||||
with cancel_window():
|
||||
pass
|
||||
|
||||
with (
|
||||
patch.object(signal, "signal"),
|
||||
patch.object(_runner, "_hold_lock", return_value=None),
|
||||
patch.dict(HANDLERS, {command: handler}),
|
||||
patch(_GATE),
|
||||
):
|
||||
_run_command(path, writer, JobLogSink(writer), {"command": command})
|
||||
return _window_events(path)
|
||||
|
||||
def test_done_opens_and_closes_a_window(self) -> None:
|
||||
"""A ``done`` job reports the window open, then closed."""
|
||||
assert self._run("done") == [True, False]
|
||||
|
||||
def test_abandon_pick_has_no_window(self) -> None:
|
||||
"""A command without the flag never reports one."""
|
||||
assert self._run("abandon-pick") == []
|
||||
@ -141,7 +141,7 @@ class TestRunAsUser:
|
||||
_SPAWNED.clear()
|
||||
|
||||
def test_non_root_runs_directly(self) -> None:
|
||||
"""A non-root caller runs the command unchanged."""
|
||||
"""A non-root caller runs the command itself, under the session env."""
|
||||
with (
|
||||
patch(f"{STEAM_PROCESS_PKG}.os.geteuid", return_value=1000),
|
||||
patch(f"{STEAM_PROCESS_PKG}.subprocess.Popen") as mock_popen,
|
||||
@ -149,7 +149,9 @@ class TestRunAsUser:
|
||||
_run_as_user(["steam", "-shutdown"], "alice")
|
||||
mock_popen.assert_called_once()
|
||||
cmd = mock_popen.call_args[0][0]
|
||||
assert cmd == ["steam", "-shutdown"]
|
||||
assert cmd[0] == "env"
|
||||
assert cmd[-2:] == ["steam", "-shutdown"]
|
||||
assert "sudo" not in cmd
|
||||
|
||||
def test_root_drops_to_user(self) -> None:
|
||||
"""Root launches through sudo -u as the desktop user."""
|
||||
|
||||
147
steam_backlog_enforcer/tests/test_steam_launch_failfast.py
Normal file
147
steam_backlog_enforcer/tests/test_steam_launch_failfast.py
Normal file
@ -0,0 +1,147 @@
|
||||
"""Tests for failing fast when a launched Steam cannot come up.
|
||||
|
||||
A web job once launched Steam with no DISPLAY: the client logged "Unable to
|
||||
open X11 display" and exited after ~2 s, yet the CDP wait still polled all 45 s
|
||||
while the job held the global mutating lock. These pin the fast failures: the
|
||||
launched process died, or there is no X display to launch it on.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from steam_backlog_enforcer._steam_errors import SteamUnavailableError
|
||||
from steam_backlog_enforcer._steam_launch import (
|
||||
_launch_steam_with_debug,
|
||||
_wait_for_cdp_ready,
|
||||
ensure_steam_debug_port,
|
||||
)
|
||||
from steam_backlog_enforcer._steam_process import _run_as_user
|
||||
from steam_backlog_enforcer.tests._desktop_launch_patches import (
|
||||
STEAM_LAUNCH_PKG,
|
||||
STEAM_PROCESS_PKG,
|
||||
launch_patches,
|
||||
)
|
||||
|
||||
NO_DISPLAY = "No X display for Steam: :0 is not up"
|
||||
|
||||
|
||||
def _proc(exit_code: int | None) -> MagicMock:
|
||||
"""A launched process whose ``poll()`` reports *exit_code* (None = alive)."""
|
||||
proc = MagicMock()
|
||||
proc.poll.return_value = exit_code
|
||||
return proc
|
||||
|
||||
|
||||
class TestWaitForCdpReadyWatchesTheLaunch:
|
||||
"""_wait_for_cdp_ready gives up as soon as the launched Steam is gone."""
|
||||
|
||||
def test_dead_launch_fails_on_the_first_poll(self) -> None:
|
||||
"""A process that exited with no Steam left stops the wait at once."""
|
||||
with (
|
||||
patch(f"{STEAM_LAUNCH_PKG}._get_shared_js_ws_url", return_value=None),
|
||||
patch(f"{STEAM_LAUNCH_PKG}._is_steam_running", return_value=False),
|
||||
patch(f"{STEAM_LAUNCH_PKG}.time.sleep") as sleep,
|
||||
pytest.raises(
|
||||
SteamUnavailableError,
|
||||
match=r"Steam exited during startup \(exit code 1\)",
|
||||
),
|
||||
):
|
||||
_wait_for_cdp_ready(_proc(1))
|
||||
assert sleep.call_count <= 1
|
||||
|
||||
def test_exited_launcher_with_a_live_client_keeps_waiting(self) -> None:
|
||||
"""A launcher that handed off to a running client is not a failure.
|
||||
|
||||
``steam`` may fork the real client and exit; the port then opens a
|
||||
few seconds later, so exit alone must not abort the wait.
|
||||
"""
|
||||
with (
|
||||
patch(
|
||||
f"{STEAM_LAUNCH_PKG}._get_shared_js_ws_url",
|
||||
side_effect=[None, None, "ws://steam"],
|
||||
),
|
||||
patch(f"{STEAM_LAUNCH_PKG}._is_steam_running", return_value=True),
|
||||
patch(f"{STEAM_LAUNCH_PKG}.time.sleep") as sleep,
|
||||
):
|
||||
assert _wait_for_cdp_ready(_proc(0)) is True
|
||||
assert sleep.call_count == 2
|
||||
|
||||
def test_alive_launch_times_out_as_before(self) -> None:
|
||||
"""A process that keeps running but never opens the port times out."""
|
||||
with (
|
||||
patch(f"{STEAM_LAUNCH_PKG}._get_shared_js_ws_url", return_value=None),
|
||||
patch(f"{STEAM_LAUNCH_PKG}._STEAM_STARTUP_WAIT", 3),
|
||||
patch(f"{STEAM_LAUNCH_PKG}.time.sleep") as sleep,
|
||||
):
|
||||
assert _wait_for_cdp_ready(_proc(None)) is False
|
||||
assert sleep.call_count == 3
|
||||
|
||||
|
||||
class TestEnsureFailsFast:
|
||||
"""ensure_steam_debug_port stops early for a dead launch or no display."""
|
||||
|
||||
def test_dead_launch_raises_without_waiting_for_collections(self) -> None:
|
||||
"""The whole call fails within a poll or two, naming the exit code."""
|
||||
with (
|
||||
launch_patches(
|
||||
"_wait_for_collections_ready",
|
||||
_launch_steam_with_debug=_proc(1),
|
||||
_steam_has_debug_port=False,
|
||||
_get_shared_js_ws_url=None,
|
||||
_is_steam_running=False,
|
||||
steam_is_installed=True,
|
||||
x_display_error=None,
|
||||
) as mocks,
|
||||
patch(f"{STEAM_LAUNCH_PKG}.time.sleep") as sleep,
|
||||
pytest.raises(SteamUnavailableError, match=r"exited during startup"),
|
||||
):
|
||||
ensure_steam_debug_port()
|
||||
assert sleep.call_count <= 1
|
||||
mocks["_wait_for_collections_ready"].assert_not_called()
|
||||
|
||||
def test_no_display_refuses_before_any_shutdown_or_launch(self) -> None:
|
||||
"""No X display: Steam is neither shut down nor started."""
|
||||
with (
|
||||
launch_patches(
|
||||
"_launch_steam_with_debug",
|
||||
"_shutdown_steam",
|
||||
_steam_has_debug_port=False,
|
||||
_is_steam_running=True,
|
||||
steam_is_installed=True,
|
||||
x_display_error=NO_DISPLAY,
|
||||
) as mocks,
|
||||
pytest.raises(SteamUnavailableError, match="No X display"),
|
||||
):
|
||||
ensure_steam_debug_port()
|
||||
mocks["_launch_steam_with_debug"].assert_not_called()
|
||||
mocks["_shutdown_steam"].assert_not_called()
|
||||
|
||||
|
||||
class TestLaunchHandsBackTheProcess:
|
||||
"""The launched process reaches the wait instead of being discarded."""
|
||||
|
||||
def test_launch_returns_the_spawned_handle(self) -> None:
|
||||
"""_launch_steam_with_debug returns what _run_as_user spawned."""
|
||||
spawned = _proc(None)
|
||||
with patch(f"{STEAM_LAUNCH_PKG}._run_as_user", return_value=spawned):
|
||||
assert _launch_steam_with_debug() is spawned
|
||||
|
||||
def test_run_as_user_returns_the_popen(self) -> None:
|
||||
"""_run_as_user hands back the Popen it started."""
|
||||
with (
|
||||
patch(f"{STEAM_PROCESS_PKG}.os.geteuid", return_value=1000),
|
||||
patch(f"{STEAM_PROCESS_PKG}.subprocess.Popen") as popen,
|
||||
):
|
||||
assert _run_as_user(["steam"], "bob") is popen.return_value
|
||||
|
||||
def test_run_as_user_refusal_returns_none(self) -> None:
|
||||
"""Root with no desktop user starts nothing and returns None."""
|
||||
with (
|
||||
patch(f"{STEAM_PROCESS_PKG}.os.geteuid", return_value=0),
|
||||
patch(f"{STEAM_PROCESS_PKG}.subprocess.Popen") as popen,
|
||||
):
|
||||
assert _run_as_user(["steam"], None) is None
|
||||
popen.assert_not_called()
|
||||
@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@12.18.0",
|
||||
"packageManager": "pnpm@12.21.0",
|
||||
"engines": {
|
||||
"node": ">=24",
|
||||
"pnpm": ">=10"
|
||||
@ -20,20 +20,20 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@kuhyx/web-ui": "github:kuhyx/utils#web_ui-v0.5.0&path:/web_ui",
|
||||
"astro": "7.4.10"
|
||||
"astro": "7.4.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@astrojs/check": "0.9.12",
|
||||
"@eslint/js": "10.0.1",
|
||||
"@testing-library/dom": "10.4.2",
|
||||
"@testing-library/jest-dom": "7.0.1",
|
||||
"@testing-library/user-event": "14.6.9",
|
||||
"@testing-library/user-event": "14.6.10",
|
||||
"@types/node": "26.6.6",
|
||||
"@vitest/coverage-v8": "5.1.0",
|
||||
"eslint": "10.14.0",
|
||||
"eslint": "10.15.0",
|
||||
"eslint-plugin-astro": "3.2.1",
|
||||
"globals": "17.14.0",
|
||||
"jsdom": "31.0.0",
|
||||
"jsdom": "31.0.1",
|
||||
"typescript": "6.0.3",
|
||||
"typescript-eslint": "8.72.2",
|
||||
"vitest": "5.1.0"
|
||||
|
||||
@ -7,153 +7,162 @@ importers:
|
||||
configDependencies: {}
|
||||
packageManagerDependencies:
|
||||
pnpm:
|
||||
specifier: 12.18.0
|
||||
version: 12.18.0
|
||||
specifier: 12.21.0
|
||||
version: 12.21.0
|
||||
|
||||
packages:
|
||||
|
||||
'@pnpm/exe.android-arm64@12.18.0':
|
||||
resolution: {integrity: sha512-fOF6IwgvnUKEmVedGqiAsNPfN2Ry8GvaqzSQOiF3RJFbpBfPKO/6YT54s1GjToyYinRxw9preHHPe4y2N3SzhA==}
|
||||
'@pnpm/exe.android-arm64@12.21.0':
|
||||
resolution: {integrity: sha512-iaWidxR5B9NUBpwMznCQu1yUpKB6BjTY5BYX2lORj76VsfINdj8Z8XWSzSNrGI8qlxa28Jzdp5fiaspzOaJZlA==}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@pnpm/exe.android-x64@12.18.0':
|
||||
resolution: {integrity: sha512-6OiolnaCsB3/GcJ9XNrenbUH3zFHRJ+5QynrMUUEyThbgnnCzWxa199hpQlOmxN4rAXuYQ0IYgWFNUZxyzg31Q==}
|
||||
'@pnpm/exe.android-x64@12.21.0':
|
||||
resolution: {integrity: sha512-35e5v3wlwjIYxDywq+R6/z8CE4gLOEgRxt18yqz1tMRLmx2mnW+CFJI2Q8+srTNjn7gykXUC0x1k195JNikC5A==}
|
||||
cpu: [x64]
|
||||
os: [android]
|
||||
|
||||
'@pnpm/exe.darwin-arm64@12.18.0':
|
||||
resolution: {integrity: sha512-zkq+4YzVIX39ETYLyC3W7LY7MpHEU/J3nRhHl4i2yPld2Cf2+rEKRh3ejJ4AmaQ77HHJLCktY4Z3jq0fpcxFXg==}
|
||||
'@pnpm/exe.darwin-arm64@12.21.0':
|
||||
resolution: {integrity: sha512-F5OyMX/6zLSowpTZEQRojbCmPS1Pq+fyRaIinslsIe6Glh3qbyQ52u+Fe0eEzSaRuIbWZkXmAAXSWh6Q5Wrlgg==}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@pnpm/exe.darwin-x64@12.18.0':
|
||||
resolution: {integrity: sha512-qMsL9qx92unOTa6hgkfiTJv8ceZaTx0IQg7InhYDVX2ZrTECujaVEEVypnJK5m3eGUsP1KD7Y4qIgleCwfRsYw==}
|
||||
'@pnpm/exe.darwin-x64@12.21.0':
|
||||
resolution: {integrity: sha512-EzpvcsaE6hrrgYeEiAFYd2rSgFybYyxXhkAY7K3y6Hg3loVfcyJ81hHczpFzi8lW5RXtUlFECRPZ8ZAMRFQYYg==}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@pnpm/exe.freebsd-x64@12.18.0':
|
||||
resolution: {integrity: sha512-/9vy/4ms52cU4MjZ5NhHd6N2d9L9W0kARf5/ff2tweAHu0VeUzs/0qp/7ZHFuddm2Wa/m0AKQoPum9AVUCqKsw==}
|
||||
'@pnpm/exe.freebsd-x64@12.21.0':
|
||||
resolution: {integrity: sha512-wNjuEnmdLks4aayPu/QZWQ5tQM9Jn+odUp/vwQM8BXRYoulkTZhtZTHoD60N6mUdLWef1hgUeUh8llNGEUsimw==}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@pnpm/exe.linux-arm64-musl@12.18.0':
|
||||
resolution: {integrity: sha512-Vp+TIMPPyackVCXkOdEKH/RmAn/r07EcIyrgZYQK7VrkksqZOie0GnWIx+85mPqeFEYCRtXIZAFJ9L4ceTndDg==}
|
||||
'@pnpm/exe.linux-arm64-musl@12.21.0':
|
||||
resolution: {integrity: sha512-Ceit9zn4g5ZqCJtx1fV8eJE7p8aeXMrGZ+Dc01vRqZLIUNgNeI+Ur0ruyqxtsnJx6rGADyXzohumxPLHjaJ5AQ==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@pnpm/exe.linux-arm64@12.18.0':
|
||||
resolution: {integrity: sha512-2dpyVBCHT+FfpuQh9i+7MXAqNWYLCvD5vYr5p6Eimxoga8USLnjbUgyj72AOrO0hjc5ri3TEFP3jiyBHjkSZpQ==}
|
||||
'@pnpm/exe.linux-arm64@12.21.0':
|
||||
resolution: {integrity: sha512-4Oj/iF2TDCe2lcH0n4TupPR5sSdrNLclJB6xBElLMPCUOAvBhdf2rRlSaO5M4erJ6g4Fyy7YTXTpcmfFsKyxEA==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.linux-ppc64@12.18.0':
|
||||
resolution: {integrity: sha512-BBOOOfNJ2QwIIya3eKqOjiN4WNTszfRz7HCvw9XggcT7+ftMjNP8XJ/GfW+ltCBeUFR9d8WBVsr2m/NLjX2CZQ==}
|
||||
'@pnpm/exe.linux-ppc64@12.21.0':
|
||||
resolution: {integrity: sha512-s2o7rdSDeUTBFsNqxptpZXlTgT6cojmMVUOvTQvFNSv6Easian02ha4tR32fwwD97Au4YzIIjMCwywCF4D82Sw==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.linux-riscv64@12.18.0':
|
||||
resolution: {integrity: sha512-7kMN77xSOYJX8GPSH5RbNAc5oM61LMmcSUukDDUwllnZPXm8GRPskCNsTWy8SCw01Kr1FB+5SwGNMiTdiziLNQ==}
|
||||
'@pnpm/exe.linux-riscv64@12.21.0':
|
||||
resolution: {integrity: sha512-EYv3GzxeBTITCuM3yGHHbpRFpUvyulkXpQ6LsjKAQNL3iaba1E6h9iDmlouLb3Io4AMMsfdk0/uG6poQ41uewA==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.linux-s390x@12.18.0':
|
||||
resolution: {integrity: sha512-htuSCpEcmDzhKoJqXbPkvfr176dBHU0QIF5mWcRiqxRXAB/1JoYiMYotfjWpk+ztgpB9qlx4XnWlLFAf7gzc6g==}
|
||||
'@pnpm/exe.linux-s390x@12.21.0':
|
||||
resolution: {integrity: sha512-8VXGNGVNEfs7pL9GTZOzFxjFEnMt4WL3rLOADR5/kPQ7ROTV9GfpVI2DPO/zArXFSkvfc9Zad/WypHLbvzoaTQ==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.linux-x64-musl@12.18.0':
|
||||
resolution: {integrity: sha512-Uj+vzfIQ62kDP10x36yHZIXVs5ohdNtiPYwn5FhCLlNScHPo0OAI+ShGDtLofiBXKE7umu71Jmjm7N8a8zVcDw==}
|
||||
'@pnpm/exe.linux-x64-musl@12.21.0':
|
||||
resolution: {integrity: sha512-MnC5vpIXYubhDZCgCwlfJMg7Cg6HupN2IuouT9gD/tUmOfVdQYqeyYccWbthyo/Jeto8de1oQlxeRN1+1Hl2DQ==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@pnpm/exe.linux-x64@12.18.0':
|
||||
resolution: {integrity: sha512-OJ+X2wcraldCwj75pCIerWARQSRpdfj0eBTs/2ODyhfeW46ylOnjTIE/GKra6Mn6E72/gBmXS8igrUioa+F9fQ==}
|
||||
'@pnpm/exe.linux-x64@12.21.0':
|
||||
resolution: {integrity: sha512-8eufCjHXspKbNS/kh8q4Q0gqJoOuvC4Q5pgos6XS8By/nAMtP+jf8F1Cw9er840kfAX+PJ/ts+A9qnLE91rvXQ==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@pnpm/exe.win32-arm64@12.18.0':
|
||||
resolution: {integrity: sha512-wEY6jiACGcbhhi5yD59doHqNTndS7AaujaPmtWAu1DKkHru2hy5fJ9yUGecW72Ypaw2/I3BEprfMOopap2NQtw==}
|
||||
'@pnpm/exe.netbsd-x64@12.21.0':
|
||||
resolution: {integrity: sha512-eyh1M8hQZCkLWxuva7S/fc1SbFbgqg0/5di0dgWmyiuc2Io3dbWVihDun8X+XM8zsR5uhIDvvZpbS9aZQbCovg==}
|
||||
cpu: [x64]
|
||||
os: [netbsd]
|
||||
|
||||
'@pnpm/exe.win32-arm64@12.21.0':
|
||||
resolution: {integrity: sha512-7xTxxUXo/grRLivSeIl6B21gnsz7ooe5EMPcJmQqwxc8WLJVReN8MzrlHru8bqXfVr4X3+6ZGZscntKenlCBqQ==}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@pnpm/exe.win32-x64@12.18.0':
|
||||
resolution: {integrity: sha512-5FJkghO7RLRkQpWxeVEygW9XsmnNuxzPfXbgwFWCHsFyFhpDn/vOdL88ToQEM0Kt5igdW5s6U0/IDH8Dvkt3pg==}
|
||||
'@pnpm/exe.win32-x64@12.21.0':
|
||||
resolution: {integrity: sha512-9TpkJemVApxJ1Z1w0ZFGN+AuSx4nJOqXSJUqMqDvaXTYwGOzvBiiWdFP9GN0ketiWCQS1Q0/pza2E7I3pP0OBQ==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
pnpm@12.18.0:
|
||||
resolution: {integrity: sha512-nXiC1dyCFH7PxOBiqjSDTgrQKWcQoYN6ERWuASEn02txCeMhrBWYod0KZVl2gbHpmRfhLtDXSerpEYeUM2O+sw==}
|
||||
pnpm@12.21.0:
|
||||
resolution: {integrity: sha512-Zv2CeO4ok1zpUXktNDZ/869cQyonVkRYIwKVM4NbjaUpu+C+UTCv1W7QcT+4eJ5Hutgtk71a4v5UsVVi1idu8A==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
snapshots:
|
||||
|
||||
'@pnpm/exe.android-arm64@12.18.0':
|
||||
'@pnpm/exe.android-arm64@12.21.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.android-x64@12.18.0':
|
||||
'@pnpm/exe.android-x64@12.21.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.darwin-arm64@12.18.0':
|
||||
'@pnpm/exe.darwin-arm64@12.21.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.darwin-x64@12.18.0':
|
||||
'@pnpm/exe.darwin-x64@12.21.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.freebsd-x64@12.18.0':
|
||||
'@pnpm/exe.freebsd-x64@12.21.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-arm64-musl@12.18.0':
|
||||
'@pnpm/exe.linux-arm64-musl@12.21.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-arm64@12.18.0':
|
||||
'@pnpm/exe.linux-arm64@12.21.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-ppc64@12.18.0':
|
||||
'@pnpm/exe.linux-ppc64@12.21.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-riscv64@12.18.0':
|
||||
'@pnpm/exe.linux-riscv64@12.21.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-s390x@12.18.0':
|
||||
'@pnpm/exe.linux-s390x@12.21.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-x64-musl@12.18.0':
|
||||
'@pnpm/exe.linux-x64-musl@12.21.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.linux-x64@12.18.0':
|
||||
'@pnpm/exe.linux-x64@12.21.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.win32-arm64@12.18.0':
|
||||
'@pnpm/exe.netbsd-x64@12.21.0':
|
||||
optional: true
|
||||
|
||||
'@pnpm/exe.win32-x64@12.18.0':
|
||||
'@pnpm/exe.win32-arm64@12.21.0':
|
||||
optional: true
|
||||
|
||||
pnpm@12.18.0:
|
||||
'@pnpm/exe.win32-x64@12.21.0':
|
||||
optional: true
|
||||
|
||||
pnpm@12.21.0:
|
||||
optionalDependencies:
|
||||
'@pnpm/exe.android-arm64': 12.18.0
|
||||
'@pnpm/exe.android-x64': 12.18.0
|
||||
'@pnpm/exe.darwin-arm64': 12.18.0
|
||||
'@pnpm/exe.darwin-x64': 12.18.0
|
||||
'@pnpm/exe.freebsd-x64': 12.18.0
|
||||
'@pnpm/exe.linux-arm64': 12.18.0
|
||||
'@pnpm/exe.linux-arm64-musl': 12.18.0
|
||||
'@pnpm/exe.linux-ppc64': 12.18.0
|
||||
'@pnpm/exe.linux-riscv64': 12.18.0
|
||||
'@pnpm/exe.linux-s390x': 12.18.0
|
||||
'@pnpm/exe.linux-x64': 12.18.0
|
||||
'@pnpm/exe.linux-x64-musl': 12.18.0
|
||||
'@pnpm/exe.win32-arm64': 12.18.0
|
||||
'@pnpm/exe.win32-x64': 12.18.0
|
||||
'@pnpm/exe.android-arm64': 12.21.0
|
||||
'@pnpm/exe.android-x64': 12.21.0
|
||||
'@pnpm/exe.darwin-arm64': 12.21.0
|
||||
'@pnpm/exe.darwin-x64': 12.21.0
|
||||
'@pnpm/exe.freebsd-x64': 12.21.0
|
||||
'@pnpm/exe.linux-arm64': 12.21.0
|
||||
'@pnpm/exe.linux-arm64-musl': 12.21.0
|
||||
'@pnpm/exe.linux-ppc64': 12.21.0
|
||||
'@pnpm/exe.linux-riscv64': 12.21.0
|
||||
'@pnpm/exe.linux-s390x': 12.21.0
|
||||
'@pnpm/exe.linux-x64': 12.21.0
|
||||
'@pnpm/exe.linux-x64-musl': 12.21.0
|
||||
'@pnpm/exe.netbsd-x64': 12.21.0
|
||||
'@pnpm/exe.win32-arm64': 12.21.0
|
||||
'@pnpm/exe.win32-x64': 12.21.0
|
||||
|
||||
---
|
||||
lockfileVersion: '9.0'
|
||||
@ -172,17 +181,17 @@ importers:
|
||||
dependencies:
|
||||
'@kuhyx/web-ui':
|
||||
specifier: github:kuhyx/utils#web_ui-v0.5.0&path:/web_ui
|
||||
version: https://codeload.github.com/kuhyx/utils/tar.gz/decf5824e609b099f9455be93c4d09b4c1fd6cae#path:/web_ui(astro@7.4.10(@types/node@26.6.6)(yaml@2.9.1))
|
||||
version: https://codeload.github.com/kuhyx/utils/tar.gz/decf5824e609b099f9455be93c4d09b4c1fd6cae#path:/web_ui(astro@7.4.12(@types/node@26.6.6)(yaml@2.9.1))
|
||||
astro:
|
||||
specifier: 7.4.10
|
||||
version: 7.4.10(@types/node@26.6.6)(yaml@2.9.1)
|
||||
specifier: 7.4.12
|
||||
version: 7.4.12(@types/node@26.6.6)(yaml@2.9.1)
|
||||
devDependencies:
|
||||
'@astrojs/check':
|
||||
specifier: 0.9.12
|
||||
version: 0.9.12(@emnapi/runtime@1.11.3)(prettier@3.9.10)(typescript@6.0.3)
|
||||
'@eslint/js':
|
||||
specifier: 10.0.1
|
||||
version: 10.0.1(eslint@10.14.0(supports-color@7.2.0))
|
||||
version: 10.0.1(eslint@10.15.0(supports-color@7.2.0))
|
||||
'@testing-library/dom':
|
||||
specifier: 10.4.2
|
||||
version: 10.4.2
|
||||
@ -190,8 +199,8 @@ importers:
|
||||
specifier: 7.0.1
|
||||
version: 7.0.1(@testing-library/dom@10.4.2)(vitest@5.1.0)
|
||||
'@testing-library/user-event':
|
||||
specifier: 14.6.9
|
||||
version: 14.6.9(@testing-library/dom@10.4.2)
|
||||
specifier: 14.6.10
|
||||
version: 14.6.10(@testing-library/dom@10.4.2)
|
||||
'@types/node':
|
||||
specifier: 26.6.6
|
||||
version: 26.6.6
|
||||
@ -199,26 +208,26 @@ importers:
|
||||
specifier: 5.1.0
|
||||
version: 5.1.0(vitest@5.1.0)
|
||||
eslint:
|
||||
specifier: 10.14.0
|
||||
version: 10.14.0(supports-color@7.2.0)
|
||||
specifier: 10.15.0
|
||||
version: 10.15.0(supports-color@7.2.0)
|
||||
eslint-plugin-astro:
|
||||
specifier: 3.2.1
|
||||
version: 3.2.1(@typescript-eslint/parser@8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript-eslint@8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))
|
||||
version: 3.2.1(@typescript-eslint/parser@8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript-eslint@8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))
|
||||
globals:
|
||||
specifier: 17.14.0
|
||||
version: 17.14.0
|
||||
jsdom:
|
||||
specifier: 31.0.0
|
||||
version: 31.0.0
|
||||
specifier: 31.0.1
|
||||
version: 31.0.1
|
||||
typescript:
|
||||
specifier: 6.0.3
|
||||
version: 6.0.3
|
||||
typescript-eslint:
|
||||
specifier: 8.72.2
|
||||
version: 8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
version: 8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
vitest:
|
||||
specifier: 5.1.0
|
||||
version: 5.1.0(@types/node@26.6.6)(@vitest/coverage-v8@5.1.0)(jsdom@31.0.0)(vite@8.3.7(@types/node@26.6.6)(yaml@2.9.1))
|
||||
version: 5.1.0(@types/node@26.6.6)(@vitest/coverage-v8@5.1.0)(jsdom@31.0.1)(vite@8.3.7(@types/node@26.6.6)(yaml@2.9.1))
|
||||
|
||||
packages:
|
||||
|
||||
@ -321,22 +330,22 @@ packages:
|
||||
prettier-plugin-astro:
|
||||
optional: true
|
||||
|
||||
'@astrojs/markdown-satteri@0.4.8':
|
||||
resolution: {integrity: sha512-IKAfvJGJ/RhXzvRkZ89kXp5woRTlRm0LVqhu8HOZAW3FAdWyZY9fYKcoVc472CJAsq8JjJjQzRkW6uaUkyufSw==}
|
||||
'@astrojs/markdown-satteri@0.4.10':
|
||||
resolution: {integrity: sha512-3h/wheVjZIcP/m295nkiUjOvCsCs6QpvZ3l4BfDU4ghNQcrcFrNVu1+K+I+YT61hH9tuCDQiGdF8QDzfDoG42w==}
|
||||
|
||||
'@astrojs/prism@4.1.2':
|
||||
resolution: {integrity: sha512-jMrUEpFDarDO1KWPvVc9eSa8DSfwBlwEOHwX+8zvZQpiqXRGDxFnOXHsYqV6DP7w+0qIgTr98gS1GdQlm8ypWg==}
|
||||
engines: {node: '>=22.23.4'}
|
||||
|
||||
'@astrojs/runtime@0.1.0':
|
||||
resolution: {integrity: sha512-Ips60LS4g0jEwOq7qOZqBhVl/6/nUDsk83bFbPBDYwtSfIiknaN48aSD+ycnwhBpUvbxQMQHv1ZotrCJFsJzPw==}
|
||||
'@astrojs/runtime@0.1.1':
|
||||
resolution: {integrity: sha512-2Tr9IJ4aQBPDFzlSLq139eWS9OZnuhL0yU2al8cCpnTE/RszygSyGIP8piBmEio1zDUaItb/+YxxsrmldUCBmg==}
|
||||
|
||||
'@astrojs/telemetry@3.4.2':
|
||||
resolution: {integrity: sha512-2JOMRUxJrBSfiVDfeKLv1wBmvSIx1Y6u2YEO8awZ9qSq3u/rNAiUyFdOYi8dHv91kHrmYEQX7pRDw0J4xyj3UA==}
|
||||
engines: {node: '>=22.23.4'}
|
||||
|
||||
'@astrojs/vite-plugin-astro@0.1.1':
|
||||
resolution: {integrity: sha512-JiRu3n9jWRFwSuarVKFYFQEqxAuy+k5Hqyr0IMmafjpd75tiPyQ4W9MTSrnjsqNs0SYcS6vGNXZ5CTwrXNSglQ==}
|
||||
'@astrojs/vite-plugin-astro@0.1.3':
|
||||
resolution: {integrity: sha512-yj+xGnr3HeHUtIdra/tWizJuisBoxAuWlBTElMlf22FpSxinrTwTl/dqftG0D2BsQTcn4/shgCCUwcnkcZ8buA==}
|
||||
peerDependencies:
|
||||
vite: ^8.3.3
|
||||
|
||||
@ -489,8 +498,8 @@ packages:
|
||||
resolution: {integrity: sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==}
|
||||
engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}
|
||||
|
||||
'@eslint/config-array@0.23.5':
|
||||
resolution: {integrity: sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==}
|
||||
'@eslint/config-array@0.23.6':
|
||||
resolution: {integrity: sha512-WrTH7nioI9QPY4NZGnsywmecswJdgeq4BCM76qok9VgjTO29ZgUzUvcuJLVPYVQM4uDbaPBU0M33R9DIxI8X3w==}
|
||||
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
|
||||
|
||||
'@eslint/config-helpers@0.7.0':
|
||||
@ -709,6 +718,9 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@isaacs/nonrecursive-glob-match@1.1.0':
|
||||
resolution: {integrity: sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==}
|
||||
|
||||
'@jridgewell/resolve-uri@3.1.2':
|
||||
resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
@ -903,8 +915,8 @@ packages:
|
||||
vitest:
|
||||
optional: true
|
||||
|
||||
'@testing-library/user-event@14.6.9':
|
||||
resolution: {integrity: sha512-/8boTjZHNXFi8JGUI2Ev05cq0Szh0OX35Bamkq6CK1ne+l1Xm8BKE3+nGgsnFgaYk0MX67Vh59cZDsNz5lJJEg==}
|
||||
'@testing-library/user-event@14.6.10':
|
||||
resolution: {integrity: sha512-tA4stGNp3mLGOGO+lh87UA56Tz4c8NVGBSkyIF58O+W/bs2Re9BCI9xihnL70+DsThncFznE0skS88SM1D2hyg==}
|
||||
engines: {node: '>=12', npm: '>=6'}
|
||||
peerDependencies:
|
||||
'@testing-library/dom': '>=7.21.4'
|
||||
@ -1165,8 +1177,8 @@ packages:
|
||||
resolution: {integrity: sha512-WavQUarfgwSbpCq4xsdcIBdX5KArfI2d6DD8EIloJIMthnB1508iNpx4C77EhUyMd03LpEt8HAPzwF/cG0V39g==}
|
||||
engines: {node: ^22.22.3 || ^24.16.0 || >=26.3.0}
|
||||
|
||||
astro@7.4.10:
|
||||
resolution: {integrity: sha512-NQfkQCCGZz3pzUy04tN3iRehKZq0S+FcjnrBwLTmVNZC6+BUAzMYxmdzLpf6Dovb6zVjMQJeMziKI4hjX3BQlw==}
|
||||
astro@7.4.12:
|
||||
resolution: {integrity: sha512-DKX+Ds0rqV49HrLwEB9JFrCyfvQeC16FCe1HrPK8S3osiJH/e2vQ22CHIDOpI48UaeiPbxPT26peXgGTy6w0ig==}
|
||||
engines: {node: '>=22.23.4', npm: '>=9.6.5', pnpm: '>=7.1.0'}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
@ -1195,6 +1207,10 @@ packages:
|
||||
boolbase@1.0.0:
|
||||
resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==}
|
||||
|
||||
brace-expansion@5.0.13:
|
||||
resolution: {integrity: sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==}
|
||||
engines: {node: 20 || >=22}
|
||||
|
||||
brace-expansion@5.0.9:
|
||||
resolution: {integrity: sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==}
|
||||
engines: {node: 20 || >=22}
|
||||
@ -1409,8 +1425,8 @@ packages:
|
||||
resolution: {integrity: sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==}
|
||||
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
|
||||
|
||||
eslint@10.14.0:
|
||||
resolution: {integrity: sha512-T0pNsxkb9IKmtQjhpK3d7nWOpFv+YHuMbTJnSVMoQblF0onvXfErrtp4V1jHtsQPan7dKaGVD0q1WCXnzMF31A==}
|
||||
eslint@10.15.0:
|
||||
resolution: {integrity: sha512-+5Wg4p+ze3sG1WErYgUO/3H1IQIfFBymVUA0Fo/XTeBOLS6UQIUekpSJ8sdRkn7O7wjh84b55w/roqavH2aScg==}
|
||||
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
@ -1627,8 +1643,8 @@ packages:
|
||||
js-tokens@4.0.0:
|
||||
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
|
||||
|
||||
jsdom@31.0.0:
|
||||
resolution: {integrity: sha512-xAkhD9z1eyFC5+QUi9K24CaZJgdCQ2GOGLW1GdVDoQvkp/AxEH9TQ0pAplPOlIiV92hfcgnFOADZypbjgbBT6Q==}
|
||||
jsdom@31.0.1:
|
||||
resolution: {integrity: sha512-CbhJL8ZQg3eKswxSZth4QO9tW0jPIhmR0vtSXQSbKSfWbwIT6hoRc17wdHIVTQ43KI0mdV5iTJr3281IDgVZ5g==}
|
||||
engines: {node: ^22.22.2 || ^24.15.0 || >=26.0.0}
|
||||
peerDependencies:
|
||||
'@napi-rs/canvas': ^1.0.13
|
||||
@ -1786,6 +1802,10 @@ packages:
|
||||
resolution: {integrity: sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==}
|
||||
engines: {node: 18 || 20 || >=22}
|
||||
|
||||
minimatch@11.0.8:
|
||||
resolution: {integrity: sha512-nFQuYSTVrGvysVBps5Ih+0BdnYFN/Cj3C816r6+p7yK+FHrVLGE4O4N9AFwykrlNlvM2HYt+Rad1Uiro6h88Ig==}
|
||||
engines: {node: 20 || >=22}
|
||||
|
||||
mri@1.2.0:
|
||||
resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==}
|
||||
engines: {node: '>=4'}
|
||||
@ -2656,7 +2676,7 @@ snapshots:
|
||||
- '@emnapi/runtime'
|
||||
- typescript
|
||||
|
||||
'@astrojs/markdown-satteri@0.4.8':
|
||||
'@astrojs/markdown-satteri@0.4.10':
|
||||
dependencies:
|
||||
'@astrojs/internal-helpers': 0.13.2
|
||||
'@astrojs/prism': 4.1.2
|
||||
@ -2667,7 +2687,7 @@ snapshots:
|
||||
dependencies:
|
||||
prismjs: 1.30.0
|
||||
|
||||
'@astrojs/runtime@0.1.0':
|
||||
'@astrojs/runtime@0.1.1':
|
||||
dependencies:
|
||||
'@oslojs/encoding': 1.1.0
|
||||
clsx: 2.1.1
|
||||
@ -2679,11 +2699,11 @@ snapshots:
|
||||
is-docker: 4.0.0
|
||||
package-manager-detector: 1.9.0
|
||||
|
||||
'@astrojs/vite-plugin-astro@0.1.1(vite@8.3.7(@types/node@26.6.6)(yaml@2.9.1))':
|
||||
'@astrojs/vite-plugin-astro@0.1.3(vite@8.3.7(@types/node@26.6.6)(yaml@2.9.1))':
|
||||
dependencies:
|
||||
'@astrojs/compiler-rs': 0.5.2
|
||||
'@astrojs/internal-helpers': 0.13.2
|
||||
'@astrojs/runtime': 0.1.0
|
||||
'@astrojs/runtime': 0.1.1
|
||||
common-ancestor-path: 2.0.0
|
||||
devalue: 6.0.3
|
||||
magic-string: 1.4.5
|
||||
@ -2820,18 +2840,18 @@ snapshots:
|
||||
dependencies:
|
||||
tslib: 2.9.1
|
||||
|
||||
'@eslint-community/eslint-utils@4.10.1(eslint@10.14.0(supports-color@7.2.0))':
|
||||
'@eslint-community/eslint-utils@4.10.1(eslint@10.15.0(supports-color@7.2.0))':
|
||||
dependencies:
|
||||
eslint: 10.14.0(supports-color@7.2.0)
|
||||
eslint: 10.15.0(supports-color@7.2.0)
|
||||
eslint-visitor-keys: 3.4.3
|
||||
|
||||
'@eslint-community/regexpp@4.12.2': {}
|
||||
|
||||
'@eslint/config-array@0.23.5(supports-color@7.2.0)':
|
||||
'@eslint/config-array@0.23.6(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
'@eslint/object-schema': 3.0.5
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
minimatch: 10.2.6
|
||||
minimatch: 11.0.8
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@ -2843,9 +2863,9 @@ snapshots:
|
||||
dependencies:
|
||||
'@types/json-schema': 7.0.15
|
||||
|
||||
'@eslint/js@10.0.1(eslint@10.14.0(supports-color@7.2.0))':
|
||||
'@eslint/js@10.0.1(eslint@10.15.0(supports-color@7.2.0))':
|
||||
optionalDependencies:
|
||||
eslint: 10.14.0(supports-color@7.2.0)
|
||||
eslint: 10.15.0(supports-color@7.2.0)
|
||||
|
||||
'@eslint/object-schema@3.0.5': {}
|
||||
|
||||
@ -2979,6 +2999,8 @@ snapshots:
|
||||
'@img/sharp-win32-x64@0.35.5':
|
||||
optional: true
|
||||
|
||||
'@isaacs/nonrecursive-glob-match@1.1.0': {}
|
||||
|
||||
'@jridgewell/resolve-uri@3.1.2': {}
|
||||
|
||||
'@jridgewell/sourcemap-codec@1.6.0': {}
|
||||
@ -2996,9 +3018,9 @@ snapshots:
|
||||
|
||||
'@keyv/serialize@1.1.1': {}
|
||||
|
||||
'@kuhyx/web-ui@https://codeload.github.com/kuhyx/utils/tar.gz/decf5824e609b099f9455be93c4d09b4c1fd6cae#path:/web_ui(astro@7.4.10(@types/node@26.6.6)(yaml@2.9.1))':
|
||||
'@kuhyx/web-ui@https://codeload.github.com/kuhyx/utils/tar.gz/decf5824e609b099f9455be93c4d09b4c1fd6cae#path:/web_ui(astro@7.4.12(@types/node@26.6.6)(yaml@2.9.1))':
|
||||
dependencies:
|
||||
astro: 7.4.10(@types/node@26.6.6)(yaml@2.9.1)
|
||||
astro: 7.4.12(@types/node@26.6.6)(yaml@2.9.1)
|
||||
|
||||
'@napi-rs/wasm-runtime@1.2.4(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)':
|
||||
dependencies:
|
||||
@ -3127,9 +3149,9 @@ snapshots:
|
||||
picocolors: 1.1.1
|
||||
redent: 3.0.0
|
||||
optionalDependencies:
|
||||
vitest: 5.1.0(@types/node@26.6.6)(@vitest/coverage-v8@5.1.0)(jsdom@31.0.0)(vite@8.3.7(@types/node@26.6.6)(yaml@2.9.1))
|
||||
vitest: 5.1.0(@types/node@26.6.6)(@vitest/coverage-v8@5.1.0)(jsdom@31.0.1)(vite@8.3.7(@types/node@26.6.6)(yaml@2.9.1))
|
||||
|
||||
'@testing-library/user-event@14.6.9(@testing-library/dom@10.4.2)':
|
||||
'@testing-library/user-event@14.6.10(@testing-library/dom@10.4.2)':
|
||||
dependencies:
|
||||
'@testing-library/dom': 10.4.2
|
||||
|
||||
@ -3174,15 +3196,15 @@ snapshots:
|
||||
|
||||
'@types/unist@3.0.3': {}
|
||||
|
||||
'@typescript-eslint/eslint-plugin@8.72.2(@typescript-eslint/parser@8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)':
|
||||
'@typescript-eslint/eslint-plugin@8.72.2(@typescript-eslint/parser@8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)':
|
||||
dependencies:
|
||||
'@eslint-community/regexpp': 4.12.2
|
||||
'@typescript-eslint/parser': 8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/parser': 8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/scope-manager': 8.72.2
|
||||
'@typescript-eslint/type-utils': 8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/utils': 8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/type-utils': 8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/utils': 8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/visitor-keys': 8.72.2
|
||||
eslint: 10.14.0(supports-color@7.2.0)
|
||||
eslint: 10.15.0(supports-color@7.2.0)
|
||||
ignore: 7.0.6
|
||||
natural-compare: 1.4.0
|
||||
ts-api-utils: 2.5.0(typescript@6.0.3)
|
||||
@ -3190,14 +3212,14 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/parser@8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)':
|
||||
'@typescript-eslint/parser@8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)':
|
||||
dependencies:
|
||||
'@typescript-eslint/scope-manager': 8.72.2
|
||||
'@typescript-eslint/types': 8.72.2
|
||||
'@typescript-eslint/typescript-estree': 8.72.2(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/visitor-keys': 8.72.2
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
eslint: 10.14.0(supports-color@7.2.0)
|
||||
eslint: 10.15.0(supports-color@7.2.0)
|
||||
typescript: 6.0.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@ -3225,13 +3247,13 @@ snapshots:
|
||||
dependencies:
|
||||
typescript: 6.0.3
|
||||
|
||||
'@typescript-eslint/type-utils@8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)':
|
||||
'@typescript-eslint/type-utils@8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)':
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 8.72.2
|
||||
'@typescript-eslint/typescript-estree': 8.72.2(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/utils': 8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/utils': 8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
debug: 4.4.3(supports-color@7.2.0)
|
||||
eslint: 10.14.0(supports-color@7.2.0)
|
||||
eslint: 10.15.0(supports-color@7.2.0)
|
||||
ts-api-utils: 2.5.0(typescript@6.0.3)
|
||||
typescript: 6.0.3
|
||||
transitivePeerDependencies:
|
||||
@ -3256,13 +3278,13 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/utils@8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)':
|
||||
'@typescript-eslint/utils@8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)':
|
||||
dependencies:
|
||||
'@eslint-community/eslint-utils': 4.10.1(eslint@10.14.0(supports-color@7.2.0))
|
||||
'@eslint-community/eslint-utils': 4.10.1(eslint@10.15.0(supports-color@7.2.0))
|
||||
'@typescript-eslint/scope-manager': 8.72.2
|
||||
'@typescript-eslint/types': 8.72.2
|
||||
'@typescript-eslint/typescript-estree': 8.72.2(supports-color@7.2.0)(typescript@6.0.3)
|
||||
eslint: 10.14.0(supports-color@7.2.0)
|
||||
eslint: 10.15.0(supports-color@7.2.0)
|
||||
typescript: 6.0.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@ -3289,7 +3311,7 @@ snapshots:
|
||||
obug: 3.0.0
|
||||
std-env: 4.3.0
|
||||
tinyrainbow: 3.2.0
|
||||
vitest: 5.1.0(@types/node@26.6.6)(@vitest/coverage-v8@5.1.0)(jsdom@31.0.0)(vite@8.3.7(@types/node@26.6.6)(yaml@2.9.1))
|
||||
vitest: 5.1.0(@types/node@26.6.6)(@vitest/coverage-v8@5.1.0)(jsdom@31.0.1)(vite@8.3.7(@types/node@26.6.6)(yaml@2.9.1))
|
||||
|
||||
'@vitest/istanbul-lib-coverage@2.1.0': {}
|
||||
|
||||
@ -3438,14 +3460,14 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
astro@7.4.10(@types/node@26.6.6)(yaml@2.9.1):
|
||||
astro@7.4.12(@types/node@26.6.6)(yaml@2.9.1):
|
||||
dependencies:
|
||||
'@astrojs/compiler-rs': 0.5.2
|
||||
'@astrojs/internal-helpers': 0.13.2
|
||||
'@astrojs/markdown-satteri': 0.4.8
|
||||
'@astrojs/runtime': 0.1.0
|
||||
'@astrojs/markdown-satteri': 0.4.10
|
||||
'@astrojs/runtime': 0.1.1
|
||||
'@astrojs/telemetry': 3.4.2
|
||||
'@astrojs/vite-plugin-astro': 0.1.1(vite@8.3.7(@types/node@26.6.6)(yaml@2.9.1))
|
||||
'@astrojs/vite-plugin-astro': 0.1.3(vite@8.3.7(@types/node@26.6.6)(yaml@2.9.1))
|
||||
'@capsizecss/unpack': 4.0.1
|
||||
'@clack/prompts': 1.8.1
|
||||
'@oslojs/encoding': 1.1.0
|
||||
@ -3543,6 +3565,10 @@ snapshots:
|
||||
|
||||
boolbase@1.0.0: {}
|
||||
|
||||
brace-expansion@5.0.13:
|
||||
dependencies:
|
||||
balanced-match: 4.0.4
|
||||
|
||||
brace-expansion@5.0.9:
|
||||
dependencies:
|
||||
balanced-match: 4.0.4
|
||||
@ -3701,21 +3727,21 @@ snapshots:
|
||||
|
||||
escape-string-regexp@4.0.0: {}
|
||||
|
||||
eslint-plugin-astro@3.2.1(@typescript-eslint/parser@8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript-eslint@8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)):
|
||||
eslint-plugin-astro@3.2.1(@typescript-eslint/parser@8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript-eslint@8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)):
|
||||
dependencies:
|
||||
'@eslint-community/eslint-utils': 4.10.1(eslint@10.14.0(supports-color@7.2.0))
|
||||
'@eslint-community/eslint-utils': 4.10.1(eslint@10.15.0(supports-color@7.2.0))
|
||||
'@jridgewell/sourcemap-codec': 1.6.0
|
||||
'@typescript-eslint/types': 8.72.1
|
||||
astro-eslint-parser: 3.2.0(supports-color@7.2.0)
|
||||
eslint: 10.14.0(supports-color@7.2.0)
|
||||
eslint: 10.15.0(supports-color@7.2.0)
|
||||
espree: 11.2.0
|
||||
globals: 17.14.0
|
||||
postcss: 8.5.31
|
||||
postcss-selector-parser: 7.1.7
|
||||
synckit: 0.11.13
|
||||
optionalDependencies:
|
||||
'@typescript-eslint/parser': 8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
typescript-eslint: 8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/parser': 8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
typescript-eslint: 8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@ -3730,11 +3756,11 @@ snapshots:
|
||||
|
||||
eslint-visitor-keys@5.0.1: {}
|
||||
|
||||
eslint@10.14.0(supports-color@7.2.0):
|
||||
eslint@10.15.0(supports-color@7.2.0):
|
||||
dependencies:
|
||||
'@eslint-community/eslint-utils': 4.10.1(eslint@10.14.0(supports-color@7.2.0))
|
||||
'@eslint-community/eslint-utils': 4.10.1(eslint@10.15.0(supports-color@7.2.0))
|
||||
'@eslint-community/regexpp': 4.12.2
|
||||
'@eslint/config-array': 0.23.5(supports-color@7.2.0)
|
||||
'@eslint/config-array': 0.23.6(supports-color@7.2.0)
|
||||
'@eslint/config-helpers': 0.7.0
|
||||
'@eslint/core': 1.2.1
|
||||
'@eslint/plugin-kit': 0.7.3
|
||||
@ -3759,7 +3785,7 @@ snapshots:
|
||||
imurmurhash: 0.1.4
|
||||
is-glob: 4.0.3
|
||||
json-stable-stringify-without-jsonify: 1.0.1
|
||||
minimatch: 10.2.6
|
||||
minimatch: 11.0.8
|
||||
natural-compare: 1.4.0
|
||||
optionator: 0.9.4
|
||||
transitivePeerDependencies:
|
||||
@ -3951,7 +3977,7 @@ snapshots:
|
||||
|
||||
js-tokens@4.0.0: {}
|
||||
|
||||
jsdom@31.0.0:
|
||||
jsdom@31.0.1:
|
||||
dependencies:
|
||||
'@exodus/bytes': 1.16.0
|
||||
bcp-47: 2.1.2
|
||||
@ -4101,6 +4127,11 @@ snapshots:
|
||||
dependencies:
|
||||
brace-expansion: 5.0.9
|
||||
|
||||
minimatch@11.0.8:
|
||||
dependencies:
|
||||
'@isaacs/nonrecursive-glob-match': 1.1.0
|
||||
brace-expansion: 5.0.13
|
||||
|
||||
mri@1.2.0: {}
|
||||
|
||||
mrmime@2.0.1: {}
|
||||
@ -4469,13 +4500,13 @@ snapshots:
|
||||
dependencies:
|
||||
semver: 7.8.5
|
||||
|
||||
typescript-eslint@8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3):
|
||||
typescript-eslint@8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3):
|
||||
dependencies:
|
||||
'@typescript-eslint/eslint-plugin': 8.72.2(@typescript-eslint/parser@8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/parser': 8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/eslint-plugin': 8.72.2(@typescript-eslint/parser@8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/parser': 8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/typescript-estree': 8.72.2(supports-color@7.2.0)(typescript@6.0.3)
|
||||
'@typescript-eslint/utils': 8.72.2(eslint@10.14.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
eslint: 10.14.0(supports-color@7.2.0)
|
||||
'@typescript-eslint/utils': 8.72.2(eslint@10.15.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
eslint: 10.15.0(supports-color@7.2.0)
|
||||
typescript: 6.0.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@ -4577,7 +4608,7 @@ snapshots:
|
||||
optionalDependencies:
|
||||
vite: 8.3.7(@types/node@26.6.6)(yaml@2.9.1)
|
||||
|
||||
vitest@5.1.0(@types/node@26.6.6)(@vitest/coverage-v8@5.1.0)(jsdom@31.0.0)(vite@8.3.7(@types/node@26.6.6)(yaml@2.9.1)):
|
||||
vitest@5.1.0(@types/node@26.6.6)(@vitest/coverage-v8@5.1.0)(jsdom@31.0.1)(vite@8.3.7(@types/node@26.6.6)(yaml@2.9.1)):
|
||||
dependencies:
|
||||
'@types/chai': 5.2.3
|
||||
'@vitest/mocker': 5.1.0(vite@8.3.7(@types/node@26.6.6)(yaml@2.9.1))
|
||||
@ -4596,7 +4627,7 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@types/node': 26.6.6
|
||||
'@vitest/coverage-v8': 5.1.0(vitest@5.1.0)
|
||||
jsdom: 31.0.0
|
||||
jsdom: 31.0.1
|
||||
transitivePeerDependencies:
|
||||
- msw
|
||||
|
||||
|
||||
@ -61,6 +61,13 @@ export type JobEvent =
|
||||
| (JobEventBase & { type: 'state'; state: JobState })
|
||||
| (JobEventBase & { type: 'log'; level: 'info' | 'warning' | 'error'; message: string })
|
||||
| (JobEventBase & { type: 'progress' } & JobProgress)
|
||||
/**
|
||||
* Sent only by commands with a cancel window (`done`, `pick`, `pick-manual`,
|
||||
* `hide`; `check` has the flag but no hide step yet). The job is cancellable only while `open` is true
|
||||
* (it is hiding games in the Steam library); `POST …/cancel` is refused
|
||||
* outside it.
|
||||
*/
|
||||
| (JobEventBase & { type: 'cancel_window'; open: boolean })
|
||||
| (JobEventBase & {
|
||||
type: 'prompt'
|
||||
prompt_id: string
|
||||
|
||||
@ -24,14 +24,16 @@ export interface LiveJob {
|
||||
connected: boolean
|
||||
/** Seconds since epoch of the first progress event, for rate display. */
|
||||
startedProgressAt: number | null
|
||||
/** A job that is not cancellable as a command can be, right now. */
|
||||
cancelWindowOpen: boolean
|
||||
}
|
||||
|
||||
const EMPTY: LiveJob = {
|
||||
lastSeq: 0, state: null, progress: null, logs: [], prompt: null, result: null,
|
||||
connected: false, startedProgressAt: null,
|
||||
connected: false, startedProgressAt: null, cancelWindowOpen: false,
|
||||
}
|
||||
const TERMINAL = new Set<JobState>(['succeeded', 'failed', 'cancelled'])
|
||||
const EVENT_TYPES = ['state', 'log', 'progress', 'prompt', 'result'] as const
|
||||
const EVENT_TYPES = ['state', 'log', 'progress', 'cancel_window', 'prompt', 'result'] as const
|
||||
const MAX_LOGS = 500
|
||||
|
||||
function reduce(live: LiveJob, e: JobEvent): LiveJob {
|
||||
@ -50,6 +52,9 @@ function reduce(live: LiveJob, e: JobEvent): LiveJob {
|
||||
next.startedProgressAt ??= Date.now() / 1000
|
||||
break
|
||||
}
|
||||
case 'cancel_window':
|
||||
next.cancelWindowOpen = e.open
|
||||
break
|
||||
case 'prompt':
|
||||
next.prompt = e
|
||||
break
|
||||
|
||||
44
web/src/jobs/jobProgress.cancelWindow.test.ts
Normal file
44
web/src/jobs/jobProgress.cancelWindow.test.ts
Normal file
@ -0,0 +1,44 @@
|
||||
// A done/check job is not cancellable as a command, but it announces a cancel
|
||||
// window while it hides games in the Steam library: Cancel shows only then.
|
||||
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { bodiesOf, installEventSource } from '../test/harness'
|
||||
import { button } from '../test/events'
|
||||
import { mountJob } from '../test/jobHelpers'
|
||||
|
||||
beforeEach(installEventSource)
|
||||
|
||||
const cancelButton = (el: Element) => el.querySelector('[aria-label="Cancel job"]')
|
||||
|
||||
describe('<job-progress> cancel window', () => {
|
||||
it('shows Cancel only while the job reports the window open', async () => {
|
||||
const { el, send } = mountJob({ cancellable: false })
|
||||
await vi.waitFor(() => { expect(el.querySelector('section')).not.toBeNull() })
|
||||
send('state', { state: 'running' })
|
||||
expect(cancelButton(el)).toBeNull()
|
||||
|
||||
send('cancel_window', { open: true })
|
||||
expect(cancelButton(el)).not.toBeNull()
|
||||
|
||||
send('cancel_window', { open: false })
|
||||
expect(cancelButton(el)).toBeNull()
|
||||
})
|
||||
|
||||
it('cancels through the API from inside the window', async () => {
|
||||
const { el, send, routes, id, mock } = mountJob({ cancellable: false })
|
||||
routes[`POST /api/jobs/${id}/cancel`] = undefined
|
||||
send('state', { state: 'running' })
|
||||
send('cancel_window', { open: true })
|
||||
button(el, 'Cancel job').click()
|
||||
await vi.waitFor(() => {
|
||||
expect(bodiesOf(mock, `POST /api/jobs/${id}/cancel`)).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
it('drops the button once the job has finished, window or not', () => {
|
||||
const { el, send } = mountJob({ cancellable: false })
|
||||
send('cancel_window', { open: true })
|
||||
send('state', { state: 'succeeded' })
|
||||
expect(cancelButton(el)).toBeNull()
|
||||
})
|
||||
})
|
||||
@ -180,7 +180,7 @@ export class JobProgressElement extends LiveElement {
|
||||
)
|
||||
f.actions.replaceChildren(
|
||||
...(this.cancel.error ? [errorNotice(this.cancel.error)] : []),
|
||||
...((spec?.cancellable || waiting) && !finished
|
||||
...((spec?.cancellable || waiting || live.cancelWindowOpen) && !finished
|
||||
? [
|
||||
h(
|
||||
'div',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user