From 9cb0ebbed623f7137e3b20a5a4f4c45ead69d1ba Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sun, 22 Nov 2026 20:47:22 +0100 Subject: [PATCH] Install params icons and result marks in UI The install dialog paints its own icons for the new target, dry-run and Valve-Proton params. A job result paints a dry-run mark, or a game-running mark when the fast installer (it closes Steam) was skipped because a game was running (InstallResultData). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WzxdWZCxnNWLtpVwFLVk9w --- web/src/api/contract.ts | 8 ++++++++ web/src/commands/paramsForm.test.ts | 13 +++++++++++++ web/src/commands/paramsForm.ts | 3 +++ web/src/icons/registry.json | 7 ++++++- web/src/jobs/jobProgress.ts | 6 +++++- web/src/jobs/resultMarks.test.ts | 30 +++++++++++++++++++++++++++++ web/src/jobs/resultMarks.ts | 21 ++++++++++++++++++++ 7 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 web/src/jobs/resultMarks.test.ts create mode 100644 web/src/jobs/resultMarks.ts diff --git a/web/src/api/contract.ts b/web/src/api/contract.ts index 9b534bb..102515a 100644 --- a/web/src/api/contract.ts +++ b/web/src/api/contract.ts @@ -86,6 +86,14 @@ export interface CommandSpec { view_endpoint?: string } +/** `install`'s `result.data` once a game was chosen (else the assignment). */ +export interface InstallResultData { + app_id: number + dry_run: boolean + /** Why the fast installer (it closes Steam) was not used. */ + fast_install_skipped: 'game_running' | null +} + // ---- views --------------------------------------------------------------- export interface ManualPickInfo { diff --git a/web/src/commands/paramsForm.test.ts b/web/src/commands/paramsForm.test.ts index d5c779d..f5595e0 100644 --- a/web/src/commands/paramsForm.test.ts +++ b/web/src/commands/paramsForm.test.ts @@ -136,3 +136,16 @@ describe('ParamsForm', () => { expect(document.querySelector('.field-help')?.textContent).toBe('') }) }) + +describe('install params', () => { + it('paints its own icon for target, dry run and Valve Proton', () => { + const specs: ParamSpec[] = [ + { name: 'target', label: 't', type: 'string', required: false }, + { name: 'dry_run', label: 'd', type: 'bool', required: false, default: 0 }, + { name: 'valve_proton', label: 'v', type: 'bool', required: false, default: 0 }, + ] + const form = new ParamsForm({ specs, values: {}, disabled: false, onChange: () => undefined }) + const ids = form.nodes.map((n) => n.querySelector('[data-icon]')?.getAttribute('data-icon')) + expect(ids).toEqual(['params.target', 'params.dry_run', 'params.valve_proton']) + }) +}) diff --git a/web/src/commands/paramsForm.ts b/web/src/commands/paramsForm.ts index 5710c89..71b9d53 100644 --- a/web/src/commands/paramsForm.ts +++ b/web/src/commands/paramsForm.ts @@ -19,6 +19,9 @@ const PARAM_ICON: Record = { reason: 'params.reason', replace: 'params.replace', demo: 'params.demo', + target: 'params.target', + dry_run: 'params.dry_run', + valve_proton: 'params.valve_proton', } function paramGlyph(spec: ParamSpec): HTMLSpanElement { diff --git a/web/src/icons/registry.json b/web/src/icons/registry.json index a719ad7..4723bd7 100644 --- a/web/src/icons/registry.json +++ b/web/src/icons/registry.json @@ -264,6 +264,11 @@ "health.unknown": { "glyph": "โ€ฆ", "spoken": "Unknown", "desc": "State mark on a health badge before the daemon state is known.", "words": ["unknown", "loading", "pending"], "alts": ["โ”", "๐Ÿ’ค", "๐Ÿ”˜"] }, "health.stale": { "glyph": "โš ๏ธ๐ŸŒ", "spoken": "Stale server", "desc": "Banner mark: the running server is older than the code on disk. The restart button beside it fixes that.", "words": ["stale", "outdated", "old"], "alts": ["๐Ÿ•ฐ๏ธ๐ŸŒ", "๐Ÿฅ€", "๐Ÿ“›"] }, "dialog.close": { "glyph": "ร—", "spoken": "Close", "desc": "Close button in the corner of every dialog.", "words": ["close", "exit", "dismiss"], "alts": ["โœ–๏ธ", "โŒ", "๐Ÿšช"] }, - "words.page": { "glyph": "๐Ÿท๏ธ", "spoken": "Icon words", "desc": "Command palette entry that opens this icon-words picker. You are here now.", "words": ["words", "labels", "names"], "alts": ["๐Ÿ”–", "๐Ÿ—จ๏ธ", "๐Ÿ”ค"] } + "words.page": { "glyph": "๐Ÿท๏ธ", "spoken": "Icon words", "desc": "Command palette entry that opens this icon-words picker. You are here now.", "words": ["words", "labels", "names"], "alts": ["๐Ÿ”–", "๐Ÿ—จ๏ธ", "๐Ÿ”ค"] }, + "params.target": { "glyph": "๐ŸŽฏ", "spoken": "Game", "desc": "Install dialog field: an AppID, a Steam URL or a name. Only games allowed today install; an ambiguous name asks you to pick.", "words": ["game", "target", "which"], "alts": ["๐Ÿ”Ž", "๐Ÿ†”", "๐Ÿ•น๏ธ"] }, + "params.dry_run": { "glyph": "๐Ÿ”", "spoken": "Dry run", "desc": "Switch in the install dialog: show what the installer would do and change nothing.", "words": ["preview", "dry-run", "simulate"], "alts": ["๐Ÿ‘“", "๐Ÿ“‹", "๐Ÿง"] }, + "params.valve_proton": { "glyph": "โš›๏ธ", "spoken": "Valve Proton", "desc": "Switch in the install dialog: keep the game on Valve's default Proton instead of the mapped one.", "words": ["proton", "valve", "default"], "alts": ["๐Ÿท", "๐Ÿงช", "๐Ÿ”ง"] }, + "result.dry-run": { "glyph": "๐Ÿ”", "spoken": "Dry run", "desc": "Mark on an install result: it was a dry run, nothing was installed or changed.", "words": ["preview", "dry-run", "simulated"], "alts": ["๐Ÿ‘“", "๐Ÿ“‹", "๐Ÿง"] }, + "result.game-running": { "glyph": "๐ŸŽฎโธ๏ธ", "spoken": "Game running", "desc": "Mark on an install result: a game was running, so the fast installer (which closes Steam) was skipped and Steam's own download started.", "words": ["playing", "running", "busy"], "alts": ["๐ŸŽฎ๐Ÿ”’", "๐Ÿ•น๏ธโธ๏ธ", "๐ŸŽฎโš ๏ธ"] } } } diff --git a/web/src/jobs/jobProgress.ts b/web/src/jobs/jobProgress.ts index c9dd73c..a8b077b 100644 --- a/web/src/jobs/jobProgress.ts +++ b/web/src/jobs/jobProgress.ts @@ -18,6 +18,7 @@ import { clock, duration, logTime } from '../ui/format' import { hub, type LiveJob } from './hub' import { progressBar, stateBadge } from './progress' import { promptForm } from './promptForm' +import { resultMarks } from './resultMarks' /** Remaining seconds: the job's own estimate, else extrapolated from pace. */ export function eta(p: Progress, live: LiveJob, now: number): number | null { @@ -177,7 +178,10 @@ export class JobProgressElement extends LiveElement { this.updatePrompt(f, live, state) f.result.replaceChildren( ...(live.result - ? [notice(live.result.ok ? 'success' : 'danger', null, h('span', { class: 'sr-only' }, live.result.summary))] + ? [ + notice(live.result.ok ? 'success' : 'danger', null, ...resultMarks(live.result.data).map((id) => glyph(id)), + h('span', { class: 'sr-only' }, live.result.summary)), + ] : []), ) f.actions.replaceChildren( diff --git a/web/src/jobs/resultMarks.test.ts b/web/src/jobs/resultMarks.test.ts new file mode 100644 index 0000000..4e41660 --- /dev/null +++ b/web/src/jobs/resultMarks.test.ts @@ -0,0 +1,30 @@ +import { beforeEach, describe, expect, it } from 'vitest' +import { installEventSource } from '../test/harness' +import { mountJob } from '../test/jobHelpers' +import { resultMarks } from './resultMarks' + +beforeEach(installEventSource) + +describe('resultMarks', () => { + it('marks a dry run and a fast install skipped for a running game', () => { + expect(resultMarks({ app_id: 3, dry_run: true, fast_install_skipped: null })).toEqual(['result.dry-run']) + expect(resultMarks({ app_id: 3, dry_run: false, fast_install_skipped: 'game_running' })).toEqual(['result.game-running']) + }) + it('ignores anything that is not install data', () => { + expect(resultMarks(undefined)).toEqual([]) + expect(resultMarks(null)).toEqual([]) + expect(resultMarks('x')).toEqual([]) + expect(resultMarks({ dry_run: 'yes', fast_install_skipped: 'other' })).toEqual([]) + }) +}) + +describe(' result marks', () => { + it('paints the game-running mark beside the result', () => { + const { el, send } = mountJob() + send('result', { ok: true, summary: 'x', data: { app_id: 3, dry_run: false, fast_install_skipped: 'game_running' } }) + const mark = el.querySelector('[data-icon="result.game-running"]') + expect(mark).not.toBeNull() + expect(mark).toHaveAttribute('title') + expect(el.querySelector('[data-icon="result.dry-run"]')).toBeNull() + }) +}) diff --git a/web/src/jobs/resultMarks.ts b/web/src/jobs/resultMarks.ts new file mode 100644 index 0000000..b4ca07c --- /dev/null +++ b/web/src/jobs/resultMarks.ts @@ -0,0 +1,21 @@ +// Painted marks for what a job's `result.data` says (textgate: icons, the +// summary stays spoken). Only `install` sends these flags today +// (`InstallResultData` in the contract); any other data paints nothing. + +import type { InstallResultData } from '../api/contract' +import type { IconId } from '../icons/registry' + +/** Runtime check at the event-stream boundary: `data` is `unknown` there. */ +function isInstallResultData(data: unknown): data is InstallResultData { + if (typeof data !== 'object' || data === null) return false + const d = data as Record + return typeof d.dry_run === 'boolean' && (d.fast_install_skipped === null || d.fast_install_skipped === 'game_running') +} + +export function resultMarks(data: unknown): IconId[] { + if (!isInstallResultData(data)) return [] + const marks: IconId[] = [] + if (data.dry_run) marks.push('result.dry-run') + if (data.fast_install_skipped === 'game_running') marks.push('result.game-running') + return marks +}