feat: add optimistic timestamps to messages on hover #9735
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.
Summary
Added timestamp to messages. Timestamps only display on hover as recommended by @berry-13 on Discord DMs.
Closes Issue #5199.
Design Rationale
I displayed the time and date instead of using a date divider (see Slack example here) because I thought the divider would be obtrusive in an AI chat interface since most users start new threads rather than long-running conversations.
I used millisecond timestamps to give users a rough sense of request latency.
Technical Implementation
lockMessageTimestamp
immediately sets a timestamp in themessageTimestampState
Recoil atom. This gives users an instant, optimistic timestamp while the backend response arrives.useMessageTimestamp
prefers the backend’screatedAt
field; otherwise it returns the locked Recoil timestamp.Change Type
Testing
npx eslint $(git diff HEAD~1 HEAD --name-only --diff-filter=ACM | grep -E '\.(js|jsx|ts|tsx)$' | xargs)
becausenpm run lint
is not currently run on the whole project due to the number of errors.Demo
librechat-timestamps.mp4
Checklist
(from looking at the existing repo, it seems like pretty much all the files I edited don't have tests, so I wasn't sure if adding them was required)