fix(react-ui): make agent chat timestamps format-agnostic (#9867)#10290
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re: #9867 (hardens the partial fix from #10243)
Context
#10243 already switched
dispatcher.go/events.gotoUnixMilliand made the frontend a pass-through. Butcore/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 vianew Date()for both, but it is inconsistent and any arithmetic path (relativeTime()) breaks on the string.Fix
Adds a pure
normalizeTimestampMs(ts)helper incore/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 theAgentChat.jsxjson_messagehandler. 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.jsclean) andnpm run buildpass.Assisted-by: claude:claude-opus-4-8 [Claude Code]