[diffshub] Comment Support - #1046
Draft
amadeus wants to merge 5 commits into
Draft
Conversation
Saving a GitHub token now asks what the token is allowed to do: read private diffs only, or also post PR comments. The form's create-token link opens GitHub with the matching permissions preselected, and the active state shows which kind of token is saved. The app previously stored the bare token string and never knew what it was allowed to do, which blocks the upcoming GitHub comments work. Tokens are now saved in localStorage as a versioned JSON envelope recording the declared capability; existing bare-string tokens keep working and load as read-only. The two token forms (home page and viewer settings) also stay in sync, sharing changes via a same-tab broadcast and the cross-tab storage event.
Open a GitHub PR or commit in DiffsHub: the comments sidebar now lists the source's actual review comments — grouped into threads, ordered by file and line, with each row showing the author's real GitHub avatar and a two-line snippet of the comment. Private repos use the saved PAT; public ones work without a token. The browser talks only to a new same-origin /api/github-comments proxy, which pages through GitHub's review/commit comment APIs (up to 1,000 comments), normalizes them into a small wire model, and includes the PR head sha for the upcoming posting work. A client hook fetches alongside the patch, waits for the viewer to finish streaming, then anchors each thread root onto viewer items via the file-tree path map. Outdated, file-level, and out-of-diff comments are held back until they get dedicated UI. Locally drafted comments still work and survive refetches. Also folds the duplicate DiffsHubSavedCommentEvent type into DiffsHubSavedCommentEntry, and constrains the sidebar rows (min-w-0 + line clamp) so long unbreakable comment content can no longer force the list into horizontal overflow.
Open a GitHub PR with review comments: each thread now renders as a card directly on its line in the diff — root comment plus replies, with real avatars, relative timestamps, and a link back to GitHub. Clicking a card highlights the commented lines. File-level comments render above the file's first line. Outdated comments, whose lines no longer exist in the head diff, stay in the sidebar with an "Outdated" badge and expand in place to show their full thread, since there is nowhere honest to anchor them inline. Sidebar rows also show each thread's reply count. Adds a third CommentMetadata variant (kind: 'github') carrying the whole thread, a GitHubAnnotation card component, and annotation injection in useGitHubComments — GitHub annotations are re-applied idempotently on refetches without touching locally drafted comments. Renames ExampleAnnotation to LocalCommentAnnotation now that real comments render beside it.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
On a pull request with a write-capable token saved, the draft comment form now posts straight to GitHub: the form shows your GitHub avatar and a posting state, then the draft becomes a real thread card with the author and timestamp from GitHub's response. Thread cards gain a GitHub-style reply form. Failures keep the draft text and surface the error as a toast; with a read-only token the local demo flow remains, labeled as saved-locally with a hint to add a write token. The new POST /api/github-comments handler proxies both shapes with the caller's token only — the server env token never authors comments — and passes through actionable upstream statuses (rate limits remapped to 429 so 403 always means missing write access). A new /api/github-user route resolves the token owner's identity for the compose forms. The token control explains fine-grained PAT resource-owner scoping and preselects the viewed repo's owner in the creation link via target_name. Both compose forms are restyled after GitHub's comment box: bordered input, avatar beside the field, Cancel/Comment actions bottom-right. The comment wire model renames author to user to match GitHub's payload field names.
Open a diff with a saved non-default theme: any freshly created worker pool (a cold load, or an HMR that recreates the provider mid-session) booted on the library's default theme pair, so the first themed surface to mount committed a real theme change one tick after the viewer queued its highlight tasks — invalidating and canceling all of them, which surfaced as WorkerPoolTaskCanceledError console errors in dev. Construct the pool from the theme controller's persisted selection instead (read synchronously on the client; catalog defaults on the server and for first-time visitors), so the mount-time setRenderOptions call matches the pool's options and bails without invalidating.
amadeus
commented
Aug 3, 2026
| // Whether saved drafts post to the pull request on GitHub; only changes | ||
| // the empty-state copy. | ||
| canPostToGitHub?: boolean; | ||
| commentSections: readonly DiffsHubSavedCommentItem[]; |
Member
Author
There was a problem hiding this comment.
you really should figure out how to get good
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP