feat: add message timestamps with smart formatting

- Added timestamp field to Message struct in Rust backend
- Timestamps automatically captured on message creation
- Smart relative time formatting (Just now, Xm ago, time, date)
- Timestamps display below message content with subtle styling
- Fixed avatar squishing issue with flex-shrink: 0
- Backward compatible with existing messages via serde(default)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-14 12:07:19 -07:00
parent ab6ae14bbc
commit 4694114ff9
3 changed files with 93 additions and 3 deletions

View File

@@ -174,24 +174,38 @@ struct Message {
swipes: Vec<String>,
#[serde(default)]
current_swipe: usize,
#[serde(default)]
timestamp: i64, // Unix timestamp in milliseconds
}
impl Message {
fn new_user(content: String) -> Self {
let timestamp = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_millis() as i64;
Self {
role: "user".to_string(),
content: content.clone(),
swipes: vec![content],
current_swipe: 0,
timestamp,
}
}
fn new_assistant(content: String) -> Self {
let timestamp = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_millis() as i64;
Self {
role: "assistant".to_string(),
content: content.clone(),
swipes: vec![content],
current_swipe: 0,
timestamp,
}
}