GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): add copying terminal selection with ctrl+c in the web app by UtkarshUsername · Pull Request #5638 · pingdotgg/t3code

fix(web): add copying terminal selection with ctrl+c in the web app #5638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
shivamhwp merged 9 commits into pingdotgg:main from UtkarshUsername:fix/copy-in-terminal
Aug 14, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix(web): add copying terminal selection with ctrl+c in the web app #5638

Changes from 1 commit
Commits
Show all changes
9 commits
Select commit Hold shift + click to select a range
9cd5ade
fix(web): terminal copy uses the native copy event
UtkarshUsername Aug 7, 2026
adba30b
fix(web): fall back to clipboard write when webkit omits copy
UtkarshUsername Aug 10, 2026
5be42a7
fix(web): cancel the clipboard write fallback once the copy event fires
UtkarshUsername Aug 11, 2026
ca0c643
fix(web): clear the selection after ctrl+c copies
UtkarshUsername Aug 12, 2026
d86728b
fix(web): guard the post-copy clear and reset the clear flag
UtkarshUsername Aug 12, 2026
7f56ef7
fix(web): only clear the copy flag if the failing gesture owns it
UtkarshUsername Aug 12, 2026
6315570
fix(web): close the terminal selection menu when ctrl+c clears it
UtkarshUsername Aug 12, 2026
e8d7ab1
fix(web): keep terminal menu close scoped to its own menu
UtkarshUsername Aug 12, 2026
7a0d12c
Merge branch 'main' into fix/copy-in-terminal
UtkarshUsername Aug 14, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
fix(web): cancel the clipboard write fallback once the copy event fires
The deferred write for browsers without a native copy event now runs
behind a token, claimed by onCopyEvent when the native event fires first.
Skipping a write the native event already handled stops a stale writeText
resolution from clobbering a clipboard the user filled after this copy.
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@UtkarshUsername
UtkarshUsername committed Aug 14, 2026
commit 5be42a7d6db0b4a0a925461bc31cfbe37eac9500

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

21 changes: 16 additions & 5 deletions 21 apps/web/src/terminal/ghostty/surface.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ export class GhosttyTerminalSurface {
private theme: GhosttyTheme;
private readonly suppressedKeyCodes = new Set<string>();
private pasteShortcutToken = 0;
private copyShortcutToken = 0;
private wheelRemainder = 0;
private dprMedia: MediaQueryList | null = null;
// Read live on every blink decision, and watched so that dropping the
Expand Down Expand Up @@ -912,11 +913,19 @@ export class GhosttyTerminalSurface {
} else {
const clipboard = navigator.clipboard;
if (typeof clipboard?.writeText === "function") {
// The native copy event (dispatched with the default action) always
// wins when it fires; the write covers browsers whose shortcut
// produces no copy event.
void clipboard.writeText(this.getSelection()).catch(() => {
// Clipboard write denied; the native copy event remains the path.
// Defer the write past the default action: the native copy event
// (dispatched synchronously with the default action) claims the
// token first when it fires, and the write covers browsers whose
// shortcut produces no copy event. Skipping a write the native
// event already handled stops a stale resolution from clobbering a
// clipboard the user filled after this copy.
const token = ++this.copyShortcutToken;
const selection = this.getSelection();
void Promise.resolve().then(() => {
if (this.disposed || this.copyShortcutToken !== token) return;
void clipboard.writeText(selection).catch(() => {
// Clipboard write denied; the native copy event remains the path.
});
});
}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Expand Down Expand Up @@ -1010,6 +1019,8 @@ export class GhosttyTerminalSurface {
if (!this.hasSelection()) return;
event.preventDefault();
event.clipboardData?.setData("text/plain", this.getSelection());
// The native event beat any deferred write; drop the in-flight fallback.
this.copyShortcutToken += 1;
};

private readonly onPaste = (event: ClipboardEvent) => {
Expand Down
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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.