Repository navigation
Description
Task
T-086c· Milestone M8 — Dashboard · Size XS · Priority P1 · Epic #8Implements NFR-USE-001
Branch
feat/t-086c-units-log-axes-durations-and— one task = one branch = one PR (doc 32 §6)
Summary
Implement pure helpers: physical-unit formatting (m/s, lux log, m, ms), relative/absolute durations, number formatting honouring the Settings locale, and a keyboard manager supporting chords (g b) and single keys, ignoring typing in inputs.
Context / motivation
Shared helpers that every screen uses; small and ideal for a first contribution.
Scope
In scope
- Shortcut registry with
?dialog data source.
Implementation guidance
lib/format.ts:formatValue(value: number, unit: Unit, opts?: {precision?: number; locale?: string}): string;formatLux(log-friendly significant digits),formatDuration(ms)(1 h 02 m,850 ms),formatRelative(date, now)viaIntl.RelativeTimeFormat,formatPValue(p)(< 0.001),formatA12(a, verbal)with the verbal magnitude supplied by the API.- Units come from the API's parameter specs (OpenAPI enum), not a parallel hand-written list.
lib/keyboard.ts:registerShortcut({keys: 'g b' | '/' | 'j', handler, scope?: 'global'|'feature', description})returning an unregister function; chord timeout 1 s held in a typedkeyboardConfigobject (not inline); ignores events frominput,textarea,selectand[contenteditable].- Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff
PLR2004); public APIs typed (mypy strict) and documented.
Acceptance criteria
- Table-driven unit tests for formatting; chord timing tests with fake timers.
- Locale from Settings applied (test with
de-DEdecimal comma). - Chord timeout tested with fake timers.
- Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
- Docs, config reference and CHANGELOG
Unreleasedupdated where behaviour, keys or interfaces changed. - Definition of Done (doc 32 §3) satisfied.
Tests required
web/src/lib/format.test.ts,keyboard.test.ts.
Dependencies
Blocked by: #13 (T-007)
Blocks: #184 (T-115)
Parallelization notes
Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:
web/src/lib/format.tsweb/src/lib/keyboard.ts
Independent.
Definition of Done
Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-086c (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.
References
Design docs: doc 13 §4 · doc 13 §5
Requirements: NFR-USE-001 (traceability: doc 28)
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsReady
Activity
g b,g c,/,j/k,r,?) and shortcuts dialog #184feat(web): locale-aware format helpers and keyboard shortcut manager …