Skip to content

fix: refresh relative timestamps after midnight#481

Merged
mubarakcoded merged 3 commits into
pip/whitenoise-mac-457-v2from
pip/whitenoise-mac-470-v2
Jul 13, 2026
Merged

fix: refresh relative timestamps after midnight#481
mubarakcoded merged 3 commits into
pip/whitenoise-mac-457-v2from
pip/whitenoise-mac-470-v2

Conversation

@agent-p1p

@agent-p1p agent-p1p commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #470

Summary

  • Refreshes chat and message relative timestamp labels on NSCalendarDayChanged.
  • Refreshes after returning to the foreground when a day boundary was crossed while inactive.
  • Keeps date formatting out of ordinary chat/message row renders by preserving equatable row boundaries.
  • Makes timestamp formatting honor an injected reference date and adds a midnight regression test.

Verification

Stack

Sensitive paths

None.


Open in Stage

Summary by CodeRabbit

  • Bug Fixes

    • Improved message and conversation timestamp accuracy when the calendar day changes.
    • Timestamps now refresh when the app becomes active again.
    • Updated timestamp formatting to respect the current locale and reference date.
    • Ensured edited-message labels and date details update consistently across conversations, timelines, and the sidebar.
  • Tests

    • Added coverage for timestamp updates across calendar days and refreshed label formatting.

Refresh chat and message timestamp projections when the calendar day changes or the app returns to the foreground. Keep formatting outside ordinary row renders and cover the day-boundary transition with a regression test.

Fixes #470
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

ChatItem and MessageItem now compute timestamp labels using explicit dates and locales. SwiftUI views receive a shared timestamp reference date, refreshed on calendar-day changes and app activation, while tests cover formatting across day boundaries.

Changes

Timestamp refresh

Layer / File(s) Summary
Timestamp reference-date environment
whitenoise-mac/ContentView.swift
Adds an environment timestamp reference date and refreshes it on calendar-day changes and app activation.
Model timestamp computation
whitenoise-mac/Models/MessengerModels.swift
Removes stored rendered labels, adds parameterized formatting methods, updates equality, and uses explicit same-day checks.
Timestamp view propagation
whitenoise-mac/Views/MessageMediaViews.swift, whitenoise-mac/Views/MessengerShellView.swift, whitenoise-mac/Views/SidebarViews.swift
Passes timestamp date and locale through conversation views and computes sidebar, bubble, and timeline labels during rendering.
Timestamp refresh validation
whitenoise-macTests/whitenoise_macTests.swift
Updates row fixtures and assertions and adds day-boundary timestamp formatting coverage.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR addresses #470 by re-deriving stale timestamp labels on day changes and foregrounding, while preserving row diffing and adding regression coverage.
Out of Scope Changes check ✅ Passed The changes stay focused on timestamp refresh and formatting updates, with no obvious unrelated additions.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: refreshing stale relative timestamps after day rollover.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pip/whitenoise-mac-470-v2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@stage-review

stage-review Bot commented Jul 12, 2026

Copy link
Copy Markdown

@agent-p1p agent-p1p left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pip adversarial review

Verdict: APPROVE — no blocking findings. Submitted as a comment because agent-p1p cannot formally approve its own PR.

Blocking

None.

Suggestions

  • whitenoise-mac/Models/MessengerModels.swift:124-126, 177-180, 1578-1580, 1680-1700, 1817-1819 — the displayed chat/message labels now always come from the new (at:locale:) methods behind equatable view boundaries. The old stored timestampLabel, timeLabel, and metadataLabel projections are no longer read by production views, but are still computed and compared; their comments also still claim they are the render-time optimization. Consider removing this redundant state/equality work, or document the remaining non-view reason for retaining it. The current behavior is correct, but this leaves two competing label representations.
  • whitenoise-macTests/whitenoise_macTests.swift:3037 — strengthen the chat-row regression from != expectedTime to the exact expected weekday label. The next-day reference remains in the same week, so asserting the specific weekday branch would guard the sidebar behavior as precisely as the message assertion guards the abbreviated date-time branch.

Nitpicks

  • whitenoise-mac/Views/SidebarViews.swift:518-525ChatTimestampText's synthesized equality compares the entire ChatItem, although only updatedAt, referenceDate, and locale affect the formatted label. A narrower input/key would express the invariant and avoid reformatting when unrelated chat fields change.
  • whitenoise-mac/Views/MessageMediaViews.swift:78-79 — the default Date()/locale inputs are unnecessary at the production call site and can silently create a fresh equality key for future callers. Requiring explicit inputs would make the daily refresh contract clearer.

Verification

  • Reviewed the six-file diff at a4289d2ebda5f12b7eb52d704632a0bf29a58b5b against stacked base pip/whitenoise-mac-457-v2.
  • git diff --check passes.
  • GitHub Mac CI is green: strict Swift format, project sanity, 421 tests across two suites, and release arm64 smoke build.
  • Static Analysis is green.
  • The NSCalendarDayChanged path covers an active app; the didBecomeActive same-day guard covers a day crossed while inactive. The reference date participates in both message-row and sidebar equatable inputs, so the labels actually invalidate at the boundary.
  • Sensitive paths touched: none.

Remove stale mapping-time labels, narrow the sidebar's equatable timestamp inputs, require explicit message-row clock inputs, and assert the exact weekday transition in the regression test.
@agent-p1p

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@agent-p1p

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@agent-p1p

Copy link
Copy Markdown
Contributor Author

Addressed the adversarial review suggestions in efc1e5a:

  • removed the redundant mapping-time chat/message timestamp labels and equality work
  • narrowed ChatTimestampText to its actual updatedAt input
  • required explicit message-row reference date and locale inputs
  • strengthened the regression to assert the exact weekday label

Mac CI and static analysis pass. The fresh CodeRabbit review generated no actionable comments.

@agent-p1p
agent-p1p marked this pull request as ready for review July 12, 2026 04:41
@mubarakcoded
mubarakcoded merged commit bf28027 into pip/whitenoise-mac-457-v2 Jul 13, 2026
3 checks passed
@mubarakcoded
mubarakcoded deleted the pip/whitenoise-mac-470-v2 branch July 13, 2026 11:13
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