Skip to content

fix(react-ui): make agent chat timestamps format-agnostic (#9867)#10290

Merged
mudler merged 1 commit into
masterfrom
fix/9867-agent-chat-timestamps
Jun 13, 2026
Merged

fix(react-ui): make agent chat timestamps format-agnostic (#9867)#10290
mudler merged 1 commit into
masterfrom
fix/9867-agent-chat-timestamps

Conversation

@localai-bot

Copy link
Copy Markdown
Collaborator

Re: #9867 (hardens the partial fix from #10243)

Context

#10243 already switched dispatcher.go/events.go to UnixMilli and made the frontend a pass-through. But core/services/agentpool/agent_pool.go:474 (standalone mode) still emits an RFC3339 string, so two timestamp encodings still reach the React UI. The pass-through happens to render via new Date() for both, but it is inconsistent and any arithmetic path (relativeTime()) breaks on the string.

Fix

Adds a pure normalizeTimestampMs(ts) helper in core/http/react-ui/src/utils/format.js (RFC3339 string -> Date.parse; numeric branched by magnitude ns/us/ms/s; Date.now() fallback on null/empty/unparseable) and uses it in the AgentChat.jsx json_message handler. The UI now renders correct times regardless of which deploy mode (standalone / local dispatcher / NATS) produced the timestamp.

Test plan

  • npm run lint (zero new issues; format.js clean) and npm run build pass.
  • Pure-function check across RFC3339 / UnixMilli / UnixNano / UnixMicro / UnixSec inputs and all fallback cases.
  • No Playwright spec: agent-reply timestamps arrive over live SSE (needs a running server+model); the React UI has only e2e, no unit harness.

Assisted-by: claude:claude-opus-4-8 [Claude Code]

The agent SSE bridge emits the json_message timestamp in three different
encodings depending on deploy mode: an RFC3339 string (standalone agent
pool), Unix milliseconds (local dispatcher), and Unix nanoseconds (the
older NATS path). The React AgentChat handler passed data.timestamp
straight through, so the standalone string and any numeric value outside
the millisecond range rendered as "Invalid Timestamp" or a constant
epoch-ish time.

Add a small pure helper, normalizeTimestampMs, that accepts an RFC3339
string or a numeric epoch in s/ms/us/ns and returns JS milliseconds,
falling back to Date.now() on null/empty/unparseable input. Use it in
the json_message handler so the rendered time is correct regardless of
which backend path produced it.

Fixes #9867

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: claude:claude-opus-4-8 [Claude Code]
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@mudler
mudler merged commit e1556aa into master Jun 13, 2026
60 checks passed
@mudler
mudler deleted the fix/9867-agent-chat-timestamps branch June 13, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants