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 — Add terminal selection copy action by tarik02 · Pull Request #2904 · pingdotgg/t3code

Add terminal selection copy action #2904

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
juliusmarminge merged 9 commits into pingdotgg:main from tarik02-org:feat/terminal-context-menu-copy-upstream-main
Jul 18, 2026

Uh oh!

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

Merged

Add terminal selection copy action #2904

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
7ebecc8
Add terminal selection copy action
tarik02 Jun 2, 2026
20d9786
Merge branch 'main' into feat/terminal-context-menu-copy-upstream-main
tarik02 Jun 17, 2026
948a0cd
Discard changes to apps/web/src/components/ThreadTerminalDrawer.test.ts
juliusmarminge Jun 19, 2026
f8b111e
Merge branch 'main' into feat/terminal-context-menu-copy-upstream-main
juliusmarminge Jul 17, 2026
f24634f
release terminal selection menu before copying
tarik02 Jul 18, 2026
820e554
Merge remote-tracking branch 'upstream/main' into feat/terminal-conte…
tarik02 Jul 18, 2026
0bf347c
fix terminal selection copy lifecycle
tarik02 Jul 18, 2026
003f7ad
infer terminal selection action ids
tarik02 Jul 18, 2026
5d53eb0
Merge branch 'main' into feat/terminal-context-menu-copy-upstream-main
tarik02 Jul 18, 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
Add terminal selection copy action
  • Loading branch information

Uh oh!

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

@tarik02 @juliusmarminge
tarik02 authored and juliusmarminge committed Jun 16, 2026
commit 7ebecc8deafcf35e211b97e29de8d019eb7175e6

There are no files selected for viewing

26 changes: 25 additions & 1 deletion 26 apps/web/src/components/ThreadTerminalDrawer.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
import { describe, expect, it } from "vite-plus/test";
import { afterEach, describe, expect, it, vi } from "vite-plus/test";

import {
TERMINAL_SELECTION_ACTION_MENU_ITEMS,
copyTerminalSelectionTextToClipboard,
resolveTerminalSelectionActionPosition,
shouldHandleTerminalSelectionMouseUp,
terminalSelectionActionDelayForClickCount,
} from "./ThreadTerminalDrawer";

afterEach(() => {
vi.unstubAllGlobals();
});

describe("terminal selection action menu", () => {
it("places copy after add to chat", () => {
expect(TERMINAL_SELECTION_ACTION_MENU_ITEMS).toEqual([
{ id: "add-to-chat", label: "Add to chat" },
{ id: "copy", label: "Copy" },
]);
});

it("copies selected terminal text to the clipboard", async () => {
const writeText = vi.fn(async () => undefined);
vi.stubGlobal("navigator", { clipboard: { writeText } });

await copyTerminalSelectionTextToClipboard("first line\nsecond line");

expect(writeText).toHaveBeenCalledWith("first line\nsecond line");
});
});

describe("resolveTerminalSelectionActionPosition", () => {
it("prefers the selection rect over the last pointer position", () => {
expect(
Expand Down
44 changes: 39 additions & 5 deletions 44 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 @@ -9,6 +9,7 @@ import {
XIcon,
} from "lucide-react";
import {
type ContextMenuItem,
type ResolvedKeybindingsConfig,
type ScopedThreadRef,
type TerminalAttachStreamEvent,
Expand Down Expand Up @@ -66,6 +67,14 @@ const MIN_DRAWER_HEIGHT = 180;
const MAX_DRAWER_HEIGHT_RATIO = 0.75;
const MULTI_CLICK_SELECTION_ACTION_DELAY_MS = 260;

type TerminalSelectionActionId = "add-to-chat" | "copy";

export const TERMINAL_SELECTION_ACTION_MENU_ITEMS: readonly ContextMenuItem<TerminalSelectionActionId>[] =
[
{ id: "add-to-chat", label: "Add to chat" },
{ id: "copy", label: "Copy" },
];

function maxDrawerHeight(): number {
if (typeof window === "undefined") return DEFAULT_THREAD_TERMINAL_HEIGHT;
return Math.max(MIN_DRAWER_HEIGHT, Math.floor(window.innerHeight * MAX_DRAWER_HEIGHT_RATIO));
Expand Down Expand Up @@ -264,6 +273,13 @@ export function shouldHandleTerminalSelectionMouseUp(
return selectionGestureActive && button === 0;
}

export async function copyTerminalSelectionTextToClipboard(text: string): Promise<void> {
if (typeof navigator === "undefined" || !navigator.clipboard?.writeText) {
throw new Error("Clipboard API unavailable.");
}
await navigator.clipboard.writeText(text);
}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

Uh oh!

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


interface TerminalViewportProps {
threadRef: ScopedThreadRef;
threadId: ThreadId;
Expand Down Expand Up @@ -418,15 +434,33 @@ export function TerminalViewport({
selectionActionOpenRef.current = true;
try {
const clicked = await localApi.contextMenu.show(
[{ id: "add-to-chat", label: "Add to chat" }],
TERMINAL_SELECTION_ACTION_MENU_ITEMS,
nextAction.position,
);
if (requestId !== selectionActionRequestIdRef.current || clicked !== "add-to-chat") {
if (requestId !== selectionActionRequestIdRef.current || clicked === null) {
return;
}
handleAddTerminalContext(nextAction.selection);
terminalRef.current?.clearSelection();
terminalRef.current?.focus();
switch (clicked) {
case "add-to-chat":
handleAddTerminalContext(nextAction.selection);
terminalRef.current?.clearSelection();
terminalRef.current?.focus();
return;
case "copy":
try {
await copyTerminalSelectionTextToClipboard(nextAction.selection.text);
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

Uh oh!

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

} catch (error) {
const activeTerminal = terminalRef.current;
if (activeTerminal) {
writeSystemMessage(
activeTerminal,
error instanceof Error ? error.message : "Unable to copy terminal selection",
);
}
}
terminalRef.current?.focus();
return;
}
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.

} finally {
selectionActionOpenRef.current = false;
}
Expand Down
Loading
Oops, something went wrong.

Uh oh!

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

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.