Repository navigation
feat(extensions): expose public hunk summaries on file views - #626
Merged
Merged
Conversation
Extensions could see selectedHunkIndex but not what it pointed at: hunk headers, ranges, and counts lived inside the opaque metadata, so a hunk checklist or agent-annotation navigator meant casting into an object the contract promises not to describe — the docs' own pick-hunk example did exactly that. Add ExtensionDiffHunk (index, @@ header, inclusive old/new line spans) and fill a hunks list on every read-only file view Hunk hands outward — event payloads, sidebar props, a command's selection. The index lines up with selectedHunkIndex and actions.selectHunk, summaries are derived from metadata at the view boundary (transforms neither receive nor produce them) and cached per parsed diff, and the derivation is shared with the agent session surface through one core helper so the two external views of a review cannot drift apart. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M7EZpzieiVPdj6LZn4oBYJ
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryAdds immutable public hunk summaries to extension-facing file views and unifies their derivation with the session review surface.
Confidence Score: 5/5The pull request appears safe to merge with no actionable defects identified. The new extension-facing summaries are derived from the same metadata and range helpers used by existing review surfaces, remain immutable at the public boundary, and preserve optional-range handling for legally synthesized hunks. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
M[Parsed file metadata] --> S[summarizeHunk]
S --> C[Cached frozen summaries]
C --> E[Extension event payloads]
C --> B[Sidebar file props]
C --> X[Command selection]
S --> R[Session review export]
Reviews (1): Last reviewed commit: "feat(extensions): expose public hunk sum..." | Re-trigger Greptile |
1 task
This branch was successfully deployed
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.
What
Adds
ExtensionDiffHunkto the public extension API and fills ahunkslist on every read-only file view Hunk hands outward — event payloads, sidebar props, and a command'sselection.Each summary carries
index, the@@header, and inclusive old/new line spans, in render order. The index is the same oneselectedHunkIndexreports andactions.selectHunkaccepts, so the three hunk surfaces line up by design.Why
Extension-author feedback (follow-up 2 of the report addressed by #625):
selectedHunkIndexis public, but hunk headers, ranges, and counts lived inside the opaquefile.metadata. That limited a progress view to files viewed and made a hunk checklist or agent-annotation navigator impossible without casting into an object the contract promises not to describe — the authoring guide's own pick-hunk example did exactly that cast.How
ExtensionDiffHunkis declared insrc/extension-api/types.ts(which stays import-free;check:packpasses) and exported from the barrel.metadataat the view boundary intoReadOnlyFileViews— likechangeType, transforms neither receive nor produce them, and a stalehunksvalue spread through a transform is replaced by what the metadata actually parses to. Derivation is cached per parsed-diff metadata object (views are rebuilt on every emit), and repeated conversions hand back the identical frozen list.src/core/hunkSummary.ts, now shared with the agent session surface (buildSessionFiles), so the two external views of a review cannot drift apart. A transform-synthesized hunk without numeric line data gets its declared header text (or an empty one) and no ranges, instead ofNaNspans.ctx.selection.file.hunksinstead of casting intometadata, the sidebar props docs describe the checklist/navigator recipe, and the transform docs state the derived-at-boundary contract.Testing
src/core/hunkSummary.test.ts(real Pierre-parsed hunks plus synthesized-hunk edge cases).toReadOnlyFileViewscoverage insrc/extensions/events.test.ts: derivation, frozen/cached identity, metadata-authoritative replacement, shared empty list for binary/skipped files.bun run typecheck,bun run lint,bun run check:pack(typechecks all 20 docs examples for nodenext + bundler consumers), fullsrc/suite (1583 pass),test/cli+test/session, and the extensions PTY integration tests all green.Changeset:
minorforhunkdiff.🤖 Generated with Claude Code
https://claude.ai/code/session_01M7EZpzieiVPdj6LZn4oBYJ
Generated by Claude Code