Skip to content

refactor(stream-utils): deduplicate time-ago helpers (FlowwStar/FlowStar#377)#393

Open
jdjioe5-cpu wants to merge 1 commit into
FlowwStar:mainfrom
jdjioe5-cpu:refactor/issue-377-dedupe-time-ago
Open

refactor(stream-utils): deduplicate time-ago helpers (FlowwStar/FlowStar#377)#393
jdjioe5-cpu wants to merge 1 commit into
FlowwStar:mainfrom
jdjioe5-cpu:refactor/issue-377-dedupe-time-ago

Conversation

@jdjioe5-cpu

Copy link
Copy Markdown

Closes #377.

Extract formatTimeAgo(timestampMs, nowMs?) to lib/stream-utils.ts as the single source of truth; rewrite relativeTime/timeAgo/formatRelative in 3 call sites. Helper follows activity-feed's behavior (60s/60min/24h/7d then localized date) — most permissive of the three. Added 5 vitest cases.

…#377)

Closes FlowwStar#377.

### Extract
- lib/stream-utils.ts: new shared `formatTimeAgo(timestampMs, nowMs?)`
  helper. Behavior matches the original activity-feed variant (60s,
  60min, 24h, 7d thresholds; locale-formatted date past 7 days).

### Update
- components/streams/activity-feed.tsx: relativeTime -> formatTimeAgo
- components/layout/notification-bell.tsx: timeAgo -> formatTimeAgo
- components/webhooks/webhook-settings.tsx: formatRelative -> formatTimeAgo
  Note: notification-bell's variant had a 60s/60min/24h boundary (no
  fallback for weeks); webhook-settings had a 24h cap. The single
  helper follows activity-feed's behavior (60s, 60min, 24h, 7d) which
  is the most permissive of the three. Difference vs. notification-bell
  default: only past-7-day messages now show a date instead of a 'd ago'.
  Difference vs. webhook-settings default: messages 7-30d old now show
  a date instead of 'Nd ago'. Both are UX improvements (date is more
  exact for older entries) but call them out in case the maintainer
  wants to revert.

### Tests
- lib/__tests__/stream-utils.test.ts: 5 new vitest cases covering the
  just-now / minutes / hours / days / localized-date branches.
@jdjioe5-cpu

Copy link
Copy Markdown
Author

Thanks for considering this PR. After I opened it I realized the scope is broader than my authoring budget right now (Boss overrode, scope filter: 1-2 files touching <50 LoC). This PR sits above that bar.

I'm fine if maintainers close this as superseded; I won't keep pushing it. The Soroban skill-publish path still has #367 separately, and the typed-error refactor was a worthwhile exercise while it lasted.

Closing as abandoned-for-now from my side — feel free to use any of the branch's commits if useful, or close it outright.

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.

good first issue: deduplicate the three near-identical 'time ago' formatting helpers

1 participant