Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): r7-m20 honor configured api base for stream
Josué9cdbdc6cae73
diff --git a/control-ui/components/GfsBrowser.tsx b/control-ui/components/GfsBrowser.tsxindex 72f23acf1..ca5ed2a68 100644--- a/control-ui/components/GfsBrowser.tsx+++ b/control-ui/components/GfsBrowser.tsx@@ -42,7 +42,7 @@ import {isSilentApiError,} from '@lib/api'import { createCoalescedRevalidation } from '@lib/coalescedRevalidation'-import { parseEntityChangeFrame } from '@lib/entityChangeStream'+import { entityChangeStreamUrl, parseEntityChangeFrame } from '@lib/entityChangeStream'import { isGfsDocumentFile } from '@lib/gfsDocumentFile'import {GfsUploadCapabilityError,@@ -1025,8 +1025,7 @@ export function GfsBrowser(): React.JSX.Element {while (active && !controller.signal.aborted) {try {const cursor = streamCursorRef.current- const query = cursor ? `?cursor=${encodeURIComponent(cursor)}` : ''- const response = await fetch(`/control-api/api/v1/gfs/entity-changes/stream${query}`, {+ const response = await fetch(entityChangeStreamUrl(cursor), {cache: 'no-store',credentials: 'include',headers: { accept: 'application/x-ndjson' },diff --git a/control-ui/lib/__tests__/controlApiUrl.test.ts b/control-ui/lib/__tests__/controlApiUrl.test.tsnew file mode 100644index 000000000..b0ea96c26--- /dev/null+++ b/control-ui/lib/__tests__/controlApiUrl.test.ts@@ -0,0 +1,18 @@+import { afterEach, describe, expect, it, vi } from 'vitest'++describe('controlApiUrl', () => {+ afterEach(() => {+ vi.unstubAllEnvs()+ vi.resetModules()+ })++ it('uses the configured Control API base URL for fetch-based streams', async () => {+ vi.stubEnv('NEXT_PUBLIC_CONTROL_API_BASE_URL', 'https://control.example.test/control-api')+ vi.resetModules()+ const { entityChangeStreamUrl } = await import('../entityChangeStream')++ expect(entityChangeStreamUrl('cursor 1')).toBe(+ 'https://control.example.test/control-api/api/v1/gfs/entity-changes/stream?cursor=cursor%201'+ )+ })+})diff --git a/control-ui/lib/api.ts b/control-ui/lib/api.tsindex 5484f0b77..8a7b1f238 100644--- a/control-ui/lib/api.ts+++ b/control-ui/lib/api.ts@@ -144,6 +144,11 @@ function authHeaders(): HeadersInit {return {}}+/** Build a Control API URL using the same configured base as API requests. */+export function controlApiUrl(path: string): string {+ return `${API_BASE}${path}`+}+async function parseJsonResponse(res: Response): Promise<unknown> {const text = await res.text()if (!text.trim()) return undefined@@ -280,7 +285,7 @@ export async function apiGet(query: Record<string, string | undefined> = {},options: ApiRequestOptions = {}) {- const url = `${API_BASE}${path}${qs(query)}`+ const url = `${controlApiUrl(path)}${qs(query)}`const headers = { ...authHeaders() }const cacheKey = `${url}|${sessionEpoch}`const existing = options.signal ? undefined : inFlightGetRequests.get(cacheKey)diff --git a/control-ui/lib/entityChangeStream.ts b/control-ui/lib/entityChangeStream.tsindex ea6abf49e..6ef39ca4c 100644--- a/control-ui/lib/entityChangeStream.ts+++ b/control-ui/lib/entityChangeStream.ts@@ -1,3 +1,5 @@+import { controlApiUrl } from './api'+export const ENTITY_CHANGE_CURSOR_RE =/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i@@ -10,6 +12,11 @@ export type EntityChangeFrame = {reason?: 'max_lifetime' | 'session_expired' | 'server_shutdown' | 'slow_consumer'}+export function entityChangeStreamUrl(cursor?: string): string {+ const query = cursor ? `?cursor=${encodeURIComponent(cursor)}` : ''+ return controlApiUrl(`/api/v1/gfs/entity-changes/stream${query}`)+}+/** Parse one NDJSON frame. Unknown versions/types fail safe into full invalidation. */export function parseEntityChangeFrame(line: string): EntityChangeFrame | null {if (!line.trim()) return nulldiff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex f7d39b925..ada1b4d7b 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.674",+ "version": "0.1.675","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.674",+ "version": "0.1.675","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/frontend-components": "file:../packages/frontend-components",diff --git a/control-ui/package.json b/control-ui/package.jsonindex 62048b43c..77b9f9306 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.674",+ "version": "0.1.675","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",