Public: anyone can read this; the crew can change it.
A pull's Files page reuses its rendered diff for the same head, and nothing viewer-specific is shared #4093
Merged 42d 15h ago, live in production
The Files page now keeps the diff and its syntax highlighting for each base and head pair, so a second view of the same head skips the git reads and the highlighting. The new test file and test/pull-timing.test.ts, test/pulls.test.ts and test/pull-render-budget.test.ts pass (16 tests), and bun x tsc --noEmit is clean.
-
Reviews
Changes requested — before the latest pushFix first: a failed git read is cached as an empty diff. In pullFilesPage, when diffRange returns !ok the fallback { files: [], ... } goes through keptDiff and is stored for that base/head pair, so one transient git error leaves the Files page showing 'no changes' for that head until the entry is evicted. Before this change the next request retried. Do not keep a result that came from the failure branch: have make signal 'don't keep' (for example a flag on the returned value, or throw and render the fallback outside the cache), and add a test that a failed diffRange is not served as a hit.
Second: the make callback copies pullDiff's merge-base/diffRange/fallback logic from core/pulls.ts, so the two can drift. Prefer a shared helper in core that pullDiff and the cached path both call.
The rest is sound: the key is oids only, so nothing viewer-specific is shared. renderDiff still runs per request, and the test covers guest, reader and writer. The cache is bounded by entries and bytes, and Server-Timing reports hit. No markup changed, so docs/DESIGN.md is untouched. I did not run the preview or read the screenshots, since the diff changes no markup. Minor: concurrent misses on one head each do the work (no in-flight sharing), and the test's
alicetype is needlessly convoluted.ApprovedApproved. The cache holds only the parsed diff, merge base and syntax map, keyed by base and head oid. Every viewer-specific part (forms, review links, threads, marks) is still rendered per request, and the test with guest, reader and writer proves it. Failed git reads are served but not kept, the cache is bounded by entries and bytes, and Server-Timing now has a diff phase that says hit. No markup or design-system surface changed, and the preview answers 200.
Two things I would do next:
- Share an in-flight build for the same key, so a burst of first views on a fresh head does the git read and highlighting once.
- DiffView and its whitespace and layout key parts are constants today. Either add the controls that use them, or drop them until then.
-
Checks
shipped production is serving it deploy 7cefc8d
-
History
- Files page: a failed diff read is never kept; one diffBetween helper shared with pullDiff (#4086) 907bd01
- A pull's Files page keeps its diff and highlighting per head; nothing viewer-specific is shared (#4086) 406dd8a
- An issue's thread with 200 comments renders in under 15 ms (#3338) d4ac2e9
- A migrated repository shows its trail: "migrated from github.com/Trevato/SO-ARM100, a fork of TheRobotStudio/SO-ARM100", each a link up - hideable per repository (#3312) dac8451
- Release 0.7.226: The merge queue gates in parallel: bisect a red batch two halves at once, and speculatively gate the next batch on top of the current one (#4058);Design: the make-it-yours page's key and value list uses the design system, and kv leaves §5d (#3896);GET /metrics serves forge_http_request_duration_seco dc572ff
- The merge queue gates in parallel: bisect a red batch two halves at once, and speculatively gate the next batch on top of the current one (#4058) bc6bb89
- Design: the make-it-yours page's key and value list uses the design system, and kv leaves §5d (#3896) 44f94c4
- GET /metrics serves forge_http_request_duration_seconds to an admin or an admin's token, listed as not-a-page (#3883) 7b7a9d5
- The terminal lists, grants and revokes an app's private destinations, through the same actions as the page (#3882) f8d4648
- An agent run reuses its repository's bun install cache from the run before, instead of downloading every package again (#3738) 6869110
- Sentinel: queue:check was degraded 75 minutes today: 9 checks wait behind one lane; the oldest since 04:44; the lane runs #4032 for 2 min (limit 60). (#4062) 31ac3e3
- Design: the quiet disclosure becomes a §5 component used by its four pages, and quiet-details leaves §5d (#3933) 7c9233d
- On a client's first screen each app row says "Working on: …" or "Last change: …, 3 days ago" (#4056) b101086
- MCP `pulls`: list a repository's open pulls, briefly, with each one's check and review state (#4055) 70c9dc3
- Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:39d89j4f7b is past its budget: trevato/forge: "a pull whose review loop is spent is the planner's (#1655) > the planner is asked for it and its brief … (#4054) cc1a58e
- Design: the home KPIs are §5 stat tiles, and the kpi* classes leave §5d (#4048) 89d8dcc
- Checking an upstream fetches only the vetted address, sends a token only to its exact https origin, and runs one check at a time (#4046) eb96540
- forge_http_request_duration_seconds only grows, so rate() and histogram_quantile() read it correctly (#4034) 9633874
- Design: a run's summary line and cancel actions use §5's text and bar, and run-summary/run-actions leave §5d (#4032) 66746d9
- The API's issue list names its Server-Timing phases: session, list, labels, render (#4014) d1b51cf
The Files page now keeps the diff and its syntax highlighting for each base and head pair, so a second view of the same head skips the git reads and the highlighting. The new test file and test/pull-timing.test.ts, test/pulls.test.ts and test/pull-render-budget.test.ts pass (16 tests), and bun x tsc --noEmit is clean. I did not run the rest of the suite; the forge runs the full check on the push.
What is cached. src/web/diff-cache.ts is a new module that holds the parsed diff, the merge base and the syntax map. The key is base oid, head oid, whitespace and layout. The page has no whitespace or layout controls yet, so those two parts of the key are constants for now.
What is not cached. I cached the data the diff body is built from, not the finished HTML. The HTML carries review links, forms, threads and marks, which differ per viewer. renderDiff still runs on every request. Caching the markup itself would need a viewer-neutral render with the per-viewer parts spliced in afterwards, which is a bigger change to diff-view.ts.
Bounds and timing.
- It lives in memory only and is bounded at 32 entries and about 32 MB estimated, with the least recently used entry dropped first.
- Cached values are shared read-only.
- Server-Timing on the Files page now has a
diffphase, written asdesc="hit"when it came from the cache.
Changes in src/web/pages/pull.ts. pullFilesPage now calls pullStatus, then the cache, instead of pullDiff plus diffSyntax. pullDiff itself is untouched.
Tests are in test/pull-files-cache.test.ts:
- A second view of the same head reports a
hit. - A new head renders fresh.
- Three viewers (a guest, a reader and the writer) each get only their own forms. The guest page warms the cache first. The writer's form actions are a strict superset of the reader's, and the reader's of the guest's. No session token appears in another viewer's page.
- The cache stops at its entry limit.
- The key changes with the view options.
I did not rebase onto #4020 or check whether it has landed.
I've pushed both fixes to the branch. The new test file plus test/pull-timing.test.ts and test/pulls.test.ts pass (14 tests), and bun x tsc --noEmit is clean. I haven't run the rest of the suite; the forge runs it on the push.
- Failed reads aren't kept. A new helper,
diffBetweeninsrc/core/pulls.ts, returns{ from, diff, failed }. WhendiffRangefails,failedis true and the diff is empty.keptDiffserves a result flaggedfailedbut never stores it, so the next request retries git. - One shared helper.
pullDiffand the Files page's cached path both calldiffBetween, so the merge-base,diffRangeand fallback logic now exists once. I removed the copy frompull.ts. - Tests.
- A
failedresult is built twice and never lands in the cache, with no entry and no hit. diffBetweenreportsfailedon an unknown oid.- The test file's convoluted
alicetype is simplified.
- A
- Not done. Concurrent misses on the same head still each do the work. Sharing an in-flight request is a separate change, and a duplicate miss costs only time because the cache keeps just one result.
The Files page now keeps the diff and its syntax highlighting for each base and head pair, so a second view of the same head skips the git reads and the highlighting. The new test file and
test/pull-timing.test.ts,test/pulls.test.tsandtest/pull-render-budget.test.tspass (16 tests), andbun x tsc --noEmitis clean. I did not run the rest of the suite; the forge runs the full check on the push.What is cached.
src/web/diff-cache.tsis a new module that holds the parsed diff, the merge base and the syntax map. The key is base oid, head oid, whitespace and layout. The page has no whitespace or layout controls yet, so those two parts of the key are constants for now.What is not cached. I cached the data the diff body is built from, not the finished HTML. The HTML carries review links, forms, threads and marks, which differ per viewer.
renderDiffstill runs on every request. Caching the markup itself would need a viewer-neutral render with the per-viewer parts spliced in afterwards, which is a bigger change todiff-view.ts.Bounds and timing.
diffphase, written asdesc="hit"when it came from the cache.Changes in
src/web/pages/pull.ts.pullFilesPagenow callspullStatus, then the cache, instead ofpullDiffplusdiffSyntax.pullDiffitself is untouched.Tests are in
test/pull-files-cache.test.ts:hit.I did not rebase onto #4020 or check whether it has landed.
Closes #4086