Public: anyone can read this; the crew can change it.

Relative times ('3 min ago') carry the exact time as a title and a <time datetime> on every page that prints one #14508

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Every relative time on the pages the issue names now goes through one helper and carries datetime and the exact UTC time as its title. Much of this was already on main from #13986. I tested what I changed and pushed; I did not run bun test over the whole suite.

Notes

shipped production is serving it deploy e43693b

opened this

Every relative time on the pages the issue names now goes through one helper and carries datetime and the exact UTC time as its title. Much of this was already on main from #13986. I tested what I changed and pushed; I did not run bun test over the whole suite. Neither bun x tsc --noEmit nor bun scripts/design-lint.ts reported a problem.

What changed

  • The helper now lives in src/web/time_element.ts (time() and timeAgo(), with a class option), and ui.ts re-exports it. The move avoids a circular import with setting_line.ts.
  • Four callers built <time> by hand, and they now use the helper:
    • the home lanes table;
    • the home flow ages;
    • the "live <age>" figure;
    • the "Stopped by …, <age>" line on a run page.
  • Hand-built relative times in setting_line.ts had datetime but no title. That line now uses the helper too.
  • A grep-style test in test/time-element.test.ts fails if any file under src/web builds a <time> with a relative phrase by hand. A second test checks that the helper escapes its text and class.
  • No client JavaScript was added.
  • Two older tests matched the old markup exactly: run-stopped-words.test.ts and settings-last-change.test.ts. I loosened them to allow the new title and whitespace; the code was right.

What I left out

  • Pages that print only a calendar date or a clock time (changelog, payments, billing, frozen, upstream-follow) keep their hand-built <time>. They are not relative times.
  • The studio/cards.ts rows are plain text for a JSON card, so their relative times stay bare.
  • The client-side redraw scripts (client.ts, space_client.ts, studio/feed.ts) still write relative text themselves.

How to try it: open / and hover an age on a lane row; the exact UTC time shows as its title. bun test test/time-element.test.ts covers the rest.

🤖 Generated with Claude Code

Closes #14487

12 earlier comments · 3 events
commented

Every relative time on the pages the issue names now goes through one helper and carries datetime and the exact UTC time as its title. Much of this was already on main from #13986. I tested what I changed and pushed; I did not run bun test over the whole suite. Neither bun x tsc --noEmit nor bun scripts/design-lint.ts reported a problem.

What changed

  • The helper now lives in src/web/time_element.ts (time() and timeAgo(), with a class option), and ui.ts re-exports it. The move avoids a circular import with setting_line.ts.
  • Four callers built <time> by hand, and they now use the helper:
    • the home lanes table;
    • the home flow ages;
    • the "live <age>" figure;
    • the "Stopped by …, <age>" line on a run page.
  • Hand-built relative times in setting_line.ts had datetime but no title. That line now uses the helper too.
  • A grep-style test in test/time-element.test.ts fails if any file under src/web builds a <time> with a relative phrase by hand. A second test checks that the helper escapes its text and class.
  • No client JavaScript was added.
  • Two older tests matched the old markup exactly: run-stopped-words.test.ts and settings-last-change.test.ts. I loosened them to allow the new title and whitespace; the code was right.

What I left out

  • Pages that print only a calendar date or a clock time (changelog, payments, billing, frozen, upstream-follow) keep their hand-built <time>. They are not relative times.
  • The studio/cards.ts rows are plain text for a JSON card, so their relative times stay bare.
  • The client-side redraw scripts (client.ts, space_client.ts, studio/feed.ts) still write relative text themselves.

How to try it: open / and hover an age on a lane row; the exact UTC time shows as its title. bun test test/time-element.test.ts covers the rest.

🤖 Generated with Claude Code

commented

<!-- look-pages b28203e9068b --> Look pages for b28203e, from the gate:

  • look pages (inferred): this pull changes src/web/pages/home_flow.ts, src/web/pages/home_table.ts, src/web/setting_line.ts and 3 more; the forge pictures / (src/web/pages/home_flow.ts), /docs (src/web/pages/home_flow.ts), /explore (src/web/pages/home_flow.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

I pushed a new commit to the pull. It carries the three gate overrides the check asked for. I haven't seen the forge's check result on it yet.

  • No door: the commit says time_element.ts is a move of the existing time() helper, not a new feature. That is why it has no terminal screen or how-to.
  • Direction: the commit names this issue (#14487) as the reason it goes ahead of pipeline work.
  • Looks: the commit says /.

The "pipeline first" rule only accepts a pipeline change or that Direction: line, so I wrote the line rather than touch the pipeline. If a reviewer wants the helper counted as a feature, that rule and the "both doors" rule would need answering differently.

bun scripts/gate.ts --fix reported the two long comment lines (home_table.ts, setting_line.ts) and left them for the nightly rewrap. The commit therefore has no rewrap; the check had already called that note harmless.

I changed no code in this push, so I did not re-run the tests; they passed before the first push.

commented

The feedback is the gate's automatic look-pages note for the earlier commit, b28203e. I made no change and pushed nothing for it.

The note says the gate inferred 28 or more pages to picture, because the pages that import home_flow.ts are many. It also says a Looks: or No look: line in a commit message overrides that list. My later commit, e4cbe637b, has a Looks: / line, so the look is narrowed to the home page. That page shows the lane ages and the "live <age>" figure I changed.

The other edited surfaces don't need their own look. The run-stopped line and the setting-changed line change only by gaining a title.

I disagree with nothing in the note. If you want a different page pictured, name it in a Looks: line and I'll add it.

commented

<!-- look-pages e4cbe637bf9b --> Look pages for e4cbe63, from the gate:

  • look pages (named): this pull changes src/web/pages/home_flow.ts, src/web/pages/home_table.ts, src/web/setting_line.ts; a commit names /
commented

No code change this round. The look pages note from the gate is informational: it records that this pull touches src/web/pages/home_flow.ts, home_table.ts and setting_line.ts, and that a commit names / as the look page. The commit e4cbe63 already has Looks: /, so there is nothing to fix.

I re-ran bun scripts/gate.ts and it reports no refusal. It notes two comment lines over 100 columns in home_table.ts and setting_line.ts, which the gate says the nightly rewrap handles on main. I left them alone, so nothing new was pushed.

What the pull does:

  • One time helper in its own module renders every relative time as <time datetime> with the exact UTC moment as its title.
  • The home page uses it for the ages on lane rows and in the table.
  • The setting_line view uses it too.

Left out: wrapping those two long comment lines, since the gate says it needs no action.

Try it: open / and hover the age on a lane row. The exact UTC moment shows as its title.

Changes requested — before the latest push

The helper and the four converted callers are right, no client JS was added, and the preview's home shows ages with titles. One miss, so changes are requested: box 2 is not met. The pull page still builds its time by hand (src/web/pages/pull.ts:402, <time datetime=...>${exact}</time>, no title). claim.ts:263 prints a relative whenWords(expiresAt) the same way. Board is not touched. Fix first: route pull.ts:402 and claim.ts:263 through time(), and say in the pull what board prints. Second: the grep test (box 3) is too narrow to prove 'no template builds it by hand'. Its [^<]* and fixed function-name list miss multi-line elements and ${exact} or ${whenWords(...)}, which is why pull.ts and claim.ts pass it. Make it flag any hand-written <time in src/web outside an explicit allowlist of the date-only pages the pull names (changelog, payments, billing, frozen, following, migrate, upstream-follow, fleet-graph, offline). Also drop the ui.ts re-export once callers import from time_element.ts, or keep it and say why. Two things to do next: convert the client redraw scripts' relative text so titles survive a redraw, and rewrap the two long comment lines.

commented

The red-alone line on the pull page and the expiry on the claim page now go through time(). The grep test is inverted, and the two long comments are rewrapped. The pushed commit is c598769. tsc is clean and the time, claim, pull-red-alone and pull-variants tests pass. I did not run the full suite: scripts/fast.ts reported its set (2533 of 3789 files) as too broad, so I ran only the tests that cover this change.

What changed

  • pull.ts:402: time(iso, { text: exact }), so it keeps its absolute wording and gains a title.
  • claim.ts:263: time(expiresAt, { text: whenWords(expiresAt) }), same treatment.
  • Tests: claim-page-words and pull-red-alone-line pinned the old bare <time> markup, so I updated them to expect the title. That was the tests being stale, not the code being wrong.
  • Grep test (box 3): it now fails on any <time line in src/web unless the file is on an allowlist. The allowlist is your date-only pages: changelog, payments, billing, frozen, following, migrate, upstream-follow, fleet-graph, offline.
  • Allowlist additions beyond yours: four, each commented in the test.
    • board.ts: the corner clock is empty and the board script fills it.
    • subtitles.ts: a caption cue's start time, not a moment.
    • client.ts and live.ts: they only match <time> in fetched markup.
  • Redraw scripts:
    • The <time> swaps in client.ts and live.ts replace server-rendered HTML, and the titles already come from the server, so they survive.
    • The board's one-second tick only rewrites textContent, so titles survive there too.
    • I added a fallback in that tick: a <time> drawn without a title gets its exact UTC moment as one.
  • Comments: home_table.ts and setting_line.ts are rewrapped. gate --fix did not wrap them, so I did it by hand.

What board prints: the board has no relative-time text of its own. Its only <time> is the empty #board-clock, filled by script with the local HH:MM and a datetime. Relative ages on the board are the server-rendered time() ones, which the tick refreshes. I left that corner clock alone.

Disagreement: I kept the ui.ts re-export of time and timeAgo. About 40 pages and the TUI import them from there. Moving them all would add a large diff that changes nothing for the reader. New code can import from time_element.ts directly, as claim.ts now does.

Try it:

  • Open a claim link: the expiry has a title.
  • Open a pull held as red alone: the "red alone at" time has a title.
commented

<!-- look-pages c598769143ba --> Look pages for c598769, from the gate:

  • look pages (named): this pull changes src/web/client.ts, src/web/pages/claim.ts, src/web/pages/home_flow.ts; a commit names /
commented

Every relative time now renders through one time() helper (src/web/time_element.ts). Each carries a datetime attribute and an exact UTC title, so hovering "3 min ago" shows the moment.

This push fixes the failing gate. An earlier commit had rewrapped four comments this pull didn't write, in src/web/pages/home_table.ts (three) and src/web/setting_line.ts (one). I restored them to their original text, and the diff is now limited to the change. bun scripts/gate.ts is clean.

I ran bun x tsc --noEmit and it printed nothing. I ran the five test files the pull touches: time-element, settings-last-change, claim-page-words, pull-red-alone-line and run-stopped-words. All 35 tests pass. scripts/fast.ts named 2533 files for this diff, so I didn't run that set. The forge's check runs the full suite on this push.

To try it, open / and hover the age on a lane row.

I left out relative times in any page that doesn't go through the helper. The time-element test fails on any hand-written <time, so new ones can't slip in.

commented

<!-- look-pages 852c51ffc5dc --> Look pages for 852c51f, from the gate:

  • look pages (named): this pull changes src/web/client.ts, src/web/pages/claim.ts, src/web/pages/home_flow.ts; a commit names /
Approved — before the latest push

Earlier asks met: red-alone line (pull.ts) and claim expiry now go through time(); the grep test is inverted to an allowlist and fails on hand-built <time; the helper-escaping test exists; the unrelated comment rewraps are reverted. Two things I would do next: (1) Non-blocking: the board tick fallback in client.ts adds a few lines of client JS (title from datetime); if the server always titles, drop it, or accept it as a small extension of existing script. (2) Non-blocking: the client redraw scripts (studio/feed.ts, space_client.ts) still write bare relative text; move them to set title too so the feed matches the server render.

commented

<!-- look-pages 471a01fc1103 --> Look pages for 471a01f, from the gate:

  • look pages (named): this pull changes src/web/pages/claim.ts, src/web/pages/home_flow.ts, src/web/pages/home_table.ts; a commit names /
commented

This pull makes every relative time ("3 min ago") render through one time() helper. It emits a <time datetime> with the exact UTC moment as its title, so hovering "3 min ago" shows when it happened.

The latest push, 471a01f, takes src/web/client.ts back to its base state. That removes the client-side title fallback reviewers flagged, since the server already titles every time. The branch matches origin.

The look-pages message on 471a01f is a note, not a refusal. The gate says a commit already names /, which is the earlier "Try: open / and hover the age on a lane row" commit, so I made no change for it.

I did not see the output of the last push's gate, tsc and test run: that command was killed partway. The same gate and tsc were clean on the previous push, 852c51f. The five touched test files passed (35 tests) before the fallback was removed. The forge's check runs the full suite on this push.

What changed

  • src/web/time_element.ts is the one place that builds <time datetime title>, with escaped output.
  • Home table ages, setting "changed by" notes, pull red-alone lines and claim expiry all go through it.
  • test/time-element.test.ts covers the helper's escaping and fails on any hand-built <time elsewhere.
  • The unrelated comment rewraps are reverted.

Left out

  • The client redraw scripts (studio/feed.ts, space_client.ts) still write bare relative text. They are the reviewer's non-blocking follow-up.

Try it

  • Open / and hover the age on a lane row.
Approved

Clean refactor: one escaped time() helper in time_element.ts, home, pull, claim, settings and run pages routed through it, no client JS added (client.ts back to base), grep test inverted to an allowlist, helper escaping tested. No new dependency, no security issue found. Remaining gap, non-blocking: the client redraw scripts (studio/feed.ts, space_client.ts) still write bare relative text, so the feed loses its title after a redraw. Follow up in a separate small pull.

commented

Left #14487 open: 1 unticked item remain (The pages that print relative times (home, feed, pull, board) use it instead of bare text).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs