fix: AI search updates time picker instead of filtering by timestamp#319
fix: AI search updates time picker instead of filtering by timestamp#319tonyalaribe merged 8 commits intomasterfrom
Conversation
Add updateTimePicker() to centralize time picker state management from AI search responses. The AI now receives the user's timezone and returns time_range in its response instead of embedding timestamp filters in KQL queries, keeping query logic and time selection properly separated.
PR Review: AI search updates time picker instead of filtering by timestampGood overall approach — centralising time picker updates into Bug:
|
…trigger - Fall back to fresh query when cache trim returns empty but cache had data - Refactor timepicker onClickHandler to use NeatInterpolation - Simplify custom date range submit (updateTimePicker already sets params) - Move pricing modal trigger button outside modalWith_
…sing - Group IMPORTANT blocks together in kqlGuide - Append timezone/time info when systemPromptOverride is used - Parse input and timezone fields in single pass in aiSearchH - Fix hlint redundant pure warning in Replay.hs
PR Review: fix AI search updates time picker instead of filtering by timestampOverall this is a clean fix — moving time filtering out of KQL and into the time picker UI is the right architectural call. A few issues worth addressing:
|
| Area | Verdict |
|---|---|
| Core AI timezone feature | ✅ Good approach |
buildSystemPrompt / whenJust' |
maybe "" (const ...) |
setParams({}, true) in TimePicker |
|
parseInt in TS label formatter |
🔧 Use m[1] !== "1" |
| Cache fallback on truly empty range |
|
test comment - please ignore |
|
hello world - test 2 |
PR Review test |
PR ReviewOverall this is a clean, well-scoped change. A few issues worth addressing.
|
| Severity | Item |
|---|---|
| Blocking | whenJust' guard is inverted - timezone appended to the wrong branch |
| Blocking | Prompt-injection risk from unsanitised timezone field |
| Non-blocking | whenJust' helper can be replaced with maybe/foldMap inline |
| Non-blocking | Fallback pattern duplicated in Charts.hs |
| Non-blocking | opts.label ignored in absolute-range branch of updateTimePicker |
PR ReviewOverall this is a clean, well-scoped change. A few issues worth addressing.
|
| Severity | Item |
|---|---|
| Blocking | whenJust' guard is inverted — timezone appended to the wrong branch |
| Blocking | Prompt-injection risk from unsanitised timezone field |
| Non-blocking | whenJust' helper can be replaced with maybe/foldMap inline |
| Non-blocking | Fallback pattern duplicated in Charts.hs |
| Non-blocking | opts.label ignored in absolute-range branch of updateTimePicker |
- Add cached-range coverage guard to skip redundant DB fallback when cache fully covers the requested range (CacheHit and PartialHit) - Replace local whenJust' helper with inline maybe combinator - Use string comparison instead of parseInt for time label pluralization
PR Review: AI search time picker integrationOverall this is a clean, well-scoped fix. A few observations:
|
| Area | Severity | Note |
|---|---|---|
| Timezone prompt injection | Low | Strip newlines/control chars from user-supplied timezone before embedding in system prompt |
PartialHit cache condition |
Medium | Third predicate differs from CacheHit; extract named helper to make intent clear and guard against silent divergence |
setParams({}, true) |
Low | Verify empty-object call clears from/to/since correctly |
Both query + time_range in response |
Low | Confirm form re-submit fires when handleAddQuery is called with an updated time range |
updateTimePicker targetPr coverage |
Low | Test with all TimePicker prefix variants (replay, charts, log explorer) |
The core approach — moving time range concerns out of KQL and into the time picker UI — is the right design. The TypeScript updateTimePicker centralisation is a net improvement.
- Drop timezoneM param from systemPrompt, always append timezone in buildSystemPrompt unconditionally - Extract duplicated cache fallback guard into fallbackIfEmpty helper - Use liftA2 for JSON parsing in AI search handler - Respect opts.label for absolute time ranges in updateTimePicker
Code ReviewOverall this is a clean, well-motivated PR. A few targeted observations:
|
…bad timeRange - Rename fallbackIfEmpty → refetchUnlessAdequate with guards for clarity - Remove orphaned "Use this to interpret..." comment and unused `now` param from systemPrompt - Add console.warn in updateTimePicker for malformed input
Code ReviewOverall this is a solid, well-scoped fix. The separation of time-range handling out of KQL and into a dedicated UI mechanism is the right architectural move. A few observations:
|
| Area | Verdict |
|---|---|
| Core bug fix (AI → time picker) | Correct and well-structured |
refetchUnlessAdequate guard |
Works; minor readability nit |
null vs absent time_range in JSON |
Low-risk; being explicit is cleaner |
submitAction reload logic |
Fragile; use location.reload() or clarify comment |
updateTimePicker default 'n' |
Add a comment |
systemPromptOverride + timezone |
Verify callers are unaffected |
| Settings modal fix | Clean |
Replay pure cleanup |
Correct |
Summary
updateTimePicker()function to centralize time picker state updates from AI search responsestime_rangein response instead of embedding timestamp filters in KQL queriesupdateTimePicker()for preset range clicks, reducing duplicated state management logictime_rangeresponses and trigger form submissionTest plan
where timestamp >= ...to KQL