Repository navigation
Description
What happened
In the desktop app, I clicked Refresh (the circular arrow) by mistake in the Files panel of a large project. The panel got stuck on "Refreshing…" and nothing stops it. The Expand/Collapse-all button keeps flipping between "Expand all folders" and "Collapse all folders" by itself. Quitting and relaunching the app didn't help: the refreshing started again as soon as the window came back.
Diagnosis
The server is healthy. Every projects.listEntries call succeeds in about 12 ms. The client keeps sending them, and the renderer is the bottleneck because it rebuilds the whole tree after each reply.
Code references are at v0.1.11. The same code is unchanged in v0.1.12 and on main today.
- Refresh re-lists every folder ever loaded, with no cap or cancel.
apps/web/src/components/files/useDirectoryEntries.ts:177-183:refresh()callsload(path, true)for every path inrequested.currentthat is still reachable. That means every folder the tree has listed this session, not only the visible ones. The work runs four at a time (:40), and nothing can cancel it. The Refresh button only showsisPending. - Agent activity restarts the sweep.
FileBrowserPanel.tsx:435-442:useWorkspaceMutationRefreshcalls the same fullrefresh()on every newworkspaceMutationId, which changes on every completed command or file change in the thread. If a refresh is already running for a folder,load(..., true)queues a follow-up refresh (useDirectoryEntries.ts:123-138). With an agent running in a big project, full sweeps run back to back indefinitely. - Each listing costs O(tree) on the main thread. Every success calls
setDirectories(new Map(...))(useDirectoryEntries.ts:62-82).visit("")andbuildTreeEntriesthen run over everything loaded, followed bybuildFileTreePathUpdates, andresetPathsorbatchon the Pierre model (FileBrowserPanel.tsx:445-470). TheloadExpandedsubscriber (:364-398) walks alldirectoryPathsagain on every model event. - Expanded folders persist without a cap, so the problem survives a relaunch.
fileTreeExpansion.ts:writeExpandedDirectorieskeeps up to 20 roots but has no limit on paths per root. It re-reads, re-parses and rewrites the whole localStorage value on every change. On remount,pendingExpandedPaths(FileBrowserPanel.tsx:362) re-expands every saved folder, and each one is listed again. This machine had about 730 saved paths for the project. - The flicker comes from
areAllDirectoriesExpanded(model, expandableDirectoryPaths)(FileBrowserPanel.tsx:329-331) being recomputed as each listing adds or removes child folders that aren't expanded yet.
#21246 described part of this: "refresh() re-lists every folder ever loaded each time workspaceMutationId changes … and Collapse all does not reset that". The fix in #21258 deliberately left directory refresh unchanged ("Directory refresh behavior and server contracts are unchanged"), so this part is still open.
Possible directions: refresh only folders that are expanded and visible (or invalidate lazily on expand). Make refresh cancellable and coalesce it into a single in-flight sweep. Debounce or scope mutation-driven refreshes to the paths that changed. Cap persisted expanded paths per root.
Steps to reproduce
- Open a project with many non-ignored folders (hundreds to thousands) in the desktop app, and open the right panel → Files.
- Expand a lot of folders, or use "Expand all folders", which skips ignored folders but still covers every non-ignored folder.
- Click Refresh files.
- While the panel is open, run an agent turn in that project that edits files.
- Observed: the spinner never settles. The server trace shows a continuous stream of
projects.listEntriescalls, and the Expand/Collapse-all button flips back and forth. - Quit and relaunch: the saved expanded folders are restored and listed again, and the flood resumes.
Version
0.1.11 (desktop app, local server). The triage CLI that collected this was 0.1.12.
Environment
macOS 27.0 (Darwin 27.0.0) arm64, Node v26.13.1, desktop app against a local server at 127.0.0.1:3773
Evidence
# server.trace.ndjson*: WorkspaceEntries.list spans per minute (local time), after relaunch at 20:18
922 20:18
2039 20:19
2161 20:20
1869 20:22
1103 20:23
# ~7,600 listings in the first ~6 minutes. 11 rotated ~10 MB trace files covered only ~5 minutes.
# Each listing: durationMs ~12-15, exit Success, plus 2x processRunner.runProcessCore {"process.command":"git"}
# Top span counts in one 10 MB trace file
1415 VcsProcess.spawn
722 WorkspacePaths.statWorkspaceRoot
721 ws.rpc.projects.listEntries
721 WorkspaceEntries.list
# renderer-history.ndjson: renderer destroyed 20:07:17, created 20:18:11, then
workingSetBytes 1836220416 -> 821985280 -> 1781776384 -> 2080505856 (peakWorkingSetBytes 3797811200)
# Local Storage key t3code.fileTreeExpandedDirectories: ~730 paths saved for the project root
# A provider session was active the whole time (agent edits -> workspaceMutationId changes)Related issues
#21246 / #21258: fixed "Expand all walks node_modules" (that fix is in 0.1.11). #21246 mentioned the refresh behavior, but #21258 left it out of scope. This report is about Refresh and mutation-driven refresh, plus persisted expansion, so it is not a duplicate. #6452 is about the opposite problem (a stale panel after Refresh).
Fix applied or workaround
Nothing was changed on disk, in the database, or in the server. The fix was three in-app steps, and the server trace confirmed each one:
- Close the right panel (⌘⌥B / "Toggle right panel"). Switching away from the Files tab isn't enough, because hidden panel tabs stay mounted. Listings stopped within a second of closing it: the last one was at 20:33:39.
- Open View → Toggle Developer Tools → Console and run
localStorage.removeItem("t3code.fileTreeExpandedDirectories")to drop the saved expanded folders. Then reload with ⌘R. - Reopen Files. It made 5 listings in total and then went idle. The spinner stopped and the Expand/Collapse-all button stayed put.
Until this is fixed: avoid Refresh with many folders expanded, and keep the right panel closed while agents work in large projects.
Filed by
Claude Code (claude-opus-5-5) via t3 triage
Activity