Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix: make desktop app deep links shareable

Josué6b2193f86d27
diff --git a/desktop-app/package-lock.json b/desktop-app/package-lock.json
index a39979438..b48db81b8 100644
--- a/desktop-app/package-lock.json
+++ b/desktop-app/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "evenfire",
- "version": "0.1.316",
+ "version": "0.1.317",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "evenfire",
- "version": "0.1.316",
+ "version": "0.1.317",
"license": "MPL-2.0",
"dependencies": {
"@tanstack/react-query": "5.100.10",
diff --git a/desktop-app/package.json b/desktop-app/package.json
index eea7eccdf..e70913995 100644
--- a/desktop-app/package.json
+++ b/desktop-app/package.json
@@ -1,7 +1,7 @@
{
"name": "evenfire",
"productName": "Evenfire",
- "version": "0.1.316",
+ "version": "0.1.317",
"private": true,
"license": "MPL-2.0",
"description": "Evenfire desktop client for secure agent and workflow access",
diff --git a/desktop-app/src/__tests__/sandboxUiDeepLinks.test.ts b/desktop-app/src/__tests__/sandboxUiDeepLinks.test.ts
index 2b28812ce..b87e09a4a 100644
--- a/desktop-app/src/__tests__/sandboxUiDeepLinks.test.ts
+++ b/desktop-app/src/__tests__/sandboxUiDeepLinks.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest'
import {
buildSandboxUiDeepLink,
+ buildSandboxUiWebLink,
extractSandboxUiViewRoute,
parseSandboxUiDeepLink,
} from '../sandboxUiDeepLinks.js'
@@ -21,6 +22,30 @@ describe('sandbox UI deep links', () => {
})
})
+ it('builds a browser-safe HTTPS handoff link for messaging apps', () => {
+ expect(
+ buildSandboxUiWebLink('https://profile.prod.evenfire.ai', {
+ recipeNs: 'sandbox-recipes',
+ recipeName: 'agentic-task-board',
+ path: '/tasks/task-42?view=detail#activity',
+ teamId: 'team-123',
+ })
+ ).toBe(
+ 'https://profile.prod.evenfire.ai/open/apps/sandbox-recipes/agentic-task-board' +
+ '?path=%2Ftasks%2Ftask-42%3Fview%3Ddetail%23activity&team=team-123'
+ )
+ })
+
+ it('rejects a non-web handoff origin', () => {
+ expect(() =>
+ buildSandboxUiWebLink('javascript:alert(1)', {
+ recipeNs: 'sandbox-recipes',
+ recipeName: 'agentic-task-board',
+ path: '/',
+ })
+ ).toThrow('Cannot create a shareable link')
+ })
+
it('rejects malformed app routes and unrelated evenfire links', () => {
expect(parseSandboxUiDeepLink('evenfire://[email protected]')).toBeNull()
expect(
diff --git a/desktop-app/src/__tests__/sandboxUiDriver.test.ts b/desktop-app/src/__tests__/sandboxUiDriver.test.ts
index 0246670c9..37c3a22cc 100644
--- a/desktop-app/src/__tests__/sandboxUiDriver.test.ts
+++ b/desktop-app/src/__tests__/sandboxUiDriver.test.ts
@@ -1,12 +1,41 @@
import { describe, expect, it, vi } from 'vitest'
import {
SANDBOX_UI_COOKIE_NAME,
+ applySandboxUiClientRoute,
extractSandboxUiCookie,
extractSandboxUiPath,
partitionFor,
reloadSandboxUiWebContents,
} from '../sandboxUiDriver.js'
+describe('applySandboxUiClientRoute', () => {
+ it('hands a nested route to the loaded app without requesting it from the server', async () => {
+ const executeJavaScript = vi.fn().mockResolvedValue(true)
+
+ const applied = await applySandboxUiClientRoute(
+ { isDestroyed: () => false, executeJavaScript },
+ 'https://rpc.example/api/v1/sandbox-ui/sandbox-recipes/task-board/view/tasks/task-42'
+ )
+
+ expect(applied).toBe(true)
+ expect(executeJavaScript).toHaveBeenCalledOnce()
+ expect(executeJavaScript.mock.calls[0]?.[0]).toContain('window.history.replaceState')
+ expect(executeJavaScript.mock.calls[0]?.[0]).toContain("PopStateEvent('popstate'")
+ })
+
+ it('does not hand off a route to a destroyed app view', async () => {
+ const executeJavaScript = vi.fn()
+
+ await expect(
+ applySandboxUiClientRoute(
+ { isDestroyed: () => true, executeJavaScript },
+ 'https://rpc.example'
+ )
+ ).resolves.toBe(false)
+ expect(executeJavaScript).not.toHaveBeenCalled()
+ })
+})
+
describe('partitionFor', () => {
it('produces a stable persist:sandbox-ui partition name per (env, recipe)', () => {
expect(partitionFor('env1', 'sandbox-recipes', 'r1')).toBe(
diff --git a/desktop-app/src/appService.ts b/desktop-app/src/appService.ts
index 3f005546d..9fb1e4a97 100644
--- a/desktop-app/src/appService.ts
+++ b/desktop-app/src/appService.ts
@@ -2764,6 +2764,7 @@ export class AppService {
recipeNs: string
recipeName: string
defaultPath?: string
+ routePath?: string
bounds: import('./sandboxUiDriver.js').SandboxUiBounds
parentWindow: import('electron').BrowserWindow
onClosed?: () => void
@@ -2782,6 +2783,7 @@ export class AppService {
setCookie,
rpcProxyUrl: config.rpcProxyBaseUrl,
defaultPath: args.defaultPath,
+ routePath: args.routePath,
parentWindow: args.parentWindow,
bounds: args.bounds,
onClosed: () => {
@@ -2832,11 +2834,11 @@ export class AppService {
async createSandboxUiDeepLink(teamId?: string): Promise<{ url: string }> {
const driver = await import('./sandboxUiDriver.js')
- const { buildSandboxUiDeepLink } = await import('./sandboxUiDeepLinks.js')
+ const { buildSandboxUiWebLink } = await import('./sandboxUiDeepLinks.js')
const location = driver.getActiveSandboxUiLocation()
if (!location) throw new Error('No app is currently open')
return {
- url: buildSandboxUiDeepLink({
+ url: buildSandboxUiWebLink(config.desktopProfileUiBaseUrl, {
...location,
teamId: String(teamId || '').trim() || undefined,
}),
diff --git a/desktop-app/src/ipc.ts b/desktop-app/src/ipc.ts
index 6f2616b7d..2446e4db9 100644
--- a/desktop-app/src/ipc.ts
+++ b/desktop-app/src/ipc.ts
@@ -1298,6 +1298,7 @@ export function registerIpcHandlers(service: AppService): void {
recipeNs: string
recipeName: string
defaultPath?: string
+ routePath?: string
bounds: unknown
}
) => {
@@ -1317,6 +1318,7 @@ export function registerIpcHandlers(service: AppService): void {
recipeNs,
recipeName,
defaultPath: typeof payload?.defaultPath === 'string' ? payload.defaultPath : undefined,
+ routePath: typeof payload?.routePath === 'string' ? payload.routePath : undefined,
bounds,
parentWindow,
onClosed: () => {
diff --git a/desktop-app/src/main.ts b/desktop-app/src/main.ts
index 5ce7115d0..9962464c7 100644
--- a/desktop-app/src/main.ts
+++ b/desktop-app/src/main.ts
@@ -112,6 +112,10 @@ function focusMainWindow(): void {
mainWindow.focus()
}
+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
@@ -313,6 +317,12 @@ async function createWindow(): Promise<void> {
mainWindow.maximize()
// Show window after successful load to avoid hidden-startup deadlocks.
mainWindow.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)
diff --git a/desktop-app/src/preload.ts b/desktop-app/src/preload.ts
index acb731f15..3f02e4666 100644
--- a/desktop-app/src/preload.ts
+++ b/desktop-app/src/preload.ts
@@ -406,6 +406,7 @@ const clerum = Object.freeze({
recipeNs: string
recipeName: string
defaultPath?: string
+ routePath?: string
bounds: { x: number; y: number; width: number; height: number; dpr?: number }
}) => ipcRenderer.invoke('sandboxUi:open', args),
close: () => ipcRenderer.invoke('sandboxUi:close'),
diff --git a/desktop-app/src/renderer.d.ts b/desktop-app/src/renderer.d.ts
index 323a7ebbc..c950f0975 100644
--- a/desktop-app/src/renderer.d.ts
+++ b/desktop-app/src/renderer.d.ts
@@ -530,6 +530,7 @@ declare global {
recipeNs: string
recipeName: string
defaultPath?: string
+ routePath?: string
bounds: { x: number; y: number; width: number; height: number; dpr?: number }
}) => Promise<void>
close: () => Promise<void>
diff --git a/desktop-app/src/sandboxUiDeepLinks.ts b/desktop-app/src/sandboxUiDeepLinks.ts
index a54665228..096f1510c 100644
--- a/desktop-app/src/sandboxUiDeepLinks.ts
+++ b/desktop-app/src/sandboxUiDeepLinks.ts
@@ -1,5 +1,6 @@
export const SANDBOX_UI_DEEP_LINK_HOST = 'app'
export const SANDBOX_UI_DEEP_LINK_PROTOCOL = 'evenfire:'
+export const SANDBOX_UI_WEB_LINK_PATH = '/open/apps'
const MAX_APP_SEGMENT_LENGTH = 253
const MAX_APP_ROUTE_LENGTH = 4096
@@ -77,6 +78,31 @@ export function buildSandboxUiDeepLink(parts: SandboxUiDeepLinkParts): string {
return url.toString()
}
+export function buildSandboxUiWebLink(
+ profileUiBaseUrl: string,
+ parts: SandboxUiDeepLinkParts
+): string {
+ const recipeNs = String(parts.recipeNs || '').trim()
+ const recipeName = String(parts.recipeName || '').trim()
+ const deepLink = new URL(buildSandboxUiDeepLink({ ...parts, recipeNs, recipeName }))
+ let baseUrl: URL
+ try {
+ baseUrl = new URL(profileUiBaseUrl)
+ } catch {
+ throw new Error('Cannot create a shareable link for this desktop environment')
+ }
+ if (!['http:', 'https:'].includes(baseUrl.protocol) || baseUrl.username || baseUrl.password) {
+ throw new Error('Cannot create a shareable link for this desktop environment')
+ }
+
+ const url = new URL(
+ `${SANDBOX_UI_WEB_LINK_PATH}/${encodeURIComponent(recipeNs)}/` + encodeURIComponent(recipeName),
+ baseUrl
+ )
+ url.search = deepLink.search
+ return url.toString()
+}
+
export function parseSandboxUiDeepLink(rawUrl: string): SandboxUiDeepLinkTarget | null {
let parsed: URL
try {
diff --git a/desktop-app/src/sandboxUiDriver.ts b/desktop-app/src/sandboxUiDriver.ts
index 1b1cf892c..3408aea37 100644
--- a/desktop-app/src/sandboxUiDriver.ts
+++ b/desktop-app/src/sandboxUiDriver.ts
@@ -1,7 +1,7 @@
import { BrowserWindow, WebContentsView, session } from 'electron'
import path from 'node:path'
import { getActiveEnvKey } from './config.js'
-import { extractSandboxUiViewRoute } from './sandboxUiDeepLinks.js'
+import { extractSandboxUiViewRoute, normalizeSandboxUiRoute } from './sandboxUiDeepLinks.js'
import { touchSandboxUiPartition } from './sandboxUiPartitionGc.js'
import {
applySandboxUiNavigationPolicies,
@@ -78,6 +78,7 @@ export type MountSandboxUiArgs = {
defaultPath?: string
parentWindow: BrowserWindow
bounds: SandboxUiBounds
+ routePath?: string
onClosed?: () => void
/**
* Spec §9.9 — recipe-author Connect button affordance. Fired when the
@@ -263,6 +264,7 @@ export async function mountSandboxUiView(args: MountSandboxUiArgs): Promise<void
defaultPath,
parentWindow,
bounds,
+ routePath,
onClosed,
} = args
@@ -280,7 +282,8 @@ export async function mountSandboxUiView(args: MountSandboxUiArgs): Promise<void
const partition = partitionFor(getActiveEnvKey(), recipeNs, recipeName)
const proxyOriginUrl = new URL(rpcProxyUrl).toString().replace(/\/+$/, '')
- const viewPath = defaultPath && defaultPath.startsWith('/') ? defaultPath : '/'
+ const viewPath = normalizeSandboxUiRoute(defaultPath || '/') || '/'
+ const clientRoutePath = normalizeSandboxUiRoute(routePath || '')
const allowedNavigationPrefix =
`${proxyOriginUrl}/api/v1/sandbox-ui/` +
`${encodeURIComponent(recipeNs)}/${encodeURIComponent(recipeName)}/view/`
@@ -350,7 +353,7 @@ export async function mountSandboxUiView(args: MountSandboxUiArgs): Promise<void
view,
recipeNs,
recipeName,
- initialPath: viewPath,
+ initialPath: clientRoutePath || viewPath,
partition,
parentWindow,
rpcProxyOrigin: proxyOriginUrl,
@@ -373,6 +376,17 @@ export async function mountSandboxUiView(args: MountSandboxUiArgs): Promise<void
const url =
`${proxyOriginUrl}/api/v1/sandbox-ui/` +
`${encodeURIComponent(recipeNs)}/${encodeURIComponent(recipeName)}/view${viewPath}`
+ if (clientRoutePath && clientRoutePath !== viewPath) {
+ const clientRouteUrl =
+ `${proxyOriginUrl}/api/v1/sandbox-ui/` +
+ `${encodeURIComponent(recipeNs)}/${encodeURIComponent(recipeName)}/view${clientRoutePath}`
+ view.webContents.once('did-finish-load', () => {
+ if (!active || active.view !== view || view.webContents.isDestroyed()) return
+ void applySandboxUiClientRoute(view.webContents, clientRouteUrl).catch(err => {
+ console.warn('[SandboxUI] client route handoff failed:', err)
+ })
+ })
+ }
// Drop the HTTP cache on every open so a stale entry from a prior
// broken pod can't keep painting after the recipe is healthy. The
// partition is persistent (cookies, IndexedDB, localStorage all
@@ -392,6 +406,30 @@ export async function mountSandboxUiView(args: MountSandboxUiArgs): Promise<void
void view.webContents.loadURL(url)
}
+export async function applySandboxUiClientRoute(
+ webContents: Pick<WebContentsView['webContents'], 'executeJavaScript' | 'isDestroyed'>,
+ targetUrl: string
+): Promise<boolean> {
+ if (webContents.isDestroyed()) return false
+ const serializedTarget = JSON.stringify(targetUrl)
+ return Boolean(
+ await webContents.executeJavaScript(`(() => {
+ const targetUrl = ${serializedTarget};
+ const previousUrl = window.location.href;
+ if (previousUrl === targetUrl) return true;
+ window.history.replaceState(window.history.state, '', targetUrl);
+ window.dispatchEvent(new PopStateEvent('popstate', { state: window.history.state }));
+ if (new URL(previousUrl).hash !== new URL(targetUrl).hash) {
+ window.dispatchEvent(new HashChangeEvent('hashchange', {
+ oldURL: previousUrl,
+ newURL: targetUrl,
+ }));
+ }
+ return window.location.href === targetUrl;
+ })()`)
+ )
+}
+
/**
* Unmount the active view (no-op if nothing is mounted). Called on user
* "Close" / navigate-away. Leaves the per-recipe partition intact so a
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsx
index 8e74fd452..44e00ae38 100644
--- a/desktop-app/ui/src/App.tsx
+++ b/desktop-app/ui/src/App.tsx
@@ -374,7 +374,7 @@ export function App() {
launchSandboxUiApp(
{
...app,
- defaultPath: pending.link.path,
+ routePath: pending.link.path,
},
pending.conversationOrigin
)
diff --git a/desktop-app/ui/src/pages/SandboxUiPage.tsx b/desktop-app/ui/src/pages/SandboxUiPage.tsx
index 8868b21eb..172573fc8 100644
--- a/desktop-app/ui/src/pages/SandboxUiPage.tsx
+++ b/desktop-app/ui/src/pages/SandboxUiPage.tsx
@@ -239,6 +239,7 @@ export function SandboxUiPage({
label: string
icon?: string
defaultPath: string
+ routePath?: string
ready?: boolean
}) => {
if (app.ready === false) return
@@ -266,6 +267,7 @@ export function SandboxUiPage({
recipeNs,
recipeName,
defaultPath: app.defaultPath,
+ ...(app.routePath ? { routePath: app.routePath } : {}),
bounds,
})
setLaunch({ kind: 'mounted', appRef: app.appRef })
@@ -293,6 +295,7 @@ export function SandboxUiPage({
label: appLabel(app),
icon: app.icon,
defaultPath: app.defaultPath,
+ routePath: app.routePath,
ready: app.ready,
})
},
diff --git a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
index 509034a4d..5dfa52d49 100644
--- a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
@@ -152,6 +152,39 @@ describe('SandboxUiPage', () => {
expect(screen.getAllByRole('button', { name: /^Back to / })).toHaveLength(1)
})
+ it('opens a deep-linked app at its stable entry point before handing off the client route', async () => {
+ sandboxUi.listApps.mockResolvedValueOnce({ apps: [] })
+ sandboxUi.open.mockResolvedValueOnce(undefined)
+
+ render(
+ <SandboxUiPage
+ shortcutApp={{
+ appRef: 'sandbox-recipes/task-board',
+ label: 'Agentic Task Board',
+ defaultPath: '/',
+ routePath: '/tasks/task-42?panel=details',
+ }}
+ shortcutOpenRequestId={1}
+ />
+ )
+
+ await waitFor(() => {
+ expect(sandboxUi.open).toHaveBeenCalledWith({
+ recipeNs: 'sandbox-recipes',
+ recipeName: 'task-board',
+ defaultPath: '/',
+ routePath: '/tasks/task-42?panel=details',
+ bounds: {
+ x: 16,
+ y: 12,
+ width: 400,
+ height: 300,
+ dpr: expect.any(Number),
+ },
+ })
+ })
+ })
+
it('returns to the originating conversation from an app', async () => {
sandboxUi.listApps.mockResolvedValueOnce({
apps: [
diff --git a/desktop-app/ui/src/uiTypes.ts b/desktop-app/ui/src/uiTypes.ts
index 0139d11b1..4559acf64 100644
--- a/desktop-app/ui/src/uiTypes.ts
+++ b/desktop-app/ui/src/uiTypes.ts
@@ -15,6 +15,7 @@ export type ActiveSandboxUiApp = {
label: string
icon?: string
defaultPath: string
+ routePath?: string
}
export type Tone = 'info' | 'success' | 'error' | 'warn'
export type ThemeMode = 'dark' | 'light'
diff --git a/profile-ui/app/constants/routes.ts b/profile-ui/app/constants/routes.ts
index 5f5eb9dca..e65874d77 100644
--- a/profile-ui/app/constants/routes.ts
+++ b/profile-ui/app/constants/routes.ts
@@ -25,6 +25,8 @@ export const PROFILE_ROUTES = {
desktopSetup: '/desktop-setup',
forgotPassword: (query?: ProfileRouteQuery) => withQuery('/forgot-password', query),
invitation: (token: string) => `/invitations/${segment(token)}`,
+ openDesktopApp: (recipeNs: string, recipeName: string, query?: ProfileRouteQuery) =>
+ withQuery(`/open/apps/${segment(recipeNs)}/${segment(recipeName)}`, query),
members: {
root: '/members',
invite: '/members/invite',
diff --git a/profile-ui/app/open/apps/[recipeNs]/[recipeName]/page.tsx b/profile-ui/app/open/apps/[recipeNs]/[recipeName]/page.tsx
new file mode 100644
index 000000000..8d8168679
--- /dev/null
+++ b/profile-ui/app/open/apps/[recipeNs]/[recipeName]/page.tsx
@@ -0,0 +1,76 @@
+'use client'
+
+import { Suspense, useEffect, useMemo, useRef } from 'react'
+import { useParams, useSearchParams } from 'next/navigation'
+import { Button } from '@components/Button'
+import { buildEvenfireDesktopAppLink } from '@lib/desktopAppLinks'
+
+function OpenDesktopAppContent() {
+ const params = useParams<{ recipeNs: string; recipeName: string }>()
+ const searchParams = useSearchParams()
+ const attemptedOpenRef = useRef(false)
+ const deepLink = useMemo(
+ () =>
+ buildEvenfireDesktopAppLink({
+ recipeNs: params.recipeNs,
+ recipeName: params.recipeName,
+ path: searchParams.get('path') || '/',
+ teamId: searchParams.get('team') || undefined,
+ }),
+ [params.recipeName, params.recipeNs, searchParams]
+ )
+
+ useEffect(() => {
+ if (!deepLink || attemptedOpenRef.current) return
+ attemptedOpenRef.current = true
+ window.location.href = deepLink
+ }, [deepLink])
+
+ return (
+ <main className="center-page">
+ <section className="page-card">
+ <div className="stack-tight">
+ <p className="eyebrow">Evenfire Desktop</p>
+ <h1 className="page-title page-title--large">Open {params.recipeName}</h1>
+ <p className="body-copy">
+ {deepLink
+ ? 'Evenfire should open this app automatically. Use the button if your browser asks for confirmation.'
+ : 'This app link is invalid or incomplete.'}
+ </p>
+ </div>
+
+ <Button
+ disabled={!deepLink}
+ onClick={() => {
+ if (deepLink) window.location.href = deepLink
+ }}
+ >
+ Open in Evenfire
+ </Button>
+
+ {deepLink ? (
+ <p className="body-copy">
+ If nothing happens, make sure the Evenfire desktop app is installed and try again.
+ </p>
+ ) : null}
+ </section>
+ </main>
+ )
+}
+
+export default function OpenDesktopAppPage() {
+ return (
+ <Suspense
+ fallback={
+ <main className="center-page">
+ <section className="page-card">
+ <h1 className="page-title page-title--large">Open in Evenfire</h1>
+ <p className="body-copy">Preparing the desktop app link...</p>
+ </section>
+ </main>
+ }
+ >
+ <OpenDesktopAppContent />
+ </Suspense>
+ )
+}
diff --git a/profile-ui/lib/desktopAppLinks.ts b/profile-ui/lib/desktopAppLinks.ts
new file mode 100644
index 000000000..3169e33a0
--- /dev/null
+++ b/profile-ui/lib/desktopAppLinks.ts
@@ -0,0 +1,40 @@
+const APP_SEGMENT_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/
+const TEAM_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]*$/
+const MAX_APP_SEGMENT_LENGTH = 253
+const MAX_APP_ROUTE_LENGTH = 4096
+const MAX_TEAM_ID_LENGTH = 255
+
+export function buildEvenfireDesktopAppLink(parts: {
+ recipeNs: string
+ recipeName: string
+ path: string
+ teamId?: string
+}): string | null {
+ const recipeNs = String(parts.recipeNs || '').trim()
+ const recipeName = String(parts.recipeName || '').trim()
+ const path = String(parts.path || '').trim()
+ const teamId = String(parts.teamId || '').trim()
+ const validSegment = (value: string) =>
+ value.length > 0 && value.length <= MAX_APP_SEGMENT_LENGTH && APP_SEGMENT_PATTERN.test(value)
+
+ if (
+ !validSegment(recipeNs) ||
+ !validSegment(recipeName) ||
+ !path ||
+ path.length > MAX_APP_ROUTE_LENGTH ||
+ !path.startsWith('/') ||
+ path.startsWith('//') ||
+ path.includes('\\') ||
+ /[\u0000-\u001f\u007f]/.test(path) ||
+ (teamId && (teamId.length > MAX_TEAM_ID_LENGTH || !TEAM_ID_PATTERN.test(teamId)))
+ ) {
+ return null
+ }
+
+ const url = new URL(
+ `evenfire://app/${encodeURIComponent(recipeNs)}/${encodeURIComponent(recipeName)}`
+ )
+ url.searchParams.set('path', path)
+ if (teamId) url.searchParams.set('team', teamId)
+ return url.toString()
+}
diff --git a/profile-ui/package-lock.json b/profile-ui/package-lock.json
index cf7a9429a..af0f44bc8 100644
--- a/profile-ui/package-lock.json
+++ b/profile-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.101",
+ "version": "0.1.102",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-profile-ui",
- "version": "0.1.101",
+ "version": "0.1.102",
"dependencies": {
"next": "16.2.6",
"react": "^18.3.1",
diff --git a/profile-ui/package.json b/profile-ui/package.json
index 8b58d506a..d9f0a014e 100644
--- a/profile-ui/package.json
+++ b/profile-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.101",
+ "version": "0.1.102",
"private": true,
"scripts": {
"dev": "next dev",
diff --git a/profile-ui/test/desktopAppLinks.test.ts b/profile-ui/test/desktopAppLinks.test.ts
new file mode 100644
index 000000000..3f9c809f9
--- /dev/null
+++ b/profile-ui/test/desktopAppLinks.test.ts
@@ -0,0 +1,27 @@
+import assert from 'node:assert/strict'
+import test from 'node:test'
+import { buildEvenfireDesktopAppLink } from '../lib/desktopAppLinks'
+
+test('buildEvenfireDesktopAppLink preserves a nested app route and team', () => {
+ assert.equal(
+ buildEvenfireDesktopAppLink({
+ recipeNs: 'sandbox-recipes',
+ recipeName: 'agentic-task-board',
+ path: '/tasks/task-42?view=detail#activity',
+ teamId: 'team-123',
+ }),
+ 'evenfire://app/sandbox-recipes/agentic-task-board' +
+ '?path=%2Ftasks%2Ftask-42%3Fview%3Ddetail%23activity&team=team-123'
+ )
+})
+
+test('buildEvenfireDesktopAppLink rejects unsafe routes', () => {
+ assert.equal(
+ buildEvenfireDesktopAppLink({
+ recipeNs: 'sandbox-recipes',
+ recipeName: 'agentic-task-board',
+ path: '//outside.example',
+ }),
+ null
+ )
+})