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 @@...@@ -1,10 +1,12 @@
1import type { ContextMenuItem } from "@t3tools/contracts";
2
1/**3/**
2 * Imperative DOM-based context menu for non-Electron environments.4 * Imperative DOM-based context menu for non-Electron environments.
3 * Shows a positioned dropdown and returns a promise that resolves5 * Shows a positioned dropdown and returns a promise that resolves
4 * with the clicked item id, or null if dismissed.6 * with the clicked item id, or null if dismissed.
5 */7 */
6export function showContextMenuFallback<T extends string>(8export function showContextMenuFallback<T extends string>(
7 items: readonly { id: T; label: string; destructive?: boolean }[],9 items: readonly ContextMenuItem<T>[],
8 position?: { x: number; y: number },10 position?: { x: number; y: number },
9): Promise<T | null> {11): Promise<T | null> {
10 return new Promise<T | null>((resolve) => {12 return new Promise<T | null>((resolve) => {
apps/web/src/wsNativeApi.test.ts+2-1
...@@ -1,5 +1,6 @@...@@ -1,5 +1,6 @@
1import {1import {
2 CommandId,2 CommandId,
3 type ContextMenuItem,
3 ORCHESTRATION_WS_CHANNELS,4 ORCHESTRATION_WS_CHANNELS,
4 ORCHESTRATION_WS_METHODS,5 ORCHESTRATION_WS_METHODS,
5 ProjectId,6 ProjectId,
...@@ -11,7 +12,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";...@@ -11,7 +12,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
11const requestMock = vi.fn<(...args: Array<unknown>) => Promise<unknown>>();12const requestMock = vi.fn<(...args: Array<unknown>) => Promise<unknown>>();
12const showContextMenuFallbackMock = vi.fn<13const showContextMenuFallbackMock = vi.fn<
13 <T extends string>(14 <T extends string>(
14 items: readonly { id: T; label: string; destructive?: boolean }[],15 items: readonly ContextMenuItem<T>[],
15 position?: { x: number; y: number },16 position?: { x: number; y: number },
16 ) => Promise<T | null>17 ) => Promise<T | null>
17>();18>();
apps/web/src/wsNativeApi.ts+2-1
...@@ -2,6 +2,7 @@ import {...@@ -2,6 +2,7 @@ import {
2 OrchestrationEvent,2 OrchestrationEvent,
3 ORCHESTRATION_WS_CHANNELS,3 ORCHESTRATION_WS_CHANNELS,
4 ORCHESTRATION_WS_METHODS,4 ORCHESTRATION_WS_METHODS,
5 type ContextMenuItem,
5 type NativeApi,6 type NativeApi,
6 ServerConfigUpdatedPayload,7 ServerConfigUpdatedPayload,
7 TerminalEvent,8 TerminalEvent,
...@@ -171,7 +172,7 @@ export function createWsNativeApi(): NativeApi {...@@ -171,7 +172,7 @@ export function createWsNativeApi(): NativeApi {
171 },172 },
172 contextMenu: {173 contextMenu: {
173 show: async <T extends string>(174 show: async <T extends string>(
174 items: readonly { id: T; label: string; destructive?: boolean }[],175 items: readonly ContextMenuItem<T>[],
175 position?: { x: number; y: number },176 position?: { x: number; y: number },
176 ): Promise<T | null> => {177 ): Promise<T | null> => {
177 if (window.desktopBridge) {178 if (window.desktopBridge) {
packages/contracts/src/ipc.ts+1-1
...@@ -37,7 +37,7 @@ import type {...@@ -37,7 +37,7 @@ import type {
37} from "./orchestration";37} from "./orchestration";
38import { EditorId } from "./editor";38import { EditorId } from "./editor";
3939
40interface ContextMenuItem<T extends string = string> {40export interface ContextMenuItem<T extends string = string> {
41 id: T;41 id: T;
42 label: string;42 label: string;
43 destructive?: boolean;43 destructive?: boolean;