Registry Mirror
Skip to content

Conversation

@benvinegar

Copy link
Copy Markdown
Member

What

Replaces the authoring guide's "pane geometry / selection follow are not supportable in a third-party sidebar" caveat with a documented, committed contract: the scrollbox ref. Custom sidebars hold a React ref to their <scrollbox>, give rows stable id props, and get:

  • scrollChildIntoView(id) for selection following (with a full recipe in the guide),
  • scrollTop / viewport.height for pane geometry — including the pre-first-layout zero-read caveat,
  • verticalScrollBar / viewport change events for reacting to scrolling and pane resizes.

Why

Extension-author feedback (round 2, finding 1) claimed a third-party sidebar cannot reproduce the built-in sidebar's windowing or follow-selection without host internals. Investigation showed the claim was overstated: everything the built-in sidebar does with its scrollbox goes through host-served @opentui/core and plain refs, which extensions already receive — the only internal pieces are rendering helpers. The real gap was that none of this was documented or committed, so authors reasonably treated it as off-limits. The feedback itself suggested "a supported scrollbox ref contract" as the alternative; this PR makes that the answer, instead of new viewport props that would duplicate what the ref already exposes.

How

  • The sidebar section gains a "Scrolling: the scrollbox ref contract" subsection with a follow-selection recipe (rows modeled on the built-in sidebar's id-on-box pattern), the committed ref surface, and an honest caveat that the contract rides on Hunk's pinned OpenTUI version — with the built-in sidebar exercising the same calls as the compatibility guarantee.
  • The bundled sidebar's module header now marks its scrollbox usage as load-bearing: changing how it talks to its scrollbox means updating the published contract.
  • A new AppHost test runs the exact published recipe from a TSX fixture extension through the real host runtime: a 30-row list overflows its pane, the selection walks to the last file, and the last row being on screen proves scrollChildIntoView scrolled; the fixture's ref reads prove the geometry side.

Testing

  • New test in src/ui/AppHost.extension-sidebar.test.tsx (suite now 8 passing).
  • bun run typecheck, bun run lint, bun run check:pack, full src/ suite — all green.

Changeset: patch for hunkdiff.

🤖 Generated with Claude Code

https://claude.ai/code/session_01M7EZpzieiVPdj6LZn4oBYJ


Generated by Claude Code

Extension-author feedback said windowing and selection follow were
impossible without host internals. Investigation showed otherwise:
everything the built-in sidebar does runs through the scrollbox ref
from host-served @opentui/core — scrollChildIntoView over child id
props, scrollTop/viewport.height reads, and the scrollbar/viewport
change events. The gap was that none of it was documented or committed.

Replace the guide's "not supportable today" caveat with the supported
ref contract and a follow-selection recipe, note the pre-first-layout
zero read, name the OpenTUI-version coupling honestly, and mark the
bundled sidebar's scrollbox usage as load-bearing so changing it means
updating the contract. A new AppHost test runs the exact published
recipe from a TSX fixture extension: a 30-row list follows the
selection to its last row, which is only on screen if the ref contract
actually scrolled the pane.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M7EZpzieiVPdj6LZn4oBYJ
@greptile-apps

greptile-apps Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR establishes and tests a supported scrollbox-ref contract for custom extension sidebars.

  • Documents selection following, viewport geometry, event subscriptions, cleanup, and first-layout behavior.
  • Marks the bundled sidebar’s scrollbox usage as the compatibility reference.
  • Adds an AppHost extension fixture covering selection following and viewport-height access.
  • Adds a patch changeset for hunkdiff.

Confidence Score: 4/5

The PR appears safe to merge, with a non-blocking coverage gap for several members of the newly committed scrollbox contract.

The documented API matches the built-in sidebar’s existing ref usage and the extension fixture validates the main follow-selection path, but regressions in scrollTop and the scrollbar/viewport event APIs would not be detected.

Files Needing Attention: src/ui/AppHost.extension-sidebar.test.tsx

Important Files Changed

Filename Overview
docs/extensions.md Replaces the unsupported-geometry caveat with a concrete scrollbox-ref recipe and compatibility contract.
src/extensions/default/ui/sidebar/index.tsx Adds a maintenance comment identifying the built-in sidebar’s existing scrollbox usage as contract-bearing.
src/ui/AppHost.extension-sidebar.test.tsx Adds realistic extension-runtime coverage for selection following and viewport height, but leaves the documented scroll offset and event APIs unexercised.
.changeset/sidebar-scroll-ref-contract.md Records the documentation and compatibility-contract addition as a patch release.
Prompt To Fix All With AI
### Issue 1
src/ui/AppHost.extension-sidebar.test.tsx:520-524
**Contract test omits event APIs**

The fixture exercises only `viewport.height` and `scrollChildIntoView`, leaving `scrollTop` and the three documented scrollbar/viewport event subscriptions without extension-runtime regression coverage. A later host or OpenTUI change can break geometry updates for extensions while this contract test remains green.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "docs(extensions): commit the scrollbox r..." | Re-trigger Greptile

…t test

Review feedback: the fixture proved scrollChildIntoView and a viewport
read but left scrollTop and the three documented event subscriptions
without extension-runtime coverage, so a host or OpenTUI change could
break geometry updates for extensions while the contract test stayed
green.

The fixture now subscribes to the scrollbar change and viewport
layout-changed/resized events exactly as the guide documents (including
the .off cleanup) and reports scrollTop and viewport.height from each
firing; the test asserts the events delivered a nonzero viewport height
after layout and a nonzero scrollTop after the follow scrolled the pane.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M7EZpzieiVPdj6LZn4oBYJ
@vercel

vercel Bot commented Jul 28, 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 Jul 28, 2026 7:10pm

Request Review

@benvinegar
benvinegar merged commit 076ac6f into main Jul 28, 2026
11 checks passed

This branch was successfully deployed

1 active deployment
Preview — 93c002d8 Deployed Jul 28, 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.

2 participants