Repository navigation
feat(terminal): copy the selection to the clipboard - #5642
Closed
diallosouleymane wants to merge 3 commits into
Closed
diallosouleymane wants to merge 3 commits into
diallosouleymane wants to merge 3 commits into
Conversation
Selecting output in the Docker terminal left no way to copy it. Ctrl+C has to keep sending SIGINT, Ctrl+Shift+C is reserved by browsers for DevTools and never reaches the page, and the ClipboardAddon already loaded only implements OSC 52, a copy requested by the remote program. The selection is now copied when the drag ends, the way a Unix terminal has done since X11's primary selection, and a toast confirms it. The selection itself is left in place: a copy that erases what you highlighted gives no way to tell it apart from a copy that did nothing. The release is caught on the document rather than on the terminal, because reaching the end of a line means dragging past its edge, and reading the selection waits a tick, because xterm settles it in its own mouseup handler registered after this one. navigator.clipboard only exists on a secure context, and many instances are reached over plain HTTP on an IP before a domain is set up, so execCommand remains as a fallback. It restores the focus it takes from the terminal. The web server terminal gets the same treatment, it shared the gap.
Both terminals open inside a modal dialog. Its focus trap pulls the focus back in as soon as something outside takes it, and selecting a textarea focuses it, so a textarea appended to the body lost its selection before execCommand could read it. On a plain HTTP instance, where the clipboard API does not exist, selecting output therefore copied nothing.
narcisonunez
requested changes
Oct 12, 2026
narcisonunez
left a comment
Collaborator
There was a problem hiding this comment.
Remove all the unnecessary comments. No need for them
Author
|
@narcisonunez Done in 190e769, all the comments added by this PR are gone. |
Collaborator
|
Will check again soon, thanks |
Collaborator
|
Thanks for working on this. Closing it, as I couldn't reproduce #5640.
Why I don't think this PR should be merged:
If discoverability is the real problem, a "Copy selection" button or an opt-in setting would be a better fix. |
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.
What is this PR about?
Selecting output in the Docker terminal left no way to copy it, so the only way to get a line out of the browser was retyping it or taking a screenshot.
Ctrl+Chas to keep sending SIGINT,Ctrl+Shift+Cis reserved by browsers for DevTools and never reaches the page, and theClipboardAddonalready loaded only implements OSC 52, a copy requested by the remote program. The selection is now copied when the drag ends, the way a Unix terminal has done since X11's primary selection, and a toast confirms it. The selection itself is left in place, because a copy that erases what you highlighted gives no way to tell it apart from a copy that did nothing. The web server terminal gets the same treatment, it shared the gap.Three details worth a reviewer's attention. The release is caught on the document rather than on the terminal element, because reaching the end of a line means dragging past its edge and that release lands elsewhere. Reading the selection waits a tick, because xterm settles it in its own mouseup handler, registered on the document when the drag starts and therefore after this one. And
navigator.clipboardonly exists on a secure context, while many instances are reached over plain HTTP on an IP before a domain is set up, soexecCommandremains as a fallback and restores the focus it takes from the terminal.Checklist
Before submitting this PR, please make sure that:
canarybranch.Tested on a local instance running this branch, against a real container opened from
/dashboard/docker: selecting output copies it, the toast appears, the selection stays, and pasting elsewhere returns the selected text. An earlier version of this patch listened on the terminal element and copied only intermittently, which is what led to the two details above.Issues related (if applicable)
closes #5640
Screenshots (if applicable)