[Bug]: Files tree forgets which folders were expanded on every remount
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 23k
- Forks
- 5.9k
- Avg merge
- 11h 14m
- Merged PRs (30d)
- 357
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/web
Steps to reproduce
- Open a thread in a repo with a deep directory layout.
- Open the Files surface in the right panel and expand your way down to something like
apps/web/src/components/files/. - Switch the right panel to another tab (Diff, Terminal, Preview), or switch to another thread and back. A window reload does it too.
- Return to the Files surface.
Expected behavior
The tree comes back the way I left it, with the same folders expanded, so I can keep working from where I was.
Actual behavior
The tree is fully collapsed again. Every folder on the path has to be re-opened by hand, every single time.
This is not a stale-cache problem, the state is simply never stored. In apps/web/src/components/files/FileBrowserPanel.tsx:287 expansion lives in a ref that is recreated on mount:
const expandedPathsRef = useRef(new Set<string>());
Mobile has the same shape in apps/mobile/src/features/files/FileTreeBrowser.tsx:122:
const [expandedPaths, setExpandedPaths] = useState<ReadonlySet<string>>(() => new Set());
Nothing writes either one to storage. The surrounding surface already persists plenty: open file tabs per thread in apps/web/src/rightPanelStore.ts (t3code:right-panel-state:v2), and even the explorer pane's own open/closed flag in apps/web/src/components/files/FilePreviewPanel.tsx:112 (t3code.fileExplorerOpen). So the tree's expansion is the odd one out, and it is the piece that costs the most clicks to rebuild.
Impact
Minor bug or occasional failure
Version or commit
0.0.41-nightly.20260910.1486
Environment
macOS 26.x, T3 Code Desktop (Nightly) 0.0.41-nightly.20260910.1486
Logs or stack traces
Workaround
None. Re-expand the path manually each time.
Related
- #8759 covers the right panel losing scroll position and diff folds. Same family of state loss, different state. Filing separately because the fix there (#8826) was already flagged as too broad, and this one is a self-contained addition to
FileBrowserPanel. - #3733 (preserve reasoning/tool trace expanded state when switching threads) and #4227 (expand/collapse all in the file surface) both landed, so persisting UI expansion is established behavior elsewhere in the app.
GPT 6 Astra via Codex in T3 Code.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with apps/web/src/components/files/FileBrowserPanel.tsx and apps/mobile/src/features/files/FileTreeBrowser.tsx, then read the persistence patterns in apps/web/src/rightPanelStore.ts and FilePreviewPanel.tsx. Check how expansion state is initialized and stored, and verify that expanded folders survive panel switches, thread changes, and remounts on the affected surfaces.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100