Files
Pulse/internal
rcourtman 330fbd8c9d Add drag-to-zoom and custom time windows to drawer history charts (#5335)
Adds Grafana-style click-and-drag zoom and custom time window queries to
drawer History charts.

## Summary
- **Backend custom windows (`/api/metrics-store/history`)**: Accepts
exact Unix-millisecond `start` and `end` query parameters (mutually
exclusive with `range`, strictly validated before monitor lookup). Adds
`QueryExact` / `QueryAllExact` in `pkg/metrics/store.go` with
full-bucket aggregate eligibility, upfront sample-weighted SQLite
downsampling within `maxPoints`, inclusive in-memory ring filtering,
clipped native provider fallback, deterministic mock window sampling,
and extended-history observation that ignores synthetic mock payloads.
Updates `TestContract_MetricsHistoryLiveFallbackJSONSnapshot` to request
`range=24h` instead of legacy ignored ISO `start`/`end` strings.
- **Drawer History charts (`GuestDrawerHistory`)**: Supports
click-and-drag brush selection synchronized across all panels in a
drawer, live time-window preview pill, `Escape` cancel without closing
the drawer, double-click and `Reset zoom` controls, paused polling while
zoomed, and a keyboard-accessible `Select time window` editor using
`FormSelect` that preserves exact millisecond endpoints and
disambiguates DST fall-back hours.
- **Bundle baseline**: Raises `totals.js.baselineGzip` in
`frontend-modern/.bundlesize.json` from `1430000` to `1435000` to
account for the drag-to-zoom UI while keeping all per-chunk baselines
unchanged.

## Verification
- Go tests: `pkg/metrics` (`TestStoreExactWindow`,
`TestStoreRetainedTierCoverage`) and `internal/api`
(`TestContract_MetricsHistoryLiveFallbackJSONSnapshot`,
`TestHandleMetricsHistory_CustomWindow*`) pass against `main`.
- Frontend tests: Vitest (including
`SharedPrimitives.guardrails.test.ts` clean on `GuestDrawerHistory.tsx`,
`charts.custom-window.test.ts`, and `GuestDrawerHistory.zoom.test.tsx`),
`npm run type-check`, `npm run lint`, and production `npm run build`
pass.
- Docs check: `scripts/tests/test_truenas_docs.py`
(`test_blank_host_history_help_uses_the_rendered_chart_states`) passes.
- Browser verification: Verified in Playwright Chrome against a rebuilt
mock server at `1440x900` and `390x844` on `/proxmox/overview` guest
drawer (shared brush across 3 panels, zero requests during drag, single
custom request on release, Escape cancel, nested zoom, double-click
reset, captured outside-SVG release, fractional-second `Select time
window` with keyboard focus restoration, empty `1h` preset, `0px` mobile
overflow, zero console/page errors). Receipt recorded at
`frontend-modern/browser-verification/195e0041d45febc5.json`.
2026-11-28 13:25:00 +00:00
..