Skip to content

[codex] Add copy button for rendered code blocks#619

Merged
tlongwell-block merged 3 commits into
block:mainfrom
matbalez:codex/code-block-copy-button
May 20, 2026
Merged

[codex] Add copy button for rendered code blocks#619
tlongwell-block merged 3 commits into
block:mainfrom
matbalez:codex/code-block-copy-button

Conversation

@matbalez
Copy link
Copy Markdown

@matbalez matbalez commented May 19, 2026

Summary

Adds an icon-only copy button to rendered Markdown code blocks in the desktop client. The button appears on hover/focus in the upper-right corner of the code block.

The copy path writes both plain text and Sprout-marked HTML to the clipboard. Plain text keeps external paste behavior simple, while Sprout can recognize its own marked payload and paste it back into the message composer as a real TipTap code block. This preserves code contents that Markdown parsing would otherwise reinterpret, such as headings, indentation, or fence-like text.

Also fixes the tested long-code-block paste UX: after pasting a long copied code block into the message composer, the input scrolls to the bottom so the cursor/trailing paragraph stays visible.

Screenshot

Code block copy button hover state

Validation

Mat verified the change manually in desktop dev mode.

Automated checks run on the rebased branch:

corepack pnpm --dir desktop typecheck
corepack pnpm --dir desktop build
corepack pnpm --dir desktop exec biome check src/features/messages/ui/MessageComposer.tsx src/shared/lib/codeBlockClipboard.ts src/shared/ui/markdown.tsx tests/e2e/messaging.spec.ts
corepack pnpm --dir desktop exec playwright test tests/e2e/messaging.spec.ts --project=smoke

Playwright smoke result: 21 passed.

Notes

The branch is rebased onto current block/sprout:main and both commits include DCO sign-offs.

Scout reviewed the final local change and approved for final test, with no blockers or change requests before merge. One follow-up nit remains out of scope: forum composer has a similar long-paste scroll surface and could get a separate ticket.

@matbalez matbalez requested a review from wesbillman as a code owner May 19, 2026 20:30
matbalez added 2 commits May 19, 2026 13:33
Signed-off-by: Mat Balez <60949391+matbalez@users.noreply.github.com>
Signed-off-by: Mat Balez <60949391+matbalez@users.noreply.github.com>
@matbalez matbalez force-pushed the codex/code-block-copy-button branch from c76d1ff to a749f72 Compare May 19, 2026 20:33
@tlongwell-block
Copy link
Copy Markdown
Collaborator

Thanks, @matbalez! This lgtm

@tlongwell-block tlongwell-block enabled auto-merge (squash) May 20, 2026 13:58
The code-block copy/paste round-trip in this PR adds ~44 lines to
MessageComposer.tsx (a dedicated Sprout-marker paste branch that
inserts a literal codeBlock instead of letting Markdown reshape
the content, plus a scroll-to-bottom helper for multi-line pastes).
That pushes the file to 747 lines, over the existing 710 override.

The new logic is tightly coupled to the editor ref and the paste
handler's preventDefault flow; extracting it cleanly would mean
threading the editor and scroll ref through a helper and is out
of scope for this PR. Bump the override to 760 (leaving small
headroom) and document the new responsibility in the comment.

Signed-off-by: Tyler Longwell <109685178+tlongwell-block@users.noreply.github.com>
@tlongwell-block tlongwell-block merged commit 2da3402 into block:main May 20, 2026
14 of 15 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.

2 participants