Skip to content

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

TypeScript

fix(control-ui): r9-h1 keep drive-root refresh on one location

Josuéd50575c77582
diff --git a/control-ui/components/GfsBrowser.tsx b/control-ui/components/GfsBrowser.tsx
index e624195f7..903c40554 100644
--- a/control-ui/components/GfsBrowser.tsx
+++ b/control-ui/components/GfsBrowser.tsx
@@ -129,7 +129,9 @@ type ResolvedPreviewUpdate =
| Extract<OpenPreviewState, { kind: 'video' }>
interface Crumb {
- /** null = the synthetic drive root (listed via /gfs/tree). */
+ /** True when this is the stable drive-root location, independent of its resource ID. */
+ isDriveRoot?: boolean
+ /** Null only until /gfs/tree resolves the drive root's resource ID. */
id: string | null
rid: string | null
name: string
@@ -140,6 +142,21 @@ interface Crumb {
version?: number
}
+function isDriveRootCrumb(crumb: Crumb | undefined): boolean {
+ return crumb?.isDriveRoot === true || crumb?.id === null
+}
+
+function sameCrumbLocation(left: Crumb | undefined, right: Crumb): boolean {
+ if (isDriveRootCrumb(left) || isDriveRootCrumb(right)) {
+ return isDriveRootCrumb(left) && isDriveRootCrumb(right)
+ }
+ return left?.id === right.id
+}
+
+function createDriveRootCrumb(): Crumb {
+ return { id: null, rid: null, name: '/', isDriveRoot: true }
+}
+
interface GfsResolvedLocation {
resourceId: string
rid: string
@@ -175,6 +192,7 @@ function sameCrumbTrail(left: Crumb[], right: Crumb[]): boolean {
const other = right[index]
return (
crumb.id === other?.id &&
+ isDriveRootCrumb(crumb) === isDriveRootCrumb(other) &&
crumb.rid === other.rid &&
crumb.gfsUri === other.gfsUri &&
crumb.name === other.name &&
@@ -338,7 +356,7 @@ function entityChangeErrorStatus(error: unknown): number | undefined {
export function GfsBrowser(): React.JSX.Element {
const { showToast } = useToast()
- const [crumbs, setCrumbs] = useState<Crumb[]>([{ id: null, rid: null, name: '/' }])
+ const [crumbs, setCrumbs] = useState<Crumb[]>([createDriveRootCrumb()])
const [items, setItems] = useState<GfsChild[]>([])
const [nextCursor, setNextCursor] = useState<string | null>(null)
const [loading, setLoading] = useState(true)
@@ -499,7 +517,7 @@ export function GfsBrowser(): React.JSX.Element {
const isCurrent = () =>
!options?.signal?.aborted &&
loadArbiter.isCurrent(loadToken) &&
- currentCrumbRef.current?.id === crumb.id
+ sameCrumbLocation(currentCrumbRef.current, crumb)
if (!background && !cursor) loadedPageCountRef.current = 1
if (appending) {
setLoadingMore(true)
@@ -510,10 +528,9 @@ export function GfsBrowser(): React.JSX.Element {
}
if (!background) setError('')
try {
- const path =
- crumb.id === null
- ? '/api/v1/gfs/tree'
- : `/api/v1/gfs/resources/${encodeURIComponent(crumb.id)}/children`
+ const path = isDriveRootCrumb(crumb)
+ ? '/api/v1/gfs/tree'
+ : `/api/v1/gfs/resources/${encodeURIComponent(crumb.id!)}/children`
const query: Record<string, string> = { drive: DRIVE }
if (cursor) query.cursor = cursor
const fetchPage = (pageQuery: Record<string, string>) =>
@@ -535,19 +552,14 @@ export function GfsBrowser(): React.JSX.Element {
}
}
if (!isCurrent()) return
- if (crumb.id === null && page.rootResourceId) {
- setCrumbs(prev =>
- prev[0]?.id === null
- ? [
- {
- ...prev[0],
- id: page.rootResourceId,
- rid: ridOfResourceId(page.rootResourceId),
- },
- ...prev.slice(1),
- ]
- : prev
- )
+ if (isDriveRootCrumb(crumb) && page.rootResourceId) {
+ const rootRid = ridOfResourceId(page.rootResourceId)
+ setCrumbs(prev => {
+ const root = prev[0]
+ if (!isDriveRootCrumb(root)) return prev
+ if (root.id === page.rootResourceId && root.rid === rootRid) return prev
+ return [{ ...root, id: page.rootResourceId, rid: rootRid }, ...prev.slice(1)]
+ })
}
const sortedItems = sortChildrenWithDirectoriesFirst(allItems)
setItems(prev => (cursor ? [...prev, ...sortedItems] : sortedItems))
@@ -677,21 +689,23 @@ export function GfsBrowser(): React.JSX.Element {
}
}, [items])
+ const currentLocationKey = isDriveRootCrumb(current) ? '$root' : (current.id ?? '$root')
useEffect(() => {
- const locationKey = current.id ?? '$root'
- const sameLocation = loadedLocationRef.current === locationKey
- loadedLocationRef.current = locationKey
+ const locationCrumb = currentCrumbRef.current
+ if (!locationCrumb) return
+ const sameLocation = loadedLocationRef.current === currentLocationKey
+ loadedLocationRef.current = currentLocationKey
if (!sameLocation) setLoadingMore(false)
if (revalidateNextLoadRef.current) {
revalidateNextLoadRef.current = false
// Stale-while-revalidate: cached rows stay on screen (no spinner) while
// the server state re-syncs; divergence overwrites the rows in place.
- void load(current, undefined, { background: true })
+ void load(locationCrumb, undefined, { background: true })
return
}
- void load(current, undefined, sameLocation ? { background: true } : undefined)
+ void load(locationCrumb, undefined, sameLocation ? { background: true } : undefined)
// Reload whenever the current folder changes (navigation).
- }, [current, load])
+ }, [currentLocationKey, load])
// Navigating away from the moved folder retires the recovery notice: the
// stale trail it labels is no longer on screen.
@@ -766,10 +780,9 @@ export function GfsBrowser(): React.JSX.Element {
}
const refreshVisibleDirectory = async (crumb: Crumb, signal: AbortSignal): Promise<void> => {
- const path =
- crumb.id === null
- ? '/api/v1/gfs/tree'
- : `/api/v1/gfs/resources/${encodeURIComponent(crumb.id)}/children`
+ const path = isDriveRootCrumb(crumb)
+ ? '/api/v1/gfs/tree'
+ : `/api/v1/gfs/resources/${encodeURIComponent(crumb.id!)}/children`
const targetPageCount = Math.max(1, loadedPageCountRef.current)
try {
let page = (await apiGet(path, { drive: DRIVE }, { signal })) as TreePage
@@ -788,20 +801,15 @@ export function GfsBrowser(): React.JSX.Element {
fetchedPageCount += 1
if (signal.aborted) return
}
- if (signal.aborted || currentCrumbRef.current?.id !== crumb.id) return
- if (crumb.id === null && rootResourceId) {
- setCrumbs(previous =>
- previous[0]?.id === null
- ? [
- {
- ...previous[0],
- id: rootResourceId,
- rid: ridOfResourceId(rootResourceId),
- },
- ...previous.slice(1),
- ]
- : previous
- )
+ if (signal.aborted || !sameCrumbLocation(currentCrumbRef.current, crumb)) return
+ if (isDriveRootCrumb(crumb) && rootResourceId) {
+ const rootRid = ridOfResourceId(rootResourceId)
+ setCrumbs(previous => {
+ const root = previous[0]
+ if (!isDriveRootCrumb(root)) return previous
+ if (root.id === rootResourceId && root.rid === rootRid) return previous
+ return [{ ...root, id: rootResourceId, rid: rootRid }, ...previous.slice(1)]
+ })
}
setItems(sortChildrenWithDirectoriesFirst(refreshedItems))
setNextCursor(nextPageCursor)
@@ -815,7 +823,7 @@ export function GfsBrowser(): React.JSX.Element {
}
setError('')
} catch (error) {
- if (signal.aborted || currentCrumbRef.current?.id !== crumb.id) return
+ if (signal.aborted || !sameCrumbLocation(currentCrumbRef.current, crumb)) return
if (!isSilentApiError(error)) {
setError(error instanceof Error ? error.message : 'Failed to refresh EvenDrive')
}
@@ -1007,7 +1015,7 @@ export function GfsBrowser(): React.JSX.Element {
// Stream-triggered reads have their own non-destructive path. They never
// enter the navigation/paging loader or clear its rows, dialogs, or error.
revalidationTasks.push(refreshVisibleDirectory(visibleCrumb, signal))
- if (visibleCrumb.id === null) {
+ if (isDriveRootCrumb(visibleCrumb)) {
await Promise.all(revalidationTasks)
return
}
@@ -1016,7 +1024,11 @@ export function GfsBrowser(): React.JSX.Element {
const generation = ++hierarchyRefreshGenerationRef.current
const trailEpoch = trailReconstructionEpochRef.current
const hierarchyRefresh = (async () => {
- const rootCrumb = { ...(crumbsRef.current[0] ?? { id: null, rid: null, name: '/' }) }
+ const rootCrumb = {
+ ...(isDriveRootCrumb(crumbsRef.current[0])
+ ? crumbsRef.current[0]!
+ : createDriveRootCrumb()),
+ }
const hierarchy = await resolveGfsHierarchy({
readCurrent: () =>
apiGet(
@@ -1501,7 +1513,7 @@ export function GfsBrowser(): React.JSX.Element {
// clobber the trail they navigated to.
if (index < 0) return prev
return [
- { id: null, rid: null, name: '/' },
+ isDriveRootCrumb(prev[0]) ? prev[0]! : createDriveRootCrumb(),
...ancestors,
// Live crumb state (name/version included) — see the doc note above.
...prev.slice(index),
@@ -1907,7 +1919,10 @@ export function GfsBrowser(): React.JSX.Element {
// reconstruction (R7-M1): its late response must not re-anchor the
// trail this link-open just replaced.
trailReconstructionEpochRef.current += 1
- setCrumbs([{ id: null, rid: null, name: '/' }, folderResourceToCrumb(view)])
+ setCrumbs(prev => [
+ isDriveRootCrumb(prev[0]) ? prev[0]! : createDriveRootCrumb(),
+ folderResourceToCrumb(view),
+ ])
setOpenLinkOpen(false)
} catch (err) {
setOpenLinkError(err instanceof Error ? err.message : 'Could not open the EvenDrive link.')
@@ -2159,7 +2174,10 @@ export function GfsBrowser(): React.JSX.Element {
// The synthetic drive root and ancestor crumbs stay plain.
const activeFolder = index === crumbs.length - 1 ? crumbToChild(crumb) : null
return (
- <span className="cu-gfs-breadcrumb__item" key={`${crumb.id ?? 'root'}-${index}`}>
+ <span
+ className="cu-gfs-breadcrumb__item"
+ key={`${isDriveRootCrumb(crumb) ? 'root' : crumb.id}-${index}`}
+ >
{index > 0 ? <IconChevronRight width={14} height={14} /> : null}
<button
className={`cu-gfs-breadcrumb__button${
diff --git a/control-ui/components/__tests__/GfsBrowser.foregroundStreamArbitration.integration.test.tsx b/control-ui/components/__tests__/GfsBrowser.foregroundStreamArbitration.integration.test.tsx
index f298566d0..2102debc5 100644
--- a/control-ui/components/__tests__/GfsBrowser.foregroundStreamArbitration.integration.test.tsx
+++ b/control-ui/components/__tests__/GfsBrowser.foregroundStreamArbitration.integration.test.tsx
@@ -2,6 +2,7 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
import { EventEmitter } from 'node:events'
+import { listChildrenPaged } from '../../../control-api/src/gfs/tree.js'
import {
closeActiveEntityChangeStreams,
streamEntityChanges,
@@ -93,7 +94,7 @@ describe('GfsBrowser foreground/stream arbitration integration', () => {
let streamController: ReadableStreamDefaultController<Uint8Array> | null = null
let wakeFeed: (() => void) | null = null
let producerResponse: ProducerResponse | null = null
- let childReads = 0
+ let treeReads = 0
let staleReadSignal: AbortSignal | null = null
const existingFile = {
resourceId: '22222222-2222-2222-2222-222222222222',
@@ -145,11 +146,8 @@ describe('GfsBrowser foreground/stream arbitration integration', () => {
)
}
if (url.pathname.endsWith('/api/v1/gfs/tree')) {
- return jsonResponse({ rootResourceId: ROOT_ID, items: [], nextCursor: null })
- }
- if (url.pathname.endsWith(`/api/v1/gfs/resources/${ROOT_ID}/children`)) {
- childReads += 1
- if (childReads === 2) {
+ treeReads += 1
+ if (treeReads === 2) {
staleReadSignal = init?.signal ?? null
return new Promise<Response>((_resolve, reject) => {
const rejectAborted = () => reject(new DOMException('Aborted', 'AbortError'))
@@ -160,10 +158,11 @@ describe('GfsBrowser foreground/stream arbitration integration', () => {
}
})
}
- if (childReads >= 3) {
- return jsonResponse({ items: [existingFile, createdFolder], nextCursor: null })
- }
- return jsonResponse({ items: [existingFile], nextCursor: null })
+ return jsonResponse({
+ rootResourceId: ROOT_ID,
+ items: treeReads >= 3 ? [existingFile, createdFolder] : [existingFile],
+ nextCursor: null,
+ })
}
if (
url.pathname.endsWith(
@@ -224,7 +223,7 @@ describe('GfsBrowser foreground/stream arbitration integration', () => {
await act(async () => {
streamController!.enqueue(new TextEncoder().encode(changeFrame!))
})
- await waitFor(() => expect(childReads).toBe(2))
+ await waitFor(() => expect(treeReads).toBe(2))
expect(staleReadSignal).not.toBeNull()
fireEvent.click(screen.getByRole('button', { name: /new folder/i }))
@@ -238,4 +237,167 @@ describe('GfsBrowser foreground/stream arbitration integration', () => {
await waitFor(() => expect(staleReadSignal?.aborted).toBe(true))
expect(screen.getByRole('button', { name: 'created-after-refresh' })).toBeVisible()
})
+
+ it('keeps the resolved drive root on one location and applies its fresh stream page', async () => {
+ let streamController: ReadableStreamDefaultController<Uint8Array> | null = null
+ let wakeFeed: (() => void) | null = null
+ let producerResponse: ProducerResponse | null = null
+ let treeReads = 0
+ let rootChildReads = 0
+ let releaseInitialTree: ((response: Response) => void) | null = null
+ const apiRequests: Array<{ path: string; signal: AbortSignal | undefined }> = []
+ const initialFile = {
+ resourceId: '22222222-2222-2222-2222-222222222222',
+ rid: '22222222222222222222222222222222',
+ gfsUri: 'gfs://main/22222222222222222222222222222222',
+ name: 'initial-root.txt',
+ kind: 'file',
+ path: '/initial-root.txt',
+ bytes: 0,
+ version: 1,
+ }
+ const latestFile = {
+ resourceId: '33333333-3333-3333-3333-333333333333',
+ rid: '33333333333333333333333333333333',
+ gfsUri: 'gfs://main/33333333333333333333333333333333',
+ name: 'latest-root.txt',
+ kind: 'file',
+ path: '/latest-root.txt',
+ bytes: 0,
+ version: 1,
+ }
+ const makeTreeResponse = async (children: (typeof initialFile)[]) => {
+ const page = await listChildrenPaged(
+ {
+ listChildren: async () =>
+ children.map(item => ({
+ resourceId: item.resourceId,
+ name: item.name,
+ kind: item.kind,
+ pathCache: item.path,
+ bytes: item.bytes,
+ version: item.version,
+ updatedAt: '2026-09-30T00:00:00.000Z',
+ })),
+ },
+ 'main',
+ ROOT_ID,
+ {}
+ )
+ return jsonResponse({ ...page, rootResourceId: ROOT_ID })
+ }
+
+ controlApiProducer.isEntityChangeCursor.mockImplementation((value: string) =>
+ /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value)
+ )
+ controlApiProducer.readEntityChangeCheckpoint.mockResolvedValue({
+ resyncRequired: false,
+ cursor: CURSOR,
+ scopes: [],
+ })
+ controlApiProducer.subscribeEntityChangeFeedWake.mockImplementation((wake: () => void) => {
+ wakeFeed = wake
+ return vi.fn()
+ })
+
+ vi.stubGlobal(
+ 'fetch',
+ vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
+ const url = new URL(String(input), 'http://control-ui.test')
+ if (url.pathname.endsWith('/api/v1/gfs/entity-changes/stream')) {
+ return new Response(
+ new ReadableStream<Uint8Array>({
+ start(controller) {
+ streamController = controller
+ init?.signal?.addEventListener('abort', () => controller.close(), { once: true })
+ },
+ }),
+ { status: 200, headers: { 'content-type': 'application/x-ndjson' } }
+ )
+ }
+
+ apiRequests.push({ path: url.pathname, signal: init?.signal ?? undefined })
+ if (url.pathname === '/control-api/api/v1/gfs/tree') {
+ treeReads += 1
+ if (treeReads === 1) {
+ return new Promise<Response>(resolve => {
+ releaseInitialTree = resolve
+ })
+ }
+ return makeTreeResponse([latestFile])
+ }
+ if (url.pathname === `/control-api/api/v1/gfs/resources/${ROOT_ID}/children`) {
+ rootChildReads += 1
+ return jsonResponse({
+ items: rootChildReads === 1 ? [initialFile] : [latestFile],
+ nextCursor: null,
+ })
+ }
+ if (url.pathname.endsWith('/api/v1/gfs/resolve')) {
+ return jsonResponse({
+ resourceId: ROOT_ID,
+ rid: ROOT_RID,
+ gfsUri: `gfs://main/${ROOT_RID}`,
+ name: '/',
+ kind: 'directory',
+ path: '/',
+ version: 1,
+ })
+ }
+ return jsonResponse({ items: [], nextCursor: null })
+ })
+ )
+
+ render(
+ <ToastProvider>
+ <GfsBrowser />
+ </ToastProvider>
+ )
+ await waitFor(() => expect(treeReads).toBe(1))
+ await waitFor(() => expect(streamController).not.toBeNull())
+
+ const req = new ProducerRequest()
+ producerResponse = new ProducerResponse()
+ streamEntityChanges(
+ req as never,
+ producerResponse as never,
+ CURSOR,
+ async () => true,
+ 'operator',
+ 'control-ui-root-identity'
+ )
+ await waitFor(() => expect(producerResponse?.headersSent).toBe(true))
+ controlApiProducer.readEntityChangeCheckpoint.mockResolvedValue({
+ resyncRequired: false,
+ cursor: CURSOR,
+ scopes: ['gfs'],
+ })
+ wakeFeed?.()
+ await waitFor(() =>
+ expect(
+ producerResponse?.frames.some(frame => frame.includes('"type":"scope.invalidated"'))
+ ).toBe(true)
+ )
+ const changeFrame = producerResponse!.frames.find(frame =>
+ frame.includes('"type":"scope.invalidated"')
+ )
+ expect(changeFrame).toBeDefined()
+ await act(async () => {
+ streamController!.enqueue(new TextEncoder().encode(changeFrame!))
+ })
+
+ await act(async () => {
+ releaseInitialTree!(await makeTreeResponse([initialFile]))
+ })
+ await screen.findByRole('button', { name: 'latest-root.txt' })
+ expect(screen.getByRole('button', { name: /new folder/i })).toBeEnabled()
+ await waitFor(() => expect(treeReads + rootChildReads).toBeGreaterThanOrEqual(2))
+ expect(screen.queryByRole('button', { name: 'initial-root.txt' })).not.toBeInTheDocument()
+ expect(rootChildReads).toBe(0)
+ expect(treeReads).toBe(2)
+ expect(screen.getByRole('button', { name: /new folder/i })).toBeEnabled()
+ expect(
+ apiRequests.filter(request => request.path === '/control-api/api/v1/gfs/tree')[1]?.signal
+ ).toBeInstanceOf(AbortSignal)
+ })
})
diff --git a/control-ui/components/__tests__/GfsBrowser.revalidation.integration.test.tsx b/control-ui/components/__tests__/GfsBrowser.revalidation.integration.test.tsx
index 74f735af4..26a84d592 100644
--- a/control-ui/components/__tests__/GfsBrowser.revalidation.integration.test.tsx
+++ b/control-ui/components/__tests__/GfsBrowser.revalidation.integration.test.tsx
@@ -174,10 +174,8 @@ describe('GfsBrowser authoritative revalidation integration', () => {
)
}
if (url.pathname.endsWith('/api/v1/gfs/tree')) {
- return jsonResponse({ rootResourceId: 'root-1', items: [], nextCursor: null })
- }
- if (url.pathname.endsWith('/api/v1/gfs/resources/root-1/children')) {
return jsonResponse({
+ rootResourceId: 'root-1',
items: [child('file-1', 'rid-file-1', 'kept.txt', 'file')],
nextCursor: null,
})
@@ -220,10 +218,8 @@ describe('GfsBrowser authoritative revalidation integration', () => {
)
}
if (url.pathname.endsWith('/api/v1/gfs/tree')) {
- return jsonResponse({ rootResourceId: 'root-1', items: [], nextCursor: null })
- }
- if (url.pathname.endsWith('/api/v1/gfs/resources/root-1/children')) {
return jsonResponse({
+ rootResourceId: 'root-1',
items: [child('file-1', 'rid-file-1', 'kept.txt', 'file')],
nextCursor: null,
})
@@ -296,10 +292,8 @@ describe('GfsBrowser authoritative revalidation integration', () => {
)
}
if (url.pathname.endsWith('/api/v1/gfs/tree')) {
- return jsonResponse({ rootResourceId: 'root-1', items: [], nextCursor: null })
- }
- if (url.pathname.endsWith('/api/v1/gfs/resources/root-1/children')) {
return jsonResponse({
+ rootResourceId: 'root-1',
items: [child('file-1', 'rid-file-1', 'kept.txt', 'file')],
nextCursor: null,
})
@@ -742,7 +736,7 @@ describe('GfsBrowser authoritative revalidation integration', () => {
it('recovers the rendered list after a real API-client stream refresh fails once', async () => {
const existingFile = child('file-1', 'rid-file-1', 'existing.txt', 'file')
const remoteFolder = child('folder-2', 'rid-folder-2', 'remote-folder', 'directory')
- let rootChildReads = 0
+ let treeReads = 0
let streamController: ReadableStreamDefaultController<Uint8Array> | null = null
vi.stubGlobal(
'fetch',
@@ -760,15 +754,17 @@ describe('GfsBrowser authoritative revalidation integration', () => {
)
}
if (url.pathname.endsWith('/api/v1/gfs/tree')) {
- return jsonResponse({ rootResourceId: 'root-1', items: [], nextCursor: null })
- }
- if (url.pathname.endsWith('/api/v1/gfs/resources/root-1/children')) {
- rootChildReads += 1
- if (rootChildReads === 1) {
- return jsonResponse({ items: [existingFile], nextCursor: null })
+ treeReads += 1
+ if (treeReads === 1) {
+ return jsonResponse({
+ rootResourceId: 'root-1',
+ items: [existingFile],
+ nextCursor: null,
+ })
}
- if (rootChildReads === 2) return new Response('temporary failure', { status: 503 })
+ if (treeReads === 2) return new Response('temporary failure', { status: 503 })
return jsonResponse({
+ rootResourceId: 'root-1',
items: [existingFile, remoteFolder],
nextCursor: null,
})
@@ -788,10 +784,10 @@ describe('GfsBrowser authoritative revalidation integration', () => {
streamController!.enqueue(new TextEncoder().encode(`${await controlApiProducerFrame()}\n`))
})
- await waitFor(() => expect(rootChildReads).toBe(2))
+ await waitFor(() => expect(treeReads).toBe(2))
expect(screen.getByRole('button', { name: 'existing.txt' })).toBeVisible()
await screen.findByText('remote-folder', {}, { timeout: 2_000 })
- expect(rootChildReads).toBe(3)
+ expect(treeReads).toBe(3)
expect(screen.getByRole('button', { name: 'existing.txt' })).toBeVisible()
})
@@ -871,8 +867,7 @@ describe('GfsBrowser authoritative revalidation integration', () => {
it('retries a transient action-target resolve and closes only after authoritative deletion', async () => {
const report = child('file-1', 'rid-file-1', 'report.md', 'file')
- let childReads = 0
- let revalidationStarted = false
+ let treeReads = 0
let resolveReads = 0
let streamController: ReadableStreamDefaultController<Uint8Array> | null = null
vi.stubGlobal(
@@ -891,12 +886,10 @@ describe('GfsBrowser authoritative revalidation integration', () => {
)
}
if (url.pathname.endsWith('/api/v1/gfs/tree')) {
- return jsonResponse({ rootResourceId: 'root-1', items: [report], nextCursor: null })
- }
- if (url.pathname.endsWith('/api/v1/gfs/resources/root-1/children')) {
- if (revalidationStarted) childReads += 1
+ treeReads += 1
return jsonResponse({
- items: childReads < 2 ? [report] : [],
+ rootResourceId: 'root-1',
+ items: treeReads < 3 ? [report] : [],
nextCursor: null,
})
}
@@ -923,7 +916,6 @@ describe('GfsBrowser authoritative revalidation integration', () => {
fireEvent.click(screen.getByRole('menuitem', { name: 'Rename' }))
await screen.findByRole('dialog', { name: 'Rename file' })
- revalidationStarted = true
await act(async () => {
streamController!.enqueue(new TextEncoder().encode(`${await controlApiProducerFrame()}\n`))
})
diff --git a/control-ui/components/__tests__/GfsBrowser.test.tsx b/control-ui/components/__tests__/GfsBrowser.test.tsx
index 87d9733ee..b952b781d 100644
--- a/control-ui/components/__tests__/GfsBrowser.test.tsx
+++ b/control-ui/components/__tests__/GfsBrowser.test.tsx
@@ -640,10 +640,8 @@ describe('GfsBrowser', () => {
let created = false
mockApiGet.mockImplementation(async (path: string) => {
if (path === '/api/v1/gfs/tree') {
- return { rootResourceId: rootId, items: [], nextCursor: null }
- }
- if (path.endsWith('/children')) {
return {
+ rootResourceId: rootId,
items: created ? [child('remote-folder', 'directory', 9)] : [],
nextCursor: null,
}
@@ -746,20 +744,21 @@ describe('GfsBrowser', () => {
updatedAt: '2026-09-28T00:00:00.000Z',
})
const streamControllers: ReadableStreamDefaultController<Uint8Array>[] = []
- let releaseRefresh!: (page: { items: Array<typeof report>; nextCursor: null }) => void
- let childrenReads = 0
+ let releaseRefresh!: (page: {
+ rootResourceId: string
+ items: Array<typeof report>
+ nextCursor: null
+ }) => void
+ let treeReads = 0
mockApiGet.mockImplementation(async (path: string, query?: Record<string, string>) => {
if (path === '/api/v1/gfs/tree') {
- return { rootResourceId: rootId, items: [report], nextCursor: null }
- }
- if (path === `/api/v1/gfs/resources/${rootId}/children`) {
- childrenReads += 1
- if (childrenReads === 2) {
+ treeReads += 1
+ if (treeReads === 2) {
return new Promise(resolve => {
releaseRefresh = resolve
})
}
- return { items: [report], nextCursor: null }
+ return { rootResourceId: rootId, items: [report], nextCursor: null }
}
if (path === '/api/v1/gfs/resolve' && query?.uri === report.gfsUri) return resolvedReport
if (path === '/api/v1/gfs/resolve') {
@@ -799,12 +798,12 @@ describe('GfsBrowser', () => {
streamControllers[0]!.enqueue(new TextEncoder().encode(`${frame}\n`))
})
- await waitFor(() => expect(childrenReads).toBe(2))
+ await waitFor(() => expect(treeReads).toBe(2))
expect(screen.getByRole('button', { name: 'report.md' })).toBeVisible()
expect(screen.getByRole('dialog', { name: 'Rename file' })).toBe(dialog)
await act(async () => {
- releaseRefresh({ items: [report], nextCursor: null })
+ releaseRefresh({ rootResourceId: rootId, items: [report], nextCursor: null })
})
expect(await screen.findByRole('button', { name: 'report.md' })).toBeVisible()
expect(screen.getByRole('dialog', { name: 'Rename file' })).toBe(dialog)
@@ -846,19 +845,16 @@ describe('GfsBrowser', () => {
})
const streamControllers: ReadableStreamDefaultController<Uint8Array>[] = []
let rejectRefresh!: (error: Error) => void
- let childrenReads = 0
+ let treeReads = 0
mockApiGet.mockImplementation(async (path: string, query?: Record<string, string>) => {
if (path === '/api/v1/gfs/tree') {
- return { rootResourceId: rootId, items: [report], nextCursor: null }
- }
- if (path === `/api/v1/gfs/resources/${rootId}/children`) {
- childrenReads += 1
- if (childrenReads === 2) {
+ treeReads += 1
+ if (treeReads === 2) {
return new Promise((_resolve, reject) => {
rejectRefresh = reject
})
}
- return { items: [report], nextCursor: null }
+ return { rootResourceId: rootId, items: [report], nextCursor: null }
}
if (path === '/api/v1/gfs/resolve' && query?.uri === report.gfsUri) {
return resolvedReport
@@ -895,7 +891,7 @@ describe('GfsBrowser', () => {
await act(async () => {
streamControllers[0]!.enqueue(new TextEncoder().encode(`${frame}\n`))
})
- await waitFor(() => expect(childrenReads).toBe(2))
+ await waitFor(() => expect(treeReads).toBe(2))
expect(screen.getByRole('button', { name: 'report.md' })).toBeVisible()
expect(screen.getByRole('dialog', { name: 'Rename file' })).toBeVisible()
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index b345c42a8..b53dea647 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.701",
+ "version": "0.1.702",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.701",
+ "version": "0.1.702",
"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.json
index 533f6116b..19c877522 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.701",
+ "version": "0.1.702",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",