Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix: address desktop deep-link review feedback
Josuéb0716fcfc3ef
diff --git a/desktop-app/package-lock.json b/desktop-app/package-lock.jsonindex 3a237e3a5..c256352ae 100644--- a/desktop-app/package-lock.json+++ b/desktop-app/package-lock.json@@ -1,12 +1,12 @@{"name": "evenfire",- "version": "0.1.318",+ "version": "0.1.319","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "evenfire",- "version": "0.1.318",+ "version": "0.1.319","license": "MPL-2.0","dependencies": {"@tanstack/react-query": "5.100.10",diff --git a/desktop-app/package.json b/desktop-app/package.jsonindex 309071548..b26dfaaff 100644--- a/desktop-app/package.json+++ b/desktop-app/package.json@@ -1,7 +1,7 @@{"name": "evenfire","productName": "Evenfire",- "version": "0.1.318",+ "version": "0.1.319","private": true,"license": "MPL-2.0","description": "Evenfire desktop client for secure agent and workflow access",diff --git a/desktop-app/src/__tests__/protocolLaunchArgs.test.ts b/desktop-app/src/__tests__/protocolLaunchArgs.test.tsnew file mode 100644index 000000000..5c4011f16--- /dev/null+++ b/desktop-app/src/__tests__/protocolLaunchArgs.test.ts@@ -0,0 +1,27 @@+import { describe, expect, it } from 'vitest'+import { collectInitialProtocolUrls } from '../protocolLaunchArgs.js'++describe('collectInitialProtocolUrls', () => {+ it('collects each initial Evenfire link once', () => {+ const setupUrl =+ 'evenfire://desktop-setup?email=user%40example.com&authorizationToken=single-use-token'++ expect(collectInitialProtocolUrls(['Evenfire', setupUrl, setupUrl]).evenfireUrls).toEqual([+ setupUrl,+ ])+ })++ it('collects Clerum OAuth separately from the queued Evenfire links', () => {+ const result = collectInitialProtocolUrls([+ 'Evenfire',+ 'evenfire://app/sandbox-recipes/task-board?path=%2Ftasks',+ 'clerum://oauth-completed?clientId=github&provider=github',+ '--unrelated',+ ])++ expect(result).toEqual({+ evenfireUrls: ['evenfire://app/sandbox-recipes/task-board?path=%2Ftasks'],+ clerumUrl: 'clerum://oauth-completed?clientId=github&provider=github',+ })+ })+})diff --git a/desktop-app/src/main.ts b/desktop-app/src/main.tsindex 2a29f269c..63ae08007 100644--- a/desktop-app/src/main.ts+++ b/desktop-app/src/main.ts@@ -4,6 +4,7 @@ import { AppService } from './appService.js'import { config } from './config.js'import { assertTrustedSender, registerIpcHandlers } from './ipc.js'import { createMainWindowCoordinator } from './mainWindowCoordinator.js'+import { collectInitialProtocolUrls } from './protocolLaunchArgs.js'import { type SandboxUiDeepLinkEnvelope, parseSandboxUiDeepLink } from './sandboxUiDeepLinks.js'import { installAdaptiveSystemIcon, resolveSystemIconPath } from './systemIcon.js'@@ -127,10 +128,6 @@ function requestMainWindow(): void {})}-function findProtocolUrl(argv: string[], protocol: string): string | undefined {- return argv.find(arg => arg.startsWith(`${protocol}://`))-}-function handleSandboxUiDeepLink(rawUrl: string): boolean {const target = parseSandboxUiDeepLink(rawUrl)if (!target) return false@@ -337,12 +334,6 @@ async function createWindow(): Promise<void> {window.maximize()// Show window after successful load to avoid hidden-startup deadlocks.window.show()- if (process.platform !== 'darwin') {- const initialEvenfireUrl = findProtocolUrl(process.argv, DESKTOP_SETUP_PROTOCOL)- if (initialEvenfireUrl) handleEvenfireUrl(initialEvenfireUrl)- const initialClerumUrl = findProtocolUrl(process.argv, CLERUM_PROTOCOL)- if (initialClerumUrl) handleClerumUrl(initialClerumUrl)- }while (pendingEvenfireUrls.length > 0) {const pendingUrl = pendingEvenfireUrls.shift()if (pendingUrl) handleEvenfireUrl(pendingUrl)@@ -362,12 +353,15 @@ if (gotSingleInstanceLock) {// so recreating a closed macOS window does not repeat session network I/O.await appService.initialize()mainWindowLifecycleReady = true- for (const arg of process.argv) {- if (arg.startsWith(`${DESKTOP_SETUP_PROTOCOL}://`)) {- pendingEvenfireUrls.push(arg)- }- }+ // Collect startup argv once. `createWindow` drains the queued Evenfire URLs+ // after the renderer loads; rescanning argv there would dispatch setup links+ // twice on Windows/Linux and redeem single-use setup tokens a second time.+ const initialProtocolUrls = collectInitialProtocolUrls(process.argv)+ pendingEvenfireUrls.push(...initialProtocolUrls.evenfireUrls)await mainWindowCoordinator.ensureWindow()+ if (process.platform !== 'darwin' && initialProtocolUrls.clerumUrl) {+ handleClerumUrl(initialProtocolUrls.clerumUrl)+ }wirePowerMonitor()app.on('activate', async () => {diff --git a/desktop-app/src/protocolLaunchArgs.ts b/desktop-app/src/protocolLaunchArgs.tsnew file mode 100644index 000000000..a8f7d6942--- /dev/null+++ b/desktop-app/src/protocolLaunchArgs.ts@@ -0,0 +1,11 @@+export type InitialProtocolUrls = {+ evenfireUrls: string[]+ clerumUrl?: string+}++export function collectInitialProtocolUrls(argv: string[]): InitialProtocolUrls {+ return {+ evenfireUrls: [...new Set(argv.filter(argument => argument.startsWith('evenfire://')))],+ clerumUrl: argv.find(argument => argument.startsWith('clerum://')),+ }+}diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex 44e00ae38..58c8f46ab 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -18,6 +18,7 @@ import { DESKTOP_ROUTES, SIDEBAR_COLLAPSED_KEY } from '@constants/navigation'import { THEME_STORAGE_KEY } from '@constants/theme'import { useAgentChatActionsValue } from '@hooks/useAgentChatActionsValue'import { useAppController } from '@hooks/useAppController'+import { resolveSandboxUiDeepLinkApp, toActiveSandboxUiApps } from '@lib/sandboxUiAppSelection'import {getConversationOriginForAppLaunch,getConversationOriginForNavigation,@@ -59,25 +60,6 @@ function getInitialSidebarCollapsed(): boolean {}}-function toActiveSandboxUiApps(- apps: Array<{- appRef: string- title?: string- icon?: string- defaultPath: string- ready: boolean- }>-): ActiveSandboxUiApp[] {- return apps- .filter(app => app.ready)- .map(app => ({- appRef: app.appRef,- label: app.title?.trim() || app.appRef,- icon: app.icon,- defaultPath: app.defaultPath,- }))-}-function DesktopUpdateRequiredDialog({currentVersion,latestVersion,@@ -367,13 +349,18 @@ export function App() {const result = await window.clerum.sandboxUi.listApps()const availableApps = toActiveSandboxUiApps(result.apps)setAvailableSandboxUiApps(availableApps)- const app = availableApps.find(candidate => candidate.appRef === pending.link.appRef)- if (!app) {+ const resolution = resolveSandboxUiDeepLinkApp(result.apps, pending.link.appRef)+ if (resolution.status === 'unavailable') {throw new Error("You don't have access to this app in the linked team")}+ if (resolution.status === 'starting') {+ throw new Error(+ `${resolution.label} is still starting up. Try this link again in a moment`+ )+ }launchSandboxUiApp({- ...app,+ ...resolution.app,routePath: pending.link.path,},pending.conversationOrigindiff --git a/desktop-app/ui/src/hooks/__tests__/useWorkspaceController.test.tsx b/desktop-app/ui/src/hooks/__tests__/useWorkspaceController.test.tsxindex 920042510..dbffaacbb 100644--- a/desktop-app/ui/src/hooks/__tests__/useWorkspaceController.test.tsx+++ b/desktop-app/ui/src/hooks/__tests__/useWorkspaceController.test.tsx@@ -69,6 +69,7 @@ function installClerumHarness(options: {delayAuthenticatedLoad?: booleandelayHealth?: boolean+ healthError?: unknownpasswordLoginError?: unknown} = {}) {@@ -105,6 +106,11 @@ function installClerumHarness(releaseUrl: 'https://github.com/your-org/evenfire/releases/tag/desktop-app-0.1.250',}))+ const getDependenciesHealth = vi.fn(async () => {+ if (options.healthError) throw options.healthError+ return options.delayHealth ? healthDeferred.promise : createHealth()+ })+Object.defineProperty(window, 'clerum', {configurable: true,writable: true,@@ -116,9 +122,7 @@ function installClerumHarness(isPackaged: false,options: [],})),- getDependenciesHealth: vi.fn(async () =>- options.delayHealth ? healthDeferred.promise : createHealth()- ),+ getDependenciesHealth,getSessionState,passwordLogin,onDesktopSetupToken: vi.fn(() => () => undefined),@@ -219,6 +223,7 @@ function installClerumHarness(return {passwordLogin,+ getDependenciesHealth,getSessionState,getDesktopReleaseStatus,resolveHealth() {@@ -311,6 +316,23 @@ describe('useWorkspaceController', () => {clerum.resolveHealth()})+ it('logs dependency-health probe failures without blocking session restoration', async () => {+ const healthError = new Error('health endpoint unavailable')+ const consoleWarn = vi.spyOn(console, 'warn').mockImplementation(() => undefined)+ const clerum = installClerumHarness({ healthError })++ renderControllerHarness()++ await waitFor(() => expect(clerum.getSessionState).toHaveBeenCalledOnce())+ await waitFor(() => expect(screen.getByTestId('booting').textContent).toBe('false'))+ await waitFor(() =>+ expect(consoleWarn).toHaveBeenCalledWith(+ '[Desktop] Could not refresh dependency health:',+ healthError+ )+ )+ })+it('preserves a workflow nav selection while login session hydration finishes', async () => {const clerum = installClerumHarness({ delayAuthenticatedLoad: true })diff --git a/desktop-app/ui/src/hooks/useAppController.ts b/desktop-app/ui/src/hooks/useAppController.tsindex 1abf3d90f..4026a9fde 100644--- a/desktop-app/ui/src/hooks/useAppController.ts+++ b/desktop-app/ui/src/hooks/useAppController.ts@@ -572,7 +572,9 @@ export function useAppController() {void window.clerum.auth.getDependenciesHealth().then(auth.setDependencyHealth)- .catch(() => undefined)+ .catch(error => {+ console.warn('[Desktop] Could not refresh dependency health:', error)+ })const sessionState = await window.clerum.auth.getSessionState()const authenticated = Boolean(sessionState.authenticated && sessionState.me)auth.setIsAuthenticated(authenticated)diff --git a/desktop-app/ui/src/lib/__tests__/sandboxUiAppSelection.test.ts b/desktop-app/ui/src/lib/__tests__/sandboxUiAppSelection.test.tsnew file mode 100644index 000000000..f6b5382f6--- /dev/null+++ b/desktop-app/ui/src/lib/__tests__/sandboxUiAppSelection.test.ts@@ -0,0 +1,53 @@+import { describe, expect, it } from 'vitest'+import { resolveSandboxUiDeepLinkApp, toActiveSandboxUiApps } from '@lib/sandboxUiAppSelection'++const apps = [+ {+ appRef: 'sandbox-recipes/ready-app',+ title: 'Ready app',+ defaultPath: '/',+ ready: true,+ phase: 'Ready',+ },+ {+ appRef: 'sandbox-recipes/provisioning-app',+ title: 'Provisioning app',+ defaultPath: '/',+ ready: false,+ phase: 'Installing',+ },+]++describe('sandbox UI app selection', () => {+ it('keeps provisioning apps out of the app picker', () => {+ expect(toActiveSandboxUiApps(apps)).toEqual([+ {+ appRef: 'sandbox-recipes/ready-app',+ label: 'Ready app',+ defaultPath: '/',+ },+ ])+ })++ it('distinguishes a provisioning deep-link target from an inaccessible app', () => {+ expect(resolveSandboxUiDeepLinkApp(apps, 'sandbox-recipes/provisioning-app')).toEqual({+ status: 'starting',+ label: 'Provisioning app',+ phase: 'Installing',+ })+ expect(resolveSandboxUiDeepLinkApp(apps, 'sandbox-recipes/missing-app')).toEqual({+ status: 'unavailable',+ })+ })++ it('returns a launchable app when the deep-link target is ready', () => {+ expect(resolveSandboxUiDeepLinkApp(apps, 'sandbox-recipes/ready-app')).toEqual({+ status: 'ready',+ app: {+ appRef: 'sandbox-recipes/ready-app',+ label: 'Ready app',+ defaultPath: '/',+ },+ })+ })+})diff --git a/desktop-app/ui/src/lib/sandboxUiAppSelection.ts b/desktop-app/ui/src/lib/sandboxUiAppSelection.tsnew file mode 100644index 000000000..b500dd442--- /dev/null+++ b/desktop-app/ui/src/lib/sandboxUiAppSelection.ts@@ -0,0 +1,34 @@+import type {+ SandboxUiAppListing,+ SandboxUiDeepLinkAppResolution,+} from '@lib/sandboxUiAppSelection.types'+import type { ActiveSandboxUiApp } from '@/uiTypes'++function toActiveSandboxUiApp(app: SandboxUiAppListing): ActiveSandboxUiApp {+ return {+ appRef: app.appRef,+ label: app.title?.trim() || app.appRef,+ icon: app.icon,+ defaultPath: app.defaultPath,+ }+}++export function toActiveSandboxUiApps(apps: SandboxUiAppListing[]): ActiveSandboxUiApp[] {+ return apps.filter(app => app.ready).map(toActiveSandboxUiApp)+}++export function resolveSandboxUiDeepLinkApp(+ apps: SandboxUiAppListing[],+ appRef: string+): SandboxUiDeepLinkAppResolution {+ const match = apps.find(app => app.appRef === appRef)+ if (!match) return { status: 'unavailable' }+ if (!match.ready) {+ return {+ status: 'starting',+ label: match.title?.trim() || match.appRef,+ phase: match.phase ?? null,+ }+ }+ return { status: 'ready', app: toActiveSandboxUiApp(match) }+}diff --git a/desktop-app/ui/src/lib/sandboxUiAppSelection.types.ts b/desktop-app/ui/src/lib/sandboxUiAppSelection.types.tsnew file mode 100644index 000000000..8ae2ed13c--- /dev/null+++ b/desktop-app/ui/src/lib/sandboxUiAppSelection.types.ts@@ -0,0 +1,15 @@+import type { ActiveSandboxUiApp } from '@/uiTypes'++export type SandboxUiAppListing = {+ appRef: string+ title?: string+ icon?: string+ defaultPath: string+ ready: boolean+ phase?: string | null+}++export type SandboxUiDeepLinkAppResolution =+ | { status: 'ready'; app: ActiveSandboxUiApp }+ | { status: 'starting'; label: string; phase: string | null }+ | { status: 'unavailable' }diff --git a/desktop-app/ui/src/pages/SandboxUiPage.tsx b/desktop-app/ui/src/pages/SandboxUiPage.tsxindex 172573fc8..dd8b73046 100644--- a/desktop-app/ui/src/pages/SandboxUiPage.tsx+++ b/desktop-app/ui/src/pages/SandboxUiPage.tsx@@ -295,7 +295,6 @@ export function SandboxUiPage({label: appLabel(app),icon: app.icon,defaultPath: app.defaultPath,- routePath: app.routePath,ready: app.ready,})},