Skip to content

fix(tui): never render dead code-block copy buttons#3789

Merged
dgageot merged 1 commit into
docker:mainfrom
dgageot:fix/dead-copy-buttons
Jul 22, 2026
Merged

fix(tui): never render dead code-block copy buttons#3789
dgageot merged 1 commit into
docker:mainfrom
dgageot:fix/dead-copy-buttons

Conversation

@dgageot

@dgageot dgageot commented Jul 22, 2026

Copy link
Copy Markdown
Member

The ⎘ copy affordance rendered by FastRenderer on every fenced code block was only wired up for hit-testing in assistant message views. In reasoning blocks, elicitation dialogs, leantui, shell output, and welcome messages the icon appeared but clicking it did nothing.

The fix adds a HideCopyIcon option to FastRenderer (exposed as markdown.NewRendererWithoutCopyIcon). When hidden, the icon renders as plain padding and records no CodeBlock hit target. Reasoning blocks, elicitation dialogs, and leantui — which never participate in code-block click handling — now use this renderer. Shell-output and welcome message views gain functional copy icons by populating their codeBlocks slice (accounting for the welcome envelope's line offset) so the existing codeBlockAt click path handles them. A new test, TestCodeBlockCopyIconsAreNeverDead, asserts that every rendered copy icon is clickable and that surfaces incapable of handling clicks render no icon at all.

The markdown renderer drew a "⎘ copy" affordance on every fenced code
block, but clicks were only hit-tested for assistant message views.
Code blocks inside reasoning blocks, shell output, welcome messages,
elicitation dialogs, and leantui showed a copy button that silently did
nothing when clicked.

- add a HideCopyIcon option to FastRenderer; hidden icons render as
  plain padding and record no CodeBlock hit target
- suppress the icon in reasoning blocks, elicitation dialogs, and
  leantui, which never hit-test code-block clicks
- make shell-output and welcome message copy icons functional by
  populating the view's codeBlocks (with the welcome envelope's line
  offset) so the existing click path handles them

Assisted-By: Claude
@dgageot
dgageot requested a review from a team as a code owner July 22, 2026 14:41

@docker-agent docker-agent 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.

Assessment: 🟢 APPROVE

The implementation is clean and correct. The HideCopyIcon option integrates properly with the parser pool lifecycle, the line-offset calculations for welcome messages (border + padding = 2) and shell output (no envelope) are accurate, and the error paths correctly clear codeBlocks to avoid stale state. The new TestCodeBlockCopyIconsAreNeverDead test provides good coverage of the invariant being enforced.

@dgageot
dgageot merged commit dead312 into docker:main Jul 22, 2026
10 of 11 checks passed
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.

3 participants