Skip to content

Clamp and scroll the help overlay so it fits the terminal - #306

Merged
umputun merged 3 commits into
masterfrom
fix/help-overlay-clipping
Aug 4, 2026
Merged

umputun merged 3 commits into
masterfrom
fix/help-overlay-clipping

Conversation

@umputun

@umputun umputun commented Aug 4, 2026

Copy link
Copy Markdown
Owner

the help popup sized itself to its content and never read the terminal size, so once it outgrew the screen overlayCenter computed a negative startY, dropped rows off the top and bottom, and wrote over-wide lines past the right edge. At 100x40 it rendered 41x122 (51x137 with --vim-motion), which is what #304 reported: whole sections missing with no way to reach them. It was the only overlay that ignored ctx.Width/ctx.Height and had no scrolling.

What changed

app/ui/overlay/help.go now clamps to term_w - 4 x term_h - 4, keeps two columns when they fit, drops to a single column when they don't, and truncates with a … marker only as a last resort. A body taller than the viewport scrolls with j/k, page and half-page, Home/End, g/G and the wheel, and spends its last row on a ↑/↓ scroll · N-M of T hint. Rows are padded to the full body width so the box does not resize while scrolling.

pageSize() is there because the hint row shortens the viewport. Paging by usableHeight() instead skipped one row at every page boundary.

Docs

Four surfaces still said the help overlay ignores mouse events, which this change makes false: README, site/docs.html, and both plugin references/usage.md copies. docs/ARCHITECTURE.md is also reflowed to 100 columns in its own commit, with four wide tables converted to the bullet style the document already used. That commit is formatting only.

Related to #304

umputun added 3 commits August 4, 2026 16:47
the help popup sized itself to its content and got clipped on every side once
it outgrew the terminal. At 100x40 it rendered 41x122 (51x137 with
--vim-motion), so whole sections were unreachable with no way to scroll to
them. It now clamps to the terminal, falls back to a single column when two
don't fit, and scrolls with the usual navigation keys and the wheel.

Related to #304
prose and bullets were single lines running up to 1441 chars, and four tables
carried rows up to 884. Wrapped everything at 100 and turned those tables into
the bullet style the document already used elsewhere. Code fences and the
ASCII diagram are untouched.
four doc surfaces still said the help overlay ignores mouse events, which the
scroll support made false. Horizontal truncation cut rows with no marker while
every other truncation in the codebase carries one, and the overlay has no
horizontal scroll to recover the text.

also replaces the height assertion in TestModel_HelpOverlayNeverExceedsTerminal,
which could not fail: overlayCenter drops popup rows outside the background, so
the composed view is always exactly the terminal height. Clipping shows up as
missing content, so the test now checks the popup's first and last rows survive.

Related to #304
Copilot AI lite review requested due to automatic review settings August 4, 2026 22:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the help overlay rendering bug reported in #304 by making the help popup respect terminal dimensions and adding vertical scrolling, preventing content from being clipped off-screen on smaller terminals.

Changes:

  • Clamp help overlay dimensions to the terminal (with margins), including fallback to single-column layout when two columns don’t fit.
  • Add scroll support to the help overlay (keys + mouse wheel) with a visible “scroll position” hint row when content overflows.
  • Update documentation surfaces to reflect that the help overlay now responds to mouse wheel scrolling.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
app/ui/overlay/help.go Implements size clamping, 1↔2 column layout selection, truncation marker, and scroll state for the help overlay.
app/ui/overlay/help_test.go Adds extensive unit coverage for sizing guarantees, layout fallback, scrolling behavior, and truncation marker behavior.
app/ui/handlers_test.go Adds model-level regression tests to ensure help scrolling works and rendered lines never exceed terminal width.
README.md Updates mouse-support docs to include help overlay wheel scrolling.
site/docs.html Updates mouse-support docs to include help overlay wheel scrolling.
plugins/codex/skills/revdiff/references/usage.md Updates plugin usage docs to include help overlay wheel scrolling.
.claude-plugin/skills/revdiff/references/usage.md Updates plugin usage docs to include help overlay wheel scrolling.
docs/ARCHITECTURE.md Reflows and updates overlay documentation to describe the new help overlay behavior (including scrolling and clamping).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@umputun
umputun merged commit 3a01589 into master Aug 4, 2026
6 checks passed
@umputun
umputun deleted the fix/help-overlay-clipping branch August 4, 2026 22:22
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