Skip to content

feat(extensions): expose current selected line - #779

Merged
benvinegar merged 1 commit into
mainfrom
feat/extension-current-line
Aug 16, 2026
Merged

benvinegar merged 1 commit into
mainfrom
feat/extension-current-line

Conversation

@benvinegar

@benvinegar benvinegar commented Aug 16, 2026 •

Copy link
Copy Markdown
Member

Summary

  • add API v7 ctx.selection.currentLine snapshots for extension commands
  • keep current-line and selection reads coherent across same-flush navigation
  • document the contract and cover immutable, marker-off, async, and cross-file navigation cases

Validation

  • bun run typecheck
  • bun run lint
  • bun run check:docs
  • bun test src/ui/lib/extensionSelection.test.ts src/ui/fileViews/useFilePresentationController.test.tsx src/ui/AppHost.extension-sidebar.test.tsx

bun run check:pack remains blocked before consumer validation by the repository's missing src/assets/zig/tree-sitter-zig.wasm; the full suite also has an unrelated src/core/diffFile.test.ts pairing failure and missing @axe-core/playwright website dependency.

This PR description was generated by Pi using gpt-5.6-terra

@vercel

vercel Bot commented Aug 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hunk-web Ready Ready Preview Aug 16, 2026 7:16pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds API v7 support for immutable ctx.selection.currentLine snapshots and synchronizes command-time selection reads with live review state.

  • Adds a nullable, frozen source-line address to the public extension selection type.
  • Reads normalized selection and cursor state synchronously for same-flush command dispatch.
  • Updates package checks, extension documentation, and tests for marker-off, asynchronous, and cross-file cases.

Confidence Score: 5/5

The PR appears safe to merge, with the new selection snapshot contract consistently implemented, documented, and tested.

Runtime API versioning derives from the updated constant, production snapshots always include the new field, and ownership checks prevent stale cursor addresses from being exposed against a different file or hunk.

Important Files Changed

Filename Overview
src/extension-api/types.ts Bumps the public extension API to v7 and adds the documented nullable current-line snapshot field.
src/ui/App.tsx Builds command selection snapshots from synchronous review-controller getters while preserving stable command callbacks.
src/ui/hooks/useTerminalReview.ts Exposes synchronous normalized-selection and cursor getters backed by the live store and cursor ref.
src/ui/lib/extensionSelection.ts Copies and freezes the current line only when it belongs to the resolved public file and hunk selection.
src/ui/AppHost.extension-sidebar.test.tsx Covers immutable snapshots, same-flush movement, async retention, cross-file navigation, and marker-off behavior.
scripts/check-pack.ts Updates the packed public API consumer check for the required currentLine field.

Sequence Diagram

sequenceDiagram
  participant Key as Terminal key event
  participant App as App command dispatch
  participant Review as Review controller
  participant Builder as Selection snapshot builder
  participant Ext as Extension command
  Key->>App: Invoke extension command
  App->>Review: getSelection()
  Review-->>App: normalized file and hunk
  App->>Review: getLineCursor()
  Review-->>App: active cursor or null
  App->>Builder: buildExtensionReviewSelection(...)
  Builder-->>App: frozen file, hunkIndex, currentLine
  App->>Ext: invoke with ctx.selection
Loading

Reviews (1): Last reviewed commit: "feat(extensions): expose the current sel..." | Re-trigger Greptile

@benvinegar
benvinegar merged commit bf28a59 into main Aug 16, 2026
13 checks passed

This branch was successfully deployed

1 active deployment
Preview — ede08c61 Deployed Aug 16, 2026 by vercel[bot]
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