Skip to content

fix(web): diff hang, fast merge-base walk, short commit ids, persisted browse index (D-005, D-040, D-057, D-023) - #70

Merged
PastaPastaPasta merged 5 commits into
masterfrom
fix/web-diff-hang
Sep 27, 2026
Merged

PastaPastaPasta merged 5 commits into
masterfrom
fix/web-diff-hang

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

Fixes D-005 (S1), D-040, D-057 and D-023: web code-browsing defects from QA wave 1.

D-005: commit and PR diffs stuck on "Reading file…"

  • Root cause: found and reproduced live. DiffView wrote each finished patch with pending.current.set(key, await loadFilePatch(...)).
    • JavaScript evaluates the receiver pending.current before the await.
    • When a flush had already swapped in a fresh map, a patch that landed afterwards went into the batch that was already committed. It never rendered.
    • With nothing left in flight, the file sat on "Reading file…" forever. That matches the evidence: 0 requests in flight and an idle CPU.
  • Live repro on preact 8101ff8, a 7-file commit: master hung on 4 of 4 loads with 1 to 4 files stuck. This branch hung on 0 of 4.
  • Fix: lib/view/batcher.ts owns its pending map, so no caller can hold a stale one.
  • Also:
    • Pending patches are flushed on unmount.
    • A load that throws becomes an "unreadable" placeholder instead of a permanent spinner.

D-040: merge-base walk on PRs spanning more than 2,000 commits

  • Before: the walk read commits one ranged GET, or one chunk query, at a time: 2,065 storage GETs and about 100 s. It gave up at 2,000 commits.
  • Read-ahead: it now reads through readAheadSource, a cache of aligned 256 KiB blocks.
    • git pack-objects --revs, which forge-core pack/build.rs uses, writes all commits first and in history order. So one block holds hundreds of commits.
    • Unit test on a real 2,700-commit pack: 3 reads instead of about 2,700.
    • The cap is now 50,000 commits, as a runaway guard.
  • Scope of the cache:
    • The walker, and its block cache of at most 16 MiB, lives for one comparison only.
    • A single-copy pack does not fetch its first block twice.
    • Hash-check verdicts reach the trust panel in batches, not one re-render per commit.
  • Progress and cancel: the PR view shows "Finding where this PR branched: N commits read" with a Stop button.
    • A stopped search on a native PR falls back to the head's first parent, says so, and offers Search again.
    • On an imported PR it says the search was stopped. It does not claim that history is missing.
    • Progress also shows during a reload, and a disabled comparison aborts its walk.
  • Merge engine: findMergeBases, used by the browser merge engine from feat(web): merge pull requests in the browser (fast-forward and disjoint merges) #61, takes the same options. That engine keeps its own read budget.
  • Not used: a generation-number or commit-graph approach. Forge publishes no commit-graph artifact, so the browser has no generation numbers to read.

D-057: short or odd-length commit ids

  • Commit URLs accept 4 to 40 hex characters, including odd lengths such as the 7-character form the UI shows.
  • Resolution: as git does, by prefix over the objectLocator's sorted OID index (ObjectLocator.findByPrefix: the fanout slice, then a binary search).
    • Candidate types come from the pack entry header only. A short id that matches a large blob does not download it.
  • Clear states instead of "Input string must contain hex characters in even length":
    • Not a commit id
    • Commit not found
    • Not a commit (a file or directory)
    • Ambiguous, with the candidate commits
  • Partial fallback clone: some packs could not be fetched. Here the page says the commit may be in one of those packs rather than "not found". There is a new MissingObjectError class.

D-023: S3-stored repos re-download the browse index on every load

  • objectLocator fragments are kept in IndexedDB (dash-forge-index), keyed by network and manifest packHash.
    • A copy is re-checked against its sha256 on every read, using WebCrypto.
    • It is stored only after it verifies.
    • A corrupt row is a cache miss, never a wrong index.
  • Eviction: least recently used, under a 256 MiB budget. It reads a small meta store, never the stored bytes.
  • Scope: self-contained in lib/view/index-cache.ts, so the P-2 delta caches can fold it in.
  • Live check on ripgrep, a Platform-stored repo: reloads made 11 chunk queries instead of 13. The two saved queries are the index fragments, about 537 KB. On an S3-stored repo that is the 14.4 MB GET.
  • Not measured live: the gitgit2 repo's storage tunnel from the QA run is gone. The budget is asserted in unit tests instead:
    • browse-source.test.ts: a second resolve makes 0 fragment chunk queries.
    • index-cache.test.ts: tests against fake-indexeddb, a new dev dependency.

Tests

  • Unit tests (1,420 passing):
    • batcher.test.ts
    • read-ahead.test.ts covers block edges, pack end, failure fallback, copy keys and LRU.
    • merge-base-budget.test.ts covers the request budget, verdict batching, progress and Stop, and a short id through a real BrowseReader.
    • commit-id.test.ts
    • index-cache.test.ts
    • A new case in browse-source.test.ts.
  • Playwright e2e/code-browsing.spec.ts, run against moutai on the preact showcase repo:
    • The 7-file commit loads every file on 3 fresh loads.
    • The 7-character id resolves.
    • zzzz and 0000000 give clear states.
    • All three fail on master and pass here.
  • Not live-tested: the PR merge-base path. The showcase PRs are being re-imported, so preact #5269 does not exist right now.

Evidence: /Users/pasta/workspace/dash-forge-qa/evidence/impl/fix-web-diff-hang/

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 413f160c-064c-4f35-9ece-dadd84f6a499

📥 Commits

Reviewing files that changed from the base of the PR and between fbd3e83 and b27e2c7.

⛔ Files ignored due to path filters (1)
  • forge-web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (24)
  • forge-web/components/repo/commit-content.tsx
  • forge-web/components/repo/diff-view.tsx
  • forge-web/components/repo/pull-diff.tsx
  • forge-web/e2e/code-browsing.spec.ts
  • forge-web/lib/browse/index.ts
  • forge-web/lib/browse/indexer.ts
  • forge-web/lib/browse/locator.ts
  • forge-web/lib/browse/read-ahead.test.ts
  • forge-web/lib/browse/reader.ts
  • forge-web/lib/view/batcher.test.ts
  • forge-web/lib/view/batcher.ts
  • forge-web/lib/view/browse-fallback.ts
  • forge-web/lib/view/browse-source.test.ts
  • forge-web/lib/view/browse-source.ts
  • forge-web/lib/view/commit-id.test.ts
  • forge-web/lib/view/commit-log.ts
  • forge-web/lib/view/content-checks.ts
  • forge-web/lib/view/index-cache.test.ts
  • forge-web/lib/view/index-cache.ts
  • forge-web/lib/view/index.ts
  • forge-web/lib/view/merge-base-budget.test.ts
  • forge-web/lib/view/pull-diff.ts
  • forge-web/lib/view/tree-nav.ts
  • forge-web/package.json

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@PastaPastaPasta

Copy link
Copy Markdown
Owner Author

@coderabbitai review


🤖 Posted autonomously by Claude on behalf of pasta.

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

PastaPastaPasta and others added 5 commits September 27, 2026 12:02
DiffView wrote each finished patch with pending.current.set(key, await load()). The receiver is read before the await, so a patch that finished after a flush had swapped in a fresh map went into the batch that was already committed and never rendered. The file stayed on Reading file forever with nothing in flight: 4 of 4 loads of preact 8101ff8 on master, 0 of 4 with the fix.

The batching now lives in createBatcher, which owns its pending map, so no caller can hold a stale one.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…se index

D-040: the merge-base walk read commits one ranged GET at a time and gave up at 2,000 commits. It now reads through a block read-ahead source (256 KiB blocks); pack-objects stores commits first and in history order, so a block holds hundreds. A 2,700-commit walk costs 3 reads instead of 2,700, the cap is 50,000, and the PR view shows commits read with a Stop button. A stopped search falls back to the first parent, and a Search again button restarts it.

D-057: commit URLs accept 4 to 40 hex characters, including odd lengths. A short id is resolved by prefix over the locator's sorted OID index, as git does. Ambiguous, unknown and malformed ids get a clear message instead of a raw hex error.

D-023: objectLocator fragments are kept in IndexedDB, keyed by their manifest packHash and re-checked against it on every read. A reload no longer downloads the whole browse index. The store is self-contained so the P-2 delta caches can fold it in.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…fixes

Index cache: eviction reads a small meta store instead of loading every stored index, entries are touched on read so eviction is least recently used, a connection opened after a blocked upgrade is closed, and hashes use WebCrypto. It is tested against fake-indexeddb.

Merge base: the read-ahead walker is built per comparison and dropped afterwards, a single-copy pack keys its blocks as copy 0 so the first block is not fetched twice, and hash-check verdicts reach the trust panel in batches. A reload shows progress and Stop, a stopped search on an imported PR says it was stopped, and a disabled comparison aborts its walk.

Short ids: candidate types are read from entry headers only, a partial clone says the commit may be in an unreachable pack instead of not found, a single non-commit match gets its own message, and 16 or more matches are ambiguous. Diff view: a failed load becomes a placeholder, and pending patches are flushed on unmount.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@PastaPastaPasta
PastaPastaPasta merged commit 0fe5380 into master Sep 27, 2026
5 checks passed
PastaPastaPasta added a commit that referenced this pull request Sep 27, 2026
The CLI issue-parity scenario is renumbered 21 (20 is config + storage UX).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant