fix: file explorer not switching workdir on session change - #37
Conversation
Three bugs in the file-tree state on session switch:
1. resetFileTreeForSession used `setState("bySession", id, {})` which is
a SolidJS merge (no-op) — the old session's entries were never cleared,
so stale data persisted and memory wasn't reclaimed.
Fixed by using produce() to perform a real replacement.
2. loadDirectory on session switch kept stale entries visible while the
new fetch was in-flight (loading indicator only fires when entries===null).
Added clearFirst option that wipes entries before the request, ensuring
the "loading…" indicator always appears on session switch.
3. FileTree header showed "Files" with no workdir path, so after switching
sessions the user couldn't tell which session's directory was shown.
Added a workdir label under the header that updates with focusedSession.
Closes #36
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe file tree now reloads the focused session root with explicit clearing, shows the active workdir in the header, and the file-tree store and tests support the new clear-first loading and reset behavior. ChangesFile tree session refresh
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #37 +/- ##
=======================================
Coverage 59.69% 59.69%
=======================================
Files 47 47
Lines 7255 7255
=======================================
Hits 4331 4331
Misses 2924 2924
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Patch release rolling up six fixes/doc changes since v0.1.1: - file explorer switches workdir on session change (#37) - interrupted tool calls marked cancelled, not failed (#35) - writeBatch guarded against in-flight streams; no TUI double-print (#33) - TUI reconnects + re-mints token on JWT expiry (#34) - Telegram /attach disconnects old session before switching (#29) - richer README badges (#27) Bumps package.json to 0.1.2 so the release.yml tag check passes, and backfills the previously-undocumented 0.1.1 entry in the CHANGELOG. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Three bugs in the file-tree state when switching sessions in the web UI:
1.
resetFileTreeForSessionwas a no-op (SolidJS merge bug)setState("bySession", id, {})uses SolidJS's path-setter with a plain-object argument, which performs a merge (not a replace). Since the merged object is empty, the old session's entries were never cleared — memory wasn't reclaimed and the old session's tree state persisted indefinitely.Fixed by using
produce()(immer-style assignment) to do an actual replacement.2. Stale entries shown without a loading indicator on session switch
loadDirectorysetsloading: truebut does not clear existingentries. The loading indicator condition isloading && entries === null, so if stale entries existed (from a previous visit), no spinner appeared. The user saw the old session's file listing while the new fetch was in-flight.Fixed by adding a
clearFirst?: booleanoption toloadDirectory. WhenclearFirst: true, entries are cleared before the request so theloading…spinner always appears. Used in the FileTree effect on every session switch.3. No workdir path shown in the FileTree header
The header displayed "Files" without indicating which session's working directory was shown. Users couldn't confirm the tree had switched sessions.
Fixed by adding the current session's workdir below the header (truncated with full path on hover).
Test plan
web/src/state/files.test.ts(9 new tests):loadDirectorywith/withoutclearFirst,resetFileTreeForSessionclears stateCloses #36
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes