The best way to control Claude Code, Codex and more from any computer or phone
Use shared ContextMenuItem type from contracts
Re-export ContextMenuItem and replace the inlined { id: T; label: string; destructive?: boolean } definitions in wsNativeApi, contextMenuFallback, and the test file. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Julius Marminge committed
Mar 2, 2026 at 13:31 UTC
674720c6cd233ca8c9a7b357eb954e26cae3466d
4 files changed
+8
-4
apps/web/src/contextMenuFallback.ts
+3
-1
@@ -1,10 +1,12 @@
1
+import type { ContextMenuItem } from "@t3tools/contracts";
2
+
3
/**
4
* Imperative DOM-based context menu for non-Electron environments.
5
* Shows a positioned dropdown and returns a promise that resolves
6
* with the clicked item id, or null if dismissed.
7
*/
8
export function showContextMenuFallback<T extends string>(
7
- items: readonly { id: T; label: string; destructive?: boolean }[],
9
+ items: readonly ContextMenuItem<T>[],
10
position?: { x: number; y: number },
11
): Promise<T | null> {
12
return new Promise<T | null>((resolve) => {
apps/web/src/wsNativeApi.test.ts
+2
-1
@@ -1,5 +1,6 @@
1
import {
2
CommandId,
3
+ type ContextMenuItem,
4
ORCHESTRATION_WS_CHANNELS,
5
ORCHESTRATION_WS_METHODS,
6
ProjectId,
@@ -11,7 +12,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
12
const requestMock = vi.fn<(...args: Array<unknown>) => Promise<unknown>>();
13
const showContextMenuFallbackMock = vi.fn<
14
<T extends string>(
14
- items: readonly { id: T; label: string; destructive?: boolean }[],
15
+ items: readonly ContextMenuItem<T>[],
16
position?: { x: number; y: number },
17
) => Promise<T | null>
18
>();
apps/web/src/wsNativeApi.ts
+2
-1
@@ -2,6 +2,7 @@ import {
2
OrchestrationEvent,
3
ORCHESTRATION_WS_CHANNELS,
4
ORCHESTRATION_WS_METHODS,
5
+ type ContextMenuItem,
6
type NativeApi,
7
ServerConfigUpdatedPayload,
8
TerminalEvent,
@@ -171,7 +172,7 @@ export function createWsNativeApi(): NativeApi {
172
},
173
contextMenu: {
174
show: async <T extends string>(
174
- items: readonly { id: T; label: string; destructive?: boolean }[],
175
+ items: readonly ContextMenuItem<T>[],
176
position?: { x: number; y: number },
177
): Promise<T | null> => {
178
if (window.desktopBridge) {
packages/contracts/src/ipc.ts
+1
-1
@@ -37,7 +37,7 @@ import type {
37
} from "./orchestration";
38
import { EditorId } from "./editor";
39
40
-interface ContextMenuItem<T extends string = string> {
40
+export interface ContextMenuItem<T extends string = string> {
41
id: T;
42
label: string;
43
destructive?: boolean;