feat(desktop): code-block hover toolbar with copy-as-MD and language picker#3120
Open
HUQIANTAO wants to merge 1 commit into
Open
feat(desktop): code-block hover toolbar with copy-as-MD and language picker#3120HUQIANTAO wants to merge 1 commit into
HUQIANTAO wants to merge 1 commit into
Conversation
…picker Code blocks in chat previously had a single hover-revealed Copy button. Replace it with a richer toolbar: 1. Copy as Markdown: wraps the value in a fenced code block (```lang) so the snippet pastes into a GitHub issue or README with full syntax highlighting preserved. The leading fence uses the current effective language (override, then prop, then the workspace's remembered-most- recent pick). Brief check-mark feedback reuses the existing pattern. 2. Language picker: a small chevron button next to the copy buttons. Opens a 30-entry menu of the most common languages the agent emits. The user's manual pick is persisted per-workspace (last 5 picks) in localStorage and used as the smart default for the next unlabelled block in that workspace. The override is held in CodeViewer state so highlighter re-runs the right hljs grammar; an Escape or outside click closes the picker without committing. 3. Reserved slots: the toolbar is shaped to accept 'Run in workspace' and 'Open in editor' actions as future bridge additions — the layout doesn't need to change to add them. The toolbar wrapper is a flex row at top-right of the code block; the existing copy button keeps its position. The whole cluster is opacity-0 by default and reveals on :hover/:focus-within with an 80ms delay on the fade-out so a mouse pass over the picker list doesn't blink the buttons away mid-hover. prefers-reduced-motion is honored through the existing @media rule. New files: lib/codeBlockActions.ts (LANGS + rememberLang + suggestedLang + languageLabel), components/CodeBlockToolbar.tsx.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Code blocks in chat previously had a single hover-revealed Copy button. Replace it with a richer toolbar: