You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(logs): live duration shows ∅ for in-flight requests on page refresh (#434)
## Problem
The live duration calculator in the Logs page showed **Duration: ∅** for
in-flight requests after a page refresh, even though it worked correctly
for requests arriving via the SSE event stream.
## Root Cause
Two issues compounded:
1. **Backend**: The REST API response coerced `durationMs: null` → `0`
via `?? 0` in `usage-storage.ts`. The DB correctly stores `null` for
pending requests, but the API response lost that signal.
2. **Frontend**: The live duration check used `log.durationMs != null`
to decide whether to use the stored value or compute live. When
`durationMs` was `0` (from the backend coercion), `0 != null` is `true`,
so `formatMs(0)` was called — which returns `'∅'`.
This only manifested on page refresh (REST API path). For SSE-arrived
requests, `durationMs` was `undefined` (not in the partial record), so
`!= null` correctly fell through to the live calculation.
## Changes
- **Backend** (`usage-storage.ts`): Stop coercing `durationMs` null→0 in
REST API response; let `null` flow through
- **Frontend** (`api.ts`): Change `durationMs` type from `number` to
`number | null` to reflect reality
- **Frontend** (`Logs.tsx`): Use `!= null && > 0` guard so both `null`
and `0` fall through to `Date.now() - startTime`
- **Frontend** (`useModels.ts`, `useProviderForm.tsx`): Add null guards
on `reduce` calls for the new nullable type
0 commit comments