#7488: Handle future timestamps in relative time
Cluster:
Timezone Support Enhancements
## Summary\n- handle future timestamps in formatRelativeTime (in Xm / in Xh / Tomorrow / in Xd)\n- add vitest coverage for past & future cases\n\n## Testing\n- pnpm vitest run src/utils/time-format.test.ts\n
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates `formatRelativeTime` (`src/utils/time-format.ts`) to handle future timestamps by returning phrases like `in Xm`, `in Xh`, `Tomorrow`, and `in Xd`, falling back to a locale date string for longer ranges. It also adds Vitest coverage for both past and future cases (`src/utils/time-format.test.ts`).
This function is used in the TUI session list (e.g., `src/tui/tui-command-handlers.ts:152`), so these new strings will show up in session descriptions when timestamps are in the future.
<h3>Confidence Score: 4/5</h3>
- This PR is reasonably safe to merge; changes are localized and covered by unit tests.
- The implementation is straightforward and tests cover representative past/future outputs. Main remaining concern is the rounding behavior for future times near unit boundaries (hours/days), which could produce slightly surprising strings but won’t crash or corrupt state.
- src/utils/time-format.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#7919: feat: implement timezone support for console timestamps and add ver...
by southpy · 2026-02-03
74.8%
#15784: fix: timestamp parsing should convert seconds to milliseconds
by murasame-desu-ai · 2026-02-13
73.1%
#14709: fix: display local timezone in console logs
by Daiyimo · 2026-02-12
72.2%
#11421: Tests: add unit tests for infra/format-duration
by PythonUser42 · 2026-02-07
72.1%
#12358: fix: Sessions format timestamps in sessions_history using userTimezone
by xialonglee · 2026-02-09
72.0%
#4095: Test/add format duration tests
by TechWizard9999 · 2026-01-29
71.4%
#4137: [AI-assisted] test(cli): add missing test cases for parseDurationMs
by sind00 · 2026-01-29
71.4%
#15754: fix: handle Unix timestamps in seconds in parseAbsoluteTimeMs
by MisterGuy420 · 2026-02-13
71.0%
#5624: add support_human_readable_time_format in cron
by simran122 · 2026-01-31
70.0%
#7616: Harden zip extraction against path traversal
by lawyered0 · 2026-02-03
69.6%