Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): count folders in the folder-zip entry budget (R1-M3)
M0f9e10154e2c
diff --git a/desktop-app/ui/src/lib/__tests__/gfsFolderZip.test.ts b/desktop-app/ui/src/lib/__tests__/gfsFolderZip.test.tsindex 8c4cde36f..8e8031fd1 100644--- a/desktop-app/ui/src/lib/__tests__/gfsFolderZip.test.ts+++ b/desktop-app/ui/src/lib/__tests__/gfsFolderZip.test.ts@@ -263,7 +263,31 @@ describe('createGfsFolderZip', () => {{ resourceId: 'root', drive: 'main', name: 'Many' },{ deps, limits: { maxEntries: 2 } })- ).rejects.toThrow(/more than 2 files/)+ ).rejects.toThrow(/more than 2 entries/)+ })++ it('counts DIRECTORIES against the entry budget, bounding folder-only walks (R1-M3)', async () => {+ // 2001 empty folders used to pass the file-only budget: every one of them+ // would then cost a listing request against the shared read budget.+ const deps = depsFor({+ root: [+ {+ items: Array.from({ length: GFS_ZIP_MAX_ENTRIES + 1 }, (_, index) =>+ folder({ resourceId: `empty-${index}`, name: `empty-${index}`, kind: 'directory' })+ ),+ nextCursor: null,+ },+ ],+ })++ await expect(+ createGfsFolderZip({ resourceId: 'root', drive: 'main', name: 'Hive' }, { deps })+ ).rejects.toThrow(+ new RegExp(`more than ${GFS_ZIP_MAX_ENTRIES} entries \\(files and folders\\)`)+ )+ // Bounded work: the refusal fires inside the FIRST listing page.+ expect(deps.listChildren).toHaveBeenCalledTimes(1)+ expect(deps.download).not.toHaveBeenCalled()})it('refuses when the actual downloaded bytes exceed the ceiling', async () => {diff --git a/desktop-app/ui/src/lib/gfsFolderZip.ts b/desktop-app/ui/src/lib/gfsFolderZip.tsindex 0bf2e5f64..ae1108b50 100644--- a/desktop-app/ui/src/lib/gfsFolderZip.ts+++ b/desktop-app/ui/src/lib/gfsFolderZip.ts@@ -279,6 +279,8 @@ export async function createGfsFolderZip(]const visitedFolders = new Set<string>()let plannedBytes = 0+ // Every accepted child, files AND folders, against `maxEntries` (R1-M3).+ let entriesSeen = 0// ── Phase 1: recursive listing (breadth-first, cursor-paginated). ──report({ phase: 'listing', filesFound: 0, filesAdded: 0, currentPath: rootName })while (queue.length) {@@ -303,23 +305,23 @@ export async function createGfsFolderZip(}for (const child of page.items) {const path = `${next.prefix}/${sanitizeZipSegment(child.name)}`- if (child.kind === 'directory') {- if (child.readable === false) {- skipped.push({ path, reason: 'No access' })- continue- }- queue.push({ resourceId: child.resourceId, prefix: path })- continue- }if (child.readable === false) {skipped.push({ path, reason: 'No access' })continue}- if (files.length + 1 > maxEntries) {+ // Directories cost the same walk work as files (one listing request+ // each), so the entry budget counts BOTH kinds (R1-M3) — 2000 empty+ // folders is 2000 requests, not zero work.+ if (entriesSeen + 1 > maxEntries) {throw new GfsFolderZipLimitError(- `"${folder.name}" holds more than ${maxEntries} files, which exceeds the folder-zip limit. Download smaller subfolders individually.`+ `"${folder.name}" holds more than ${maxEntries} entries (files and folders), which exceeds the folder-zip limit. Download smaller subfolders individually.`)}+ entriesSeen += 1+ if (child.kind === 'directory') {+ queue.push({ resourceId: child.resourceId, prefix: path })+ continue+ }// Older servers omit `bytes`; a missing value must read as 0, not// NaN — NaN would poison `plannedBytes` and silently disable the// size guard for the rest of the walk (M1).