fix(messaging): make message header times date-aware#128
Conversation
The header timestamp always showed bare HH:MM, so a message sent days ago looked like it was sent today. Show progressively more context the older a message is: - today: 18:43 - yesterday: Yesterday at 18:43 - 2-6 days ago: Monday at 18:43 - older: 12/06/2026 18:43 The grouped-message hover gutter (a fixed narrow slot) keeps a bare-clock `_clock` getter so the longer strings don't overflow. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Extract _clock/_time logic into lib/features/spaces/utils/message_time.dart as pure functions (messageClockString / messageTimeString), making the date-aware formatting unit-testable without a full widget harness. - Fix double timestamp parse: _time previously called _clock, causing DateTime.tryParse to run twice per render. Each getter now parses once and delegates to the utility. - Simplify redundant condition: `daysAgo >= 2 && daysAgo <= 6` → `daysAgo <= 6` (the >= 2 branch is unreachable after the == 1 guard). - Also handle future-dated timestamps (daysAgo < 0) consistently: show bare clock instead of falling through to the calendar-date format. - Add test/features/spaces/message_time_test.dart covering all 5 label cases, edge-case boundaries (today/yesterday/6-day cutoff), clock padding, and the full weekday name cycle. https://claude.ai/code/session_01WhnvGRQwPvBqHgSSuFornY
Review findings and fixes (commit 98d2f9f)All three issues below have been fixed in the follow-up commit on this branch. 🔴 High — No test coverageThe date-aware Fix: Extracted the core logic into 🟡 Medium — Double timestamp parse
Fix: Both getters now parse once and delegate to the extracted utility functions. 🟡 Medium — Dead conditionif (daysAgo >= 2 && daysAgo <= 6) { // the >= 2 half is unreachableThe Fix: Simplified to ℹ️ Minor — Future-dated timestampsThe original fell through to the calendar-date format for messages with No new dependencies were added. No visual changes beyond what the PR already describes. The file is well under 1 000 lines so no structural split was needed. Generated by Claude Code |
Problem
The message header timestamp always rendered as bare
HH:MM, so a message sent days ago looked identical to one sent today (e.g.18:43).Change
_timeinaccord_home_message_row.dartnow shows progressively more context the older a message is:18:43Yesterday at 18:43Monday at 18:4312/06/2026 18:43The 6-day bound keeps the weekday unambiguous (a 7-day-old message would repeat today's weekday name), so it falls through to the calendar date.
The grouped-message hover gutter is a fixed narrow slot (
avatarRadius * 2) where the longer strings would overflow, so it uses a new bare-clock_clockgetter. Grouped rows are within minutes of their header anyway, so the clock alone is correct there. The full hover tooltip (Monday, 5 June 2026 at 14:30) is unchanged.No new dependencies — still hand-formatted (intl isn't a dep).
🤖 Generated with Claude Code