Skip to content

fix: add copy controls to elicitation messages - #4992

Open
aheritier wants to merge 6 commits into
mainfrom
fix/elicitation-code-copy
Open

aheritier wants to merge 6 commits into
mainfrom
fix/elicitation-code-copy

Conversation

@aheritier

Copy link
Copy Markdown
Collaborator

Clicking a fenced-code copy label copies the original, unwrapped code. Press Ctrl+O to copy the entire message as Markdown, without the elicitation answer. Drag selection remains unavailable.

Adds tests for code-label hit testing (including wrapped, scrolled, resized, and moved dialogs), whole-message copying, and help layout.

Validation previously completed: build, full tests, focused race test, vet, and scoped lint passed. Full lint reported three errors in unchanged test files. No live terminal retest was performed.

Signed-off-by: Arnaud Héritier <arnaud.heritier@docker.com>
@aheritier
aheritier requested a review from a team as a code owner November 21, 2026 18:13
Copilot AI balanced review requested due to automatic review settings November 21, 2026 18:13

Copilot AI 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.

🟡 Changes recommended

Copy controls can miss clicks or copy altered or truncated code, while help sizing can cause dialogs to overflow short or narrow terminals.

6 open issues
What changed in this PR

This PR adds copy controls to full-TUI elicitation dialogs, reusing the message component’s clipboard handling while keeping form answers out of whole-message copies.

Changes:

  • Add clickable code-block copy labels and a Ctrl+O shortcut for copying message Markdown.
  • Wrap footer help text and include its rows in dialog layout calculations.
  • Add copying and layout regression tests, and document the controls.
File Description
pkg/​tui/​dialog/​elicitation.go Adds copy controls, label hit testing, and wrapped footer layout.
pkg/​tui/​dialog/​elicitation_copy_test.go Tests copying, scrolling, resizing, moving, and help layout.
pkg/​tui/​components/​messages/​clipboard.go Exports the shared clipboard command for dialog use.
docs/​features/​tui/​index.md Documents elicitation copy labels and the Ctrl+O shortcut.

Review effort: Balanced

Comment thread pkg/tui/dialog/elicitation.go Resolved
Comment thread pkg/tui/dialog/elicitation.go Resolved
Comment thread pkg/tui/dialog/elicitation.go Resolved
Comment thread pkg/tui/dialog/elicitation.go Resolved
Comment thread pkg/tui/dialog/elicitation.go Resolved
Comment thread pkg/tui/dialog/elicitation.go Resolved
@aheritier aheritier added area/docs Documentation changes area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Nov 21, 2026
Signed-off-by: Arnaud Héritier <arnaud.heritier@docker.com>
Copilot AI balanced review requested due to automatic review settings November 21, 2026 19:44

Copilot AI 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.

🟡 Changes recommended

Copying can alter code or retain invisible escape bytes, while CRLF messages can lose copy labels or trigger quadratic processing for large UTF-8 blocks.

6 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve source bytes when parsing container-indented code

pkg/​tui/​components/​markdown/​fast_renderer.go:337

This fast path can copy altered code: - step\n ~~~\n echo hello\n ~~~ produces ho hello because the list parser removes non-whitespace bytes. Nested blockquotes also lose trailing whitespace. Preserve source content with correct container indentation in both parsing paths before exposing copy labels.

3 resolved since last review

Review effort: Balanced

Signed-off-by: Arnaud Héritier <arnaud.heritier@docker.com>
Copilot AI balanced review requested due to automatic review settings November 21, 2026 21:43

Copilot AI 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.

🟡 Changes recommended

Nested quotes with non-ASCII whitespace can freeze the TUI, and unindented fences after list items can lose code; other fence parsing errors also affect rendering and copied text.

3 open issues
2 previously missed issues

In code that hasn't changed since last review

Medium severity Require contiguous fence characters before trailing whitespace

pkg/​tui/​components/​markdown/​fast_renderer.go:483

This accepts fence characters after intervening whitespace as part of the closing fence. For example, inside a ~~~ block, the valid code line ~~~ ~~~ is treated as the closing delimiter, so the copy label returns only the preceding code and the rest of the message is rendered incorrectly. Only allow additional contiguous fence characters followed by whitespace.

Medium severity Align fence detection before caching paragraph splits

pkg/​tui/​components/​markdown/​incremental.go:396

openingFence recognizes a non-breaking space before a fence, but isBlockStart does not. For intro\n\u00a0~~~\ninside\n~~~\n\nafter, this allows a cached split inside the full parser's open code block, so incremental rendering displays and copies different code. Align paragraph fence detection and boundary classification before caching the split.

5 resolved since last review

Review effort: Balanced

Signed-off-by: Arnaud Héritier <arnaud.heritier@docker.com>
Copilot AI balanced review requested due to automatic review settings November 21, 2026 23:58

Copilot AI 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.

🔵 Needs a closer look

Small-terminal usability and the fidelity and safety of copied Markdown content warrant human assessment across several edge cases.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

@aheritier aheritier left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for adding copy controls to the full TUI. I checked both copy paths, including that Ctrl+O copies the prompt without the form answer.

Prior threads: The short-terminal and wrapped-help cases (4654275845, 4654275857), multiline title offsets (4654275896), longer fences (4654275909), source preservation and control handling (4654275918, 4654685385, 4654685404, 4654685429), Unicode quote prefixes (4655170262), and zero-indent list fences (4655170298) are addressed. Covered tab-bar clicks now reach the dialog, including after dragging; thread 4654275878 is still open on GitHub, but the reported behavior is fixed.

Comment thread pkg/tui/dialog/elicitation_copy_test.go Resolved
Signed-off-by: Arnaud Héritier <arnaud.heritier@docker.com>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 00:26

Copilot AI 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.

🟡 Changes recommended

List indentation errors can split fenced code or swallow following prose, while the top-level fence guard causes quadratic reparsing during streaming.

3 open issues

Review effort: Balanced

Signed-off-by: Arnaud Héritier <arnaud.heritier@docker.com>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 11:02

Copilot AI 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.

🔵 Needs a closer look

A subtle mismatch between list-context classification and parser fence handling can truncate code blocks during incremental rendering, requiring human assessment.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

@aheritier
aheritier enabled auto-merge November 22, 2026 11:18

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

area/docs Documentation changes area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants