Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): let terminal programs copy with OSC 52 #25051

Closedmaria-rckswants to merge 2 commits intomain frommaria/takeover-pr-22470opened View on GitHub

Showing 4 changed files with 180 additions and 0 deletions (loading 1).

x
0 of 4 viewed, 4 left
13 additions and 0 deletionsapps/web/src/components/ThreadTerminalDrawer.tsxModified
View file
@@ -142,6 +142,18 @@
terminal.write(`\r\n[terminal] ${message}\r\n`);
​
+function copyTerminalProgramText(text: string): void {
+ void writeTextToClipboard(text, "terminal output").catch((error: unknown) => {
+ toastManager.add(
+ stackedThreadToast({
+ type: "error",
+ title: "Failed to copy terminal output",
+ description: error instanceof Error ? error.message : "An error occurred.",
+ }),
+ );
+ });
+}
+​
export function writeTerminalOutputUpdate(
terminal: Pick<GhosttyTerminalSurface, "resetAndWrite" | "write">,
update: TerminalOutputUpdate,
@@ -642,6 +654,7 @@
beforeKey: (event) => handleBeforeKey(event),
onLinkActivate: (text, event) => handleLinkActivate(text, event),
canActivateLink: (text) => canActivateTerminalLink(text),
+ onClipboardWrite: copyTerminalProgramText,
// Surface listeners start before WASM loading finishes and the terminal handler exists.
onContextMenu: (event) => {
if (terminalRef.current) void showTerminalContextMenu(event);