Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): present GFS read failures as verdicts, not as IPC transport
Alfredo Lopeze07340f81023
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsxindex ff53ade57..3d2307355 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx@@ -96,6 +96,8 @@ function Probe() {<div data-testid="discovery-failure-retry-at">{ctrl.discoveryFailure?.retryAvailableAt ?? 'none'}</div>+ <div data-testid="affordances-error">{ctrl.affordancesError ?? 'none'}</div>+ <div data-testid="open-error">{ctrl.openError ?? 'none'}</div><div data-testid="loading">{ctrl.loading ? 'loading' : 'idle'}</div><div data-testid="loading-accessible">{ctrl.loadingAccessible ? 'loading' : 'idle'}</div><div data-testid="row-affordances">{ctrl.rowAffordances?.held.join(',') ?? 'none'}</div>@@ -279,6 +281,97 @@ describe('useGfsBrowserController', () => {expect(lastHarnessQueryClient?.getQueryData(grantsKey)).toBeUndefined()})+ it('exposes the presented verdict for a failed affordances read, not the IPC wrapper', async () => {+ // Every rejection that crosses ipcRenderer.invoke arrives wrapped in+ // "Error invoking remote method '<channel>': ", which names our own+ // main/renderer split. FilesPage renders this field straight into a+ // StatusBanner and interpolates it into the drag-overlay copy, so the raw+ // string put the channel name — and a bare status line for a rate limit —+ // in front of the user.+ const affordances = vi.fn(async () => {+ throw new Error(+ "Error invoking remote method 'gfs:affordances': Error: 429 Too Many Requests: " ++ 'Too Many Requests retryAfterSeconds=7'+ )+ })+ Object.defineProperty(window, 'clerum', {+ configurable: true,+ value: {+ gfs: {+ listAccessible: vi.fn(async () => ({ items: [], nextCursor: null })),+ resolve: vi.fn(async () => ({+ resourceId: 'root',+ gfsUri: 'gfs://main/root',+ name: 'Root',+ kind: 'directory',+ })),+ listChildren: vi.fn(async () => ({ items: [], nextCursor: null })),+ affordances,+ },+ },+ })++ render(<Probe />, { wrapper: Harness })++ await act(async () => {+ screen.getByRole('button', { name: 'open' }).click()+ })+ await waitFor(() => expect(screen.getByTestId('current').textContent).toBe('root'))++ await waitFor(() =>+ expect(screen.getByTestId('affordances-error').textContent).toBe(+ 'Too many file requests — try again in 7s.'+ )+ )+ // Liveness witness: the read really ran and really rejected, so the+ // assertion above is about how the failure is presented and not about a+ // field that stayed at its 'none' default.+ expect(affordances).toHaveBeenCalled()+ })++ it('exposes the presented verdict for a failed open, not the IPC wrapper', async () => {+ const resolve = vi.fn(async () => {+ throw new Error(+ "Error invoking remote method 'gfs:resolve': Error: 503 Service Unavailable: " ++ 'upstream_unreachable'+ )+ })+ Object.defineProperty(window, 'clerum', {+ configurable: true,+ value: {+ gfs: {+ listAccessible: vi.fn(async () => ({ items: [], nextCursor: null })),+ resolve,+ listChildren: vi.fn(async () => ({ items: [], nextCursor: null })),+ affordances: vi.fn(async () => ({+ held: [],+ canDelegate: false,+ grantableBits: [],+ canCreateShare: false,+ })),+ },+ },+ })++ render(<Probe />, { wrapper: Harness })++ await act(async () => {+ screen.getByRole('button', { name: 'open' }).click()+ })++ // The server verdict survives in full — fail loud — and only the wrapper+ // naming our own process boundary is gone.+ await waitFor(() =>+ expect(screen.getByTestId('open-error').textContent).toBe(+ '503 Service Unavailable: upstream_unreachable'+ )+ )+ // Liveness witness: the open really was attempted, and the session was not+ // failed closed by this non-authority failure.+ expect(resolve).toHaveBeenCalledTimes(1)+ expect(screen.getByTestId('access-state').textContent).toBe('active')+ })+it('refreshes cached affordances after permissions change outside Desktop', async () => {let held = ['read']const affordances = vi.fn(async () => ({diff --git a/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts b/desktop-app/ui/src/hooks/domain/useGfsBrowserController.tsindex 258d22850..a3edbb83e 100644--- a/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts+++ b/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts@@ -8,7 +8,7 @@ import {useQueryClient,} from '@tanstack/react-query'import { GFS_BREADCRUMB_MAX_DEPTH } from '@constants/gfsBrowser'-import { isRateLimited, parseRetryAfterSeconds } from '@lib/gfsGrantErrors'+import { describeGfsReadError, isRateLimited, parseRetryAfterSeconds } from '@lib/gfsGrantErrors'import type { GfsGrantListItem, GfsShareListItem } from '@/gfs/delegation.types'import { desktopQueryKeys } from './queryKeys'@@ -139,6 +139,24 @@ function toMessage(error: unknown): string {return error instanceof Error ? error.message : String(error)}+/**+ * Present a read-plane failure as the verdict a user can act on.+ *+ * `toMessage` returns the RAW `Error.message`, which still carries Electron's+ * `Error invoking remote method '<channel>': ` wrapper — the name of our own+ * main/renderer split, which means nothing to a user — and spells a 429 as a+ * bare status line rather than as "too many file requests".+ *+ * Only fields that feed a BANNER are presented here. Fields that feed a+ * CLASSIFIER stay raw on purpose: `accessibleError` is read by+ * `classifyDiscoveryFailure`, and `error` by the folder failure card, both of+ * which match status tokens and the `retryAfterSeconds=` suffix that this+ * mapping deliberately replaces with prose.+ */+function toPresentedMessage(error: unknown): string {+ return describeGfsReadError(error).message+}+export type GfsDiscoveryFailureKind = 'unsupported' | 'rate-limited' | 'failed'export interface GfsDiscoveryFailure {@@ -786,7 +804,10 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {// Opening a URI is an operation on one resource. A generic 403 may be// a per-resource policy decision; only a session-authority failure// (bare 401 / typed lifecycle code) fails the session closed.- if (!handleAuthorityFailure(message, 'operation')) setOpenError(message)+ //+ // The authority check reads the RAW message — it matches status codes+ // and lifecycle tokens — while the banner shows the presented verdict.+ if (!handleAuthorityFailure(message, 'operation')) setOpenError(toPresentedMessage(error))return false} finally {setResolving(false)@@ -941,7 +962,7 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {authorityPending || accessState === 'revoked'? null: ((affordancesQuery.data as GfsBrowserAffordances | undefined) ?? null),- affordancesError: affordancesQuery.error ? toMessage(affordancesQuery.error) : null,+ affordancesError: affordancesQuery.error ? toPresentedMessage(affordancesQuery.error) : null,loadingAffordances: affordancesQuery.isFetching,rowAffordancesByResourceId,rowAffordancesResourceId,@@ -950,7 +971,9 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {authorityPending || accessState === 'revoked'? null: ((rowAffordancesQuery.data as GfsBrowserAffordances | undefined) ?? null),- rowAffordancesError: rowAffordancesQuery.error ? toMessage(rowAffordancesQuery.error) : null,+ rowAffordancesError: rowAffordancesQuery.error+ ? toPresentedMessage(rowAffordancesQuery.error)+ : null,loading: (authorityPending || childrenQuery.isFetching) && items.length === 0,// A settled discovery error is not a pending load. Without this the// spinner outlived the failure for every consumer that derives its