Skip to content

feat(session-ui): add floating header strip to markdown code blocks - #59814

Closed
imsoul11 wants to merge 1 commit into
anomalyco:devfrom
imsoul11:code-header-v2
Closed

imsoul11 wants to merge 1 commit into
anomalyco:devfrom
imsoul11:code-header-v2

Conversation

@imsoul11

Copy link
Copy Markdown

Issue for this PR

Closes #53519

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Port of #53522 to V2 (that one was closed because V1 is no longer accepting PRs).

Long code blocks lose their copy button: it sits at the top of the block and scrolls away with the content, so you have to scroll back up to copy.

This adds a slim sticky header strip to each markdown code block — language label on the left, copy button on the right. The strip floats pinned at the top while scrolling through tall code and scrolls away when the block ends. No height cap, so the block still extends fully. The button is always visible, which also removes the old hover show/hide flicker.

Changed files:

  • packages/session-ui/src/components/markdown.css — wrapper becomes a flex column, the copy-button host becomes the sticky strip, and the code block's top corners/border join the strip so it reads as one box.
  • packages/session-ui/src/components/markdown.tsx — the language label is copied onto the strip host (and re-synced in applyCodeMetadata), so it survives streaming re-renders. Copy behavior itself is untouched.

Works for both streamed and completed blocks (both use a pre inside [data-component="markdown-code"]). Mermaid blocks still hide the pre and strip once the diagram renders.

How did you verify your code works?

  • bun test src in packages/session-ui: 317 pass, 0 fail
  • tsc -b in packages/session-ui: clean; prettier: clean
  • Rendered the component with the real stylesheet and checked both states: at rest the strip shows the language + copy icon; scrolled to line 58 of a 90-line block the strip is still pinned at the top with label and button visible.

Screenshots / recordings

Before + after (recorded against V1; the V2 styling is unchanged apart from the strip): https://drive.google.com/drive/folders/1JsEkJbQ2TeCiMD-LkjR-fz3WmQxHaboq?usp=sharing

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@opencodejr

opencodejr Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Thanks for porting this to V2, @imsoul11!

I think this duplicates #59159. It also closes #53519 and keeps the code block copy button pinned while you scroll through long code blocks. It keeps the button where it is today instead of adding a header strip, and it includes a component test.

If you think the language label or the always-visible header strip is worth having, please comment on #59159 or review and test it there, so the discussion stays in one place.

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.

[FEATURE]: Sticky code block header (language + copy button) while scrolling long code

1 participant