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

Show file tree
Hide file tree
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
Next Next commit
fix(web): terminal copy uses the native copy event
Plain Ctrl+C now copies a terminal selection in the web app on Windows. Copy no longer routes through navigator.clipboard.writeText; instead the surface writes the selection into the native copy event's clipboardData (mirroring the existing paste path), with execCommand synthesizing the event for Ctrl+Shift+C since that key fires no native one. Drops the dead onCopy option and its drawer handler.
  • Loading branch information

Uh oh!

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

@UtkarshUsername
UtkarshUsername committed Aug 14, 2026
commit 9cd5ade333e64da4efe7575eb2b7091a2c92bcd0

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

There are no files selected for viewing

12 changes: 0 additions & 12 deletions 12 apps/web/src/components/ThreadTerminalDrawer.tsx
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ export function TerminalViewport({
onData: (data) => handleData(data),
onResize: (cols, rows) => void resizeTerminal(cols, rows),
onSelectionChange: () => handleSelectionChange(),
onCopy: (text) => handleCopy(text),
beforeKey: (event) => handleBeforeKey(event),
onLinkActivate: (text, event) => handleLinkActivate(text, event),
};
Expand Down Expand Up @@ -668,17 +667,6 @@ export function TerminalViewport({
})();
}

function handleCopy(text: string): void {
void writeTextToClipboard(text, "terminal selection").catch((error: unknown) => {
const activeTerminal = terminalRef.current;
if (!activeTerminal) return;
writeSystemMessage(
activeTerminal,
error instanceof Error ? error.message : "Unable to copy terminal selection",
);
});
}

function handleData(data: string): void {
void (async () => {
const result = await writeTerminal(data);
Expand Down
1 change: 0 additions & 1 deletion 1 apps/web/src/components/settings/SettingsFontPreviews.tsx
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ export function TerminalFontPreview({ family, size }: { family: string; size: nu
onData: echo,
onResize: noop,
onSelectionChange: noop,
onCopy: (text) => void navigator.clipboard?.writeText(text).catch(noop),
// Tab keeps walking the settings page instead of feeding the echo loop.
beforeKey: (event) => event.key !== "Tab",
onLinkActivate: noop,
Expand Down
5 changes: 3 additions & 2 deletions 5 apps/web/src/terminal/ghostty/surface.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,12 @@ describe("isTerminalCopyShortcut", () => {
expect(isTerminalCopyShortcut(event({ metaKey: true }), "MacIntel")).toBe(true);
});

it("uses the conventional Ctrl+Shift+C shortcut elsewhere", () => {
expect(isTerminalCopyShortcut(event({ ctrlKey: true }), "Linux x86_64")).toBe(false);
it("copies with Ctrl+C and Ctrl+Shift+C elsewhere", () => {
expect(isTerminalCopyShortcut(event({ ctrlKey: true }), "Linux x86_64")).toBe(true);
expect(isTerminalCopyShortcut(event({ ctrlKey: true, shiftKey: true }), "Linux x86_64")).toBe(
true,
);
expect(isTerminalCopyShortcut(event({}), "Linux x86_64")).toBe(false);
});

it("uses the produced character instead of the physical key position", () => {
Expand Down
21 changes: 17 additions & 4 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 @@ -333,7 +333,7 @@ export function isTerminalCopyShortcut(
platform = navigator.platform,
) {
if (event.key.toLowerCase() !== "c") return false;
return isMacPlatform(platform) ? event.metaKey : event.ctrlKey && event.shiftKey;
return isMacPlatform(platform) ? event.metaKey : event.ctrlKey;
}

export function isTerminalPasteShortcut(
Expand Down Expand Up @@ -463,7 +463,6 @@ export interface GhosttyTerminalSurfaceOptions {
readonly onData: (data: string) => void;
readonly onResize: (cols: number, rows: number) => void;
readonly onSelectionChange: () => void;
readonly onCopy: (text: string) => void;
readonly beforeKey: (event: KeyboardEvent) => boolean;
readonly onLinkActivate: (text: string, event: MouseEvent) => void;
}
Expand Down Expand Up @@ -901,9 +900,15 @@ export class GhosttyTerminalSurface {
return;
}
if (isTerminalCopyShortcut(event) && this.hasSelection()) {
event.preventDefault();
// A plain Ctrl+C/Cmd+C fires the browser's native copy event, caught in
// onCopyEvent; not preventing the default keeps that path alive. The
// Shift variant has no native event (Chrome binds Ctrl+Shift+C to
// inspect), so synthesize one with execCommand("copy").
if (event.shiftKey) {
event.preventDefault();
document.execCommand("copy");
}
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.

this.suppressedKeyCodes.add(event.code);
this.options.onCopy(this.getSelection());
return;
}
if (isTerminalPasteShortcut(event)) {
Expand Down Expand Up @@ -989,6 +994,12 @@ export class GhosttyTerminalSurface {
this.dprMedia.addEventListener("change", this.onDevicePixelRatioChange);
}

private readonly onCopyEvent = (event: ClipboardEvent) => {
if (!this.hasSelection()) return;
event.preventDefault();
event.clipboardData?.setData("text/plain", this.getSelection());
};

private readonly onPaste = (event: ClipboardEvent) => {
// Always suppress the browser's default insertion: content the textarea
// would receive (for example an html-only clipboard converted to text)
Expand Down Expand Up @@ -1384,6 +1395,7 @@ export class GhosttyTerminalSurface {
this.input.addEventListener("blur", this.onBlur);
this.input.addEventListener("input", this.onInput);
this.input.addEventListener("paste", this.onPaste);
this.input.addEventListener("copy", this.onCopyEvent);
this.input.addEventListener("compositionstart", this.onCompositionStart);
this.input.addEventListener("compositionend", this.onCompositionEnd);
this.canvas.addEventListener("pointerdown", this.onPointerDown);
Expand All @@ -1408,6 +1420,7 @@ export class GhosttyTerminalSurface {
this.input.removeEventListener("blur", this.onBlur);
this.input.removeEventListener("input", this.onInput);
this.input.removeEventListener("paste", this.onPaste);
this.input.removeEventListener("copy", this.onCopyEvent);
this.input.removeEventListener("compositionstart", this.onCompositionStart);
this.input.removeEventListener("compositionend", this.onCompositionEnd);
this.canvas.removeEventListener("pointerdown", this.onPointerDown);
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.