Skip to content

feat(mobile): show relative timestamp on inbox signal cards#2403

Merged
Gilbert09 merged 2 commits into
mainfrom
posthog-code/mobile-inbox-signal-relative-timestamp
May 28, 2026
Merged

feat(mobile): show relative timestamp on inbox signal cards#2403
Gilbert09 merged 2 commits into
mainfrom
posthog-code/mobile-inbox-signal-relative-timestamp

Conversation

@Gilbert09
Copy link
Copy Markdown
Member

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 own timestamp.

Reuses the existing formatRelativeTime util from @/lib/format instead 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

  • Open a signal report on the mobile app and expand the Signals section
  • Confirm each signal card shows a relative timestamp (e.g. 5m ago, 2h ago) on the right side of the header
  • Confirm the timestamp wraps cleanly alongside the source-line label and the verified badge (no overflow)
  • Confirm cards with a missing/invalid signal.timestamp simply omit the timestamp (no crash, no NaN)

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
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 28, 2026

Prompt To Fix All With AI
Fix 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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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
@Gilbert09 Gilbert09 added the Stamphog This will request an autostamp by stamphog on small changes label May 28, 2026
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Simple UI addition showing a relative timestamp on signal cards. The bot's concern about future timestamps is already addressed in the diff with the timestampMs <= Date.now() guard.

@Gilbert09 Gilbert09 merged commit 101ba72 into main May 28, 2026
20 checks passed
@Gilbert09 Gilbert09 deleted the posthog-code/mobile-inbox-signal-relative-timestamp branch May 28, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant