fix: use created_at for message timestamps to prevent Invalid date on history messages #729
Open
NaitikVerma6776 wants to merge 1 commit into
Open
Conversation
… history messages
|
@NaitikVerma6776 is attempting to deploy a commit to the param20h's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
🔗 Related Issue
Closes #728
📝 What does this PR do?
MessageBubble.tsxwas extracting the display timestamp by splitting the message ID on "-" and parsing the second segment as a number:This works for streamed messages, which use synthetic IDs like
user-1717000000000. But all messages loaded from chat history use real database UUIDs (e.g.550e8400-e29b-41d4-a716-446655440000).Splitting a UUID on "-" and parsing "e29b" as a Number gives NaN →
new Date(NaN)→formatDistanceToNowrenders "Invalid date" under every historical message.Fix:
getMessageDate()helper that first triesmessage.created_at(returned by the history API forall persisted messages), falls back to the synthetic
ID-based timestamp for streamed messages, and returns
nullif both produce an invalid datemessageDateis notnull — no more "Invalid date" shown to users
created_at?: stringto theChatMsginterfacein
chat-store.tsso TypeScript correctly types thefield the history API already returns
🗂️ Type of Change
🧪 How was this tested?
npm run devinsidefrontend/)during streaming ✅
from history → confirmed timestamps now show correctly
(e.g. "2 hours ago") instead of "Invalid date" ✅
response_time_msbadge still renderscorrectly alongside the timestamp ✅
npx prettier --writeon both changed files ✅Two files changed:
frontend/src/components/chat/MessageBubble.tsx— core fix:getMessageDate()helper + updatedtimestamp render
frontend/src/store/chat-store.ts— one line added:created_at?: stringonChatMsginterface to properly type the field the history API already returns (previously untyped/missing from the interface)No other behavior is affected — streamed messages continue to work exactly as before via the ID-based fallback.
✅ Self-Review Checklist
dev, notmainmainbranch or any HuggingFace deployment config(no unnecessary formatting changes)