feat(sidebar): implement canonicalize roots, authoritative mount handling & preserved incremental UX for local folder mode

This commit is contained in:
Anish Sarkar 2026-04-27 19:58:12 +05:30
parent dbdeaa1bcf
commit 95511f0915
5 changed files with 98 additions and 22 deletions

View file

@ -150,6 +150,13 @@ export function LocalFilesystemBrowser({
setMountByRootKey(new Map());
return;
}
if (rootPaths.length === 0) {
setMountByRootKey(new Map());
setMountStatus("complete");
setMountRefreshInFlight(false);
hasLoadedMountsOnceRef.current = true;
return;
}
let cancelled = false;
const isInitialMountLoad = !hasLoadedMountsOnceRef.current;
if (isInitialMountLoad) {
@ -161,13 +168,9 @@ export function LocalFilesystemBrowser({
.getAgentFilesystemMounts()
.then((mounts: LocalRootMount[]) => {
if (cancelled) return;
const knownRootKeys = new Set(
rootPaths.map((rootPath) => normalizeRootPathForLookup(rootPath, isWindowsPlatform))
);
const next = new Map<string, string>();
for (const entry of mounts) {
const normalizedRootKey = normalizeRootPathForLookup(entry.rootPath, isWindowsPlatform);
if (!knownRootKeys.has(normalizedRootKey)) continue;
next.set(normalizedRootKey, entry.mount);
}
setMountByRootKey(next);