feat(mobile): show relative timestamp on inbox signal cards#2403
Merged
Gilbert09 merged 2 commits intoMay 28, 2026
Conversation
Mirrors the desktop change (#2240): each signal card on the report detail screen now displays a short relative timestamp ("2h ago", "3d ago") in the header, sourced from the signal's own timestamp. Reuses the existing `formatRelativeTime` util from `@/lib/format` rather than introducing a new component, since the desktop's `<RelativeTimestamp />` wrapper exists mainly to add a tooltip that has no native mobile equivalent. Generated-By: PostHog Code Task-Id: 20e1fb88-d6bc-4c56-ba14-468a32bd491b
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/mobile/src/features/inbox/components/SignalCard.tsx:211-212
`formatRelativeTime` performs no bounds-check on negative differences. If `signal.timestamp` is a valid but future date (e.g., due to clock skew or a bad server timestamp), `diffMs` is negative, and the first branch (`diffSec < 60`) passes for any difference up to 60 seconds in the future, returning `"just now"`. Beyond that, the function falls through to `return \`${diffMin}m ago\`` with `diffMin` being a large negative integer — so the card would show something like `-120m ago`. A simple pre-render clamp on `hasTimestamp` keeps the output sensible.
```suggestion
const timestampMs = signal.timestamp ? Date.parse(signal.timestamp) : NaN;
const hasTimestamp = !Number.isNaN(timestampMs) && timestampMs <= Date.now();
```
Reviews (1): Last reviewed commit: "feat(mobile): show relative timestamp on..." | Re-trigger Greptile |
Comment on lines
+211
to
+212
| const timestampMs = signal.timestamp ? Date.parse(signal.timestamp) : NaN; | ||
| const hasTimestamp = !Number.isNaN(timestampMs); |
Contributor
There was a problem hiding this comment.
formatRelativeTime performs no bounds-check on negative differences. If signal.timestamp is a valid but future date (e.g., due to clock skew or a bad server timestamp), diffMs is negative, and the first branch (diffSec < 60) passes for any difference up to 60 seconds in the future, returning "just now". Beyond that, the function falls through to return \${diffMin}m ago`withdiffMinbeing a large negative integer — so the card would show something like-120m ago. A simple pre-render clamp on hasTimestamp` keeps the output sensible.
Suggested change
| const timestampMs = signal.timestamp ? Date.parse(signal.timestamp) : NaN; | |
| const hasTimestamp = !Number.isNaN(timestampMs); | |
| const timestampMs = signal.timestamp ? Date.parse(signal.timestamp) : NaN; | |
| const hasTimestamp = !Number.isNaN(timestampMs) && timestampMs <= Date.now(); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/mobile/src/features/inbox/components/SignalCard.tsx
Line: 211-212
Comment:
`formatRelativeTime` performs no bounds-check on negative differences. If `signal.timestamp` is a valid but future date (e.g., due to clock skew or a bad server timestamp), `diffMs` is negative, and the first branch (`diffSec < 60`) passes for any difference up to 60 seconds in the future, returning `"just now"`. Beyond that, the function falls through to `return \`${diffMin}m ago\`` with `diffMin` being a large negative integer — so the card would show something like `-120m ago`. A simple pre-render clamp on `hasTimestamp` keeps the output sensible.
```suggestion
const timestampMs = signal.timestamp ? Date.parse(signal.timestamp) : NaN;
const hasTimestamp = !Number.isNaN(timestampMs) && timestampMs <= Date.now();
```
How can I resolve this? If you propose a fix, please make it concise.`formatRelativeTime` doesn't bound-check negative diffs, so a server timestamp ahead of the device clock would render as e.g. `-120m ago`. Clamp at the caller — if the timestamp is in the future, just omit it. Generated-By: PostHog Code Task-Id: 20e1fb88-d6bc-4c56-ba14-468a32bd491b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports #2240 ("feat(inbox): show relative timestamp on signal cards") to the mobile app. Each signal card on the report detail screen now shows a short relative timestamp (e.g.
2h ago,3d ago) in the header, derived from the signal's owntimestamp.Reuses the existing
formatRelativeTimeutil from@/lib/formatinstead of introducing a new component — the desktop's<RelativeTimestamp />wrapper exists primarily to add a tooltip with the full date, which has no native equivalent on mobile.Test plan
5m ago,2h ago) on the right side of the headersignal.timestampsimply omit the timestamp (no crash, noNaN)