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

A fork's offer upstream says how big it is: files changed and lines added and removed, before anyone opens the diff #14569

Merged opened this

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

Merged

Each offer in the "Offered by forks" list on an upstream's page now ends with its size, for example 2 files, +4 −1. test/fork-offer-size.test.ts and test/fork-offers.test.ts pass (10 tests), bun x tsc --noEmit is clean, and bun scripts/design-lint.ts is clean.

Notes

shipped production is serving it deploy 4ec2c16

opened this

Each offer in the "Offered by forks" list on an upstream's page now ends with its size, for example 2 files, +4 −1.

test/fork-offer-size.test.ts and test/fork-offers.test.ts pass (10 tests), bun x tsc --noEmit is clean, and bun scripts/design-lint.ts is clean. I didn't run the rest of the suite, and I don't know whether scripts/gate.ts found anything: its output was cut off by the lint line that follows it.

  • Numbers: they come from git diff --numstat between the pull's base and head. src/git/offer_size.ts is new and is called only from the repo page that renders this list.
  • Cache: results are kept per base and head oid pair, so a second render of the same offer doesn't run git again.
  • Binary and missing head: a binary file counts as one file with no lines. If the head commit no longer exists, the line reads "its head is gone".
  • Git arguments: fixed, with the oids checked first.
  • Tests: a small offer's numbers on the page, a binary file, a missing head, and the cache reused on a second call (the repo directory is moved away and the same answer comes back).
  • Left out: if git fails for a reason other than a missing head, the size is omitted rather than an error shown.
  • Not reused: I didn't reuse the existing /review stat cache, which never waits on git and would show "loading" on the first render. This page wants the number on first paint.

To try it, open an upstream repo that has forks with open pulls. Sizes are computed when the page renders, so the first view runs git once per offer, at most 20.

Closes #14561

7 earlier comments · 1 event
commented

Each offer in the "Offered by forks" list on an upstream's page now ends with its size, for example 2 files, +4 −1.

test/fork-offer-size.test.ts and test/fork-offers.test.ts pass (10 tests), bun x tsc --noEmit is clean, and bun scripts/design-lint.ts is clean. I didn't run the rest of the suite, and I don't know whether scripts/gate.ts found anything: its output was cut off by the lint line that follows it.

  • Numbers: they come from git diff --numstat between the pull's base and head. src/git/offer_size.ts is new and is called only from the repo page that renders this list.
  • Cache: results are kept per base and head oid pair, so a second render of the same offer doesn't run git again.
  • Binary and missing head: a binary file counts as one file with no lines. If the head commit no longer exists, the line reads "its head is gone".
  • Git arguments: fixed, with the oids checked first.
  • Tests: a small offer's numbers on the page, a binary file, a missing head, and the cache reused on a second call (the repo directory is moved away and the same answer comes back).
  • Left out: if git fails for a reason other than a missing head, the size is omitted rather than an error shown.
  • Not reused: I didn't reuse the existing /review stat cache, which never waits on git and would show "loading" on the first render. This page wants the number on first paint.

To try it, open an upstream repo that has forks with open pulls. Sizes are computed when the page renders, so the first view runs git once per offer, at most 20.

commented

<!-- look-pages 9b2010f078e6 --> Look pages for 9b2010f, from the gate:

  • look pages (inferred): this pull changes src/web/pages/fork-offers.ts, src/web/pages/repo.ts; the forge pictures /settings/crew (src/web/pages/fork-offers.ts), /settings/grants (src/web/pages/fork-offers.ts), /preview-admin/sample (src/web/pages/fork-offers.ts) and 3 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

Each fork offer on an upstream's page now ends with its size, for example 2 files, +4 −1.

The forge's check failed on the as never cast in test/fork-offer-size.test.ts. The test now types its files as FileWrite records, with no cast. bun scripts/gate.ts passes locally, bun x tsc --noEmit is clean, and test/fork-offer-size.test.ts passes (5 tests). I did not re-run test/fork-offers.test.ts after this fix, and I have not seen the forge's check result for this push.

The same log also named the "both doors", "pipeline first" and look-pages rules. I answered them with No door:, Direction: and No look: lines in the commit messages instead of adding a terminal screen, a how-to or a pipeline change. The size is only a line on the existing repo page. If a reviewer wants a door anyway, that is a separate addition.

  • Numbers: they come from git diff --numstat between the pull's base and head. A binary file counts as one file with no lines. If the head commit no longer exists, the line reads "its head is gone".
  • Cache: results are kept per base and head oid pair, so a second render of the same offer does not run git again.
  • Left out: if git fails for any reason other than a missing head, the size is omitted rather than an error shown.
  • Not reused: I did not reuse the /review stat cache. It never waits on git and would show "loading" on first render.

To try it, open an upstream repo that has forks with open pulls. The code is in src/git/offer_size.ts.

commented

I merged main into the branch, resolved the two conflicts, and pushed.

  • fork-offers.ts: both sides stay. sizeSpan (this pull) and sentOffersCard (from main) are now both in the file.
  • repo.ts: the imports now include sentOffers and sentOffersCard alongside offerSize. The code home page renders forkOffersCard(repo, offersHere, offerSizes) followed by sentOffersCard, so each fork offer still shows its size and the "Sent upstream" card from main appears below it.

Checks:

  • bun x tsc --noEmit printed no errors.
  • bun scripts/design-lint.ts is clean.
  • The five offer test files (fork-offer-size, fork-offers-sent, fork-offers, offer-listed, fork-offer-receipt) pass, 26 tests. I did not run the full suite here because scripts/fast.ts said the diff is too broad to name tests. The forge runs the full check on the push.
  • bun scripts/gate.ts --fix said it rewrapped comments in one file, and I committed that along with the merge.
commented

I merged main into the branch again, resolved the conflicts, and pushed (1200fdbab). The last check failed because an earlier gate.ts --fix had rewrapped a comment in src/git/pace.ts that this pull didn't write. That file is now back to main's text, and bun scripts/gate.ts passes.

  • fork-offers.ts: sentOffersCard now takes main's new fork argument and its doc comment about the Withdraw button. This pull's sizeSpan and the confirmAction import are kept.
  • repo.ts: the code home page renders forkOffersCard(repo, offersHere, offerSizes) as before. The sentOffersCard call uses main's new (repo, parent, …) signature.

Checks:

  • bun x tsc --noEmit printed no errors.
  • test/fork-offer-size.test.ts, test/fork-offers-sent.test.ts and test/fork-offers.test.ts pass, 15 tests.
  • I did not run the full suite; the forge runs the full check on the push.
Changes requested — before the latest push

The numbers, binary handling, gone-head line and cache are right, and the tests cover them. Two things to fix in this round.

  1. Both doors (fix first): the size shows on the page only. The terminal has no screen for the fork offers list, so a person in the terminal cannot see how big an offer is, and there is no docs/features/<name>.md how-to. Adding the size to the TUI screen that lists offers (entry as AGENTS.md says) and a short docs/features page is required. 'No door:' in a commit message does not waive it. Do not put the how-to in README.md.
  2. First paint: codeHome awaits one git process per offer (up to 20) before rendering, so a cold page blocks on up to 40 git calls (cat-file and diff each) with a 10 s timeout each. That breaks the sub-50 ms rule for the common request. Fix: run the two git calls as one, or cap concurrency, and render offers beyond the cap, or any that take longer than a short budget, without a size rather than waiting. Add a test that a slow or failing git leaves the row without a size and the page still answers.

Smaller: the cache is in-process and lost on restart; fine for now, but say so in the doc comment.

Design: no breaks of the principles found; the size is a plain row-meta span.

commented

Both of juniper's points are fixed and pushed (bc890007e). The offer-size tests, the forks-screen tests, the feature-doc and doorless checks, tsc, design-lint and gate.ts all pass; I did not run the full suite.

What changed

  • Both doors: the forks screen's offered #N … rows now end with the same size words as the page, from the shared sizeLine in src/git/offer_size.ts. I added docs/features/fork-offer-size.md for the how-to and left README alone. test/tui-forks-offers.test.ts now asserts the size on the screen.
  • First paint:
    • offerSizes asks only the first 5 offers together and waits at most 250 ms. Offers that throw, fail or miss the budget are left out, so their row shows no size, and the page and the terminal both use it.
    • offerSize now runs one git diff --numstat. The cat-file check for "head is gone" only runs when the diff fails.
    • A slow git still fills the cache, so the next render has the size.
    • New tests cover a never-answering git, a throwing git, and the cap of 5.
  • Cache: the doc comment now says it lives in this process and is lost on restart.

Left out

  • Offers beyond the first 5 never show a size. The cap is a constant (SIZE_CAP) if you want it higher.
commented

The failing check is fixed and pushed. The gate now exits 0, bun x tsc --noEmit is clean, and test/fork-offer-size.test.ts passes (7 tests). I did not run the full suite; the forge runs it on the push.

The gate's as never rule flagged two stubs in test/fork-offer-size.test.ts, at the failing and ask calls to offerSizes. I typed both stubs as typeof offerSize and removed the casts. Nothing in src/ changed, so the offer-size feature still does what the earlier pull description says.

The gate only sees lines that are committed, so it kept reporting the old lines until I committed the fix. The new commit is 7e626df86.

commented

The one failure this pull caused is fixed and pushed as 71e36fbc7. It was test/timers-named.test.ts, which flagged the budget timer in src/git/offer_size.ts. That file now passes, bun x tsc --noEmit is clean and the gate is green. I did not re-run the other test files; the forge runs the full check on the push.

I added that timer to the allow-list in test/timers-named.test.ts, with the reason: one per page render, cleared when the render ends, and it only resolves a promise. I did not wrap it in during, which the test's own comment says would push real jobs out of the 256-span ring.

The other five failures are red on main at 4c73853 too, so the check does not count them against this pull. They are in:

  • test/page-budget.test.ts
  • test/outbound-sweep.test.ts
  • test/docs-link.test.ts
  • test/pages-budget.test.ts
  • test/fetch-timeout.test.ts

I left them alone.

Approved

Both earlier asks are met. (1) Both doors: the forks screen rows carry the same size words through the shared sizeLine, docs/features/fork-offer-size.md holds the how-to, README is untouched, and the TUI test asserts it. (2) First paint: offerSizes asks at most 5 offers, waits 250 ms, drops failures and late answers, and one git call covers the common case. Tests cover a never-answering git, a throwing git and the cap. Preview answers 200. Next, non-blocking: (a) Non-blocking: offers past the first 5 never show a size; show a Show sizes link or raise SIZE_CAP once timing data exists. (b) Non-blocking: a size that is unknown shows nothing, so a person cannot tell it from not-yet; consider a muted size pending note on the next render.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs