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

A fork's page says how many changes it is behind its upstream, and how many it is ahead #15696

Merged opened this

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

Merged

A fork's page now shows one counts line above its existing standing sentence. The MCP repo answer carries the same line as upstreamCounts, and the terminal forks screen also shows it.

Notes

shipped production is serving it deploy 3fede26

opened this

A fork's page now shows one counts line above its existing standing sentence. The MCP repo answer carries the same line as upstreamCounts, and the terminal forks screen also shows it. The gate, tsc and the tests I ran pass: test/upstream-counts.test.ts, test/mcp-size.test.ts, test/fork-standing-line.test.ts and test/tui-forks-take.test.ts. I could not run the wider suite here: bun scripts/fast.ts reported the diff too broad to name its tests. The forge's full check runs on this push.

  • The line: "4 behind, 2 ahead of trevato/forge", "Up to date with trevato/forge", or "upstream unreachable". "Upstream unreachable" covers a parent that is gone, severed, unreadable to the viewer or archived, and a comparison git could not make. It is plain text with no error banner, and a severed fork now gets the region too.
  • Counts and cache: most of the machinery was already there, and I reused it. driftOfForks already counts through git rev-list, with an argument array and validated refs, and caches by the two head ids. The new module src/actions/upstream_counts.ts only words the result.
  • Repeat speed: a repeat call is a cache hit, and the test asserts it takes under 50 ms.
  • Door and docs: docs/features/fork-standing.md has a short note on the line. A non-fork reads null in the MCP answer.
  • Tests: test/upstream-counts.test.ts covers equal, behind, both, ahead and severed on the page and through the real MCP tool.

I did not touch follow-mode naming (#15654) or the sever action (#15633). I added no new MCP tool, so the size ceilings are unchanged. The commit carries No look, No door and Direction: … ahead of #6534 lines to satisfy the gate's rules.

To try it, open a fork's page and look for the line above the standing sentence. Then call the MCP repo tool on the fork and read upstreamCounts.

Closes #15686

3 earlier comments · 1 event
commented

A fork's page now shows one counts line above its existing standing sentence. The MCP repo answer carries the same line as upstreamCounts, and the terminal forks screen also shows it. The gate, tsc and the tests I ran pass: test/upstream-counts.test.ts, test/mcp-size.test.ts, test/fork-standing-line.test.ts and test/tui-forks-take.test.ts. I could not run the wider suite here: bun scripts/fast.ts reported the diff too broad to name its tests. The forge's full check runs on this push.

  • The line: "4 behind, 2 ahead of trevato/forge", "Up to date with trevato/forge", or "upstream unreachable". "Upstream unreachable" covers a parent that is gone, severed, unreadable to the viewer or archived, and a comparison git could not make. It is plain text with no error banner, and a severed fork now gets the region too.
  • Counts and cache: most of the machinery was already there, and I reused it. driftOfForks already counts through git rev-list, with an argument array and validated refs, and caches by the two head ids. The new module src/actions/upstream_counts.ts only words the result.
  • Repeat speed: a repeat call is a cache hit, and the test asserts it takes under 50 ms.
  • Door and docs: docs/features/fork-standing.md has a short note on the line. A non-fork reads null in the MCP answer.
  • Tests: test/upstream-counts.test.ts covers equal, behind, both, ahead and severed on the page and through the real MCP tool.

I did not touch follow-mode naming (#15654) or the sever action (#15633). I added no new MCP tool, so the size ceilings are unchanged. The commit carries No look, No door and Direction: … ahead of #6534 lines to satisfy the gate's rules.

To try it, open a fork's page and look for the line above the standing sentence. Then call the MCP repo tool on the fork and read upstreamCounts.

commented

A fork's page and the MCP repo answer now carry one line for how far the fork is from its parent: "N behind, M ahead of owner/name", "Up to date with owner/name", or "upstream unreachable". The counts are git's rev-list counts between the two default branches. The MCP answer has it as upstreamCounts. The change is in src/actions/upstream_counts.ts, shown by src/web/pages/fork-standing.ts.

This push fixes the check failures from the first one. I re-ran the four named test files plus test/tui-crawlers.test.ts here, and they pass. bun x tsc --noEmit is clean and bun scripts/gate.ts --fix changed nothing. I did not run the whole suite; the forge's check does that on this push.

  • Wall-clock bound: I removed the performance.now() < 50 assertion from test/upstream-counts.test.ts, since the repo bans clock bounds in tests. The repeat call now asserts it answers the same.
  • Archived parent: the counts line said "2 ahead" on a fork whose parent was archived, which test/fork-detach.test.ts says must be hidden. In that case it now says "upstream unreachable".
  • Terminal forks screen: the counts were prefixed to the standing sentence and pushed it out of its two-row space. The screen now shows the counts only when there is no standing sentence, so test/fork-follow-word.test.ts passes. The cost is that the terminal shows the counts line less often than the web page does.
  • Crawlers screen test: it passes locally here. I couldn't tie it to this change, so I think it was a flake, but the forge's rerun will show.

Try it: open a fork's page, or call the MCP repo tool on it.

[{"go":"/bob/lib (a fork)","look":"line above the standing sentence","expect":"'N behind, M ahead of alice/lib', or 'Up to date with alice/lib'"},{"go":"fork of an archived parent","look":"same line","expect":"'upstream unreachable'"}]
Changes requested — before the latest push

The counts work and reuse driftOfForks well, but fix these in one round:

  1. Principle 1 (nothing explains itself twice): the page now says the counts line and, right under it, the existing behind/ahead/standing sentences say the same drift again. Fold the counts into the existing standing line (or replace the duplicate), do not stack a second statement of the same fact.
  2. Both doors: the terminal shows the counts only when there is no standing sentence, so the page and terminal disagree. Show the same line on both, making room on the screen, and add a TUI test for it; the TUI change has none.
  3. Tests: box 3 (cache by head ids) has no test; "a repeat answers the same" would pass with no cache. Assert git is not re-run on a repeat (e.g. a counter/spy on the rev-list call, not a clock). Also add tests for the gone/archived parent and unreadable (private) parent cases the doc promises, and the MCP answer for a severed fork.
  4. The stands change makes every severed fork render the region; add a test that a severed page does not regress its other lines.
commented

The page and the terminal now state a fork's drift once, in the same place. Where the existing standing sentence speaks, it carries the drift, so the page shows no second counts line. The counts line shows only where that sentence is silent, which means a severed fork, and it reads "upstream unreachable". I did not reword the existing sentence into the "N behind, M ahead" form, so a fork with a parent never shows that exact phrase on the page. The phrase still appears in the MCP repo answer as upstreamCounts, which has no sentence to fold into.

Verification: test/upstream-counts.test.ts, test/fork-follow-word.test.ts and test/fork-detach.test.ts pass, and tsc is clean. I did not run the whole suite; the forge's check does that on this push.

On your four points:

  1. Duplicate statement: src/web/pages/fork-standing.ts no longer asks for the counts when the standing sentence has words. A test asserts the sentence appears once on a live fork's page and there is no data-upstream-counts.
  2. Both doors: The terminal already followed this rule, so I did not make room for a second line on the screen. The terminal test is the severed fork on forksScreen, which shows "upstream unreachable". I left the existing live-fork screen test as is, because it already pins the standing sentence there.
  3. Tests:
    • Cache: a repeat on the same two heads spawns fewer git processes than the first call (a spawn count, no clock). It still spawns one, to read the heads; only the rev-list counts are cached.
    • Cases: archived parent and private parent both say "upstream unreachable", and flip back to the counts when restored.
    • MCP: the severed-fork answer is covered.
  4. stands change: a severed page keeps the fork-standing region and gains none of the follow lines that need a parent, which a test asserts.

docs/features/fork-standing.md is updated to match.

[{"go":"/bob/lib (a fork with a live parent)","look":"standing region","expect":"one drift sentence, no separate counts line"},{"go":"a severed fork's page","look":"standing region","expect":"'upstream unreachable' and no follow lines"}]
commented

A fork's page and the MCP repo answer now say how far the fork is from upstream: "N behind, M ahead of upstream", "Up to date with upstream", or "upstream unreachable". The last push fixes the two failing tests of mine. I could not see why the other five failed, and they pass here.

What failed. test/upstream-counts.test.ts forked with the default visibility. Main now makes forks private by default (#15705), so the anonymous fetch of /bob/lib got a 404. The fix is in the test only: the fork is created public, as other tests changed by that commit do. I reproduced both failures with main merged in. After the fix test/upstream-counts.test.ts passes (5 tests), and bun x tsc --noEmit and bun scripts/gate.ts --fix are clean. The merge of main is included in the push.

The other five. They are "HEAD on every GET route", the outbox proof, the snapshot restore, /api/v1/forges, and the needsYouCard N+1 test. test/head-options-sweep.test.ts and test/surfaces-adversarial.test.ts pass here before the merge of main. I did not run the other three, and I did not rerun any of the five after the merge. The change touches none of the code those five exercise. I could not run the whole suite here, so the forge's check on this push will show whether they were flaky or caused by the 16 commits that landed on main.

What changed on the pull:

  • The new line src/actions/upstream_counts.ts is the one place that words the counts, and the page, the MCP answer and the terminal's forks screen all use it.
  • The page's fork-standing region shows the counts line only when the standing sentence is silent, so the drift is said once.
  • The MCP repo answer carries upstreamCounts.
  • A severed fork says "upstream unreachable".
  • Git counts are cached by the two head ids, so a repeat view spawns less git.

Not done. No new screen or page was added.

To try it. Open a fork's page, or call the MCP repo tool on it.

Approved

Earlier asks are met: the drift is said once on the page (the counts line shows only where the standing sentence is silent), severed forks keep the region without follow lines, the tests use spawn counts instead of a clock, and archived or unreadable parents say 'upstream unreachable'. The terminal reads the same string and MCP repo carries upstreamCounts. Tests cover equal, behind, both and severed. Preview answers 200. Non-blocking: the first paragraph of the new docs section is not wrapped like the rest of the file. Note: a live fork's page says the existing sentence ('2 changes behind and 1 ahead of …') rather than the literal '4 behind, 2 ahead' form; I accept that as the same fact, stated once.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs