Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Problem

Assistant message timestamps were inconsistent across reloads:

  • Before reload: All parts showed the timestamp of the first message
  • After reload: All parts showed the timestamp of the last message (or Date.now())

This happened because:

  1. Text/reasoning parts weren't getting timestamps during streaming (unlike tool parts)
  2. Display logic used message-level timestamp instead of part-level timestamps
  3. Reconnection case was overwriting metadata.timestamp with Date.now()

Solution

  • Add timestamp field to text/reasoning parts during streaming (matching tool parts)
  • Preserve first timestamp when merging adjacent parts of the same type
  • Use part.timestamp ?? baseTimestamp when displaying (consistent with tool parts)
  • Preserve metadata.timestamp in reconnection case instead of overwriting

Testing

Added comprehensive tests covering:

  • Timestamp assignment during streaming
  • Timestamp preservation when displaying
  • Fallback to message-level timestamp for old history without part-level timestamps

All existing tests pass.

Generated with cmux

…times

Before this fix, all parts of an assistant message (text, reasoning, tool calls)
were using the message-level timestamp, causing all parts to show the same time
before reload, and then all show a different (wrong) time after reload.

Changes:
- Add timestamp field to text/reasoning parts during streaming (matching tool parts)
- Preserve first timestamp when merging adjacent parts of the same type
- Use part.timestamp ?? baseTimestamp when displaying (consistent with tool parts)
- Preserve metadata.timestamp in reconnection case instead of overwriting with Date.now()

Result: Each part now shows its actual creation time, consistent across reloads.

Generated with `cmux`
@ammario ammario added this pull request to the merge queue Oct 18, 2025
Merged via the queue into main with commit 7d2ada3 Oct 18, 2025
8 checks passed
@ammario ammario deleted the timestamps branch October 18, 2025 20:59
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