Update files
This commit is contained in:
@@ -36,7 +36,11 @@ import {
|
|||||||
MoreVertical,
|
MoreVertical,
|
||||||
X,
|
X,
|
||||||
} from "lucide-react-native";
|
} 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 { useDaemonConnections } from "@/contexts/daemon-connections-context";
|
||||||
import { useSessionStore } from "@/stores/session-store";
|
import { useSessionStore } from "@/stores/session-store";
|
||||||
import { useDownloadStore } from "@/stores/download-store";
|
import { useDownloadStore } from "@/stores/download-store";
|
||||||
@@ -312,6 +316,11 @@ export function FileExplorerPane({ serverId, agentId }: FileExplorerPaneProps) {
|
|||||||
const showInitialLoading =
|
const showInitialLoading =
|
||||||
!directories.has(".") &&
|
!directories.has(".") &&
|
||||||
Boolean(isExplorerLoading && pendingRequest?.mode === "list" && pendingRequest?.path === ".");
|
Boolean(isExplorerLoading && pendingRequest?.mode === "list" && pendingRequest?.path === ".");
|
||||||
|
const showBackFromError = Boolean(error && selectedEntryPath);
|
||||||
|
const errorRecoveryPath = useMemo(
|
||||||
|
() => getErrorRecoveryPath(explorerState),
|
||||||
|
[explorerState]
|
||||||
|
);
|
||||||
|
|
||||||
const shouldShowInlinePreview = !isMobile && Boolean(selectedEntryPath);
|
const shouldShowInlinePreview = !isMobile && Boolean(selectedEntryPath);
|
||||||
const minTreeWidth = 220;
|
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) {
|
if (!agentExists) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.centerState}>
|
<View style={styles.centerState}>
|
||||||
@@ -491,19 +511,26 @@ export function FileExplorerPane({ serverId, agentId }: FileExplorerPaneProps) {
|
|||||||
{error ? (
|
{error ? (
|
||||||
<View style={styles.centerState}>
|
<View style={styles.centerState}>
|
||||||
<Text style={styles.errorText}>{error}</Text>
|
<Text style={styles.errorText}>{error}</Text>
|
||||||
<Pressable
|
<View style={styles.errorActions}>
|
||||||
style={styles.retryButton}
|
{showBackFromError ? (
|
||||||
onPress={() => {
|
<Pressable style={styles.retryButton} onPress={handleBackFromError}>
|
||||||
if (agentId) {
|
<Text style={styles.retryButtonText}>Back</Text>
|
||||||
requestDirectoryListing(agentId, ".", {
|
</Pressable>
|
||||||
recordHistory: false,
|
) : null}
|
||||||
setCurrentPath: false,
|
<Pressable
|
||||||
});
|
style={styles.retryButton}
|
||||||
}
|
onPress={() => {
|
||||||
}}
|
if (agentId) {
|
||||||
>
|
requestDirectoryListing(agentId, ".", {
|
||||||
<Text style={styles.retryButtonText}>Retry</Text>
|
recordHistory: false,
|
||||||
</Pressable>
|
setCurrentPath: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text style={styles.retryButtonText}>Retry</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
) : showInitialLoading ? (
|
) : showInitialLoading ? (
|
||||||
<View style={styles.centerState}>
|
<View style={styles.centerState}>
|
||||||
@@ -960,6 +987,21 @@ function getAncestorDirectories(directory: string): string[] {
|
|||||||
return ancestors;
|
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) => ({
|
const styles = StyleSheet.create((theme) => ({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
@@ -1065,6 +1107,11 @@ const styles = StyleSheet.create((theme) => ({
|
|||||||
fontSize: theme.fontSize.sm,
|
fontSize: theme.fontSize.sm,
|
||||||
fontWeight: theme.fontWeight.semibold,
|
fontWeight: theme.fontWeight.semibold,
|
||||||
},
|
},
|
||||||
|
errorActions: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: theme.spacing[2],
|
||||||
|
},
|
||||||
emptyText: {
|
emptyText: {
|
||||||
color: theme.colors.foregroundMuted,
|
color: theme.colors.foregroundMuted,
|
||||||
fontSize: theme.fontSize.base,
|
fontSize: theme.fontSize.base,
|
||||||
|
|||||||
Reference in New Issue
Block a user