mirror of
https://github.com/kuhyx/steam-backlog-enforcer.git
synced 2026-11-22 23:02:19 +01:00
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWZCxnNWLtpVwFLVk9w
This commit is contained in:
parent
c9ae0bf0b1
commit
9cb0ebbed6
@ -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 {
|
||||
|
||||
@ -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'])
|
||||
})
|
||||
})
|
||||
|
||||
@ -19,6 +19,9 @@ const PARAM_ICON: Record<string, IconId> = {
|
||||
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 {
|
||||
|
||||
@ -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": ["🎮🔒", "🕹️⏸️", "🎮⚠️"] }
|
||||
}
|
||||
}
|
||||
|
||||
@ -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(
|
||||
|
||||
30
web/src/jobs/resultMarks.test.ts
Normal file
30
web/src/jobs/resultMarks.test.ts
Normal file
@ -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('<job-progress> 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()
|
||||
})
|
||||
})
|
||||
21
web/src/jobs/resultMarks.ts
Normal file
21
web/src/jobs/resultMarks.ts
Normal file
@ -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<string, unknown>
|
||||
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
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user