fix(mcp): window the scope picker to the terminal height - #8
Merged
Conversation
The /mcp scope list rendered all ~30 lines of the grouped catalogue inside the fixed-height ScreenFrame (height = terminal rows). On common terminal sizes yoga shrank the body and Ink overlaid the overflowing rows, so arbitrary entries vanished (group headers, the read scopes, clusters:provision:plan) and the visible set shifted on every cursor move — tokens could not be minted with the hidden scopes. Flatten the grouped catalogue into lines and window it around the cursor, following the Select primitive's viewport pattern, with dimmed '▲/▼ n more' markers for the clipped remainder. Group headers stay attached to their first scope at the window edge. On tall terminals the full list still renders unwindowed.
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.
Bug
On the
/mcptoken screen ("Select the resources the MCP server may access"), the scope list rendered incomplete and unstable on common terminal sizes:readscopes andclusters:provision:plandid not show;clusters:read,clusters:provision:plan), breaking the plan→apply flow over MCP.Reproducible with ink-testing-library at the default 30-row height: adjacent rows were overlaid and corrupted (e.g.
Provision infrastructure (apply)des and VMs).Root cause
ScopePicker(tui/ink/src/mcp/scope-picker.tsx) rendered the full grouped catalogue — about 30 lines — with no viewport, insideScreenFrame, whose root box is pinned to the terminal height (height={rows},screen-frame.tsx:100). When the list is taller than the space left by the chrome, yoga shrinks the body (flexShrink/minHeight: 0) and Ink overlays the overflowing rows, so seemingly arbitrary lines disappear — and the dropped set changes as the cursor re-renders. The scope catalogue itself was never the problem: both the UI catalogue andserver/src/shared/inbound/mcp/scope/catalog.tscontain every scope.Fix
Flatten the grouped catalogue into render lines (headers, scopes, spacers) and window it around the cursor, following the existing viewport pattern of the
Selectprimitive, with dimmed▲/▼ n moremarkers for the clipped remainder. Group headers stay attached to their first scope at the window edge; on tall terminals the full list still renders unwindowed. Navigation (flat cursor over scopes, space toggles, enter confirms) is unchanged.Tests
tui/ink/tests/mcp/mcp-screen.test.tsx: walks the cursor across the whole catalogue and asserts the previously-dropped rows are visible up front, no frame overflows the terminal height, and every scope and group renders during navigation.deno fmt --check,deno task lint,deno task check,deno task test— 622 passed, 0 failed.