Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Use shared ContextMenuItem type from contracts

Julius Marminge674720c6cd23
diff --git a/apps/web/src/contextMenuFallback.ts b/apps/web/src/contextMenuFallback.ts
index 3fe6c572e..63cdef848 100644
--- a/apps/web/src/contextMenuFallback.ts
+++ b/apps/web/src/contextMenuFallback.ts
@@ -1,10 +1,12 @@
+import type { ContextMenuItem } from "@t3tools/contracts";
+
/**
* Imperative DOM-based context menu for non-Electron environments.
* Shows a positioned dropdown and returns a promise that resolves
* with the clicked item id, or null if dismissed.
*/
export function showContextMenuFallback<T extends string>(
- items: readonly { id: T; label: string; destructive?: boolean }[],
+ items: readonly ContextMenuItem<T>[],
position?: { x: number; y: number },
): Promise<T | null> {
return new Promise<T | null>((resolve) => {
diff --git a/apps/web/src/wsNativeApi.test.ts b/apps/web/src/wsNativeApi.test.ts
index 80e283ee4..1dd19c4c6 100644
--- a/apps/web/src/wsNativeApi.test.ts
+++ b/apps/web/src/wsNativeApi.test.ts
@@ -1,5 +1,6 @@
import {
CommandId,
+ type ContextMenuItem,
ORCHESTRATION_WS_CHANNELS,
ORCHESTRATION_WS_METHODS,
ProjectId,
@@ -11,7 +12,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
const requestMock = vi.fn<(...args: Array<unknown>) => Promise<unknown>>();
const showContextMenuFallbackMock = vi.fn<
<T extends string>(
- items: readonly { id: T; label: string; destructive?: boolean }[],
+ items: readonly ContextMenuItem<T>[],
position?: { x: number; y: number },
) => Promise<T | null>
>();
diff --git a/apps/web/src/wsNativeApi.ts b/apps/web/src/wsNativeApi.ts
index 871e01c91..f3bdfe5d0 100644
--- a/apps/web/src/wsNativeApi.ts
+++ b/apps/web/src/wsNativeApi.ts
@@ -2,6 +2,7 @@ import {
OrchestrationEvent,
ORCHESTRATION_WS_CHANNELS,
ORCHESTRATION_WS_METHODS,
+ type ContextMenuItem,
type NativeApi,
ServerConfigUpdatedPayload,
TerminalEvent,
@@ -171,7 +172,7 @@ export function createWsNativeApi(): NativeApi {
},
contextMenu: {
show: async <T extends string>(
- items: readonly { id: T; label: string; destructive?: boolean }[],
+ items: readonly ContextMenuItem<T>[],
position?: { x: number; y: number },
): Promise<T | null> => {
if (window.desktopBridge) {
diff --git a/packages/contracts/src/ipc.ts b/packages/contracts/src/ipc.ts
index a182d2325..aeec16ca0 100644
--- a/packages/contracts/src/ipc.ts
+++ b/packages/contracts/src/ipc.ts
@@ -37,7 +37,7 @@ import type {
} from "./orchestration";
import { EditorId } from "./editor";
-interface ContextMenuItem<T extends string = string> {
+export interface ContextMenuItem<T extends string = string> {
id: T;
label: string;
destructive?: boolean;