feat: Pattern Lab Discover + fix history run display

Fix: history runs now always show results — create synthetic selected preset
from run data when no matching preset found (was broken for custom events).
Also force mode='events' and reset matchResults on history load.

Discover tab: new "Discover" panel in left sidebar (AI knowledge search).
- GPT-4o generates 6 matching events from a free-text query (date, assets, hint)
- Confidence score + category badge per event
- Click → pre-fills experiment form exactly like a preset → ready to Run
- Backend: POST /api/pattern-lab/discover (DiscoverRequest, sorted by confidence)
- Frontend: useDiscoverEvents hook + DiscoveredEvent type + Discover UI with
  Enter-to-search, spinner, empty states

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OpenSquared
2026-06-22 21:36:00 +02:00
parent a2315c3b78
commit 78c60d5254
3 changed files with 238 additions and 52 deletions

View File

@@ -1036,6 +1036,17 @@ export const useFindMatchingPattern = () =>
api.post('/pattern-lab/find-matching', body).then(r => r.data),
})
export type DiscoveredEvent = {
label: string; date: string; category: string; horizon_days: number
assets: string[]; hint: string; confidence: number
}
export const useDiscoverEvents = () =>
useMutation({
mutationFn: (body: { query: string; n?: number }): Promise<{ events: DiscoveredEvent[]; source: string; query: string }> =>
api.post('/pattern-lab/discover', body).then(r => r.data),
})
export const useDeleteLabRun = () => {
const qc = useQueryClient()
return useMutation({