Skip to content

feat(tui): scale elapsed time to hours and days - #11

Merged
hoaitan merged 2 commits into
hoaitan:mainfrom
nwebbot:feat/elapsed-hours
Jul 17, 2026
Merged

feat(tui): scale elapsed time to hours and days#11
hoaitan merged 2 commits into
hoaitan:mainfrom
nwebbot:feat/elapsed-hours

Conversation

@nwebbot

@nwebbot nwebbot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

The task card timer rendered a raw minute count, so a 90-minute session read 90:30. It now scales its precision to the duration:

Elapsed Renders
under 1h 05:30 (unchanged)
1h – 24h 1:15:30
24h+ 2d3h

Past a day, seconds are noise — 73:15:30 has the same readability problem as 90:30, one scale up. The day format is kubectl's compact AGE notation, which most people already read fluently.

Changes

  • Extracts formatElapsed as a pure function, with a table test across every threshold.
  • Widens the elapsed column Width(5)Width(8). renderCard derives nameMaxW from lipgloss.Width(rightStr), so the name column reflows automatically.

Why the width is exactly 8

lipgloss wraps rather than truncates when content exceeds Width, so an over-long value would corrupt the card layout. The formats are bounded so that can't happen:

  • mm:ss maxes at 59:59 (5)
  • h:mm:ss only covers sub-24h, so it maxes at 23:59:59 (8)
  • NdNh maxes at 1000d23h (8) — i.e. not in this universe

TestFormatElapsedFitsColumn pins that invariant.

Why not fix it downstream

retask-cli hosts long-lived sandbox sessions, where 90:30 is easy to misread as seconds-since-something. It can't fix this on its side: TUIConfig exposes no elapsed-formatting hook, so the format is only reachable here.

go test ./... passes.

A 90-minute session rendered as 90:30, which reads as a minute count
rather than an hour and a half. Past 1h the timer now renders h:mm:ss.

The elapsed column widens from 5 to 8 to fit 25:01:02; sub-hour
rendering is unchanged. renderCard derives nameMaxW from the rendered
width of the right-hand side, so the name column reflows automatically.
A three-day session rendered as 73:15:30, which has the same
readability problem as 90:30 did, one scale up. Past 24h the timer now
uses kubectl's compact AGE notation (2d3h) — at day scale the seconds
are noise.

This also makes the column width exact rather than optimistic: the
h:mm:ss branch now only covers sub-24h, so its longest value is
23:59:59 (8 chars) and the day branch maxes at 1000d23h (8). Nothing
can overflow Width(8) and wrap the card, which a 100h+ session would
have done before. Pinned by a test.
@nwebbot nwebbot changed the title feat(tui): show hours in elapsed time past one hour feat(tui): scale elapsed time to hours and days Jul 17, 2026
@hoaitan
hoaitan merged commit c36ffbb into hoaitan:main Jul 17, 2026
4 of 5 checks passed
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