Skip to content

fix(messaging): make message header times date-aware#128

Merged
krazyjakee merged 2 commits into
masterfrom
claude/pensive-torvalds-065fe9
Jun 13, 2026
Merged

fix(messaging): make message header times date-aware#128
krazyjakee merged 2 commits into
masterfrom
claude/pensive-torvalds-065fe9

Conversation

@krazyjakee

Copy link
Copy Markdown
Contributor

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

_time in accord_home_message_row.dart now shows progressively more context the older a message is:

When Shown
Today 18:43
Yesterday Yesterday at 18:43
2–6 days ago Monday at 18:43
Older 12/06/2026 18:43

The 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 _clock getter. 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

krazyjakee and others added 2 commits June 14, 2026 00:05
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

Copy link
Copy Markdown
Contributor Author

Review findings and fixes (commit 98d2f9f)

All three issues below have been fixed in the follow-up commit on this branch.


🔴 High — No test coverage

The date-aware _time logic has five distinct rendering cases and non-trivial boundary conditions (today/yesterday cut, 6-day weekday ceiling), but shipped with zero tests. A regression here (wrong day label, off-by-one on the weekday window) would be invisible.

Fix: Extracted the core logic into lib/features/spaces/utils/message_time.dart as two pure functions (messageClockString, messageTimeString) and added test/features/spaces/message_time_test.dart with 9 cases covering all branches, clock padding, the full weekday cycle, and the future-timestamp edge case.


🟡 Medium — Double timestamp parse

_time called _clock to reuse the HH:MM string, but _clock re-ran DateTime.tryParse(_message.timestamp) independently. Every render of a non-grouped header triggered two parses of the same string.

Fix: Both getters now parse once and delegate to the extracted utility functions. messageTimeString computes the clock string from the already-converted DateTime rather than calling back into a getter.


🟡 Medium — Dead condition

if (daysAgo >= 2 && daysAgo <= 6) {  // the >= 2 half is unreachable

The daysAgo == 1 branch above already handles 1, so daysAgo is always ≥ 2 when this line is reached.

Fix: Simplified to if (daysAgo <= 6).


ℹ️ Minor — Future-dated timestamps

The original fell through to the calendar-date format for messages with timestamp in the future (daysAgo < 0). The new code treats future timestamps the same as "today" (bare clock). This is arguably better UX and is covered by a dedicated test case.


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

@krazyjakee krazyjakee merged commit b518dac into master Jun 13, 2026
2 checks passed
@krazyjakee krazyjakee deleted the claude/pensive-torvalds-065fe9 branch June 28, 2026 23:01
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