feat(apps): render native date/time pickers for schema format fields - #3187
Conversation
- widgetFor maps a JSON Schema string `format` of date-time/date/time to a datetime-local/date/time input instead of a bare text box - extract widgetFor into its own leaflet-free module so the mapping is unit-testable without pulling in the browser-only location-map chain - add SettingSchema.format; add widget-for tests Fixes the Timer app's "Target date & time" (format: date-time) rendering as a plain text input the operator had to hand-type an ISO string into. The value stays a naive wall-clock time, resolved against the app's time-zone field — matching the Timer's documented behaviour. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01XrDBimoWjmEyF3A4Eo9sbh
There was a problem hiding this comment.
Pull request overview
Adds native HTML5 date/time pickers to the manifest-driven “Add → Apps” configuration form by teaching the widget selector to consider JSON Schema string format values (while still honoring explicit x-widget overrides). This improves operator UX for settings like Timer’s target date/time, and refactors the widget selection logic into a pure module so it can be unit-tested without browser-only dependencies.
Changes:
- Extracts
widgetFor()into a new pure module and adds unit tests for widget selection behavior. - Extends the schema typing to include JSON Schema
formatand mapsdate-time/date/timeformats to new widget keys. - Updates
manifest-formrendering to producedatetime-local,date, andtimenative inputs for those widget keys.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/anthias_server/app/static/src/apps/widget-for.ts | New pure widget-selection helper that maps schema to widget keys (now including string format). |
| src/anthias_server/app/static/src/apps/widget-for.test.ts | New Bun unit tests pinning format→widget mapping and precedence rules. |
| src/anthias_server/app/static/src/apps/types.ts | Extends SettingSchema with format?: string for JSON Schema string formats. |
| src/anthias_server/app/static/src/apps/manifest-form.ts | Imports extracted widgetFor and renders native date/time inputs for the new widget keys. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The renderer now also keys off a string `format` (date-time/date/time) for native pickers; say so in the interface comment. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01XrDBimoWjmEyF3A4Eo9sbh
|



Issues Fixed
The Timer signage app's "Target date & time" field — a JSON Schema
stringwithformat: date-time— rendered as a plain text input in the Add → Apps config form, so operators had to hand-type or paste an ISO 8601 string. Same gap for any app field using adate/time/date-timeformat.Description
widgetFor()(the manifest-form control picker) only keyed off the schematype/enum/x-widget, so astringwithformat: date-timefell through to a bare<input type="text">. It now maps the standard JSON Schema string formats to native HTML5 pickers:date-time→<input type="datetime-local">date→<input type="date">time→<input type="time">The datetime value stays a naive wall-clock time (
YYYY-MM-DDTHH:mm), which apps like Timer resolve against their separate time-zone field — matching the app's own documented behaviour ("read in the time zone below"). An explicitx-widgetstill overridesformat, and unknown formats degrade to text as before.Also extracts
widgetForinto its own module (widget-for.ts) so the mapping is unit-testable without importing the browser-only location-map / Leaflet chain thatmanifest-form.tspulls in.The plain-text
date-timefield was confirmed live in the Add → Apps modal on a device (it also looked out of place next to the Time zone field, which already renders as a dropdown). After this change it's a native date/time picker.Checklist
widget-fortests + the existing apps suite: 18/18 green.)manifest-formmodule doc comment; new module is self-documented.)