Skip to content

Agent: give code blocks a horizontal scrollbar - #1666

Draft
maple-engineering[bot] wants to merge 1 commit into
masterfrom
fix/code-block-horizontal-scroll
Draft

maple-engineering[bot] wants to merge 1 commit into
masterfrom
fix/code-block-horizontal-scroll

Conversation

@maple-engineering

@maple-engineering maple-engineering Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What

Fixes #1664.

A code block already kept its longest line unwrapped and clipped it at the block edge, but it never drew a horizontal scrollbar. The scroll region only answered a trackpad or shift-wheel, so with an ordinary mouse the clipped end of a long URL or command was unreachable.

The block now keeps a ScrollHandle in element state and draws the same overlay horizontal bar markdown tables already use (scrollbar::horizontal_scrollbar), along the block's bottom edge inside the body's existing bottom padding. The bar hides while the content fits, appears when the pointer is over its strip, while scrolling, or during a drag, and drags/pages the code sideways like the table bar.

Diff

  • apps/maple-agent/app/src/ui/rich_text.rs: code_block returns a CodeBlockElement instead of a Div. Its request_layout takes the persistent handle from window.with_element_state (same pattern as markdown/table.rs) and builds the existing tree with .track_scroll(&scroll) plus the overlay bar. Selection ordinals, copy button, language label and unwrapped line measurement are unchanged.

Validation

  • just ci-lint — pass (fmt, clippy -D warnings for every feature set, dependency graph checks).
  • just ci-test equivalent (RUSTFLAGS="-D warnings" cargo test --workspace --locked) — 3036 passed, 0 failed.

I did not add a UI test: the bar component's geometry and drag behavior are already covered in ui/scrollbar.rs, and this change only wires the tested component into the block. I have not run the GUI itself; a quick look at a long code block in the desktop app would confirm the bar's placement.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

A code block already kept its longest line on one line, but the only way
to move it sideways was a trackpad or a shift-wheel over the body: no bar
was drawn, so with a mouse the clipped end was unreachable.

The block is now an element that keeps a ScrollHandle in element state,
and draws the same overlay horizontal bar markdown tables use along its
bottom edge, inside the body's existing bottom padding.

Co-authored-by: Maple Engineering <ed24cd5651d75896f9c44c4caf0efe89abd3b86a7531feffdf6b87e3cc0bc37c@buzz-01.tail87ed4d.ts.net>

This branch has not been deployed

No deployments
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.

Maple Work: Cannot use horizontal scroll inside a code block

0 participants