Fix file explorer back loader

This commit is contained in:
Mohamed Boudra
2025-12-29 00:10:23 +07:00
parent 5120f73f49
commit 025fd97143
2 changed files with 34 additions and 12 deletions
+32 -11
View File
@@ -1603,6 +1603,7 @@ export function SessionProvider({ children, serverUrl, serverId }: SessionProvid
pendingRequest: { path: targetPath, mode: "list" },
currentPath: targetPath,
history: nextHistory,
lastVisitedPath: targetPath,
};
});
@@ -1610,18 +1611,38 @@ export function SessionProvider({ children, serverUrl, serverId }: SessionProvid
return null;
}
const msg: WSInboundMessage = {
type: "session",
message: {
type: "file_explorer_request",
agentId,
path: targetPath,
mode: "list",
},
};
ws.send(msg);
directoryListingRequest
.execute({ agentId, path: targetPath })
.then((payload) => {
updateExplorerState(agentId, (state: any) => {
const nextState: any = {
...state,
isLoading: false,
lastError: payload.error ?? null,
pendingRequest: null,
directories: state.directories,
files: state.files,
};
if (!payload.error && payload.directory) {
const directories = new Map(state.directories);
directories.set(payload.directory.path, payload.directory);
nextState.directories = directories;
}
return nextState;
});
})
.catch((error) => {
updateExplorerState(agentId, (state: any) => ({
...state,
isLoading: false,
lastError: error.message,
pendingRequest: null,
}));
});
return targetPath;
}, [updateExplorerState, ws]);
}, [directoryListingRequest, updateExplorerState]);
const refreshSession = useCallback(() => {
console.log(`[Session] Manual refresh requested for ${serverId}`);
+2 -1
View File
@@ -74,10 +74,11 @@ Improvements to the new agent screen in the app.
- Image timeouts should never crash the entire view.
- **Done (2025-12-29 00:01)**: WHAT: `packages/app/src/contexts/session-context.tsx:1550-1584` stops updating `lastError` during file preview requests so thumbnail timeouts no longer trigger the full-screen error state. RESULT: gallery image timeouts no longer replace the directory view; thumbnails remain in loading state. EVIDENCE: Not run (not requested).
- [ ] **Iteration 7**: Fix spurious loader showing at top of gallery even when directory has loaded.
- [x] **Iteration 7**: Fix spurious loader showing at top of gallery even when directory has loaded.
- Sometimes the loader at the top of the gallery keeps showing even when the directory content has clearly loaded.
- Investigate the loading state management and fix the race condition.
- **Done (2025-12-29 00:10)**: WHAT: `packages/app/src/contexts/session-context.tsx:1588-1645` routes back-navigation directory listings through the request helper and clears `pendingRequest`/`isLoading` on response. RESULT: gallery header loader no longer sticks after navigating back to cached directories. EVIDENCE: Not run (not requested).
- [ ] **Iteration 8**: Review and fix file/directory auto-linking logic.