diff --git a/steam_backlog_enforcer/_web_store_report.py b/steam_backlog_enforcer/_web_store_report.py index 95cf499..1d8b8fe 100644 --- a/steam_backlog_enforcer/_web_store_report.py +++ b/steam_backlog_enforcer/_web_store_report.py @@ -6,9 +6,9 @@ the ``store_unblock`` call itself. A failed end-of-window re-block happens in the daemon with nobody asking, so a background thread fetches those reports every minute (``store_reports``) and records each as a failed job. -The re-block job is recorded under the ``unblock`` command with -``params.phase = "re-block"``: the web UI knows only catalog commands, and a -new one would need its own icon. +The re-block job is recorded under its own ``re-block`` command, a job-only +name like ``restore-backup``: the web contract and icon registry list it, the +CLI has no such command. """ from __future__ import annotations @@ -64,8 +64,7 @@ def record_reblock_failure(report: Mapping[str, object]) -> str: log=filing_log(report), ) created_at = datetime.now().astimezone().isoformat() - params = {"phase": "re-block"} - return record_daemon_job("unblock", params, created_at=created_at, outcome=outcome) + return record_daemon_job("re-block", {}, created_at=created_at, outcome=outcome) def collect_store_reports() -> int: diff --git a/steam_backlog_enforcer/tests/test_web_store_report.py b/steam_backlog_enforcer/tests/test_web_store_report.py index 3877ac0..4eeb321 100644 --- a/steam_backlog_enforcer/tests/test_web_store_report.py +++ b/steam_backlog_enforcer/tests/test_web_store_report.py @@ -112,6 +112,7 @@ def test_collect_records_one_failed_reblock_job_per_report(filer: MagicMock) -> (job,) = list_jobs() assert job["summary"] == "Store re-block failed: dns" assert job["state"] == "failed" + assert job["command"] == "re-block" filer.assert_called_once_with(report) diff --git a/web/src/api/contract.ts b/web/src/api/contract.ts index 4a9d537..9b534bb 100644 --- a/web/src/api/contract.ts +++ b/web/src/api/contract.ts @@ -32,6 +32,8 @@ export type CommandName = | 'serve' /** Job spawned by `POST /api/backups/{id}/restore`, not a CLI command. */ | 'restore-backup' + /** Failed end-of-window store re-block the web server records; never started by hand. */ + | 're-block' /** How the UI surfaces a command. */ export type CommandKind = diff --git a/web/src/commands/catalog.ts b/web/src/commands/catalog.ts index cb9ddc8..749b84d 100644 --- a/web/src/commands/catalog.ts +++ b/web/src/commands/catalog.ts @@ -43,6 +43,7 @@ export const COMMAND_HOME = { 'gaming-unblock': '/gaming', serve: '/system', 'restore-backup': '/system', + 're-block': '/store', } as const satisfies Record /** A command's registered icon id (`cmd.`); the compiler proves every command has one. */ diff --git a/web/src/icons/coverage.test.ts b/web/src/icons/coverage.test.ts index f079296..68da6f4 100644 --- a/web/src/icons/coverage.test.ts +++ b/web/src/icons/coverage.test.ts @@ -48,9 +48,9 @@ describe('icon words cover the whole UI', () => { expect(hits, `${hits.length} unregistered icon sites`).toEqual([]) }) - it('the first 45 registry entries are the answered pass-1 icons, so the picker opens after them', () => { + it('the first 46 registry entries are the pass-1 icons (all answered but cmd.re-block), then the rest', () => { const ids = ICONS.map((e) => e.id) - expect(ids.slice(0, 45).filter((id) => /^(nav|palette|cmd|job\.state|notice)\./.test(id))).toHaveLength(45) - expect(ids[44]).toBe('notice.danger') + expect(ids.slice(0, 46).filter((id) => /^(nav|palette|cmd|job\.state|notice)\./.test(id))).toHaveLength(46) + expect(ids[45]).toBe('notice.danger') }) }) diff --git a/web/src/icons/registry.json b/web/src/icons/registry.json index e1f4d02..a719ad7 100644 --- a/web/src/icons/registry.json +++ b/web/src/icons/registry.json @@ -35,6 +35,7 @@ "cmd.gaming-reset": { "glyph": "âĒ", "spoken": "Gaming reset", "desc": "Runs gaming reset: resets today's gaming counter as root, after a typed phrase and a five-minute countdown.", "words": ["rewind", "reset", "refill"], "alts": ["âŽī¸", "🔙", "🔂"] }, "cmd.gaming-unblock": { "glyph": "🔌", "spoken": "Gaming unblock", "desc": "Runs gaming unblock: force-releases the playtime bind mounts. It is the root recovery hatch.", "words": ["release", "unplug", "recover"], "alts": ["đŸĒĢ", "🆘", "đŸ§¯"] }, "cmd.serve": { "glyph": "🌐", "spoken": "Serve", "desc": "Restarts this web UI server. It comes back on the current code by itself.", "words": ["server", "web", "restart"], "alts": ["đŸ•¸ī¸", "đŸ“ļ", "🔗"] }, + "cmd.re-block": { "glyph": "🔒", "spoken": "Re-block", "desc": "The daemon's end-of-window store re-block. It shows up as a job only when its checks failed.", "words": ["reblock", "relock", "close"], "alts": ["🛒🔒", "🚧", "🔐"] }, "cmd.restore-backup": { "glyph": "đŸ—„ī¸", "spoken": "Restore backup", "desc": "Restores a saved state backup after you type its phrase.", "words": ["restore", "backup", "rollback"], "alts": ["đŸ’ŧ", "đŸ§ŗ", "đŸ“ŧ"] }, "job.state.queued": { "glyph": "â¸ī¸", "spoken": "Queued", "desc": "Job state badge: the job waits to start.", "words": ["queued", "waiting", "pending"], "alts": ["🕒", "âŗ", "💤"] }, "job.state.running": { "glyph": "â–ļī¸", "spoken": "Running", "desc": "Job state badge: the job is running now.", "words": ["running", "active", "busy"], "alts": ["🏃", "⚡", "đŸ”ĩ"] }, diff --git a/web/src/icons/registry.test.ts b/web/src/icons/registry.test.ts index ee628cd..51d6486 100644 --- a/web/src/icons/registry.test.ts +++ b/web/src/icons/registry.test.ts @@ -9,13 +9,13 @@ const JOB_STATES: JobState[] = ['queued', 'running', 'waiting_input', 'succeeded const TONES: Tone[] = ['info', 'success', 'warning', 'danger'] describe('icon registry', () => { - it('registers pass 1 first (8 nav, the palette, 26 commands, 6 job states, 4 tones), then the rest of the UI', () => { + it('registers pass 1 first (8 nav, the palette, 27 commands, 6 job states, 4 tones), then the rest of the UI', () => { const ids = ICONS.map((e) => e.id) expect(new Set(ids).size).toBe(ids.length) const pass1 = /^(nav|palette|cmd|job\.state|notice)\./ - expect(ids.slice(0, 8 + 1 + 26 + 6 + 4).every((id) => pass1.test(id))).toBe(true) - expect(ids.slice(8 + 1 + 26 + 6 + 4).some((id) => pass1.test(id))).toBe(false) - expect(ids.length).toBeGreaterThan(45) + expect(ids.slice(0, 8 + 1 + 27 + 6 + 4).every((id) => pass1.test(id))).toBe(true) + expect(ids.slice(8 + 1 + 27 + 6 + 4).some((id) => pass1.test(id))).toBe(false) + expect(ids.length).toBeGreaterThan(46) for (const n of NAV) expect(isIconId(n.icon)).toBe(true) expect(isIconId('palette.open')).toBe(true) for (const name of Object.keys(COMMAND_HOME) as (keyof typeof COMMAND_HOME)[]) { diff --git a/web/src/jobs/jobs.icons.test.ts b/web/src/jobs/jobs.icons.test.ts index 5530367..ed08a10 100644 --- a/web/src/jobs/jobs.icons.test.ts +++ b/web/src/jobs/jobs.icons.test.ts @@ -30,6 +30,12 @@ describe('job view icons', () => { expect(word(icon)).toBe('Survey') }) + it('a failed end-of-window re-block shows as its own re-block job', async () => { + const { el } = mountJob({ job: { command: 're-block', state: 'failed' } }) + await vi.waitFor(() => { expect(el.querySelector('h3 .sr-only')).toHaveTextContent('Re block') }) + expect(el.querySelector('h3 [data-icon="cmd.re-block"]')?.textContent).toBe('🔒') + }) + it('the phase mark, the log count and the cancel button use their ids', async () => { useIcons({ 'job.state.running': { word: 'busy' }, 'jobs.log': { word: 'log' }, 'jobs.cancel': { word: 'stop' } }) const { el, send } = mountJob({ job: { state: 'running' }, cancellable: true })