Make the Insights tab respect the selected time range #3

Closed
zzg wants to merge 0 commits from fix-insights-time-range-filter into main
Owner

The Insights tab ignored the time-range picker in the upper right: clicking "15 minutes" still showed findings from the analyzer's fixed background window (WindowDays, e.g. 7 days), because /api/insights always returned the cached background result regardless of what range the UI requested.

  • internal/insights/analyzer.go: split Refresh()'s logic into a shared analyze(from, to) core, and add a public AnalyzeRange(from, to) that runs the detectors on demand for an arbitrary window without disturbing the cached background result used by Latest() and the Stop-hook/surfacing path.
  • internal/web/insights.go: handleInsights now honors optional from/to query params, calling AnalyzeRange for that window instead of Latest() when present.
  • internal/web/static/app.js: loadInsights() sends the current state.rangeMicros as from/to, and the window label now renders minutes/hours/days appropriately (windowLabel()) instead of always rounding up to whole days, so a 15-minute selection reads as "15 minutes" rather than "1 day".
The Insights tab ignored the time-range picker in the upper right: clicking "15 minutes" still showed findings from the analyzer's fixed background window (WindowDays, e.g. 7 days), because `/api/insights` always returned the cached background result regardless of what range the UI requested. - `internal/insights/analyzer.go`: split `Refresh()`'s logic into a shared `analyze(from, to)` core, and add a public `AnalyzeRange(from, to)` that runs the detectors on demand for an arbitrary window without disturbing the cached background result used by `Latest()` and the Stop-hook/surfacing path. - `internal/web/insights.go`: `handleInsights` now honors optional `from`/`to` query params, calling `AnalyzeRange` for that window instead of `Latest()` when present. - `internal/web/static/app.js`: `loadInsights()` sends the current `state.rangeMicros` as `from`/`to`, and the window label now renders minutes/hours/days appropriately (`windowLabel()`) instead of always rounding up to whole days, so a 15-minute selection reads as "15 minutes" rather than "1 day".
zzg added 1 commit 2026-09-19 21:18:08 -07:00
The Insights tab ignored the time-range picker in the upper right: clicking
'15 minutes' still showed findings from the analyzer's fixed background
window (WindowDays, e.g. 7 days), because /api/insights always returned the
cached background result regardless of what range the UI requested.

- internal/insights/analyzer.go: split Refresh()'s logic into a shared
  analyze(from, to) core, and add a public AnalyzeRange(from, to) that runs
  the detectors on demand for an arbitrary window without disturbing the
  cached background result used by Latest() and the Stop-hook/surfacing
  path.
- internal/web/insights.go: handleInsights now honors optional from/to query
  params, calling AnalyzeRange for that window instead of Latest() when
  present.
- internal/web/static/app.js: loadInsights() sends the current
  state.rangeMicros as from/to, and the window label now renders
  minutes/hours/days appropriately (windowLabel()) instead of always
  rounding up to whole days, so a 15-minute selection reads as '15 minutes'
  rather than '1 day'.
zzg closed this pull request 2026-09-19 21:19:08 -07:00
Author
Owner

Merged manually via fast-forward (git merge --ff-only) and pushed directly to main at 47fbe58, so Gitea did not flag this as merged automatically. Closing — the change is on main.

Merged manually via fast-forward (`git merge --ff-only`) and pushed directly to `main` at 47fbe58, so Gitea did not flag this as merged automatically. Closing — the change is on main.

Pull request closed

This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: zzg/fathom#3