Wire FilterBar to server-side filter query language (ticket 016)

Send the raw filter string to GET /api/logs and GET /api/timeline
instead of doing a naive client-side substring match, surface the
API's 400 parse error inline under the FilterBar input, and drop the
now-dead visibleLogs client-side filtering in App.tsx.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
Hugh Kaznowski
2026-09-05 13:18:11 +01:00
co-authored by Claude Sonnet 5
parent 57d23c62e9
commit 10753cc9f8
3 changed files with 55 additions and 26 deletions
+14 -1
View File
@@ -46,7 +46,16 @@ export interface Stats {
async function getJson<T>(path: string): Promise<T> {
const res = await fetch(path)
if (!res.ok) {
throw new Error(`${path} failed: ${res.status}`)
let message = `${path} failed: ${res.status}`
try {
const body: unknown = await res.json()
if (body && typeof body === 'object' && 'error' in body && typeof (body as { error: unknown }).error === 'string') {
message = (body as { error: string }).error
}
} catch {
// body wasn't JSON (or had no `error` field) — fall back to the generic message
}
throw new Error(message)
}
return res.json() as Promise<T>
}
@@ -56,12 +65,14 @@ export function fetchLogs(params: {
startMs?: number
endMs?: number
limit?: number
filter?: string
}): Promise<LogEntry[]> {
const search = new URLSearchParams()
if (params.sinceSequence !== undefined) search.set('since_sequence', String(params.sinceSequence))
if (params.startMs !== undefined) search.set('start_ms', String(params.startMs))
if (params.endMs !== undefined) search.set('end_ms', String(params.endMs))
if (params.limit !== undefined) search.set('limit', String(params.limit))
if (params.filter) search.set('filter', params.filter)
return getJson(`/api/logs?${search.toString()}`)
}
@@ -69,11 +80,13 @@ export function fetchTimeline(params: {
startMs?: number
endMs?: number
bucketMs?: number
filter?: string
}): Promise<TimelineBucket[]> {
const search = new URLSearchParams()
if (params.startMs !== undefined) search.set('start_ms', String(params.startMs))
if (params.endMs !== undefined) search.set('end_ms', String(params.endMs))
if (params.bucketMs !== undefined) search.set('bucket_ms', String(params.bucketMs))
if (params.filter) search.set('filter', params.filter)
return getJson(`/api/timeline?${search.toString()}`)
}