Skip to content

feat(web): image previews, line anchors, permalinks and windowed rendering for blobs (D-054, D-055) - #71

Merged
PastaPastaPasta merged 3 commits into
masterfrom
fix/web-blob-view
Sep 27, 2026
Merged

PastaPastaPasta merged 3 commits into
masterfrom
fix/web-blob-view

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

Fixes D-054 and D-055: the blob view from QA wave 1.

D-054: image previews, line anchors and permalinks

Image previews

  • PNG, JPEG, GIF, WebP and SVG blobs are previewed as an <img>.
  • Raster types must match their magic bytes, so a misnamed file is not "previewed". Anything over 10 MB stays Raw-only.
  • SVG is never inline, and never a same-origin blob: URL. It is shown from a data:image/svg+xml URL.
    • Review found that a blob: SVG opened with "Open image in new tab" loads as a document on the forge origin and runs its script. That was checked in Chromium and Firefox.
    • A data: document is opaque-origin, and top-level data: navigation is blocked.
  • An SVG also has a Code view, as on GitHub.

Line anchors

  • #L10 and #L10-L20 are highlighted and scrolled into view on open, or when the fragment is edited. A click selects a line and shift-click extends the selection, without scrolling the page.
  • Rows are exactly 20 px, with no td padding. U+2028 and U+2029 are shown as markers, so WebKit keeps each row to one line and deep links land on the right line.

Permalinks

  • Copy permalink pins the commit: ?ref=<full commit id>.
  • selectRef now treats a full commit id that no branch or tag is named as a pinned commit. So the blob, tree, home, commits and zip views all follow a permalink.
  • The trust panel says the commit was opened by its id and that no ref vouches for it, shown as "Partly verified". Before this, it would have said the ref does not exist.

D-055: large blobs rendered every line

Windowing

  • Files over 2,000 lines render only the rows near the viewport, using spacer rows and a rAF-throttled scroll listener.

  • Live on jq vendor/decNumber/decNumber.c (388 KB, 8,144 lines):

    DOM elements JS heap
    Before 35,410 81 MB
    After about 650 45 MB
  • #L8000 lands on the line.

Large files

  • Text over 1 MB offers View raw, which opens as text/plain, or Render anyway. The choice resets per file.
  • Syntax highlighting keeps its existing caps of 512 KB and 20,000 lines.

Tests

Unit tests

  • blob-view.test.ts covers magic bytes, SVG detection, hash parsing, shift-click, the window math and the 1 MB gate.
  • refs.test.ts covers pinned commits.

Playwright (e2e/blob-view.spec.ts, against moutai on the fd and jq showcase repos)

  • A PNG is shown from a blob: URL and the SVG from a data: URL; the SVG's Code view works.
  • #L10-L20 highlights the range, and click and shift-click select without scrolling.
  • The permalink pins the commit and opens again.
  • #L500 of a 561-line file is in the viewport, and a row is exactly 20 px.
  • The 8,144-line file renders fewer than 300 rows.

Regression

  • v2-reads.spec.ts still passes, 9 of 9.

Not covered live

  • The 1 MB gate. No showcase file is that large, and the gitgit2 storage tunnel from the QA run is gone. It is covered by unit tests.

Evidence: /Users/pasta/workspace/dash-forge-qa/evidence/impl/fix-web-blob-view/

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 47 seconds.

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: 4bce7869-93db-4726-9c04-107694a8a8c5

📥 Commits

Reviewing files that changed from the base of the PR and between e0462ea and a8f25fa.

📒 Files selected for processing (13)
  • forge-web/components/repo/blob-content.tsx
  • forge-web/components/repo/clone-box.tsx
  • forge-web/components/repo/commits-content.tsx
  • forge-web/components/repo/repo-home-content.tsx
  • forge-web/components/repo/repo-rail.tsx
  • forge-web/components/repo/tree-content.tsx
  • forge-web/e2e/blob-view.spec.ts
  • forge-web/lib/view/blob-view.test.ts
  • forge-web/lib/view/blob-view.ts
  • forge-web/lib/view/index.ts
  • forge-web/lib/view/refs.test.ts
  • forge-web/lib/view/refs.ts
  • forge-web/lib/view/trust.ts

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 3 commits September 27, 2026 12:09
D-054: PNG, JPEG, GIF, WebP and SVG blobs are previewed through an img of a blob: URL; raster formats must match their magic bytes, and an SVG is never put in the document. Line numbers are #L10 and #L10-L20 anchors (shift-click extends) with highlighting, and Copy permalink pins the commit: blob and tree views now accept a full commit id as ref.

D-055: files over 2,000 lines render only the rows near the viewport, so decNumber.c (388 KB) drops from 35,410 DOM elements to about 650. Text over 1 MB offers View raw or Render anyway instead of rendering. Syntax highlighting keeps its existing 512 KB and 20,000-line caps.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
selectBrowseRef replaces the pinned-commit logic that was duplicated in the tree and blob views. Object URLs are now created in an effect, so React StrictMode's effect replay can no longer revoke a URL that is still on screen. The display kinds are handled in a switch, and the unused exports are removed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
An SVG preview is a data: URL, not a same-origin blob: URL. Opened in a new tab, a blob: SVG loaded as a document on the forge origin and ran its script. SVGs also get a Code view. View raw opens text/plain instead of downloading.

Line cells have no vertical padding, so rows are exactly 20 px and #L links land on the line; U+2028 and U+2029 are shown as markers so WebKit keeps them on one line. Only a URL fragment scrolls, not a click; line numbers are not tab stops; a modified click opens a new tab. The render-large choice resets per file.

A pinned commit (ref=<full id>) is now part of selectRef, so home, commits, the zip and the trust panel follow a permalink instead of saying the ref does not exist. The trust panel says the commit was opened by id and no ref vouches for it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@PastaPastaPasta
PastaPastaPasta merged commit a420fb5 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