@devries-cameron20 / t3code Mirror · read-only / commits / 2922e8fb59
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 00:45 UTC

fix(desktop): right-clicking a mailto link offers Copy Email Address (#33262)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 10, 2026 at 00:58 UTC 2922e8fb5952277793e0915b6adbceb58ebef1b0
2 files changed +80 -5
apps/desktop/src/window/DesktopWindow.test.ts
+52 -5
@@ -233,7 +233,7 @@ function layerTest(input: {
233 readonly destroyAll?: Effect.Effect<void>;
234 readonly onWindowCreate?: Effect.Effect<void>;
235 readonly openedExternalUrls?: unknown[];
236 - readonly copiedTexts?: string[];
236 + readonly onCopyText?: (text: string) => Effect.Effect<void>;
237 readonly onPopupTemplate?: (input: ElectronMenu.ElectronMenuTemplateInput) => Effect.Effect<void>;
238 readonly previewZoomReapplies?: number[];
239 readonly onReveal?: (window: Electron.BrowserWindow) => void;
@@ -325,10 +325,7 @@ function layerTest(input: {
325 return true;
326 }),
327 openSystemSettings: () => Effect.succeed(true),
328 - copyText: (text) =>
329 - Effect.sync(() => {
330 - input.copiedTexts?.push(text);
331 - }),
328 + copyText: input.onCopyText ?? (() => Effect.void),
329 } satisfies ElectronShell.ElectronShell["Service"]),
330 layerElectronTheme,
331 layerElectronWindow,
@@ -1186,6 +1183,56 @@ describe("DesktopWindow", () => {
1183 }),
1184 );
1185
1186 + it.effect("offers to copy the bare address when right-clicking a mailto link", () =>
1187 + Effect.gen(function* () {
1188 + const fakeWindow = makeFakeBrowserWindow();
1189 + const createCount = yield* Ref.make(0);
1190 + const mainWindow = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());
1191 + const popup = yield* Deferred.make<ElectronMenu.ElectronMenuTemplateInput>();
1192 + const copied = yield* Deferred.make<string>();
1193 + const layer = layerTest({
1194 + window: fakeWindow.window,
1195 + createCount,
1196 + mainWindow,
1197 + onPopupTemplate: (input) => Deferred.succeed(popup, input),
1198 + onCopyText: (text) => Deferred.succeed(copied, text),
1199 + });
1200 +
1201 + yield* Effect.gen(function* () {
1202 + const desktopWindow = yield* DesktopWindow.DesktopWindow;
1203 + yield* desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773"));
1204 +
1205 + const contextMenu = fakeWindow.webContentsListeners.get("context-menu");
1206 + if (!contextMenu) {
1207 + return yield* Effect.die("context-menu listener was not registered");
1208 + }
1209 + contextMenu(
1210 + { preventDefault: vi.fn() },
1211 + {
1212 + linkURL: "mailto:restaurant%40example.com?subject=Hi",
1213 + misspelledWord: "",
1214 + dictionarySuggestions: [],
1215 + mediaType: "none",
1216 + editFlags: { canCut: false, canCopy: false, canPaste: false, canSelectAll: true },
1217 + },
1218 + );
1219 +
1220 + const { template } = yield* Deferred.await(popup);
1221 + const copyEmail = template.find((item) => item.label === "Copy Email Address");
1222 + assert.isDefined(
1223 + copyEmail,
1224 + `no "Copy Email Address" item in ${JSON.stringify(template.map((item) => item.label ?? item.role ?? item.type))}`,
1225 + );
1226 + copyEmail?.click?.(
1227 + {} as Electron.MenuItem,
1228 + fakeWindow.window,
1229 + {} as Electron.KeyboardEvent,
1230 + );
1231 + assert.equal(yield* Deferred.await(copied), "restaurant@example.com");
1232 + }).pipe(Effect.provide(layer));
1233 + }),
1234 + );
1235 +
1236 it.effect(
1237 "retries opening the real main on activate when a failed post-readiness open left only the splash",
1238 () =>
apps/desktop/src/window/DesktopWindow.ts
+28
@@ -53,6 +53,21 @@ class ContextMenuImageCopyError extends Schema.TaggedError<ContextMenuImageCopyE
53 const MACOS_WORKSPACE_TOPBAR_HEIGHT = 52;
54 const MACOS_WINDOW_BUTTON_RADIUS = 7;
55
56 +function parseMailtoAddress(rawUrl: string): Option.Option<string> {
57 + let url: URL;
58 + try {
59 + url = new URL(rawUrl);
60 + } catch {
61 + return Option.none();
62 + }
63 + if (url.protocol !== "mailto:" || url.pathname === "") return Option.none();
64 + try {
65 + return Option.some(decodeURIComponent(url.pathname));
66 + } catch {
67 + return Option.some(url.pathname);
68 + }
69 +}
70 +
71 function syncMacosWindowButtons(window: Electron.BrowserWindow): void {
72 if (window.isDestroyed() || window.isFullScreen()) return;
73 window.setWindowButtonPosition({
@@ -590,6 +605,19 @@ export const make = Effect.gen(function* () {
605 );
606 }
607
608 + const mailtoAddress = parseMailtoAddress(params.linkURL);
609 + if (Option.isSome(mailtoAddress)) {
610 + menuTemplate.push(
611 + {
612 + label: "Copy Email Address",
613 + click: () => {
614 + void runPromise(electronShell.copyText(mailtoAddress.value));
615 + },
616 + },
617 + { type: "separator" },
618 + );
619 + }
620 +
621 if (params.mediaType === "image") {
622 menuTemplate.push({
623 label: "Copy Image",