perf(workspace): stop the sidebar fetching palette data on every route - #6670
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Workspace file list SSR seeding moves off the layout sidebar prefetch into Tests split file-seed behavior into Reviewed by Cursor Bugbot for commit c43c934. Configure here. |
Greptile SummaryThe PR moves palette-only queries out of the persistent workspace sidebar and relocates workspace-file hydration to the pages that consume it.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal/search-modal.tsx | Moves palette-specific resource queries and mapping into the modal while preserving hidden-tab filtering. |
| apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx | Removes eager palette-only list and folder-map subscriptions from the persistent sidebar. |
| apps/sim/app/workspace/[workspaceId]/lib/seed-workspace-files.ts | Extracts bounded file-list seeding and deliberately falls back to client fetching after oversized or failed reads. |
| apps/sim/app/workspace/[workspaceId]/home/prefetch.ts | Adds authorization-gated file-list seeding for Home surfaces. |
| apps/sim/app/workspace/[workspaceId]/files/prefetch.ts | Moves file-list seeding into the Files surface’s existing authorization-gated prefetch. |
| apps/sim/app/workspace/[workspaceId]/home/page.tsx | Adds page-owned Home prefetching and hydration. |
| apps/sim/app/workspace/[workspaceId]/chat/[chatId]/page.tsx | Adds feature-flag gating and page-owned Home-surface prefetching for chat routes. |
| apps/sim/app/workspace/[workspaceId]/prefetch.ts | Stops the shared workspace layout prefetch from reading and serializing workspace files. |
Sequence Diagram
sequenceDiagram
participant User
participant Sidebar
participant Palette as Cmd+K Palette
participant QueryCache as React Query Cache
participant API
Sidebar->>Sidebar: Render on workspace route
Note over Sidebar,API: Palette-only lists remain deferred
User->>Palette: Open Cmd+K
Palette->>QueryCache: Request tables, files, knowledge bases, folder maps
alt Data is cached and fresh
QueryCache-->>Palette: Return cached lists
else Data is absent or stale
QueryCache->>API: Fetch palette data
API-->>QueryCache: Return lists and folder maps
QueryCache-->>Palette: Render searchable entities
end
Reviews (6): Last reviewed commit: "fix(chat): guard the chat page prefetch ..." | Re-trigger Greptile
25d036c to
79ccbfc
Compare
|
@cursor review |
|
Researched the registration problem properly and found the clean fix — it needed no mounting changes at all.
export function SearchModal({ open, ...props }: SearchModalProps) {
const [mounted, setMounted] = useState(false)
useEffect(() => { setMounted(true) }, [])
if (!mounted || !open) return null
return <SearchModalContent {...props} />
}
That is strictly better than the Now nothing registers those keys unless the palette is open. Also removed four imports the move orphaned in Deliberately not in this PR: moving the file-list seed out of the layout onto |
|
@cursor review |
cbb634c to
72bc2a4
Compare
|
@cursor review |
|
@cursor review |
…never register them
4cff50f to
c43c934
Compare
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit c43c934. Configure here.
Summary
The workspace sidebar renders on every route, so anything it fetches is paid on every cold load. Three of its queries — tables, knowledge bases, and the workspace file list — plus the two folder maps that resolve their paths, exist only to populate the Cmd+K palette. The workflow folder map is the one that feeds rendered chrome, and it stays eager.
Those five now wait for the palette to open. The hooks already accept an
enabledoption for exactly this —useTablesList's own doc says "defer the fetch (e.g. until a menu that needs the list is open)" — and the folder maps follow the disable-by-undefinedidiom already used a few lines above for the hidden-tab case. React Query keeps what it fetched, so reopening the palette is served from cache.SettingsLoaderis removed. It eagerly warmed general settings on every workspace route, but the only consumer is the settings surface, which already prefetches the same key server-side, and its sibling sidebar renders only whenisOnSettingsPage.The file list moved to the pages that render it. It lived in the workspace layout because the sidebar registered the query first, and
HydrationBoundarydefers a query the cache has already seen to auseEffectthat SSR never runs — so only the first boundary could reach the server render. With the sidebar deferred,/filesand/homecan seed it themselves, and/w,/logs,/settings,/tables, and/knowledgestop paying two to three reads and up to ~150 KB for a list they never show. The payload budget moves with it and now only has to protect the pages that do render it.Net on a cold workspace route that is not Files: six fewer client requests and a smaller document.
Type of Change
Testing
Type-check, lint, and the React Query, client-boundary, and module-graph audits pass. 1,512 tests pass; the same suite on the unmodified base passes 1,510, and no test fails either way.
seedWorkspaceFilesmoved to its own module with its tests; the layout prefetch suite now asserts it does not seed the file list, and the Files prefetch suite asserts it does.Checklist