feat: add copy-to-clipboard functionality to markdown code blocks and…#2489
feat: add copy-to-clipboard functionality to markdown code blocks and…#2489rohitbathi wants to merge 5 commits into
Conversation
… remove conditional padding from session surface
…-openwork-copy-code attribute
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@rohitbathi is attempting to deploy a commit to the Different AI Team on Vercel. A member of the Team first needs to authorize it. |
Pablosinyores
left a comment
There was a problem hiding this comment.
The copy button itself works, but a few things below the line before this is ready.
- [high] The change to
session-surface.tsxremoves thefindOpen ? "pt-16" : "pt-4"top padding entirely. That padding is intentional — its own comment says it keeps the find bar from covering the first message on short transcripts that cannot scroll it clear. Dropping it reintroduces that bug, and it is unrelated to copy-to-clipboard, so it should come out of this PR. - [high] The base (non-highlighted)
coderenderer now returns a multi-line template with the<code>indented on its own line inside<pre>.<pre>preserves whitespace, so this injects a leading newline + indentation into every non-highlighted code block (visible during streaming before Shiki takes over). Also that renderer only gained a wrapper<div>— no copy button — while the button lives solely in the Shikicontainer, so the two code paths are inconsistent. Either keep<pre><code>on one line, or move the button into a shared wrapper both paths use. - [medium] The sticky header hardcodes
bg-white, and both SVGs hardcodestroke="#000000". In dark mode the header renders white and the icons black. Use theme tokens (e.g.bg-gray-1/stroke-currentorcurrentColor) so it follows the active theme — there is active theme work in flight here (#2447/#2466/#2329). - [minor]
z-2is not a default Tailwind utility; unless it is in your scale it is a no-op. Usez-[2](or a real scale value) so the sticky header layers as intended. - [nit] The clipboard failure path only does
console.log('Copy failed')— leftover log, and the user gets no feedback. Consider surfacing a brief failure state on the button (mirroring the success check-mark swap).
I am working on it, thanks for the feedback. |
Pablosinyores
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround — most of it is handled. Went through the updated diff:
- find-bar padding (spacer div) — works; top padding on a scroll container scrolls with the content anyway, so the
h-16/h-4spacer is equivalent. Minor:<div className={findOpen ? "h-16" : "h-4"} />is a touch cleaner than the two-branch ternary. - shared
generateCodeBlockContainer+ single-line<pre><code>— good, the leading-newline-in-<pre>issue is gone and both the fallback and highlighted paths get the button now. z-[2],stroke="currentColor"on the copy icon, and the red-X failure state — all addressed.
Two things left:
- [medium] The sticky header uses
bg-currentColor, which isn't a stock Tailwind class — the utility forcurrentColorisbg-current, and even that would paint the text color as the background. So the header ends up with no surface and the code scrolls visibly under it, which defeats the sticky masking. You mentioned switching tobg-gray-1, but the header<div>still readsbg-currentColor; setting it tobg-gray-1(matching the container surface) fixes it. - [minor] The non-highlighted
codepath now double-wraps chrome:generateCodeBlockContaineralready carriesrounded-lg border border-border/70 bg-gray-1/80 p-4, and the inner<pre>it wraps still has its ownrounded-[18px] border border-border/70 bg-gray-1/80 px-4 py-3, so those blocks render a bordered box inside a bordered box. Dropping the border/bg/rounded from the inner<pre>(letting the container own the chrome) would match the highlighted path.
Nothing major — fix the bg-currentColor and it's basically there.
…markdown code blocks
|
Thanks for catching those! I've gone ahead and addressed both:
Let me know if everything looks good now, thanks again. |




Add copy button to code blocks & remove conditional padding from session surface
Summary
pt-16/pt-4whenfindOpenis active) from the chat session surface container.Why
Issue
Scope
apps/app/src/components/markdown/markdown.tsx(HTML wrapper container structure, copy click listener, DOMPurify whitelisting)apps/app/src/react-app/domains/session/surface/session-surface.tsx(Session surface padding layout change)Out of scope
Testing
Ran
pnpm typecheckpnpm --filter @openwork/app testResult
passCI status
passManual verification
pnpm dev).write a hello world in python).Evidence
Risk
Rollback
markdown.tsxandsession-surface.tsx.