Bug
When switching sessions in the web UI, the file explorer in the left sidebar does not correctly reflect the new session's working directory.
Two related issues:
1. Stale entries shown without loading indicator
If a session was previously visited, its root directory listing is cached. When switching back to it, the stale entries are shown without a loading indicator — the loadDirectory call updates them silently. This means the user can't tell whether the tree has refreshed.
2. No workdir path in the file tree header
The FileTree header only shows "Files". When switching sessions with different workdirs, there's no visual indicator of which session's directory is being browsed. Users may think the tree hasn't updated.
Root cause
In FileTree.tsx:
createEffect(
on(focusedSessionId, (sid, prev) => {
if (prev !== undefined && prev !== sid) {
resetFileTreeForSession(prev as string); // clears OLD session (memory cleanup)
}
if (sid) {
void loadDirectory(sid, "."); // starts fetch — but stale entries remain
}
}),
);
loadDirectory sets loading: true but does NOT clear existing entries. So the condition loading && entries === null (which shows the "loading…" indicator) is false when stale entries exist, and the stale data shows silently until the fresh response arrives.
In files.ts, loadDirectory:
setState("bySession", sessionId, path, {
loading: true,
error: null,
// entries NOT cleared — stale data persists
});
Fix
- Add a
{ clearFirst?: boolean } option to loadDirectory that clears entries before fetching — used on session switch (root reload) so the loading indicator always shows.
- Show the current session's workdir path in the FileTree header so the user can confirm which session they're browsing.
Files
web/src/state/files.ts — loadDirectory
web/src/components/files/FileTree.tsx — effect + header
Bug
When switching sessions in the web UI, the file explorer in the left sidebar does not correctly reflect the new session's working directory.
Two related issues:
1. Stale entries shown without loading indicator
If a session was previously visited, its root directory listing is cached. When switching back to it, the stale entries are shown without a loading indicator — the
loadDirectorycall updates them silently. This means the user can't tell whether the tree has refreshed.2. No workdir path in the file tree header
The FileTree header only shows "Files". When switching sessions with different workdirs, there's no visual indicator of which session's directory is being browsed. Users may think the tree hasn't updated.
Root cause
In
FileTree.tsx:loadDirectorysetsloading: truebut does NOT clear existingentries. So the conditionloading && entries === null(which shows the "loading…" indicator) is false when stale entries exist, and the stale data shows silently until the fresh response arrives.In
files.ts,loadDirectory:Fix
{ clearFirst?: boolean }option toloadDirectorythat clears entries before fetching — used on session switch (root reload) so the loading indicator always shows.Files
web/src/state/files.ts—loadDirectoryweb/src/components/files/FileTree.tsx— effect + header