-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
feat: display message timestamps in conversations #11206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
feat: display message timestamps in conversations #11206
Conversation
- Add MessageTimestamp component showing localized date/time - Integrate timestamp at the end of HoverButtons (action bar) - Timestamp displays: day, month, year, hour, minute - Uses browser's toLocaleString() with app language setting - Aligned to the right of the action buttons row
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a timestamp display feature to message hover buttons in conversations, showing users when each message was created. The implementation introduces a new reusable component and integrates it into the existing hover buttons UI.
Key Changes:
- New
MessageTimestampcomponent that formats and displays message creation timestamps with automatic localization - Integration of the timestamp into
HoverButtonscomponent at the end of the action buttons row - Uses native browser localization via
toLocaleString()with the app's language setting
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
client/src/components/Chat/Messages/MessageTimestamp.tsx |
New component that retrieves the app language from state and formats the createdAt timestamp using toLocaleString() with specified date/time options |
client/src/components/Chat/Messages/HoverButtons.tsx |
Imports and renders the new MessageTimestamp component, passing message.createdAt; adds w-full class to container to support ml-auto positioning of timestamp |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const date = new Date(createdAt); | ||
|
|
||
| const formattedDate = date.toLocaleString(lang, { | ||
| day: 'numeric', | ||
| month: 'short', | ||
| year: 'numeric', | ||
| hour: '2-digit', | ||
| minute: '2-digit', | ||
| }); |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The component doesn't validate whether the Date object is valid before attempting to format it. If createdAt contains an invalid date string, date.toLocaleString() will return "Invalid Date", which will be displayed to the user. Consider adding validation similar to the pattern used in VersionItem.tsx, which checks isNaN(date.getTime()) to detect invalid dates and handles them appropriately.
| return ( | ||
| <span className="ml-auto flex items-center text-xs text-text-secondary">{formattedDate}</span> |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timestamp should use a semantic <time> element with a dateTime attribute for better accessibility and semantic HTML. Additionally, consider adding an aria-label with a more descriptive text for screen readers. See PromptVersions.tsx line 121 for an example pattern used elsewhere in the codebase that wraps formatted dates in a <time> element with a proper dateTime attribute.
| return ( | |
| <span className="ml-auto flex items-center text-xs text-text-secondary">{formattedDate}</span> | |
| const dateTimeAttr = date.toISOString(); | |
| const ariaLabel = date.toLocaleString(lang, { | |
| weekday: 'long', | |
| year: 'numeric', | |
| month: 'long', | |
| day: 'numeric', | |
| hour: 'numeric', | |
| minute: '2-digit', | |
| second: '2-digit', | |
| }); | |
| return ( | |
| <span className="ml-auto flex items-center text-xs text-text-secondary"> | |
| <time dateTime={dateTimeAttr} aria-label={ariaLabel}> | |
| {formattedDate} | |
| </time> | |
| </span> |
feat: display message timestamps in conversations
Summary
Adds a localized timestamp display for each message in conversations, showing when the message was created.
Changes:
MessageTimestamp.tsx- displays localized date/time for each messageHoverButtons.tsx- integrates the timestamp at the end of the action buttons rowFeatures:
toLocaleString()Example output by locale:
5 Jan 2026, 14:325 janv. 2026, 14:325. Jan. 2026, 14:32Technical notes:
createdAtfield already available in the message object{ timestamps: true })toLocaleString())Change Type
Testing
Checklist