Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): reject stale folder pages for R8-H1
Josué73ba9e9e8d2b
diff --git a/control-ui/components/GfsBrowser.tsx b/control-ui/components/GfsBrowser.tsxindex 96f30e8b8..4f452a73d 100644--- a/control-ui/components/GfsBrowser.tsx+++ b/control-ui/components/GfsBrowser.tsx@@ -487,7 +487,10 @@ export function GfsBrowser(): React.JSX.Element {}const loadArbiter = loadArbiterRef.currentconst loadToken = background ? loadArbiter.beginBackground() : loadArbiter.beginForeground()- const isCurrent = () => !options?.signal?.aborted && loadArbiter.isCurrent(loadToken)+ const isCurrent = () =>+ !options?.signal?.aborted &&+ loadArbiter.isCurrent(loadToken) &&+ currentCrumbRef.current?.id === crumb.idif (!background && !cursor) loadedPageCountRef.current = 1if (appending) {setLoadingMore(true)@@ -662,6 +665,7 @@ export function GfsBrowser(): React.JSX.Element {const locationKey = current.id ?? '$root'const sameLocation = loadedLocationRef.current === locationKeyloadedLocationRef.current = locationKey+ if (!sameLocation) setLoadingMore(false)if (revalidateNextLoadRef.current) {revalidateNextLoadRef.current = false// Stale-while-revalidate: cached rows stay on screen (no spinner) whilediff --git a/control-ui/components/__tests__/GfsBrowser.test.tsx b/control-ui/components/__tests__/GfsBrowser.test.tsxindex fe4e4d1f6..4b58ac10b 100644--- a/control-ui/components/__tests__/GfsBrowser.test.tsx+++ b/control-ui/components/__tests__/GfsBrowser.test.tsx@@ -412,6 +412,51 @@ describe('GfsBrowser', () => {expect(mockApiGet).toHaveBeenCalledWith('/api/v1/gfs/tree', { drive: 'main' })})+ it('does not append a pending root page into a cached folder opened meanwhile', async () => {+ const alpha = child('alpha', 'directory', 1)+ let resolveRootPage: ((value: unknown) => void) | undefined+ const pendingRootPage = new Promise<unknown>(resolve => {+ resolveRootPage = resolve+ })+ mockApiGet.mockImplementation((path: string, query?: Record<string, string>) => {+ if (path === '/api/v1/gfs/tree') {+ return query?.cursor === 'root-page-2'+ ? pendingRootPage+ : Promise.resolve({+ items: [alpha],+ nextCursor: 'root-page-2',+ })+ }+ if (path === '/api/v1/gfs/resources/id-1/children') {+ return Promise.resolve({ items: [child('alpha-only.txt', 'file', 3)], nextCursor: null })+ }+ return Promise.resolve({ items: [], nextCursor: null })+ })++ renderBrowser()+ const folderButton = await screen.findByRole('button', { name: 'alpha' })+ await waitFor(() =>+ expect(mockApiGet).toHaveBeenCalledWith('/api/v1/gfs/resources/id-1/children', {+ drive: 'main',+ })+ )+ await act(async () => Promise.resolve())++ fireEvent.click(screen.getByRole('button', { name: 'Load more' }))+ await screen.findByText('Loading…')+ fireEvent.click(folderButton)+ await screen.findByText('alpha-only.txt')++ await act(async () => {+ resolveRootPage?.({ items: [child('root-page-2.txt', 'file', 2)], nextCursor: null })+ await pendingRootPage+ })++ const visibleItems = screen.getByRole('list', { name: 'Current folder resources' })+ expect(visibleItems).toHaveTextContent('alpha-only.txt')+ expect(visibleItems).not.toHaveTextContent('root-page-2.txt')+ })+it('orders directories first, then files, both alphabetically', async () => {mockApiGet.mockResolvedValueOnce({items: [diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex b5634104e..6b9428ce5 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.689",+ "version": "0.1.690","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.689",+ "version": "0.1.690","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 aca63cc6c..83d7c5dc5 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.689",+ "version": "0.1.690","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",