Skip to content

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

TypeScript

refactor: read active profile identity without rebuilding RPC diagnostics

Josué5c99bdcebb12
diff --git a/desktop-app/src/__tests__/appService.cancelTask.test.ts b/desktop-app/src/__tests__/appService.cancelTask.test.ts
index a54f3850b..ab9cdcf82 100644
--- a/desktop-app/src/__tests__/appService.cancelTask.test.ts
+++ b/desktop-app/src/__tests__/appService.cancelTask.test.ts
@@ -6,6 +6,7 @@ import { AppService } from '../appService.js'
// ── mock dependencies before AppService is imported ──────────────────────────
vi.mock('../config.js', () => ({
+ getActiveRuntimeConfigOptionId: () => null,
config: {
rpcProxyBaseUrl: 'http://proxy',
externalRestApiBaseUrl: 'http://rest',
diff --git a/desktop-app/src/__tests__/appService.hostWaking.test.ts b/desktop-app/src/__tests__/appService.hostWaking.test.ts
index 056f6b79c..46cb5bcf3 100644
--- a/desktop-app/src/__tests__/appService.hostWaking.test.ts
+++ b/desktop-app/src/__tests__/appService.hostWaking.test.ts
@@ -7,6 +7,7 @@ import { ApiError } from '../httpClient.js'
// ── mock dependencies before AppService is imported ──────────────────────────
vi.mock('../config.js', () => ({
+ getActiveRuntimeConfigOptionId: () => null,
config: {
rpcProxyBaseUrl: 'http://proxy',
externalRestApiBaseUrl: 'http://rest',
diff --git a/desktop-app/src/__tests__/appService.mcpConnectorDisconnect.test.ts b/desktop-app/src/__tests__/appService.mcpConnectorDisconnect.test.ts
index 7070a1413..241725abf 100644
--- a/desktop-app/src/__tests__/appService.mcpConnectorDisconnect.test.ts
+++ b/desktop-app/src/__tests__/appService.mcpConnectorDisconnect.test.ts
@@ -41,6 +41,7 @@ vi.mock('electron', () => ({
}))
vi.mock('../config.js', () => ({
+ getActiveRuntimeConfigOptionId: () => null,
config: {
rpcProxyBaseUrl: 'http://proxy',
externalRestApiBaseUrl: 'http://rest',
diff --git a/desktop-app/src/__tests__/appService.prewarm.test.ts b/desktop-app/src/__tests__/appService.prewarm.test.ts
index a8cbeef79..b3787bbd5 100644
--- a/desktop-app/src/__tests__/appService.prewarm.test.ts
+++ b/desktop-app/src/__tests__/appService.prewarm.test.ts
@@ -7,6 +7,7 @@ import { ApiError } from '../httpClient.js'
// ── mock dependencies before AppService is imported ──────────────────────────
vi.mock('../config.js', () => ({
+ getActiveRuntimeConfigOptionId: () => 'test-profile',
getActiveEnvKey: () => 'test-env',
getActiveLegacyEnvKeys: () => [],
getDesktopRuntimeConfigState: () => ({ activeOptionId: 'test-profile' }),
diff --git a/desktop-app/src/__tests__/appService.sandboxUiApps.test.ts b/desktop-app/src/__tests__/appService.sandboxUiApps.test.ts
index d08cc61f3..22da5eddf 100644
--- a/desktop-app/src/__tests__/appService.sandboxUiApps.test.ts
+++ b/desktop-app/src/__tests__/appService.sandboxUiApps.test.ts
@@ -49,6 +49,7 @@ vi.mock('../sandboxUiSessionRefresh.js', () => ({
}))
vi.mock('../config.js', () => ({
+ getActiveRuntimeConfigOptionId: () => null,
getActiveEnvKey: () => 'test-env',
config: {
rpcProxyBaseUrl: 'http://proxy',
diff --git a/desktop-app/src/__tests__/appService.sandboxUiLifecycle.test.ts b/desktop-app/src/__tests__/appService.sandboxUiLifecycle.test.ts
index d17d665c7..d5ee099a9 100644
--- a/desktop-app/src/__tests__/appService.sandboxUiLifecycle.test.ts
+++ b/desktop-app/src/__tests__/appService.sandboxUiLifecycle.test.ts
@@ -139,6 +139,7 @@ vi.mock('../config.js', async importOriginal => {
}
return {
validateRpcProxyBaseUrl,
+ getActiveRuntimeConfigOptionId: () => null,
getActiveEnvKey: () => 'test-env',
getActiveLegacyEnvKeys: () => [],
hydrateDesktopRuntimeConfig: () => undefined,
diff --git a/desktop-app/src/__tests__/appService.sandboxUiOauthConsent.test.ts b/desktop-app/src/__tests__/appService.sandboxUiOauthConsent.test.ts
index f3cb875d9..bb7c684c9 100644
--- a/desktop-app/src/__tests__/appService.sandboxUiOauthConsent.test.ts
+++ b/desktop-app/src/__tests__/appService.sandboxUiOauthConsent.test.ts
@@ -38,6 +38,7 @@ vi.mock('electron', () => ({
}))
vi.mock('../config.js', () => ({
+ getActiveRuntimeConfigOptionId: () => null,
config: {
rpcProxyBaseUrl: 'http://proxy',
externalRestApiBaseUrl: 'http://rest',
diff --git a/desktop-app/src/__tests__/appService.sandboxUiRpcTokenRetry.test.ts b/desktop-app/src/__tests__/appService.sandboxUiRpcTokenRetry.test.ts
index 7129f0264..c60be789e 100644
--- a/desktop-app/src/__tests__/appService.sandboxUiRpcTokenRetry.test.ts
+++ b/desktop-app/src/__tests__/appService.sandboxUiRpcTokenRetry.test.ts
@@ -24,6 +24,7 @@ vi.mock('electron', () => ({
}))
vi.mock('../config.js', () => ({
+ getActiveRuntimeConfigOptionId: () => null,
getActiveEnvKey: () => 'test-env',
config: {
rpcProxyBaseUrl: 'https://rpc.example',
diff --git a/desktop-app/src/appService.ts b/desktop-app/src/appService.ts
index d4bf82b60..3a8c5c14b 100644
--- a/desktop-app/src/appService.ts
+++ b/desktop-app/src/appService.ts
@@ -9,6 +9,7 @@ import {
deleteDesktopRuntimeConfigOption,
getActiveEnvKey,
getActiveLegacyEnvKeys,
+ getActiveRuntimeConfigOptionId,
getDesktopRuntimeConfigState,
hydrateDesktopRuntimeConfig,
isDesktopRuntimeConfigured,
@@ -1103,10 +1104,9 @@ export class AppService {
profileId: string | null
restBaseUrl: string
} {
- const runtimeConfig = getDesktopRuntimeConfigState()
return {
environmentKey: getActiveEnvKey(),
- profileId: runtimeConfig.activeOptionId,
+ profileId: getActiveRuntimeConfigOptionId(),
restBaseUrl: canonicalizeDesktopRestEndpoint(config.externalRestApiBaseUrl),
}
}
diff --git a/desktop-app/src/config.ts b/desktop-app/src/config.ts
index 68f1267bd..e5c0f235f 100644
--- a/desktop-app/src/config.ts
+++ b/desktop-app/src/config.ts
@@ -838,6 +838,12 @@ export function resolveEnvKey(externalRestApiBaseUrl: string, rpcProxyBaseUrl =
return `${slug || 'env'}-${hash}`
}
+/** Hydrated active profile identity without constructing the diagnostics projection. */
+export function getActiveRuntimeConfigOptionId(): string | null {
+ hydrateDesktopRuntimeConfig()
+ return activeRuntimeOptionId
+}
+
/** Env key for the CURRENTLY active runtime config (main-process surfaces). */
export function getActiveEnvKey(): string {
hydrateDesktopRuntimeConfig()