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

Relative times render as <time> with the exact time in the title, with no layout shift #13986

Merged opened this

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

Merged

Relative times that were still bare text now come out of the existing time() helper in src/web/ui.ts ( , exact UTC in the title).

Notes

shipped production is serving it deploy 8e1361f

opened this

Relative times that were still bare text now come out of the existing time() helper in src/web/ui.ts (<time datetime title>, exact UTC in the title). They are on these pages and cards:

  • prompts
  • subscriptions
  • teams
  • /now
  • detach
  • following (commit ages)
  • upstream-follow (checked / read lines)
  • scope (synced)
  • the flow card
  • the studio home "door" rows
  • the forks card
  • the fork-offers card (its "N minutes ago" wording is kept)

The feed, pulls and issues already used the helper, so no change was needed there. I did not touch the plain-text callers (TUI, MCP, string-valued card rows, agoWords in sentences) because they cannot carry markup.

Width is reserved with one rule in src/web/style/base.ts: time[datetime] gets tabular digits and no wrapping. I did not add a fixed min-width, because that would put gaps inside sentences. Nothing rewrites the text in place; live swaps ignore <time> text, so there is no reflow.

test/time-element.test.ts checks the helper's output, that a fork offer's age is a <time>, that no html template still interpolates timeAgo/agoWords outside <time>, and that the CSS rule exists. It is a source scan over src/web, not a render of three live pages. The scan only sees single-line templates, so a multi-line one could slip past it.

tsc, gate.ts --fix and design-lint are clean. 161 tests across 14 related files pass; the full suite is left to the forge's check. scripts/fast.ts judged the diff too broad to name tests, so I picked those files by hand. The push hook demanded a "Try:" commit, so there is an empty one with that message.

To try it, open /settings/following or /now and hover a time to see the exact UTC.

🤖 Generated with Claude Code

Closes #13974

11 earlier comments · 1 event
commented

Relative times that were still bare text now come out of the existing time() helper in src/web/ui.ts (<time datetime title>, exact UTC in the title). They are on these pages and cards:

  • prompts
  • subscriptions
  • teams
  • /now
  • detach
  • following (commit ages)
  • upstream-follow (checked / read lines)
  • scope (synced)
  • the flow card
  • the studio home "door" rows
  • the forks card
  • the fork-offers card (its "N minutes ago" wording is kept)

The feed, pulls and issues already used the helper, so no change was needed there. I did not touch the plain-text callers (TUI, MCP, string-valued card rows, agoWords in sentences) because they cannot carry markup.

Width is reserved with one rule in src/web/style/base.ts: time[datetime] gets tabular digits and no wrapping. I did not add a fixed min-width, because that would put gaps inside sentences. Nothing rewrites the text in place; live swaps ignore <time> text, so there is no reflow.

test/time-element.test.ts checks the helper's output, that a fork offer's age is a <time>, that no html template still interpolates timeAgo/agoWords outside <time>, and that the CSS rule exists. It is a source scan over src/web, not a render of three live pages. The scan only sees single-line templates, so a multi-line one could slip past it.

tsc, gate.ts --fix and design-lint are clean. 161 tests across 14 related files pass; the full suite is left to the forge's check. scripts/fast.ts judged the diff too broad to name tests, so I picked those files by hand. The push hook demanded a "Try:" commit, so there is an empty one with that message.

To try it, open /settings/following or /now and hover a time to see the exact UTC.

🤖 Generated with Claude Code

commented

<!-- look-pages a3e0916a56e2 --> Look pages for a3e0916, from the gate:

  • look pages (inferred): this pull changes src/web/pages/detach.ts, src/web/pages/following.ts, src/web/pages/fork-offers.ts and 10 more; the forge pictures / (src/web/scope.ts), /docs (src/web/scope.ts), /explore (src/web/scope.ts) and 23 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

Relative times on the settings, follow, now and home cards now render as <time datetime title>: the element carries the instant, the exact UTC shows on hover, and the stylesheet keeps its width steady with tabular numbers. The check failed on one gate rule: test/time-element.test.ts cast its inputs as never.

What I changed this round

  • The fork-offers test now builds a real repository with createApp, createUser and createRepo, and passes a fully typed ForkOffer.
  • It cleans up its temp data dir in a finally.
  • The commit message carries a No door: line. The both-doors rule flagged the pull for having no terminal change, and the pull only changes the markup around a time, not the words it shows.

Verified

  • bun x tsc --noEmit is clean.
  • test/time-element.test.ts passes (5 tests).
  • bun scripts/gate.ts reports no failing rules; the over-100-column comment in src/web/scope.ts is a note only.

I did not run bun scripts/design-lint.ts this round.

To try it: open /settings/following. Each commit age is a <time> with its exact UTC on hover.

Left out: I did not rewrap src/web/scope.ts; the nightly rewrap on main handles it.

🤖 Generated with Claude Code

commented

<!-- look-pages 1175359ac6b8 --> Look pages for 1175359, from the gate:

  • look pages (inferred): this pull changes src/web/pages/detach.ts, src/web/pages/following.ts, src/web/pages/fork-offers.ts and 10 more; the forge pictures / (src/web/scope.ts), /docs (src/web/scope.ts), /explore (src/web/scope.ts) and 23 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

Two of the three failing tests asserted the old bare text; I updated them and pushed. The third passes when run on its own here, so I changed nothing for it.

The two fixes

  • test/danger-language.test.ts expected the literal started 5m ago in the detach block.
  • test/repo-behind-line.test.ts expected the literal checked 2h ago in the behind-upstream line.

Both now match the word followed by <time …>5m ago</time>. The tests were wrong, not the code: the pages show the same words inside a <time datetime title> element, which is what this pull intends.

The third failure

  • "a fast-forward applies the previewed id…" is in test/take-expect.test.ts and was red in shard 17 of the check run.
  • It touches no relative time, so I treat it as a timing flake.
  • It passes here along with the other two (18 tests, 0 failures).

bun x tsc --noEmit and bun scripts/gate.ts are clean. I did not run the full suite.

To try it: open /settings/following. Each commit age is a <time> with its exact UTC on hover.

🤖 Generated with Claude Code

commented

<!-- look-pages 9b0daf6a90bc --> Look pages for 9b0daf6, from the gate:

  • look pages (inferred): this pull changes src/web/pages/detach.ts, src/web/pages/following.ts, src/web/pages/fork-offers.ts and 10 more; the forge pictures / (src/web/scope.ts), /docs (src/web/scope.ts), /explore (src/web/scope.ts) and 23 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

The look-pages comment is the gate's automatic inference, not a change request, so I changed no code. I added an empty commit with a Looks: /settings/following line, which the gate lets override the inferred list.

The gate pictured 26+ pages because they all import src/web/scope.ts. The visible change is the same on each: a relative time now renders as a <time datetime title> element with its exact UTC on hover, and the words don't change. /settings/following is the clearest place to see it, so I named that one.

If you want more pages pictured, say which and I'll add them to the commit line. Nothing was re-run this round because no code changed.

🤖 Generated with Claude Code

Changes requested — before the latest push

The swap to the existing time() helper is right and the preview-visible pages now carry <time datetime title>. Two of the three issue boxes are not met, and a few relative times are still bare. Fix in one round:

  1. FIRST: replace the single-line source scan with a test that renders real pages (feed, a pull, an issue, plus /settings/following or /now) and asserts that every relative-time word (\d+[smhd] ago, just now, etc.) sits inside a <time datetime title>. The scan only sees html... on one line, so a multi-line template slips past it; src/web/pages/upstream-follow.ts:155 (checkLine(c, timeAgo(c.at))) is a bare relative time today that the scan cannot see.
  2. Reserve width for real: tabular-nums + nowrap does not stop a shift when '9m ago' becomes '10m ago' or 'just now' becomes '1m ago'. Give time[datetime] an inline-block with a min-width in ch (e.g. min-width: 7ch; text-align: start) or document why not, and drop the source-contains CSS test for a behaviour one.
  3. Drop the as-text CSS test and the createApp/createUser/createRepo setup in the fork-offers test: forkOffersCard only reads repo for a link; a minimal Repo literal is enough.
  4. Small: fork-offers.ts import order (put time with the other ../ imports); the new CSS comment is over 100 columns.

Design: no principle broken; no new component classes, no new accent. Both doors: markup-only, the 'No door' note is fair. Phone/desktop pictures and the preview were not a concern beyond the above. Next after this: convert the cards.ts string-valued rows where a time can carry markup.

commented

All four points are addressed and pushed. The targeted tests pass, along with tsc and the gate. The diff touches 2,243 test files, so I did not run them all here; the forge's check will.

  1. Render test replaces the scan. test/time-element.test.ts now serves a real app and fetches /, /now/check, /amy/r, the repo's issues list and issue page, its pulls list and pull page, /amy/r/following and /amy/r/settings. Per page, it strips every <time datetime title>…</time> and asserts that no \d+(s|m|h|d|mo|y) ago or just now is left.

- /settings/following does not exist, so I used /amy/r/following, which is where the following card renders. /now needs a stage, so I used /now/check. - The bare time you named at upstream-follow.ts:155 is fixed: the history row's title is now time(c.at) followed by checkLine(c, ""). A separate test checks that the history's age is a <time>. - I updated the regex in test/upstream-follow-history.test.ts to allow the <time> element. That test was wrong, not the code.

  1. Width. time[datetime] is now inline-block; min-width: 7ch; text-align: start, keeping tabular digits and nowrap. The comment is wrapped under 100 columns. I dropped the CSS-contains test. There is no layout engine in the tests, so layout is not asserted at all; say if you want a browser-based check added.
  2. Fork-offers test. The createApp/createUser/createRepo setup is gone. forkOffersCard and repoBase now take Pick<Repo, "ownerName" | "name">, so the test passes a two-field literal with no cast.
  3. Import order. time now sits with the ../ imports in fork-offers.ts.

Trade-off to check: inside running prose, as in "started 5m ago." in the detach block, the 7ch minimum can leave a small gap before the punctuation. I kept it because you asked for no shift.

Not done: the cards.ts string-valued rows, which you listed as the next step.

To try it: open /amy/r/following or /amy/r/settings. Each age is a <time> with its exact UTC on hover.

🤖 Generated with Claude Code

commented

<!-- look-pages e69e07cdb79d --> Look pages for e69e07c, from the gate:

  • look pages (inferred): "Looks: /amy/r/settings" is not a page of app.looks in forge.json; this pull changes src/web/chrome.ts, src/web/pages/detach.ts, src/web/pages/following.ts and 11 more; the forge pictures / (src/web/chrome.ts), /docs (src/web/chrome.ts), /explore (src/web/chrome.ts) and 23 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

The look-pages complaint was about commit messages, not code. I fixed it with a new empty commit that has a valid Looks: line. No code or tests changed.

The previous head commit said Looks: /amy/r/settings. That path is not in app.looks in forge.json, so the gate fell back to inferring pages. An earlier commit named /settings/following, which isn't in the list either.

The new commit says Looks: /, because / is in app.looks and renders the chrome that carries relative times. I couldn't amend the old commit without a force push, so the new line sits on top of it.

I didn't run the tests, type check or gate for this push, since only a commit message changed.

I'm assuming the gate reads the override from the newest commit. If it wants one Looks: line per page, say so and I'll add /docs and /explore the same way.

commented

<!-- look-pages 9faae9710b49 --> Look pages for 9faae97, from the gate:

  • look pages (named): this pull changes src/web/chrome.ts, src/web/pages/detach.ts, src/web/pages/following.ts; a commit names /
commented

The gate accepted the Looks: / line from my last commit: it now reads the look pages as "named", with /. Nothing in that comment needs changing, so I made no new commit and pushed nothing.

I didn't run the tests, type check or gate, since nothing changed.

Approved

Earlier asks: render test over nine real pages replaces the source scan (met); width reserved with min-width 7ch (met); fork-offers test without a cast via Pick<Repo,...> (met); the bare time in the upstream history row at upstream-follow.ts is now a <time> (met); import order (met). Tests cover the helper, the pages and the history row.

Next two things: (1) 7ch is one short of "just now" (8 chars), so "just now" to "1m ago" still moves by a character, contrary to the CSS comment; use 8ch. (2) Inside prose ("started 5m ago.") the minimum leaves a small gap before punctuation; consider scoping the min-width to row meta/trail contexts. Neither blocks.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs