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

opened this

Merged 17d 18h ago, live in production

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

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

Show 4 earlier items

7 earlier comments
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

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.
  2. 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.
  3. 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.
  4. 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.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs