@@ -97,10 +97,7 @@ vi.mock('@sim/emcn', () => ({
9797
9898import { prefetchFilesBrowser } from '@/app/workspace/[workspaceId]/files/prefetch'
9999import { prefetchKnowledgeBases } from '@/app/workspace/[workspaceId]/knowledge/prefetch'
100- import {
101- prefetchWorkspaceSidebar ,
102- WORKSPACE_FILE_SEED_MAX ,
103- } from '@/app/workspace/[workspaceId]/prefetch'
100+ import { prefetchWorkspaceSidebar } from '@/app/workspace/[workspaceId]/prefetch'
104101import { prefetchTables } from '@/app/workspace/[workspaceId]/tables/prefetch'
105102import { folderKeys } from '@/hooks/queries/utils/folder-keys'
106103import { knowledgeKeys } from '@/hooks/queries/utils/knowledge-keys'
@@ -363,13 +360,15 @@ describe('workspace list prefetches', () => {
363360 * so a page-level prefetch of this key costs a request per render and still cannot reach the server
364361 * render. Restoring it here would reintroduce exactly that.
365362 */
366- it ( 'leaves the file list to the layout rather than re-reading it per page' , async ( ) => {
363+ /** The Files browser renders the list, so it is the boundary that seeds it. */
364+ it ( 'seeds the file list it renders' , async ( ) => {
365+ const files = [ { id : 'file-1' , name : 'a.txt' } ]
366+ mockListWorkspaceFilesWithShares . mockResolvedValue ( files )
367367 const client = makeClient ( )
368368
369369 await prefetchFilesBrowser ( client , WORKSPACE_ID , USER_ID )
370370
371- expect ( mockListWorkspaceFilesWithShares ) . not . toHaveBeenCalled ( )
372- expect ( client . getQueryData ( workspaceFilesKeys . list ( WORKSPACE_ID , 'active' ) ) ) . toBeUndefined ( )
371+ expect ( client . getQueryData ( workspaceFilesKeys . list ( WORKSPACE_ID , 'active' ) ) ) . toEqual ( files )
373372 } )
374373
375374 /**
@@ -514,37 +513,15 @@ describe('workspace list prefetches', () => {
514513 } )
515514
516515 /**
517- * The file list is seeded on every workspace route, so it is the one entry whose size
518- * scales with a workspace's content on routes that never read it. The budget is passed
519- * down rather than applied here, so the read can stop before the share join.
520- */
521- it ( 'seeds the file list, bounded by the document payload budget' , async ( ) => {
522- const files = [ { id : 'file-1' , name : 'a.txt' } ]
523- mockListWorkspaceFilesWithShares . mockResolvedValue ( files )
524- const client = makeClient ( )
525-
526- await prefetchWorkspaceSidebar ( client , WORKSPACE_ID , USER_ID , HOST_CONTEXT , null )
527-
528- expect ( mockListWorkspaceFilesWithShares ) . toHaveBeenCalledWith ( WORKSPACE_ID , 'active' , {
529- maxRows : WORKSPACE_FILE_SEED_MAX ,
530- /** A failed read must reach the catch, not degrade to a cached empty list. */
531- throwOnError : true ,
532- } )
533- expect ( client . getQueryData ( workspaceFilesKeys . list ( WORKSPACE_ID , 'active' ) ) ) . toEqual ( files )
534- } )
535-
536- /**
537- * The load-bearing half of the budget: a workspace over it seeds NOTHING rather than the
538- * prefix that was read. The sidebar search filters this list client-side and the Files
539- * browser renders it as the workspace's files, so a truncated seed would silently hide
540- * files — the client fetch must reach the route for the complete list instead.
516+ * The file list moved to the pages that render it. Seeding it here would put it on
517+ * every workspace route again — the cost this split removed.
541518 */
542- it ( 'seeds nothing when the workspace exceeds the budget' , async ( ) => {
543- mockListWorkspaceFilesWithShares . mockResolvedValue ( null )
519+ it ( 'does not seed the workspace file list' , async ( ) => {
544520 const client = makeClient ( )
545521
546522 await prefetchWorkspaceSidebar ( client , WORKSPACE_ID , USER_ID , HOST_CONTEXT , null )
547523
524+ expect ( mockListWorkspaceFilesWithShares ) . not . toHaveBeenCalled ( )
548525 expect ( client . getQueryData ( workspaceFilesKeys . list ( WORKSPACE_ID , 'active' ) ) ) . toBeUndefined ( )
549526 } )
550527
0 commit comments