Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): isolate development protocol registration
Alfredo Lopez2db547bcce45
diff --git a/desktop-app/src/__tests__/protocolLaunchArgs.test.ts b/desktop-app/src/__tests__/protocolLaunchArgs.test.tsindex 3a06fa667..f953b513a 100644--- a/desktop-app/src/__tests__/protocolLaunchArgs.test.ts+++ b/desktop-app/src/__tests__/protocolLaunchArgs.test.ts@@ -1,5 +1,22 @@import { describe, expect, it } from 'vitest'-import { collectInitialProtocolUrls } from '../protocolLaunchArgs.js'+import { collectInitialProtocolUrls, shouldRegisterOsProtocols } from '../protocolLaunchArgs.js'++describe('OS protocol ownership', () => {+ it('preserves ordinary development and packaged startup', () => {+ expect(shouldRegisterOsProtocols([], false)).toBe(true)+ expect(shouldRegisterOsProtocols([], true)).toBe(true)+ })++ it('allows an explicit development instance to leave OS associations untouched', () => {+ expect(shouldRegisterOsProtocols(['--no-os-protocol-registration'], false)).toBe(false)+ })++ it('rejects the opt-out in packaged applications', () => {+ expect(() => shouldRegisterOsProtocols(['--no-os-protocol-registration'], true)).toThrow(+ 'development-only'+ )+ })+})describe('collectInitialProtocolUrls', () => {it('collects each initial Evenfire link once', () => {diff --git a/desktop-app/src/main.ts b/desktop-app/src/main.tsindex fc6034a08..420268809 100644--- a/desktop-app/src/main.ts+++ b/desktop-app/src/main.ts@@ -10,7 +10,7 @@ import { createMainWindowCoordinator, createRetryableInitializer } from './mainWimport { wireMainWindowRendererReadiness } from './mainWindowReadiness.js'import { McpOauthCompletionQueue } from './mcpOauthCompletionQueue.js'import { initPluginSdkRuntime } from './pluginSdkRuntime.js'-import { collectInitialProtocolUrls } from './protocolLaunchArgs.js'+import { collectInitialProtocolUrls, shouldRegisterOsProtocols } from './protocolLaunchArgs.js'import { SandboxUiDeepLinkQueue } from './sandboxUiDeepLinkQueue.js'import {CLERUM_OAUTH_PROTOCOL,@@ -327,7 +327,7 @@ function handleClerumUrl(rawUrl: string): void {focusMainWindow()}-registerCustomProtocols()+if (shouldRegisterOsProtocols(process.argv, app.isPackaged)) registerCustomProtocols()const gotSingleInstanceLock = app.requestSingleInstanceLock()if (!gotSingleInstanceLock) {diff --git a/desktop-app/src/protocolLaunchArgs.ts b/desktop-app/src/protocolLaunchArgs.tsindex a9ae8dc1f..3018b2a94 100644--- a/desktop-app/src/protocolLaunchArgs.ts+++ b/desktop-app/src/protocolLaunchArgs.ts@@ -1,5 +1,12 @@import { CLERUM_OAUTH_PROTOCOL, SANDBOX_UI_DEEP_LINK_PROTOCOL } from '@clerum/desktop-app-links'+/** Development instances must be able to leave machine-wide URL ownership alone. */+export function shouldRegisterOsProtocols(argv: string[], isPackaged: boolean): boolean {+ if (!argv.includes('--no-os-protocol-registration')) return true+ if (isPackaged) throw new Error('Protocol registration opt-out is development-only')+ return false+}+export type InitialProtocolUrls = {evenfireUrls: string[]clerumUrls: string[]diff --git a/desktop-app/test/e2e-playwright/gfs-agent-image-read.test.ts b/desktop-app/test/e2e-playwright/gfs-agent-image-read.test.tsindex e7c6f20af..8c6055686 100644--- a/desktop-app/test/e2e-playwright/gfs-agent-image-read.test.ts+++ b/desktop-app/test/e2e-playwright/gfs-agent-image-read.test.ts@@ -327,6 +327,7 @@ test('GFS image bytes reach vision after visible upload; a host without a grantawait writeFile(filePath, visual.bytes)app = await electron.launch({args: [+ '--no-os-protocol-registration',`--user-data-dir=${path.join(local, 'desktop')}`,path.resolve(__dirname, '../../dist/main.js'),],@@ -336,6 +337,16 @@ test('GFS image bytes reach vision after visible upload; a host without a grantCLERUM_DESKTOP_CONFIG_PATH: path.join(local, 'runtime-config.json'),},})+ // This is process identity verification, not a login or product-state shortcut.+ const identity = await app.evaluate(({ app }) => ({+ userData: app.getPath('userData'),+ packaged: app.isPackaged,+ argv: process.argv,+ }))+ expect(identity.packaged).toBe(false)+ expect(identity.userData).toBe(path.join(local, 'desktop'))+ expect(identity.argv).toContain('--no-os-protocol-registration')+ expect(identity.argv).toContain(path.resolve(__dirname, '../../dist/main.js'))const page = await app.firstWindow()await test.step('login visibly into the isolated development environment', () =>visibleLogin(page))