Skip to content

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

TypeScript

refactor(profile-ui): share desktop environment link builder r1-m1

Josuéf67a0de69b34
diff --git a/profile-ui/app/page.tsx b/profile-ui/app/page.tsx
index 8f9172cdc..54f0df6af 100644
--- a/profile-ui/app/page.tsx
+++ b/profile-ui/app/page.tsx
@@ -5,16 +5,7 @@ import { useAuth } from '@components/AuthContext'
import { AuthGate } from '@components/AuthGate'
import { IconExternalLink } from '@components/icons'
import { getDesktopEnvironment } from '@lib/api'
-import type { DesktopEnvironmentResponse } from '@/app/types/api'
-
-function getDesktopAppHref(environment: DesktopEnvironmentResponse): string | null {
- if (!environment.externalRestApiBaseUrl) return null
- const params = new URLSearchParams({
- externalRestApiBaseUrl: environment.externalRestApiBaseUrl,
- tenantName: environment.appName || 'Evenfire',
- })
- return `evenfire://desktop-environment?${params.toString()}`
-}
+import { buildDesktopEnvironmentLink } from '@lib/desktopAppLinks'
function HomeContent() {
const { authState } = useAuth()
@@ -26,7 +17,7 @@ function HomeContent() {
let isCurrent = true
void getDesktopEnvironment()
.then(environment => {
- if (isCurrent) setDesktopAppHref(getDesktopAppHref(environment))
+ if (isCurrent) setDesktopAppHref(buildDesktopEnvironmentLink(environment))
})
.catch(() => {
if (isCurrent) setDesktopAppHref(null)
diff --git a/profile-ui/app/settings/SettingsContent.tsx b/profile-ui/app/settings/SettingsContent.tsx
index c5ca67275..b5efd86a3 100644
--- a/profile-ui/app/settings/SettingsContent.tsx
+++ b/profile-ui/app/settings/SettingsContent.tsx
@@ -28,6 +28,7 @@ import {
disconnectWorkflowApprovalMedium,
listWorkflowApprovalMediums,
} from '@lib/approvalChannels'
+import { buildDesktopEnvironmentLink } from '@lib/desktopAppLinks'
import {
EMPTY_PROFILE_CHANNELS,
addDraftRow,
@@ -333,11 +334,9 @@ export function SettingsContent({
}
function openDesktopAppSetup() {
- if (!desktopEnvironment?.externalRestApiBaseUrl) return
- const params = new URLSearchParams()
- params.set('externalRestApiBaseUrl', desktopEnvironment.externalRestApiBaseUrl)
- params.set('tenantName', desktopEnvironment.appName || 'Evenfire')
- window.location.href = `evenfire://desktop-environment?${params.toString()}`
+ const desktopEnvironmentLink = buildDesktopEnvironmentLink(desktopEnvironment)
+ if (!desktopEnvironmentLink) return
+ window.location.href = desktopEnvironmentLink
}
return (
diff --git a/profile-ui/lib/desktopAppLinks.ts b/profile-ui/lib/desktopAppLinks.ts
index cf5424740..09ca29d8a 100644
--- a/profile-ui/lib/desktopAppLinks.ts
+++ b/profile-ui/lib/desktopAppLinks.ts
@@ -3,9 +3,21 @@ import {
SANDBOX_UI_DEEP_LINK_PROTOCOL,
buildSandboxUiDeepLink,
} from '@clerum/desktop-app-links'
+import type { DesktopEnvironmentResponse } from '@/app/types/api'
const SCRIPT_NONCE_PATTERN = /^[A-Za-z0-9+/_-]+={0,2}$/
+export function buildDesktopEnvironmentLink(
+ environment: DesktopEnvironmentResponse | null | undefined
+): string | null {
+ if (!environment?.externalRestApiBaseUrl) return null
+ const params = new URLSearchParams({
+ externalRestApiBaseUrl: environment.externalRestApiBaseUrl,
+ tenantName: environment.appName || 'Evenfire',
+ })
+ return `evenfire://desktop-environment?${params.toString()}`
+}
+
export function buildEvenfireDesktopAppLink(parts: {
recipeNs: string
recipeName: string
diff --git a/profile-ui/package-lock.json b/profile-ui/package-lock.json
index 07a1caded..153e62e06 100644
--- a/profile-ui/package-lock.json
+++ b/profile-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.144",
+ "version": "0.1.145",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-profile-ui",
- "version": "0.1.144",
+ "version": "0.1.145",
"dependencies": {
"@clerum/desktop-app-links": "file:../packages/desktop-app-links",
"@clerum/frontend-components": "file:../packages/frontend-components",
diff --git a/profile-ui/package.json b/profile-ui/package.json
index 02f14aceb..46c7353c5 100644
--- a/profile-ui/package.json
+++ b/profile-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.144",
+ "version": "0.1.145",
"private": true,
"scripts": {
"dev": "next dev",