Skip to content

feat(native): preview a pull request's images and edited Markdown on the Pulls screen - #897

Merged
omartelo merged 1 commit into
mainfrom
feat/pr-image-markdown-preview
Oct 21, 2026
Merged

omartelo merged 1 commit into
mainfrom
feat/pr-image-markdown-preview

Conversation

@omartelo

Copy link
Copy Markdown
Collaborator

Summary

The Pulls screen's Files tab drew a changed image as "Binary file" and offered the Markdown preview only for an added file, because /blob and ReadFile read only what the clone holds. Both now reach a pull request's commits.

  • Images: /blob reads an object the clone lacks from GitHub's contents API, the way FileLines already does; a commit the clone holds is always read locally. The before side stands on the new project.PullRequestMergeBase RPC: the tips come from GitHub, and the merge base is computed with git merge-base when the clone holds both, else asked of the compare API. baseRefOid is not used, since it is the base branch's tip and goes wrong once the base moves.
  • Rate limit: the window asks the merge base once per pull request head, shared by every image card (mergeBaseMemo), and asks again only for a new head or after a failure.
  • Markdown: an edited file there gets the preview toggle, read at the head through the new project.ReadFileAt (local object first, GitHub otherwise, ReadFile's size and binary refusals).
  • docs/ceilings.md and CHANGELOG.md move with it.

Two native tests changed because their contract changed: TestBinaryFilesOpenWhenTheyHaveAPreview asserted an image in a pull request starts collapsed since the clone held neither side, and TestMarkdownPreviewIsOfferedWhereTheNewVersionIsReadable asserted an edited file in a pull request has no preview.

Test plan

  • Backend: gofmt, go vet ./..., go test ./... (new tests for the GitHub fallback, local-only reads, size cap, merge base local/compare/unreadable, ReadFileAt)
  • Native: gofmt, go vet ./..., go test ./...; mergeBaseMemo tests under -race -count=20
  • Against docs: show the native window on the social card #894 on GitHub: merge base and both sides of docs/media/og.png read from this clone and from an empty clone with only the remote, same bytes on each path

…the Pulls screen

/blob reads an object the clone lacks from GitHub's contents API, the way
FileLines does, and the new PullRequestMergeBase RPC names the commit a pull
request's old side stands on, computed locally when the clone holds both tips.
The window asks it once per head for every image card. ReadFileAt reads a
file whole at a revision, so an edited Markdown file renders at the head.
@omartelo
omartelo merged commit b1933eb into main Oct 21, 2026
10 of 11 checks passed
@omartelo
omartelo deleted the feat/pr-image-markdown-preview branch October 21, 2026 17:22
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