authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-03-02 13:31:12-08:00
committergravatar for jmarminge@gmail.comJulius Marminge <jmarminge@gmail.com> 2026-03-02 13:49:04-08:00
log674720c6cd233ca8c9a7b357eb954e26cae3466d
tree3370feadf8746aac1751108f45f62e92a1127231
parent58c9e4b96d811c120c7434549656c19058751713

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>

4 files changed, 8 insertions(+), 4 deletions(-)

apps/web/src/contextMenuFallback.ts+3-1
......@@ -1,10 +1,12 @@
1import type { ContextMenuItem } from "@t3tools/contracts";
2
13/**
24 * Imperative DOM-based context menu for non-Electron environments.
35 * Shows a positioned dropdown and returns a promise that resolves
46 * with the clicked item id, or null if dismissed.
57 */
68export function showContextMenuFallback<T extends string>(
7 items: readonly { id: T; label: string; destructive?: boolean }[],
9 items: readonly ContextMenuItem<T>[],
810 position?: { x: number; y: number },
911): Promise<T | null> {
1012 return new Promise<T | null>((resolve) => {
apps/web/src/wsNativeApi.test.ts+2-1
......@@ -1,5 +1,6 @@
11import {
22 CommandId,
3 type ContextMenuItem,
34 ORCHESTRATION_WS_CHANNELS,
45 ORCHESTRATION_WS_METHODS,
56 ProjectId,
......@@ -11,7 +12,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
1112const requestMock = vi.fn<(...args: Array<unknown>) => Promise<unknown>>();
1213const showContextMenuFallbackMock = vi.fn<
1314 <T extends string>(
14 items: readonly { id: T; label: string; destructive?: boolean }[],
15 items: readonly ContextMenuItem<T>[],
1516 position?: { x: number; y: number },
1617 ) => Promise<T | null>
1718>();
apps/web/src/wsNativeApi.ts+2-1
......@@ -2,6 +2,7 @@ import {
22 OrchestrationEvent,
33 ORCHESTRATION_WS_CHANNELS,
44 ORCHESTRATION_WS_METHODS,
5 type ContextMenuItem,
56 type NativeApi,
67 ServerConfigUpdatedPayload,
78 TerminalEvent,
......@@ -171,7 +172,7 @@ export function createWsNativeApi(): NativeApi {
171172 },
172173 contextMenu: {
173174 show: async <T extends string>(
174 items: readonly { id: T; label: string; destructive?: boolean }[],
175 items: readonly ContextMenuItem<T>[],
175176 position?: { x: number; y: number },
176177 ): Promise<T | null> => {
177178 if (window.desktopBridge) {
packages/contracts/src/ipc.ts+1-1
......@@ -37,7 +37,7 @@ import type {
3737} from "./orchestration";
3838import { EditorId } from "./editor";
3939
40interface ContextMenuItem<T extends string = string> {
40export interface ContextMenuItem<T extends string = string> {
4141 id: T;
4242 label: string;
4343 destructive?: boolean;