Where agent teams gather. Cross-platform team chat where AI agents are first-class teammates — with cloud or bring-your-own (Claude Code / Codex) brains.
TypeScript
Fix local pairing commands using the Vite API target (#3)
sushuaiyu5f742521198b
diff --git a/.env.example b/.env.exampleindex 731a76a..21b981e 100644--- a/.env.example+++ b/.env.example@@ -125,7 +125,7 @@ R2_URL_SIGNING_SECRET=# without this we'd be open-redirect bait. Comma-separated; prefix match.# Must include every host the SPA may be served at (app + admin) plus# the Electron loopback page and deep-link.-# CUMORA_AUTH_RETURN_ALLOWLIST=https://app.cumora.ai/,https://admin.cumora.ai/,http://localhost:5173/,http://127.0.0.1:47823/auth/done,cumora://auth+# CUMORA_AUTH_RETURN_ALLOWLIST=https://app.cumora.ai/,https://admin.cumora.ai/,http://localhost:5180/,http://localhost:5173/,http://127.0.0.1:47823/auth/done,cumora://auth## Public base used to construct invitation accept URLs# (`<base>/invite/<token>`). Defaults to CUMORA_AUTH_DONE_URL — set thisdiff --git a/src/api/client.ts b/src/api/client.tsindex d423c4f..65cdc9b 100644--- a/src/api/client.ts+++ b/src/api/client.ts@@ -9,6 +9,12 @@ import { getAuthToken, getActiveCompanyId, useAuth } from '@/stores/auth'const DEVTOOLS_KEY = 'cumora.devtools.enabled'const SERVER_URL_KEY = 'cumora.serverUrl'+// Vite's relative proxy keeps browser requests same-origin, but the pairing+// command runs outside the browser and must address the API directly.+const DEV_API_TARGET = import.meta.env.DEV+ ? (import.meta.env.VITE_CUMORA_DEV_API_TARGET as string | undefined)?.replace(/\/+$/, '')+ : undefined+/** Resolve the API base. Three layers, highest priority first:* 1. localStorage['cumora.serverUrl'] — runtime override, settable* from the dev console: `localStorage.setItem('cumora.serverUrl',@@ -43,6 +49,13 @@ export function getServerOrigin(): string {return SERVER_ORIGIN}+/** Origin to embed in a local computer pairing command.+ * In Vite dev the browser uses a relative proxy, so SERVER_ORIGIN is empty;+ * the daemon still needs the API target rather than the renderer origin. */+export function getPairingServerOrigin(): string {+ return SERVER_ORIGIN || DEV_API_TARGET || ''+}+/** Persist a new server origin override and clear the existing session.* We don't try to hot-swap the in-memory API/WS — anything pending against* the old origin would race or fail in confusing ways. Callers shoulddiff --git a/src/components/AgentEditor.tsx b/src/components/AgentEditor.tsxindex 00f8700..d5762f2 100644--- a/src/components/AgentEditor.tsx+++ b/src/components/AgentEditor.tsx@@ -1,5 +1,5 @@import { useEffect, useState } from 'react'-import { api, getServerOrigin, type AgentInput } from '@/api/client'+import { api, getPairingServerOrigin, type AgentInput } from '@/api/client'import { isNativePlatform } from '@/lib/native'import { useParticipants } from '@/stores/participants'import { useComputers } from '@/stores/computers'@@ -56,7 +56,7 @@ export function AgentEditor({ agent, onClose }: Props) {const selectedComputer = computerId ? computersById[computerId] : undefinedconst isByoa = !!selectedComputer && selectedComputer.kind !== 'cloud'const selectedComputerOffline = isByoa && selectedComputer.status !== 'online'- const origin = getServerOrigin()+ const origin = getPairingServerOrigin()const repairCommand = repairCode? `npx cumora@latest agent computer --pair ${repairCode}${origin ? ` --server ${origin}` : ''}`: ''diff --git a/src/desktop/MeView.tsx b/src/desktop/MeView.tsxindex 16296e3..7014716 100644--- a/src/desktop/MeView.tsx+++ b/src/desktop/MeView.tsx@@ -9,7 +9,7 @@ import { Avatar } from '@/components/Avatar'import { Checkbox } from '@/components/Checkbox'import { cn } from '@/lib/utils'import { isWindows } from '@/lib/runtime'-import { api, getServerOrigin, type ApiProject, type ApiQuotaSnapshot, type ApiQuotaWindow } from '@/api/client'+import { api, getPairingServerOrigin, getServerOrigin, type ApiProject, type ApiQuotaSnapshot, type ApiQuotaWindow } from '@/api/client'const tabs = ['Profile', 'Usage', 'Computers', 'Projects', 'Trust & autonomy', 'Preferences'] as consttype Tab = (typeof tabs)[number]@@ -734,7 +734,7 @@ function ComputersTab() {setCopied(true)}- const origin = getServerOrigin()+ const origin = getPairingServerOrigin()const serverFlag = origin ? ` --server ${origin}` : ''const pairCommand = code ? `npx cumora@latest agent computer --pair ${code}${serverFlag}${engine === 'codex' ? ' --engine codex' : ''}${asService ? ' --install-service' : ''}` : ''const list = Object.values(byId).sort((a, b) =>diff --git a/src/desktop/Onboarding.tsx b/src/desktop/Onboarding.tsxindex 1795a9c..a756aad 100644--- a/src/desktop/Onboarding.tsx+++ b/src/desktop/Onboarding.tsx@@ -1,5 +1,5 @@import { useEffect, useState } from 'react'-import { api, getServerOrigin } from '@/api/client'+import { api, getPairingServerOrigin } from '@/api/client'import { useComputers } from '@/stores/computers'import { isWindows } from '@/lib/runtime'import { TitleBar } from '@/desktop/TitleBar'@@ -35,7 +35,7 @@ export function Onboarding() {return () => window.clearTimeout(t)}, [copied])- const origin = getServerOrigin()+ const origin = getPairingServerOrigin()const engineFlag = engine === 'codex' ? ' --engine codex' : ''const serviceFlag = asService ? ' --install-service' : ''const cmd = code ? `npx cumora@latest agent computer --pair ${code}${origin ? ` --server ${origin}` : ''}${engineFlag}${serviceFlag}` : ''diff --git a/src/vite-env.d.ts b/src/vite-env.d.tsindex d3b8ed7..3b80f5c 100644--- a/src/vite-env.d.ts+++ b/src/vite-env.d.ts@@ -2,6 +2,7 @@interface ImportMetaEnv {readonly VITE_CUMORA_API_BASE?: string+ readonly VITE_CUMORA_DEV_API_TARGET?: stringreadonly VITE_PUBLIC_POSTHOG_KEY?: stringreadonly VITE_PUBLIC_POSTHOG_HOST?: string}diff --git a/vite.config.ts b/vite.config.tsindex fbe27f6..6fb1ba7 100644--- a/vite.config.ts+++ b/vite.config.ts@@ -10,6 +10,11 @@ const WS_TARGET = HTTP_TARGET.replace(/^http/, 'ws')export default defineConfig({plugins: [react()],+ // The renderer uses relative URLs through the Vite proxy, but commands+ // copied from the UI run outside that proxy and need the API origin.+ define: {+ 'import.meta.env.VITE_CUMORA_DEV_API_TARGET': JSON.stringify(HTTP_TARGET),+ },resolve: {alias: {'@': path.resolve(__dirname, './src'),