From c343931fec8946a46a05eba401570adc60d948a0 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Fri, 6 Feb 2026 13:21:52 +0700 Subject: [PATCH] Update files --- .../app/src/components/file-explorer-pane.tsx | 75 +++++++++++++++---- 1 file changed, 61 insertions(+), 14 deletions(-) diff --git a/packages/app/src/components/file-explorer-pane.tsx b/packages/app/src/components/file-explorer-pane.tsx index a7e555efe..9c1d90374 100644 --- a/packages/app/src/components/file-explorer-pane.tsx +++ b/packages/app/src/components/file-explorer-pane.tsx @@ -36,7 +36,11 @@ import { MoreVertical, X, } from "lucide-react-native"; -import type { ExplorerEntry, ExplorerFile } from "@/stores/session-store"; +import type { + AgentFileExplorerState, + ExplorerEntry, + ExplorerFile, +} from "@/stores/session-store"; import { useDaemonConnections } from "@/contexts/daemon-connections-context"; import { useSessionStore } from "@/stores/session-store"; import { useDownloadStore } from "@/stores/download-store"; @@ -312,6 +316,11 @@ export function FileExplorerPane({ serverId, agentId }: FileExplorerPaneProps) { const showInitialLoading = !directories.has(".") && Boolean(isExplorerLoading && pendingRequest?.mode === "list" && pendingRequest?.path === "."); + const showBackFromError = Boolean(error && selectedEntryPath); + const errorRecoveryPath = useMemo( + () => getErrorRecoveryPath(explorerState), + [explorerState] + ); const shouldShowInlinePreview = !isMobile && Boolean(selectedEntryPath); const minTreeWidth = 220; @@ -475,6 +484,17 @@ export function FileExplorerPane({ serverId, agentId }: FileExplorerPaneProps) { [] ); + const handleBackFromError = useCallback(() => { + if (!agentId || !requestDirectoryListing) { + return; + } + selectExplorerEntry(agentId, null); + requestDirectoryListing(agentId, errorRecoveryPath, { + recordHistory: false, + setCurrentPath: true, + }); + }, [agentId, errorRecoveryPath, requestDirectoryListing, selectExplorerEntry]); + if (!agentExists) { return ( @@ -491,19 +511,26 @@ export function FileExplorerPane({ serverId, agentId }: FileExplorerPaneProps) { {error ? ( {error} - { - if (agentId) { - requestDirectoryListing(agentId, ".", { - recordHistory: false, - setCurrentPath: false, - }); - } - }} - > - Retry - + + {showBackFromError ? ( + + Back + + ) : null} + { + if (agentId) { + requestDirectoryListing(agentId, ".", { + recordHistory: false, + setCurrentPath: false, + }); + } + }} + > + Retry + + ) : showInitialLoading ? ( @@ -960,6 +987,21 @@ function getAncestorDirectories(directory: string): string[] { return ancestors; } +function getErrorRecoveryPath(state: AgentFileExplorerState | undefined): string { + if (!state) { + return "."; + } + + const currentHistoryPath = + state.history.length > 0 ? state.history[state.history.length - 1] : null; + const candidate = currentHistoryPath ?? state.lastVisitedPath ?? state.currentPath; + + if (!candidate || candidate.length === 0) { + return "."; + } + return candidate; +} + const styles = StyleSheet.create((theme) => ({ container: { flex: 1, @@ -1065,6 +1107,11 @@ const styles = StyleSheet.create((theme) => ({ fontSize: theme.fontSize.sm, fontWeight: theme.fontWeight.semibold, }, + errorActions: { + flexDirection: "row", + alignItems: "center", + gap: theme.spacing[2], + }, emptyText: { color: theme.colors.foregroundMuted, fontSize: theme.fontSize.base,