Skip to content

feat(tui): make an expanded accordion's whole region the click/hover target - #29

Merged
jinroh merged 4 commits into
mainfrom
will.su/accordion-click-collapse
Oct 16, 2026
Merged

jinroh merged 4 commits into
mainfrom
will.su/accordion-click-collapse

Conversation

@Jiahao01121

Copy link
Copy Markdown
Contributor

What

When an accordion block (reasoning, tool results) is expanded, its entire region — the title row and every disclosed content row — is now the click target that collapses it, and hover highlights that whole region. Previously only the title row was clickable.

A collapsed block is unchanged: its header row stays the only target, since its compact body rows are its own content rather than a disclosure affordance.

QA

https://cleanshot.com/share/DpTzZhCG

Details

  • HeaderAt becomes AccordionAt — the target is no longer only the header, so the name moved with it. Hit-testing stays in chat.List; components.Accordion remains a dumb glyph renderer.
  • Hover paints per row inside renderSurface, reusing PaintRowBackground so each line's own foreground colors survive the repaint. It never touches Document() or item heights.
  • Two tones, matching the mockup: the header keeps accordionHover, and disclosed rows get a new accordionDetailHover token — accordionHover blended at 45% over the background (#1C1E26 dark, #D7DCE5 light). The header stays the region's visual anchor.
  • The hand pointer follows the whole region for free: reconcilePointerShape derives from List.Hovered, which now resolves through AccordionAt.
  • A block whose header has scrolled above the viewport still collapses when a visible disclosed row is clicked — the span's header index is left unclamped so the paint loop can tell whether row 0 is the header, while the row span itself is clamped to the viewport.
  • Drag-select still wins: the toggle stays deferred to mouse-up and fires only when the gesture never became a selection range.

Test plan

  • go build ./..., ./scripts/test.sh, ./scripts/lint.sh — all clean.
  • TestAccordionAtCoversTheExpandedBlockAndNothingElse — expanded rows are targets, a collapsed block's body rows are not, nothing past the viewport is.
  • TestAccordionAtKeepsExpandedDetailRowsAfterTheHeaderScrollsOff — the header is not the hit-test anchor.
  • TestHoverPaintsTheWholeExpandedBlock — header fill on row 0, detail fill below, no leak past the item's last row.
  • TestMouseMotionSetsHandPointerAcrossTheWholeExpandedRegion — hand across every disclosed row, default outside.
  • TestMouseWheelScrollRefreshesHoverUnderTheStationaryPointer was re-aimed rather than deleted: it previously asserted that scrolling cleared hover, which assumed header-only targets. It now asserts hover is recomputed to a different block under a stationary pointer, which is the behavior it was really guarding.

Note for review

internal/tui/styles/palette.go shows a large diff because gofmt re-aligned both palette literal blocks when the new field widened the longest key. The only substantive changes there are the one new struct field and its two values.

@Jiahao01121
Jiahao01121 requested a review from a team as a code owner October 16, 2026 01:16

@datadog-official datadog-official Bot 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.

Bits Code Review: FAIL

Collapsed tool blocks with compact previews now highlight non-clickable body rows when their header is hovered. The hover span needs to remain header-only until the block is expanded.

Open Bits AI session

🤖 Bits Code Review · Commit 19e8845

Comment thread internal/tui/chat/list.go

@jinroh jinroh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM !

Added a little followup in 0646970 to make the full tool block clickable for tools with guttered preview block (edit tools and exec). Let me know if that looks good to you.

Jiahao01121 and others added 3 commits October 16, 2026 17:19
…target

When a block (e.g. reasoning) is expanded, every disclosed row becomes part
of the click target that collapses it, and hover highlights the whole
region with two tones: a stronger fill on the header, a softer
accordionDetailHover fill (45% accordionHover over the background) on the
disclosed rows below it. A collapsed block keeps only its header row as the
target.

- chat.List: HeaderAt renamed to AccordionAt and extended via accordionAtRow
  to cover every row of an expanded item; hoverFillRows computes the
  (possibly header-scrolled-off) row span renderSurface paints.
- styles: add Accordion.DetailHoverBackground, wired from a new
  accordionDetailHover palette token (dark #1C1E26, light #D7DCE5).
- update.go/model.go: HeaderAt -> AccordionAt at the mouse-down site; the
  pendingAccordionToggle comment now reflects the larger target.
- The hand pointer shape (reconcilePointerShape) already derives from
  List.Hovered, so it follows the whole expanded region automatically.
- Tests: rewrote list_test.go's HeaderAt coverage into
  TestAccordionAtCoversTheExpandedBlockAndNothingElse plus a header-scrolled-
  off case, added TestHoverPaintsTheWholeExpandedBlock, and re-aimed
  TestMouseWheelScrollRefreshesHoverUnderTheStationaryPointer at the real
  intent (hover retargets on scroll, rather than always clearing). Added
  TestMouseMotionSetsHandPointerAcrossTheWholeExpandedRegion covering the
  hand-pointer regression explicitly.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
hoverFillRows painted a collapsed block's whole compact body even
though accordionAtRow only targets its header, so the hover
misrepresented the click target for blocks with preview rows
(exec_command, edit_file, write_file).

Add a regression test using an edit_file diff fixture, since the
existing fixture's collapsed body is a single row and hid the bug.
@jinroh
jinroh force-pushed the will.su/accordion-click-collapse branch from 814ddf8 to d6f4f90 Compare October 16, 2026 15:19
@jinroh

jinroh commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

rebased on top of main.

A collapsed block's compact preview (exec_command output, edit_file and
write_file diffs) is now part of its click and hover target, like an
expanded block's disclosed rows. The zone is simply every row a guttered
block renders, which drops the expanded-state branches from
accordionAtRow and hoverFillRows and supersedes the header-only
restriction from 780b217.

Consolidate the accordion tests around that single rule:
- TestAccordionZoneIsTheWholeRenderedBlock table-tests targeting and
  hover painting for header-only, preview and expanded blocks, replacing
  three overlapping tests.
- TestAccordionZoneSurvivesTheHeaderScrollingOff now also checks the
  visible rows keep the detail fill once the header scrolls off.
- TestMouseMotionSetsPointerShapeOverTheAccordionZone merges the two
  pointer-shape tests and asserts real OSC 22 transitions.
@jinroh
jinroh force-pushed the will.su/accordion-click-collapse branch from d6f4f90 to 9d711d9 Compare October 16, 2026 15:23
@jinroh
jinroh merged commit 7c02189 into main Oct 16, 2026
14 checks passed
@jinroh
jinroh deleted the will.su/accordion-click-collapse branch October 16, 2026 15:25
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