feat: improve project directory picker

Adds command-palette style project browsing
Keeps native Finder picker as optional desktop action
Supports disabled existing projects and create-and-add paths
This commit is contained in:
Bohdan Triapitsyn
2026-04-27 15:45:14 +03:00
parent 54a09914ac
commit c83986cd94
14 changed files with 642 additions and 412 deletions
@@ -38,8 +38,6 @@ import { CSS } from '@dnd-kit/utilities';
import type { SessionContextUsage } from '@/stores/types/sessionTypes'; import type { SessionContextUsage } from '@/stores/types/sessionTypes';
import { PROJECT_ICON_MAP, PROJECT_COLOR_MAP, getProjectIconImageUrl } from '@/lib/projectMeta'; import { PROJECT_ICON_MAP, PROJECT_COLOR_MAP, getProjectIconImageUrl } from '@/lib/projectMeta';
import { useDirectoryStore } from '@/stores/useDirectoryStore'; import { useDirectoryStore } from '@/stores/useDirectoryStore';
import { toast } from '@/components/ui';
import { isTauriShell, isDesktopLocalOriginActive, requestDirectoryAccess } from '@/lib/desktop';
import { sessionEvents } from '@/lib/sessionEvents'; import { sessionEvents } from '@/lib/sessionEvents';
import { import {
Dialog, Dialog,
@@ -1450,7 +1448,6 @@ export const MobileSessionStatusBar: React.FC<MobileSessionStatusBarProps> = ({
const projects = useProjectsStore((state) => state.projects); const projects = useProjectsStore((state) => state.projects);
const activeProjectId = useProjectsStore((state) => state.activeProjectId); const activeProjectId = useProjectsStore((state) => state.activeProjectId);
const setActiveProject = useProjectsStore((state) => state.setActiveProject); const setActiveProject = useProjectsStore((state) => state.setActiveProject);
const addProject = useProjectsStore((state) => state.addProject);
const removeProject = useProjectsStore((state) => state.removeProject); const removeProject = useProjectsStore((state) => state.removeProject);
const getActiveProject = useProjectsStore((state) => state.getActiveProject); const getActiveProject = useProjectsStore((state) => state.getActiveProject);
@@ -1492,7 +1489,6 @@ export const MobileSessionStatusBar: React.FC<MobileSessionStatusBarProps> = ({
const contextUsage = getContextUsage(contextLimit, outputLimit); const contextUsage = getContextUsage(contextLimit, outputLimit);
const [isExpanded, setIsExpanded] = React.useState(false); const [isExpanded, setIsExpanded] = React.useState(false);
const tauriIpcAvailable = React.useMemo(() => isTauriShell(), []);
if (!isMobile || !showMobileSessionStatusBar || totalCount === 0) { if (!isMobile || !showMobileSessionStatusBar || totalCount === 0) {
return null; return null;
@@ -1520,29 +1516,7 @@ export const MobileSessionStatusBar: React.FC<MobileSessionStatusBarProps> = ({
}; };
const handleAddProject = () => { const handleAddProject = () => {
if (!tauriIpcAvailable || !isDesktopLocalOriginActive()) { sessionEvents.requestDirectoryDialog();
sessionEvents.requestDirectoryDialog();
return;
}
requestDirectoryAccess('')
.then((result) => {
if (result.success && result.path) {
const added = addProject(result.path, { id: result.projectId });
if (!added) {
toast.error(t('chat.mobileStatus.toast.addProjectFailed'), {
description: t('chat.mobileStatus.toast.selectValidDirectory'),
});
}
} else if (result.error && result.error !== 'Directory selection cancelled') {
toast.error(t('chat.mobileStatus.toast.selectDirectoryFailed'), {
description: result.error,
});
}
})
.catch((error) => {
console.error('Failed to select directory:', error);
toast.error(t('chat.mobileStatus.toast.selectDirectoryFailed'));
});
}; };
if (isMobileSessionStatusBarCollapsed) { if (isMobileSessionStatusBarCollapsed) {
@@ -7,52 +7,24 @@ import { SettingsSidebarItem } from '@/components/sections/shared/SettingsSideba
import { PROJECT_COLOR_MAP, PROJECT_ICON_MAP, getProjectIconImageUrl } from '@/lib/projectMeta'; import { PROJECT_COLOR_MAP, PROJECT_ICON_MAP, getProjectIconImageUrl } from '@/lib/projectMeta';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { RiAddLine, RiFolderLine } from '@remixicon/react'; import { RiAddLine, RiFolderLine } from '@remixicon/react';
import { isDesktopLocalOriginActive, isTauriShell, isVSCodeRuntime, requestDirectoryAccess } from '@/lib/desktop'; import { isVSCodeRuntime } from '@/lib/desktop';
import { sessionEvents } from '@/lib/sessionEvents'; import { sessionEvents } from '@/lib/sessionEvents';
import { toast } from '@/components/ui';
import { useThemeSystem } from '@/contexts/useThemeSystem'; import { useThemeSystem } from '@/contexts/useThemeSystem';
import { useI18n } from '@/lib/i18n'; import { useI18n } from '@/lib/i18n';
export const ProjectsSidebar: React.FC<{ onItemSelect?: () => void }> = ({ onItemSelect }) => { export const ProjectsSidebar: React.FC<{ onItemSelect?: () => void }> = ({ onItemSelect }) => {
const { t } = useI18n(); const { t } = useI18n();
const projects = useProjectsStore((state) => state.projects); const projects = useProjectsStore((state) => state.projects);
const addProject = useProjectsStore((state) => state.addProject);
const selectedId = useUIStore((state) => state.settingsProjectsSelectedId); const selectedId = useUIStore((state) => state.settingsProjectsSelectedId);
const setSelectedId = useUIStore((state) => state.setSettingsProjectsSelectedId); const setSelectedId = useUIStore((state) => state.setSettingsProjectsSelectedId);
const { currentTheme } = useThemeSystem(); const { currentTheme } = useThemeSystem();
const [brokenIconIds, setBrokenIconIds] = React.useState<Set<string>>(new Set()); const [brokenIconIds, setBrokenIconIds] = React.useState<Set<string>>(new Set());
const isVSCode = React.useMemo(() => isVSCodeRuntime(), []); const isVSCode = React.useMemo(() => isVSCodeRuntime(), []);
const tauriIpcAvailable = React.useMemo(() => isTauriShell(), []);
const handleAddProject = React.useCallback(() => { const handleAddProject = React.useCallback(() => {
if (!tauriIpcAvailable || !isDesktopLocalOriginActive()) { sessionEvents.requestDirectoryDialog();
sessionEvents.requestDirectoryDialog(); }, []);
return;
}
requestDirectoryAccess('')
.then((result) => {
if (result.success && result.path) {
const added = addProject(result.path, { id: result.projectId });
if (!added) {
toast.error(t('sessions.sidebar.directory.errorAddProjectTitle'), {
description: t('sessions.sidebar.directory.errorAddProjectDescription'),
});
return;
}
setSelectedId(added.id);
} else if (result.error && result.error !== 'Directory selection cancelled') {
toast.error(t('sessions.sidebar.directory.errorSelectDirectoryTitle'), {
description: result.error,
});
}
})
.catch((error) => {
console.error('Failed to select directory:', error);
toast.error(t('sessions.sidebar.directory.errorSelectDirectoryTitle'));
});
}, [addProject, setSelectedId, tauriIpcAvailable, t]);
React.useEffect(() => { React.useEffect(() => {
if (projects.length === 0) { if (projects.length === 0) {
@@ -9,19 +9,24 @@ import {
} from '@/components/ui/dialog'; } from '@/components/ui/dialog';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input'; import { Input } from '@/components/ui/input';
import { DirectoryTree } from './DirectoryTree';
import { useDirectoryStore } from '@/stores/useDirectoryStore'; import { useDirectoryStore } from '@/stores/useDirectoryStore';
import { useProjectsStore } from '@/stores/useProjectsStore'; import { useProjectsStore } from '@/stores/useProjectsStore';
import { useFileSystemAccess } from '@/hooks/useFileSystemAccess'; import { useFileSystemAccess } from '@/hooks/useFileSystemAccess';
import { cn, formatPathForDisplay } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { toast } from '@/components/ui'; import { toast } from '@/components/ui';
import { import {
RiArrowDownSLine,
RiArrowLeftSLine,
RiArrowUpSLine,
RiCheckboxBlankLine, RiCheckboxBlankLine,
RiCheckboxLine, RiCheckboxLine,
RiCornerDownLeftLine,
RiFolder6Line,
RiFolderAddLine,
} from '@remixicon/react'; } from '@remixicon/react';
import { useDeviceInfo } from '@/lib/device'; import { useDeviceInfo } from '@/lib/device';
import { MobileOverlayPanel } from '@/components/ui/MobileOverlayPanel'; import { MobileOverlayPanel } from '@/components/ui/MobileOverlayPanel';
import { DirectoryAutocomplete, type DirectoryAutocompleteHandle } from './DirectoryAutocomplete'; import { opencodeClient } from '@/lib/opencode/client';
import { import {
setDirectoryShowHidden, setDirectoryShowHidden,
useDirectoryShowHidden, useDirectoryShowHidden,
@@ -33,100 +38,327 @@ interface DirectoryExplorerDialogProps {
onOpenChange: (open: boolean) => void; onOpenChange: (open: boolean) => void;
} }
type BrowseEntry = {
name: string;
path: string;
};
type BrowseRow =
| { type: 'up'; value: 'browse:up'; name: string; path: string | null; disabled?: false }
| { type: 'directory'; value: string; name: string; path: string; disabled: boolean };
const isRootPath = (value: string): boolean => value === '/';
const normalizeSeparators = (value: string): string => value.replace(/\\/g, '/');
const trimTrailingSeparators = (value: string): string => {
if (!value || isRootPath(value)) return value;
let result = value;
while (result.length > 1 && result.endsWith('/')) {
result = result.slice(0, -1);
}
return result;
};
const hasTrailingPathSeparator = (value: string): boolean => value.endsWith('/');
const ensureBrowseDirectoryPath = (value: string): string => {
const trimmed = value.trim();
if (!trimmed || hasTrailingPathSeparator(trimmed)) return trimmed;
return `${trimmed}/`;
};
const getLastPathSeparatorIndex = (value: string): number => value.lastIndexOf('/');
const getBrowseDirectoryPath = (value: string): string => {
if (hasTrailingPathSeparator(value)) return value;
const lastSeparator = getLastPathSeparatorIndex(value);
if (lastSeparator < 0) return value;
return value.slice(0, lastSeparator + 1);
};
const getBrowseLeafPathSegment = (value: string): string => {
const lastSeparator = getLastPathSeparatorIndex(value);
return value.slice(lastSeparator + 1);
};
const getBrowseParentPath = (value: string): string | null => {
const trimmed = trimTrailingSeparators(value.trim());
if (!trimmed || trimmed === '~' || trimmed === '~/' || trimmed === '/') return null;
const lastSeparator = getLastPathSeparatorIndex(trimmed);
if (lastSeparator < 0) return null;
if (trimmed.startsWith('~/') && lastSeparator <= 1) return '~/';
if (lastSeparator === 0) return '/';
return `${trimmed.slice(0, lastSeparator)}/`;
};
const canNavigateUp = (value: string): boolean => hasTrailingPathSeparator(value) && getBrowseParentPath(value) !== null;
const appendBrowsePathSegment = (currentPath: string, segment: string): string => (
`${getBrowseDirectoryPath(currentPath)}${segment}/`
);
const normalizeDirectoryPath = (path: string | null | undefined): string | null => {
if (!path) return null;
const normalized = trimTrailingSeparators(normalizeSeparators(path.trim()));
if (!normalized) return null;
return normalized.toLowerCase();
};
const displayPathToAbsolutePath = (value: string, homeDirectory: string): string => {
const trimmed = value.trim();
if (trimmed === '~') return homeDirectory;
if (trimmed.startsWith('~/')) return `${homeDirectory}${trimmed.slice(1)}`;
return trimmed;
};
const isPrimaryModifierPressed = (event: React.KeyboardEvent<HTMLInputElement>): boolean => {
const isMac = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform);
return isMac ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey;
};
const focusPathInput = (input: HTMLInputElement | null): void => {
if (!input) return;
input.focus({ preventScroll: true });
const valueLength = input.value.length;
input.setSelectionRange(valueLength, valueLength);
input.scrollLeft = input.scrollWidth;
};
const resolveFreshFilesystemHome = async (): Promise<string | null> => {
try {
const response = await fetch('/api/fs/home', {
method: 'GET',
headers: { Accept: 'application/json' },
});
if (response.ok) {
const data = await response.json() as { home?: unknown };
if (typeof data.home === 'string' && data.home.trim().length > 0) {
return normalizeSeparators(data.home.trim());
}
}
} catch {
// Fall back to the client helper below.
}
return opencodeClient.getFilesystemHome().catch(() => null);
};
export const DirectoryExplorerDialog: React.FC<DirectoryExplorerDialogProps> = ({ export const DirectoryExplorerDialog: React.FC<DirectoryExplorerDialogProps> = ({
open, open,
onOpenChange, onOpenChange,
}) => { }) => {
const { t } = useI18n(); const { t } = useI18n();
const currentDirectory = useDirectoryStore((s) => s.currentDirectory);
const homeDirectory = useDirectoryStore((s) => s.homeDirectory); const homeDirectory = useDirectoryStore((s) => s.homeDirectory);
const isHomeReady = useDirectoryStore((s) => s.isHomeReady); const projects = useProjectsStore((s) => s.projects);
const addProject = useProjectsStore((s) => s.addProject); const addProject = useProjectsStore((s) => s.addProject);
const getActiveProject = useProjectsStore((s) => s.getActiveProject);
const [pendingPath, setPendingPath] = React.useState<string | null>(null);
const [pathInputValue, setPathInputValue] = React.useState('');
const [hasUserSelection, setHasUserSelection] = React.useState(false);
const [isConfirming, setIsConfirming] = React.useState(false);
const showHidden = useDirectoryShowHidden(); const showHidden = useDirectoryShowHidden();
const { isDesktop, requestAccess, startAccessing } = useFileSystemAccess(); const { isDesktop, requestAccess, startAccessing } = useFileSystemAccess();
const { isMobile } = useDeviceInfo(); const { isMobile } = useDeviceInfo();
const [autocompleteVisible, setAutocompleteVisible] = React.useState(false); const inputRef = React.useRef<HTMLInputElement>(null);
const autocompleteRef = React.useRef<DirectoryAutocompleteHandle>(null); const addButtonRef = React.useRef<HTMLButtonElement>(null);
const rowRefs = React.useRef(new Map<string, HTMLButtonElement>());
const [dialogHomeDirectory, setDialogHomeDirectory] = React.useState('');
const [query, setQuery] = React.useState('~/');
const [entries, setEntries] = React.useState<BrowseEntry[]>([]);
const [isLoading, setIsLoading] = React.useState(false);
const [isBrowseDirectoryMissing, setIsBrowseDirectoryMissing] = React.useState(false);
const [highlightedIndex, setHighlightedIndex] = React.useState(0);
const [isConfirming, setIsConfirming] = React.useState(false);
const [isOpeningFinder, setIsOpeningFinder] = React.useState(false);
const [addButtonWidth, setAddButtonWidth] = React.useState(0);
// Helper to format path for display const explorerRootDirectory = dialogHomeDirectory || homeDirectory;
const formatPath = React.useCallback((path: string | null) => {
if (!path) return ''; const addedProjectPaths = React.useMemo(() => new Set(
return formatPathForDisplay(path, homeDirectory); projects
}, [homeDirectory]); .map((project) => normalizeDirectoryPath(project.path))
.filter((path): path is string => Boolean(path))
), [projects]);
// Reset state when dialog opens
React.useEffect(() => { React.useEffect(() => {
if (open) { if (!open) return;
setHasUserSelection(false); setQuery('~/');
setIsConfirming(false); setEntries([]);
setAutocompleteVisible(false); setHighlightedIndex(0);
// Initialize with active project or current directory setIsConfirming(false);
const activeProject = getActiveProject(); setIsOpeningFinder(false);
const initialPath = activeProject?.path || currentDirectory || homeDirectory || ''; requestAnimationFrame(() => focusPathInput(inputRef.current));
setPendingPath(initialPath);
setPathInputValue(formatPath(initialPath)); let cancelled = false;
} const resolveHome = async () => {
}, [open, currentDirectory, homeDirectory, formatPath, getActiveProject]); const resolved = await resolveFreshFilesystemHome();
if (cancelled) return;
setDialogHomeDirectory(resolved || homeDirectory || '');
requestAnimationFrame(() => focusPathInput(inputRef.current));
};
void resolveHome();
return () => {
cancelled = true;
};
}, [homeDirectory, open]);
const browseDirectoryDisplayPath = React.useMemo(() => getBrowseDirectoryPath(query), [query]);
const browseFilterQuery = React.useMemo(
() => (hasTrailingPathSeparator(query) ? '' : getBrowseLeafPathSegment(query)),
[query]
);
const browseDirectoryAbsolutePath = React.useMemo(
() => explorerRootDirectory ? displayPathToAbsolutePath(browseDirectoryDisplayPath, explorerRootDirectory) : '',
[browseDirectoryDisplayPath, explorerRootDirectory]
);
// Set initial pending path to home when ready (only if not yet selected)
React.useEffect(() => { React.useEffect(() => {
if (!open || hasUserSelection || pendingPath) { if (!open || !browseDirectoryAbsolutePath) {
setEntries([]);
return; return;
} }
if (homeDirectory && isHomeReady) {
setPendingPath(homeDirectory);
setHasUserSelection(true);
setPathInputValue('~');
}
}, [open, hasUserSelection, pendingPath, homeDirectory, isHomeReady]);
let cancelled = false;
setIsLoading(true);
setIsBrowseDirectoryMissing(false);
opencodeClient.listLocalDirectory(browseDirectoryAbsolutePath)
.then((result) => {
if (cancelled) return;
setIsBrowseDirectoryMissing(false);
const nextEntries = result
.filter((entry) => entry.isDirectory)
.map((entry) => ({
name: entry.name,
path: normalizeSeparators(entry.path),
}))
.sort((left, right) => left.name.localeCompare(right.name));
setEntries(nextEntries);
})
.catch(() => {
if (!cancelled) {
setEntries([]);
setIsBrowseDirectoryMissing(true);
}
})
.finally(() => {
if (!cancelled) setIsLoading(false);
});
return () => {
cancelled = true;
};
}, [browseDirectoryAbsolutePath, open]);
const filteredEntries = React.useMemo(() => {
const lowerFilter = browseFilterQuery.toLowerCase();
const includeHidden = showHidden || browseFilterQuery.startsWith('.');
return entries.filter((entry) => (
entry.name.toLowerCase().startsWith(lowerFilter) && (includeHidden || !entry.name.startsWith('.'))
));
}, [browseFilterQuery, entries, showHidden]);
const rows = React.useMemo<BrowseRow[]>(() => {
const nextRows: BrowseRow[] = [];
if (canNavigateUp(query)) {
nextRows.push({ type: 'up', value: 'browse:up', name: '..', path: getBrowseParentPath(query) });
}
for (const entry of filteredEntries) {
const normalized = normalizeDirectoryPath(entry.path);
nextRows.push({
type: 'directory',
value: `browse:${entry.path}`,
name: entry.name,
path: entry.path,
disabled: Boolean(normalized && addedProjectPaths.has(normalized)),
});
}
return nextRows;
}, [addedProjectPaths, filteredEntries, query]);
React.useEffect(() => {
setHighlightedIndex(0);
}, [query, rows.length]);
const targetPath = React.useMemo(() => {
if (!explorerRootDirectory) return '';
return trimTrailingSeparators(displayPathToAbsolutePath(query, explorerRootDirectory));
}, [explorerRootDirectory, query]);
const normalizedTargetPath = normalizeDirectoryPath(targetPath);
const isAlreadyAdded = Boolean(normalizedTargetPath && addedProjectPaths.has(normalizedTargetPath));
const exactEntry = React.useMemo(() => {
if (!browseFilterQuery) return null;
return filteredEntries.find((entry) => entry.name === browseFilterQuery) ?? null;
}, [browseFilterQuery, filteredEntries]);
const shouldCreateTarget = Boolean(
targetPath
&& !isAlreadyAdded
&& (
(hasTrailingPathSeparator(query) && isBrowseDirectoryMissing)
|| (!hasTrailingPathSeparator(query) && browseFilterQuery.trim().length > 0 && exactEntry === null)
)
);
const canAddProject = !isConfirming && !isOpeningFinder && !isAlreadyAdded && Boolean(targetPath);
const highlightedRow = rows[highlightedIndex] ?? null;
const hasHighlightedBrowseItem = Boolean(
highlightedRow && (highlightedRow.type === 'up' || (highlightedRow.type === 'directory' && !highlightedRow.disabled))
);
const submitModifierLabel = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform)
? '⌘'
: 'Ctrl';
const submitActionLabel = isAlreadyAdded
? t('directoryExplorerDialog.actions.alreadyAdded')
: shouldCreateTarget
? t('directoryExplorerDialog.actions.createAndAdd')
: t('directoryExplorerDialog.actions.addProject');
React.useLayoutEffect(() => {
const button = addButtonRef.current;
if (!button) return;
const updateWidth = () => setAddButtonWidth(Math.ceil(button.getBoundingClientRect().width));
updateWidth();
if (typeof ResizeObserver === 'undefined') return;
const observer = new ResizeObserver(updateWidth);
observer.observe(button);
return () => observer.disconnect();
}, [submitActionLabel]);
React.useLayoutEffect(() => {
const input = inputRef.current;
if (!input) return;
input.scrollLeft = input.scrollWidth;
}, [addButtonWidth, query]);
React.useLayoutEffect(() => {
if (!open) return;
focusPathInput(inputRef.current);
}, [open]);
React.useLayoutEffect(() => {
const row = rows[highlightedIndex];
if (!row) return;
rowRefs.current.get(row.value)?.scrollIntoView({ block: 'nearest' });
}, [highlightedIndex, rows]);
const handleClose = React.useCallback(() => { const handleClose = React.useCallback(() => {
onOpenChange(false); onOpenChange(false);
}, [onOpenChange]); }, [onOpenChange]);
const finalizeSelection = React.useCallback(async (targetPath: string) => { const finalizeSelection = React.useCallback(async (target: string) => {
if (!targetPath || isConfirming) { if (!target || isConfirming) return;
return; const normalized = normalizeDirectoryPath(target);
} if (normalized && addedProjectPaths.has(normalized)) return;
setIsConfirming(true); setIsConfirming(true);
try { try {
let resolvedPath = targetPath; const shouldCreateSelection = shouldCreateTarget && normalizeDirectoryPath(target) === normalizeDirectoryPath(targetPath);
let projectId: string | undefined; if (shouldCreateSelection) {
await opencodeClient.createDirectory(target, { allowOutsideWorkspace: true });
if (isDesktop) {
const accessResult = await requestAccess(targetPath);
if (!accessResult.success) {
toast.error(t('directoryExplorerDialog.toast.unableToAccessDirectory'), {
description: accessResult.error || t('directoryExplorerDialog.toast.desktopDeniedAccess'),
});
return;
}
resolvedPath = accessResult.path ?? targetPath;
projectId = accessResult.projectId;
const startResult = await startAccessing(resolvedPath);
if (!startResult.success) {
toast.error(t('directoryExplorerDialog.toast.failedToOpenDirectory'), {
description: startResult.error || t('directoryExplorerDialog.toast.desktopCouldNotGrantAccess'),
});
return;
}
} }
const added = addProject(target);
const added = addProject(resolvedPath, { id: projectId });
if (!added) { if (!added) {
toast.error(t('directoryExplorerDialog.toast.failedToAddProject'), { toast.error(t('directoryExplorerDialog.toast.failedToAddProject'), {
description: t('directoryExplorerDialog.toast.selectValidDirectoryPath'), description: t('directoryExplorerDialog.toast.selectValidDirectoryPath'),
}); });
return; return;
} }
handleClose(); handleClose();
} catch (error) { } catch (error) {
toast.error(t('directoryExplorerDialog.toast.failedToSelectDirectory'), { toast.error(t('directoryExplorerDialog.toast.failedToSelectDirectory'), {
@@ -135,197 +367,241 @@ export const DirectoryExplorerDialog: React.FC<DirectoryExplorerDialogProps> = (
} finally { } finally {
setIsConfirming(false); setIsConfirming(false);
} }
}, [ }, [addProject, addedProjectPaths, handleClose, isConfirming, shouldCreateTarget, targetPath, t]);
addProject,
handleClose,
isDesktop,
requestAccess,
startAccessing,
isConfirming,
t,
]);
const handleConfirm = React.useCallback(async () => { const browseToDisplayPath = React.useCallback((displayPath: string) => {
const pathToUse = pathInputValue.trim() || pendingPath; setQuery(ensureBrowseDirectoryPath(displayPath));
if (!pathToUse) {
return;
}
await finalizeSelection(pathToUse);
}, [finalizeSelection, pathInputValue, pendingPath]);
const handleSelectPath = React.useCallback((path: string) => {
setPendingPath(path);
setHasUserSelection(true);
setPathInputValue(formatPath(path));
}, [formatPath]);
const handleDoubleClickPath = React.useCallback(async (path: string) => {
setPendingPath(path);
setHasUserSelection(true);
setPathInputValue(formatPath(path));
await finalizeSelection(path);
}, [finalizeSelection, formatPath]);
const handlePathInputChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
const value = e.target.value;
setPathInputValue(value);
setHasUserSelection(true);
// Show autocomplete when typing a path
setAutocompleteVisible(value.startsWith('/') || value.startsWith('~'));
// Update pending path if it looks like a valid path
if (value.startsWith('/') || value.startsWith('~')) {
// Expand ~ to home directory
const expandedPath = value.startsWith('~') && homeDirectory
? value.replace(/^~/, homeDirectory)
: value;
setPendingPath(expandedPath);
}
}, [homeDirectory]);
const handlePathInputKeyDown = React.useCallback((e: React.KeyboardEvent<HTMLInputElement>) => {
// Let autocomplete handle the key first if visible
if (autocompleteRef.current?.handleKeyDown(e)) {
return;
}
if (e.key === 'Enter') {
e.preventDefault();
handleConfirm();
}
}, [handleConfirm]);
const handleAutocompleteSuggestion = React.useCallback((path: string) => {
setPendingPath(path);
setHasUserSelection(true);
setPathInputValue(formatPath(path));
// Keep autocomplete open to allow further drilling down
}, [formatPath]);
const handleAutocompleteClose = React.useCallback(() => {
setAutocompleteVisible(false);
}, []); }, []);
const toggleShowHidden = React.useCallback(() => { const browseToEntry = React.useCallback((entry: BrowseEntry) => {
setDirectoryShowHidden(!showHidden); setQuery(appendBrowsePathSegment(query, entry.name));
}, [showHidden]); }, [query]);
const executeRow = React.useCallback((row: BrowseRow | null) => {
if (!row) return;
if (row.type === 'up') {
if (row.path) browseToDisplayPath(row.path);
return;
}
if (row.disabled) return;
browseToEntry(row);
}, [browseToDisplayPath, browseToEntry]);
const handleOpenInFinder = React.useCallback(async () => {
if (!isDesktop || isOpeningFinder) return;
setIsOpeningFinder(true);
try {
const result = await requestAccess(targetPath);
if (!result.success || !result.path) {
if (result.error && result.error !== 'Directory selection cancelled') {
toast.error(t('directoryExplorerDialog.toast.failedToSelectDirectory'), {
description: result.error,
});
}
return;
}
const accessResult = await startAccessing(result.path);
if (!accessResult.success) {
toast.error(t('directoryExplorerDialog.toast.failedToOpenDirectory'), {
description: accessResult.error || t('directoryExplorerDialog.toast.desktopCouldNotGrantAccess'),
});
return;
}
await finalizeSelection(result.path);
} catch (error) {
toast.error(t('directoryExplorerDialog.toast.failedToSelectDirectory'), {
description: error instanceof Error ? error.message : t('directoryExplorerDialog.toast.unknownError'),
});
} finally {
setIsOpeningFinder(false);
}
}, [finalizeSelection, isDesktop, isOpeningFinder, requestAccess, startAccessing, t, targetPath]);
const handleKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {
if (event.key === 'ArrowDown') {
event.preventDefault();
setHighlightedIndex((index) => Math.min(rows.length - 1, index + 1));
return;
}
if (event.key === 'ArrowUp') {
event.preventDefault();
setHighlightedIndex((index) => Math.max(0, index - 1));
return;
}
if (event.key === 'Enter') {
event.preventDefault();
if (isPrimaryModifierPressed(event)) {
void finalizeSelection(targetPath);
return;
}
if (hasHighlightedBrowseItem) {
executeRow(highlightedRow);
}
return;
}
if (event.key === 'Backspace' && query === '') {
event.preventDefault();
handleClose();
}
}, [executeRow, finalizeSelection, handleClose, hasHighlightedBrowseItem, highlightedRow, query, rows.length, targetPath]);
const showHiddenToggle = ( const showHiddenToggle = (
<button <button
type="button" type="button"
onClick={toggleShowHidden} onClick={() => setDirectoryShowHidden(!showHidden)}
className="flex items-center gap-2 px-2 py-1 rounded-lg hover:bg-interactive-hover/40 transition-colors typography-meta text-muted-foreground flex-shrink-0" className="flex flex-shrink-0 items-center gap-2 rounded-lg px-2 py-1 typography-meta text-muted-foreground transition-colors hover:bg-interactive-hover/40"
> >
{showHidden ? ( {showHidden ? <RiCheckboxLine className="h-4 w-4 text-primary" /> : <RiCheckboxBlankLine className="h-4 w-4" />}
<RiCheckboxLine className="h-4 w-4 text-primary" />
) : (
<RiCheckboxBlankLine className="h-4 w-4" />
)}
{t('directoryExplorerDialog.toggle.showHidden')} {t('directoryExplorerDialog.toggle.showHidden')}
</button> </button>
); );
const dialogHeader = ( const inputSection = (
<DialogHeader className="flex-shrink-0 px-4 pb-2 pt-[calc(var(--oc-safe-area-top,0px)+0.5rem)] sm:px-0 sm:pb-3 sm:pt-0"> <div className="relative px-2.5 py-1.5">
<DialogTitle>{t('directoryExplorerDialog.title')}</DialogTitle> <RiFolderAddLine className="pointer-events-none absolute left-5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/80" />
<div className="hidden sm:flex sm:items-center sm:justify-between sm:gap-4">
<DialogDescription className="flex-1">
{t('directoryExplorerDialog.description')}
</DialogDescription>
{showHiddenToggle}
</div>
</DialogHeader>
);
const pathInputSection = (
<div className="relative">
<Input <Input
value={pathInputValue} ref={inputRef}
onChange={handlePathInputChange} value={query}
onKeyDown={handlePathInputKeyDown} onChange={(event) => setQuery(normalizeSeparators(event.target.value))}
onKeyDown={handleKeyDown}
placeholder={t('directoryExplorerDialog.pathInput.placeholder')} placeholder={t('directoryExplorerDialog.pathInput.placeholder')}
className="font-mono typography-meta" className="border-transparent bg-transparent pl-9 font-mono typography-ui-label shadow-none focus-visible:ring-0"
style={!isMobile && addButtonWidth > 0 ? { paddingRight: `${addButtonWidth + 24}px` } : undefined}
spellCheck={false} spellCheck={false}
autoComplete="off" autoComplete="off"
autoCorrect="off" autoCorrect="off"
autoCapitalize="off" autoCapitalize="off"
/> />
<DirectoryAutocomplete {!isMobile ? (
ref={autocompleteRef} <Button
inputValue={pathInputValue} ref={addButtonRef}
homeDirectory={homeDirectory} variant="outline"
onSelectSuggestion={handleAutocompleteSuggestion} size="xs"
visible={autocompleteVisible} tabIndex={-1}
onClose={handleAutocompleteClose} className="absolute right-4 top-1/2 h-7 -translate-y-1/2 gap-1 px-2 typography-meta"
showHidden={showHidden} disabled={!canAddProject}
/> onMouseDown={(event) => event.preventDefault()}
onClick={() => void finalizeSelection(targetPath)}
title={submitActionLabel}
>
{submitActionLabel}
</Button>
) : null}
</div> </div>
); );
const treeSection = ( const resultsSection = (
<div className="flex-1 min-h-0 rounded-xl border border-border/40 bg-sidebar/70 overflow-hidden flex flex-col"> <div className="relative min-h-0 flex-1 overflow-hidden rounded-xl border border-border/60 bg-[var(--surface-elevated)] shadow-sm">
<DirectoryTree <div className="max-h-[min(28rem,58vh)] overflow-y-auto p-2">
variant="inline" <div className="px-2 pb-1 pt-0.5 typography-meta font-medium uppercase tracking-wide text-muted-foreground/80">
currentPath={pendingPath ?? currentDirectory} {t('directoryExplorerDialog.browse.directories')}
onSelectPath={handleSelectPath} </div>
onDoubleClickPath={handleDoubleClickPath} {isLoading ? (
className="flex-1 min-h-0 sm:min-h-[280px] sm:max-h-[380px]" <div className="py-10 text-center typography-ui-label text-muted-foreground">
selectionBehavior="deferred" {t('directoryExplorerDialog.browse.loading')}
showHidden={showHidden} </div>
rootDirectory={isHomeReady ? homeDirectory : null} ) : rows.length === 0 ? (
isRootReady={isHomeReady} <div className="py-10 text-center typography-ui-label text-muted-foreground">
/> {t('directoryExplorerDialog.browse.empty')}
</div> </div>
); ) : (
<div className="space-y-0.5">
// Mobile: use flex layout where tree takes remaining space {rows.map((row, index) => {
const mobileContent = ( const isActive = index === highlightedIndex;
<div className="flex h-full min-h-0 flex-col gap-3"> return (
<div className="flex-shrink-0">{pathInputSection}</div> <button
<div className="flex-shrink-0 flex items-center justify-end"> key={row.value}
{showHiddenToggle} ref={(node) => {
</div> if (node) {
<div className="flex-1 min-h-0 rounded-xl border border-border/40 bg-sidebar/70 overflow-hidden flex flex-col"> rowRefs.current.set(row.value, node);
<DirectoryTree } else {
variant="inline" rowRefs.current.delete(row.value);
currentPath={pendingPath ?? currentDirectory} }
onSelectPath={handleSelectPath} }}
onDoubleClickPath={handleDoubleClickPath} type="button"
className="flex-1 min-h-0" disabled={row.type === 'directory' && row.disabled}
selectionBehavior="deferred" onMouseEnter={() => setHighlightedIndex(index)}
showHidden={showHidden} onMouseDown={(event) => event.preventDefault()}
rootDirectory={isHomeReady ? homeDirectory : null} onClick={() => executeRow(row)}
isRootReady={isHomeReady} className={cn(
alwaysShowActions 'flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50',
/> isActive && 'bg-interactive-selection text-interactive-selection-foreground',
!isActive && 'hover:bg-interactive-hover/50',
row.type === 'directory' && row.disabled && 'cursor-not-allowed opacity-45 hover:bg-transparent'
)}
>
{row.type === 'up' ? (
<RiArrowLeftSLine className="h-4 w-4 flex-shrink-0 text-muted-foreground/80" />
) : (
<RiFolder6Line className="h-4 w-4 flex-shrink-0 text-muted-foreground/80" />
)}
<span className="flex min-w-0 flex-1 items-center gap-1.5">
<span className="truncate typography-ui-label text-foreground">{row.name}</span>
</span>
{row.type === 'directory' && row.disabled ? (
<span className="rounded-full border border-border/60 px-2 py-0.5 typography-meta text-muted-foreground">
{t('directoryExplorerDialog.browse.addedBadge')}
</span>
) : null}
</button>
);
})}
</div>
)}
</div> </div>
</div> </div>
); );
const desktopContent = ( const content = (
<div className="flex-1 min-h-0 overflow-hidden flex flex-col gap-3"> <div className="flex min-h-0 flex-1 flex-col gap-3">
{pathInputSection} {inputSection}
{treeSection} {resultsSection}
</div> </div>
); );
const renderActionButtons = () => ( const footerHints = (
<div className="flex flex-wrap items-center gap-x-3 gap-y-1 typography-micro text-muted-foreground">
<span className="inline-flex items-center gap-1">
<RiArrowUpSLine className="h-3.5 w-3.5" />
<RiArrowDownSLine className="-ml-1 h-3.5 w-3.5" />
{t('directoryExplorerDialog.footer.navigate')}
</span>
<span className="inline-flex items-center gap-1">
<RiCornerDownLeftLine className="h-3.5 w-3.5" />
{t('directoryExplorerDialog.footer.select')}
</span>
<span className="inline-flex items-center gap-1">
<span>{submitModifierLabel}</span>
<RiCornerDownLeftLine className="h-3.5 w-3.5" />
{t('directoryExplorerDialog.footer.add')}
</span>
<span className="inline-flex items-center gap-1">
<span>Esc</span>
{t('directoryExplorerDialog.footer.close')}
</span>
</div>
);
const renderFooter = () => (
<> <>
<Button {!isMobile ? footerHints : null}
variant="ghost" <div className={cn('flex w-full flex-row justify-end gap-2 sm:w-auto', isMobile && 'justify-stretch')}>
onClick={handleClose} {isDesktop ? (
disabled={isConfirming} <Button variant="ghost" size="xs" onClick={handleOpenInFinder} disabled={isConfirming || isOpeningFinder}>
className="flex-1 sm:flex-none sm:w-auto" {isOpeningFinder ? t('directoryExplorerDialog.actions.openingFinder') : t('directoryExplorerDialog.actions.openInFinder')}
> </Button>
{t('directoryExplorerDialog.actions.cancel')} ) : null}
</Button> <Button variant="ghost" size="xs" onClick={handleClose} disabled={isConfirming || isOpeningFinder} className={cn(isMobile && 'flex-1')}>
<Button {t('directoryExplorerDialog.actions.cancel')}
onClick={handleConfirm} </Button>
disabled={isConfirming || !hasUserSelection || (!pendingPath && !pathInputValue.trim())} {isMobile ? (
className="flex-1 sm:flex-none sm:w-auto sm:min-w-[140px]" <Button size="xs" onClick={() => void finalizeSelection(targetPath)} disabled={!canAddProject} className="flex-1">
> {submitActionLabel}
{isConfirming ? t('directoryExplorerDialog.actions.adding') : t('directoryExplorerDialog.actions.addProject')} </Button>
</Button> ) : null}
</div>
</> </>
); );
@@ -333,13 +609,16 @@ export const DirectoryExplorerDialog: React.FC<DirectoryExplorerDialogProps> = (
return ( return (
<MobileOverlayPanel <MobileOverlayPanel
open={open} open={open}
onClose={() => onOpenChange(false)} onClose={handleClose}
title={t('directoryExplorerDialog.title')} title={t('directoryExplorerDialog.title')}
className="h-[88dvh] max-h-[720px] max-w-full" className="h-[88dvh] max-h-[720px] max-w-full"
contentMaxHeightClassName="flex-1" contentMaxHeightClassName="flex-1"
footer={<div className="flex flex-row gap-2">{renderActionButtons()}</div>} footer={<div className="flex flex-col gap-2">{renderFooter()}</div>}
> >
{mobileContent} <div className="flex h-full min-h-0 flex-col gap-3">
<div className="flex justify-end">{showHiddenToggle}</div>
{content}
</div>
</MobileOverlayPanel> </MobileOverlayPanel>
); );
} }
@@ -347,20 +626,21 @@ export const DirectoryExplorerDialog: React.FC<DirectoryExplorerDialogProps> = (
return ( return (
<Dialog open={open} onOpenChange={onOpenChange}> <Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent <DialogContent
className={cn( className="flex w-full max-w-xl flex-col gap-0 overflow-hidden p-0 sm:max-h-[80vh]"
'flex w-full max-w-[min(560px,100vw)] max-h-[calc(100vh-32px)] flex-col gap-0 overflow-hidden p-0 sm:max-h-[80vh] sm:max-w-xl sm:p-6' onOpenAutoFocus={(event) => event.preventDefault()}
)}
onOpenAutoFocus={(e) => {
// Prevent auto-focus on input to avoid text selection
e.preventDefault();
}}
> >
{dialogHeader} <DialogHeader className="px-5 pb-2 pt-5">
{desktopContent} <div className="flex items-start justify-between gap-4">
<DialogFooter <div>
className="sticky bottom-0 flex w-full flex-shrink-0 flex-row gap-2 border-t border-border/40 bg-sidebar px-4 py-3 sm:static sm:justify-end sm:border-0 sm:bg-transparent sm:px-0 sm:pt-4 sm:pb-0" <DialogTitle>{t('directoryExplorerDialog.title')}</DialogTitle>
> <DialogDescription className="mt-2">{t('directoryExplorerDialog.description')}</DialogDescription>
{renderActionButtons()} </div>
{showHiddenToggle}
</div>
</DialogHeader>
<div className="min-h-0 flex-1 px-2 pb-0">{content}</div>
<DialogFooter className="flex w-full flex-col gap-3 px-5 py-3 sm:flex-row sm:items-center sm:justify-between">
{renderFooter()}
</DialogFooter> </DialogFooter>
</DialogContent> </DialogContent>
</Dialog> </Dialog>
@@ -39,6 +39,7 @@ interface DirectoryTreeProps {
isRootReady?: boolean; isRootReady?: boolean;
/** Always show action icons (add, pin) instead of only on hover */ /** Always show action icons (add, pin) instead of only on hover */
alwaysShowActions?: boolean; alwaysShowActions?: boolean;
disabledPaths?: Iterable<string>;
} }
export const DirectoryTree: React.FC<DirectoryTreeProps> = ({ export const DirectoryTree: React.FC<DirectoryTreeProps> = ({
@@ -53,6 +54,7 @@ export const DirectoryTree: React.FC<DirectoryTreeProps> = ({
rootDirectory = null, rootDirectory = null,
isRootReady, isRootReady,
alwaysShowActions = false, alwaysShowActions = false,
disabledPaths,
}) => { }) => {
const { t } = useI18n(); const { t } = useI18n();
const { isMobile } = useDeviceInfo(); const { isMobile } = useDeviceInfo();
@@ -85,6 +87,20 @@ export const DirectoryTree: React.FC<DirectoryTreeProps> = ({
return trimmed.length === 0 ? '/' : trimmed; return trimmed.length === 0 ? '/' : trimmed;
}, []); }, []);
const normalizedDisabledPaths = React.useMemo(() => {
const normalized = new Set<string>();
for (const path of disabledPaths ?? []) {
const value = stripTrailingSlashes(path.replace(/\\/g, '/'));
if (value) normalized.add(value.toLowerCase());
}
return normalized;
}, [disabledPaths, stripTrailingSlashes]);
const isPathDisabled = React.useCallback((path: string) => {
const normalized = stripTrailingSlashes(path.replace(/\\/g, '/'));
return normalized ? normalizedDisabledPaths.has(normalized.toLowerCase()) : false;
}, [normalizedDisabledPaths, stripTrailingSlashes]);
const normalizedHomeDirectory = React.useMemo(() => { const normalizedHomeDirectory = React.useMemo(() => {
if (!homeDirectory) { if (!homeDirectory) {
return null; return null;
@@ -665,6 +681,7 @@ export const DirectoryTree: React.FC<DirectoryTreeProps> = ({
const isPinned = pinnedPaths.has(item.path); const isPinned = pinnedPaths.has(item.path);
const isSelected = currentPath === item.path; const isSelected = currentPath === item.path;
const isInlineVariant = variant === 'inline'; const isInlineVariant = variant === 'inline';
const isDisabled = isPathDisabled(item.path);
const rowContent = ( const rowContent = (
<> <>
@@ -688,6 +705,9 @@ export const DirectoryTree: React.FC<DirectoryTreeProps> = ({
<button <button
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
if (isDisabled) {
return;
}
handleDirectorySelect(item.path); handleDirectorySelect(item.path);
if (variant === 'dropdown' && selectionBehavior === 'immediate') { if (variant === 'dropdown' && selectionBehavior === 'immediate') {
setIsOpen(false); setIsOpen(false);
@@ -695,13 +715,15 @@ export const DirectoryTree: React.FC<DirectoryTreeProps> = ({
}} }}
onDoubleClick={(e) => { onDoubleClick={(e) => {
e.stopPropagation(); e.stopPropagation();
if (onDoubleClickPath) { if (!isDisabled && onDoubleClickPath) {
onDoubleClickPath(item.path); onDoubleClickPath(item.path);
} }
}} }}
disabled={isDisabled}
className={cn( className={cn(
'flex items-center flex-1 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/60 rounded', 'flex items-center flex-1 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/60 rounded',
isMobile ? 'gap-1.5' : 'gap-1.5', isMobile ? 'gap-1.5' : 'gap-1.5',
isDisabled && 'cursor-not-allowed opacity-45',
isInlineVariant ? (isSelected ? 'text-primary' : 'text-foreground') : 'text-foreground' isInlineVariant ? (isSelected ? 'text-primary' : 'text-foreground') : 'text-foreground'
)} )}
> >
@@ -709,6 +731,7 @@ export const DirectoryTree: React.FC<DirectoryTreeProps> = ({
className={cn( className={cn(
'text-muted-foreground flex-shrink-0', 'text-muted-foreground flex-shrink-0',
isMobile ? 'h-4 w-4' : 'h-3.5 w-3.5', isMobile ? 'h-4 w-4' : 'h-3.5 w-3.5',
isDisabled && 'text-muted-foreground',
isInlineVariant && isSelected && 'text-primary' isInlineVariant && isSelected && 'text-primary'
)} )}
/> />
@@ -716,6 +739,7 @@ export const DirectoryTree: React.FC<DirectoryTreeProps> = ({
className={cn( className={cn(
'font-medium truncate', 'font-medium truncate',
isMobile ? 'typography-ui-label' : 'typography-ui-label', isMobile ? 'typography-ui-label' : 'typography-ui-label',
isDisabled && 'text-muted-foreground',
isInlineVariant && isSelected ? 'text-primary' : 'text-foreground' isInlineVariant && isSelected ? 'text-primary' : 'text-foreground'
)} )}
> >
@@ -768,7 +792,9 @@ export const DirectoryTree: React.FC<DirectoryTreeProps> = ({
isMobile ? 'px-1.5 py-1' : 'px-2 py-1.5', isMobile ? 'px-1.5 py-1' : 'px-2 py-1.5',
isSelected isSelected
? 'bg-primary/10 text-primary' ? 'bg-primary/10 text-primary'
: 'hover:bg-interactive-hover/50 text-foreground' : isDisabled
? 'text-muted-foreground'
: 'hover:bg-interactive-hover/50 text-foreground'
)} )}
style={{ paddingLeft: `${level * (isMobile ? 12 : 14) + (isMobile ? 4 : 6)}px` }} style={{ paddingLeft: `${level * (isMobile ? 12 : 14) + (isMobile ? 4 : 6)}px` }}
> >
@@ -23,8 +23,6 @@ import * as sessionActions from '@/sync/session-actions';
import { useDirectoryStore } from '@/stores/useDirectoryStore'; import { useDirectoryStore } from '@/stores/useDirectoryStore';
import { useProjectsStore } from '@/stores/useProjectsStore'; import { useProjectsStore } from '@/stores/useProjectsStore';
import { useUIStore } from '@/stores/useUIStore'; import { useUIStore } from '@/stores/useUIStore';
import { useFileSystemAccess } from '@/hooks/useFileSystemAccess';
import { isDesktopLocalOriginActive, isTauriShell } from '@/lib/desktop';
import { useDeviceInfo } from '@/lib/device'; import { useDeviceInfo } from '@/lib/device';
import { sessionEvents } from '@/lib/sessionEvents'; import { sessionEvents } from '@/lib/sessionEvents';
import { useI18n } from '@/lib/i18n'; import { useI18n } from '@/lib/i18n';
@@ -76,9 +74,7 @@ export const SessionDialogs: React.FC = () => {
const homeDirectory = useDirectoryStore((s) => s.homeDirectory); const homeDirectory = useDirectoryStore((s) => s.homeDirectory);
const isHomeReady = useDirectoryStore((s) => s.isHomeReady); const isHomeReady = useDirectoryStore((s) => s.isHomeReady);
const projects = useProjectsStore((s) => s.projects); const projects = useProjectsStore((s) => s.projects);
const addProject = useProjectsStore((s) => s.addProject);
const activeProjectId = useProjectsStore((s) => s.activeProjectId); const activeProjectId = useProjectsStore((s) => s.activeProjectId);
const { requestAccess, startAccessing } = useFileSystemAccess();
const { isMobile, isTablet, hasTouchInput } = useDeviceInfo(); const { isMobile, isTablet, hasTouchInput } = useDeviceInfo();
const useMobileOverlay = isMobile || isTablet || hasTouchInput; const useMobileOverlay = isMobile || isTablet || hasTouchInput;
@@ -126,49 +122,11 @@ export const SessionDialogs: React.FC = () => {
setHasShownInitialDirectoryPrompt(true); setHasShownInitialDirectoryPrompt(true);
if (isTauriShell() && isDesktopLocalOriginActive()) {
requestAccess('')
.then(async (result) => {
if (!result.success || !result.path) {
if (result.error && result.error !== 'Directory selection cancelled') {
toast.error(t('sessions.sidebar.sessionDialogs.directory.errorSelectTitle'), {
description: result.error,
});
}
return;
}
const accessResult = await startAccessing(result.path);
if (!accessResult.success) {
toast.error(t('sessions.sidebar.sessionDialogs.directory.errorOpenTitle'), {
description: accessResult.error || t('sessions.sidebar.sessionDialogs.directory.errorOpenDescription'),
});
return;
}
const added = addProject(result.path, { id: result.projectId });
if (!added) {
toast.error(t('sessions.sidebar.sessionDialogs.directory.errorAddProjectTitle'), {
description: t('sessions.sidebar.sessionDialogs.directory.errorAddProjectDescription'),
});
}
})
.catch((error) => {
console.error('Desktop: Error selecting directory:', error);
toast.error(t('sessions.sidebar.sessionDialogs.directory.errorSelectTitle'));
});
return;
}
setIsDirectoryDialogOpen(true); setIsDirectoryDialogOpen(true);
}, [ }, [
addProject,
hasShownInitialDirectoryPrompt, hasShownInitialDirectoryPrompt,
isHomeReady, isHomeReady,
projects.length, projects.length,
requestAccess,
startAccessing,
t,
]); ]);
const openDeleteDialog = React.useCallback((payload: { sessions: Session[]; dateLabel?: string; mode?: 'session' | 'worktree'; worktree?: WorktreeMetadata | null }) => { const openDeleteDialog = React.useCallback((payload: { sessions: Session[]; dateLabel?: string; mode?: 'session' | 'worktree'; worktree?: WorktreeMetadata | null }) => {
@@ -4,7 +4,7 @@ import { RiLayoutLeftLine } from '@remixicon/react';
import { toast } from '@/components/ui'; import { toast } from '@/components/ui';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'; import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
import { useI18n } from '@/lib/i18n'; import { useI18n } from '@/lib/i18n';
import { isDesktopLocalOriginActive, isDesktopShell, isTauriShell } from '@/lib/desktop'; import { isDesktopShell } from '@/lib/desktop';
import { isDesktopWindowFullscreen as getDesktopWindowFullscreen, onDesktopWindowResized, startDesktopWindowDrag } from '@/lib/desktopNative'; import { isDesktopWindowFullscreen as getDesktopWindowFullscreen, onDesktopWindowResized, startDesktopWindowDrag } from '@/lib/desktopNative';
import { sessionEvents } from '@/lib/sessionEvents'; import { sessionEvents } from '@/lib/sessionEvents';
import { formatDirectoryName, cn } from '@/lib/utils'; import { formatDirectoryName, cn } from '@/lib/utils';
@@ -249,7 +249,6 @@ export const SessionSidebar: React.FC<SessionSidebarProps> = ({
const projects = useProjectsStore((state) => state.projects); const projects = useProjectsStore((state) => state.projects);
const activeProjectId = useProjectsStore((state) => state.activeProjectId); const activeProjectId = useProjectsStore((state) => state.activeProjectId);
const addProject = useProjectsStore((state) => state.addProject);
const removeProject = useProjectsStore((state) => state.removeProject); const removeProject = useProjectsStore((state) => state.removeProject);
const setActiveProjectIdOnly = useProjectsStore((state) => state.setActiveProjectIdOnly); const setActiveProjectIdOnly = useProjectsStore((state) => state.setActiveProjectIdOnly);
const updateProjectMeta = useProjectsStore((state) => state.updateProjectMeta); const updateProjectMeta = useProjectsStore((state) => state.updateProjectMeta);
@@ -430,7 +429,6 @@ export const SessionSidebar: React.FC<SessionSidebarProps> = ({
}; };
}, []); }, []);
const tauriIpcAvailable = React.useMemo(() => isTauriShell(), []);
const isDesktopShellRuntime = React.useMemo(() => isDesktopShell(), []); const isDesktopShellRuntime = React.useMemo(() => isDesktopShell(), []);
const [isDesktopWindowFullscreen, setIsDesktopWindowFullscreen] = React.useState(false); const [isDesktopWindowFullscreen, setIsDesktopWindowFullscreen] = React.useState(false);
@@ -690,32 +688,8 @@ export const SessionSidebar: React.FC<SessionSidebarProps> = ({
}, [deleteFolderConfirm, deleteFolder]); }, [deleteFolderConfirm, deleteFolder]);
const handleOpenDirectoryDialog = React.useCallback(() => { const handleOpenDirectoryDialog = React.useCallback(() => {
if (!tauriIpcAvailable || !isDesktopLocalOriginActive()) { sessionEvents.requestDirectoryDialog();
sessionEvents.requestDirectoryDialog(); }, []);
return;
}
import('@/lib/desktop')
.then(({ requestDirectoryAccess }) => requestDirectoryAccess(''))
.then((result) => {
if (result.success && result.path) {
const added = addProject(result.path, { id: result.projectId });
if (!added) {
toast.error(t('sessions.sidebar.directory.errorAddProjectTitle'), {
description: t('sessions.sidebar.directory.errorAddProjectDescription'),
});
}
} else if (result.error && result.error !== 'Directory selection cancelled') {
toast.error(t('sessions.sidebar.directory.errorSelectDirectoryTitle'), {
description: result.error,
});
}
})
.catch((error) => {
console.error('Desktop: Error selecting directory:', error);
toast.error(t('sessions.sidebar.directory.errorSelectDirectoryTitle'));
});
}, [addProject, t, tauriIpcAvailable]);
// Auto-expand parent session when navigating to a subagent (child) session // Auto-expand parent session when navigating to a subagent (child) session
React.useEffect(() => { React.useEffect(() => {
+2 -2
View File
@@ -1,11 +1,11 @@
import { useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
import { isTauriShell, requestDirectoryAccess, startAccessingDirectory, stopAccessingDirectory } from '@/lib/desktop'; import { isDesktopShell, requestDirectoryAccess, startAccessingDirectory, stopAccessingDirectory } from '@/lib/desktop';
export const useFileSystemAccess = () => { export const useFileSystemAccess = () => {
const [isDesktop, setIsDesktop] = useState(false); const [isDesktop, setIsDesktop] = useState(false);
useEffect(() => { useEffect(() => {
setIsDesktop(isTauriShell()); setIsDesktop(isDesktopShell());
}, []); }, []);
const requestAccess = useCallback(async (directoryPath: string): Promise<{ success: boolean; path?: string; projectId?: string; error?: string }> => { const requestAccess = useCallback(async (directoryPath: string): Promise<{ success: boolean; path?: string; projectId?: string; error?: string }> => {
+1 -39
View File
@@ -2,12 +2,9 @@ import React from 'react';
import { toast } from '@/components/ui'; import { toast } from '@/components/ui';
import { useSessionUIStore } from '@/sync/session-ui-store'; import { useSessionUIStore } from '@/sync/session-ui-store';
import { useUIStore } from '@/stores/useUIStore'; import { useUIStore } from '@/stores/useUIStore';
import { useProjectsStore } from '@/stores/useProjectsStore';
import { useUpdateStore } from '@/stores/useUpdateStore'; import { useUpdateStore } from '@/stores/useUpdateStore';
import { useThemeSystem } from '@/contexts/useThemeSystem'; import { useThemeSystem } from '@/contexts/useThemeSystem';
import { sessionEvents } from '@/lib/sessionEvents'; import { sessionEvents } from '@/lib/sessionEvents';
import { isTauriShell } from '@/lib/desktop';
import { useFileSystemAccess } from '@/hooks/useFileSystemAccess';
import { createWorktreeSession } from '@/lib/worktreeSessionCreator'; import { createWorktreeSession } from '@/lib/worktreeSessionCreator';
import { showOpenCodeStatus } from '@/lib/openCodeStatus'; import { showOpenCodeStatus } from '@/lib/openCodeStatus';
@@ -100,9 +97,7 @@ export const useMenuActions = (
const setActiveMainTab = useUIStore((s) => s.setActiveMainTab); const setActiveMainTab = useUIStore((s) => s.setActiveMainTab);
const setSettingsDialogOpen = useUIStore((s) => s.setSettingsDialogOpen); const setSettingsDialogOpen = useUIStore((s) => s.setSettingsDialogOpen);
const setAboutDialogOpen = useUIStore((s) => s.setAboutDialogOpen); const setAboutDialogOpen = useUIStore((s) => s.setAboutDialogOpen);
const addProject = useProjectsStore((s) => s.addProject);
const checkForUpdates = useUpdateStore((state) => state.checkForUpdates); const checkForUpdates = useUpdateStore((state) => state.checkForUpdates);
const { requestAccess, startAccessing } = useFileSystemAccess();
const { setThemeMode } = useThemeSystem(); const { setThemeMode } = useThemeSystem();
const checkUpdatesInFlightRef = React.useRef(false); const checkUpdatesInFlightRef = React.useRef(false);
@@ -132,41 +127,8 @@ export const useMenuActions = (
}, [checkForUpdates]); }, [checkForUpdates]);
const handleChangeWorkspace = React.useCallback(() => { const handleChangeWorkspace = React.useCallback(() => {
if (isTauriShell()) {
requestAccess('')
.then(async (result) => {
if (!result.success || !result.path) {
if (result.error && result.error !== 'Directory selection cancelled') {
toast.error('Failed to select directory', {
description: result.error,
});
}
return;
}
const accessResult = await startAccessing(result.path);
if (!accessResult.success) {
toast.error('Failed to open directory', {
description: accessResult.error || 'Desktop could not grant file access.',
});
return;
}
const added = addProject(result.path, { id: result.projectId });
if (!added) {
toast.error('Failed to add project', {
description: 'Please select a valid directory path.',
});
}
})
.catch((error) => {
console.error('Desktop: Error selecting directory:', error);
toast.error('Failed to select directory');
});
}
sessionEvents.requestDirectoryDialog(); sessionEvents.requestDirectoryDialog();
}, [addProject, requestAccess, startAccessing]); }, []);
const handleAction = React.useCallback( const handleAction = React.useCallback(
(action: MenuAction) => { (action: MenuAction) => {
+14
View File
@@ -997,8 +997,22 @@ export const dict = {
'directoryExplorerDialog.toggle.showHidden': 'Show hidden', 'directoryExplorerDialog.toggle.showHidden': 'Show hidden',
'directoryExplorerDialog.pathInput.placeholder': 'Enter path or select from tree...', 'directoryExplorerDialog.pathInput.placeholder': 'Enter path or select from tree...',
'directoryExplorerDialog.actions.cancel': 'Cancel', 'directoryExplorerDialog.actions.cancel': 'Cancel',
'directoryExplorerDialog.actions.openingFinder': 'Opening...',
'directoryExplorerDialog.actions.openInFinder': 'Open in Finder',
'directoryExplorerDialog.actions.adding': 'Adding...', 'directoryExplorerDialog.actions.adding': 'Adding...',
'directoryExplorerDialog.actions.addProject': 'Add project', 'directoryExplorerDialog.actions.addProject': 'Add project',
'directoryExplorerDialog.actions.createAndAdd': 'Create & add',
'directoryExplorerDialog.actions.alreadyAdded': 'Already added',
'directoryExplorerDialog.browse.directories': 'Directories',
'directoryExplorerDialog.browse.loading': 'Loading directories...',
'directoryExplorerDialog.browse.empty': 'No matching directories.',
'directoryExplorerDialog.browse.parentDirectory': 'Parent directory',
'directoryExplorerDialog.browse.addedBadge': 'Added',
'directoryExplorerDialog.footer.navigate': 'Navigate',
'directoryExplorerDialog.footer.select': 'Select',
'directoryExplorerDialog.footer.add': 'Add',
'directoryExplorerDialog.footer.close': 'Close',
'directoryExplorerDialog.shortcut.enter': 'Enter',
'directoryExplorerDialog.toast.unableToAccessDirectory': 'Unable to access directory', 'directoryExplorerDialog.toast.unableToAccessDirectory': 'Unable to access directory',
'directoryExplorerDialog.toast.desktopDeniedAccess': 'Desktop denied directory access.', 'directoryExplorerDialog.toast.desktopDeniedAccess': 'Desktop denied directory access.',
'directoryExplorerDialog.toast.failedToOpenDirectory': 'Failed to open directory', 'directoryExplorerDialog.toast.failedToOpenDirectory': 'Failed to open directory',
+14
View File
@@ -998,8 +998,22 @@ export const dict: Record<I18nKey, string> = {
"directoryExplorerDialog.toggle.showHidden": "Mostrar ocultos", "directoryExplorerDialog.toggle.showHidden": "Mostrar ocultos",
"directoryExplorerDialog.pathInput.placeholder": "Escribe la ruta o selecciona desde el árbol...", "directoryExplorerDialog.pathInput.placeholder": "Escribe la ruta o selecciona desde el árbol...",
"directoryExplorerDialog.actions.cancel": "Cancelar", "directoryExplorerDialog.actions.cancel": "Cancelar",
"directoryExplorerDialog.actions.openingFinder": "Abriendo...",
"directoryExplorerDialog.actions.openInFinder": "Abrir en Finder",
"directoryExplorerDialog.actions.adding": "Añadiendo...", "directoryExplorerDialog.actions.adding": "Añadiendo...",
"directoryExplorerDialog.actions.addProject": "Añadir proyecto", "directoryExplorerDialog.actions.addProject": "Añadir proyecto",
"directoryExplorerDialog.actions.createAndAdd": "Crear y añadir",
"directoryExplorerDialog.actions.alreadyAdded": "Ya añadido",
"directoryExplorerDialog.browse.directories": "Directorios",
"directoryExplorerDialog.browse.loading": "Cargando directorios...",
"directoryExplorerDialog.browse.empty": "No hay directorios coincidentes.",
"directoryExplorerDialog.browse.parentDirectory": "Directorio padre",
"directoryExplorerDialog.browse.addedBadge": "Añadido",
"directoryExplorerDialog.footer.navigate": "Navegar",
"directoryExplorerDialog.footer.select": "Seleccionar",
"directoryExplorerDialog.footer.add": "Añadir",
"directoryExplorerDialog.footer.close": "Cerrar",
"directoryExplorerDialog.shortcut.enter": "Enter",
"directoryExplorerDialog.toast.unableToAccessDirectory": "No se puede acceder al directorio", "directoryExplorerDialog.toast.unableToAccessDirectory": "No se puede acceder al directorio",
"directoryExplorerDialog.toast.desktopDeniedAccess": "El escritorio denegó el acceso al directorio.", "directoryExplorerDialog.toast.desktopDeniedAccess": "El escritorio denegó el acceso al directorio.",
"directoryExplorerDialog.toast.failedToOpenDirectory": "No se pudo abrir el directorio", "directoryExplorerDialog.toast.failedToOpenDirectory": "No se pudo abrir el directorio",
+14
View File
@@ -998,8 +998,22 @@ export const dict: Record<I18nKey, string> = {
'directoryExplorerDialog.toggle.showHidden': '표시 hidden', 'directoryExplorerDialog.toggle.showHidden': '표시 hidden',
'directoryExplorerDialog.pathInput.placeholder': '경로를 입력하거나 트리에서 선택…', 'directoryExplorerDialog.pathInput.placeholder': '경로를 입력하거나 트리에서 선택…',
'directoryExplorerDialog.actions.cancel': '취소', 'directoryExplorerDialog.actions.cancel': '취소',
'directoryExplorerDialog.actions.openingFinder': '여는 중...',
'directoryExplorerDialog.actions.openInFinder': 'Finder에서 열기',
'directoryExplorerDialog.actions.adding': 'Adding…', 'directoryExplorerDialog.actions.adding': 'Adding…',
'directoryExplorerDialog.actions.addProject': '프로젝트 추가', 'directoryExplorerDialog.actions.addProject': '프로젝트 추가',
'directoryExplorerDialog.actions.createAndAdd': '생성하고 추가',
'directoryExplorerDialog.actions.alreadyAdded': '이미 추가됨',
'directoryExplorerDialog.browse.directories': '디렉터리',
'directoryExplorerDialog.browse.loading': '디렉터리 로드 중...',
'directoryExplorerDialog.browse.empty': '일치하는 디렉터리가 없습니다.',
'directoryExplorerDialog.browse.parentDirectory': '상위 디렉터리',
'directoryExplorerDialog.browse.addedBadge': '추가됨',
'directoryExplorerDialog.footer.navigate': '탐색',
'directoryExplorerDialog.footer.select': '선택',
'directoryExplorerDialog.footer.add': '추가',
'directoryExplorerDialog.footer.close': '닫기',
'directoryExplorerDialog.shortcut.enter': 'Enter',
'directoryExplorerDialog.toast.unableToAccessDirectory': 'access 디렉터리할 수 없음', 'directoryExplorerDialog.toast.unableToAccessDirectory': 'access 디렉터리할 수 없음',
'directoryExplorerDialog.toast.desktopDeniedAccess': 'Desktop denied 디렉터리 access.', 'directoryExplorerDialog.toast.desktopDeniedAccess': 'Desktop denied 디렉터리 access.',
'directoryExplorerDialog.toast.failedToOpenDirectory': 'open 디렉터리 실패', 'directoryExplorerDialog.toast.failedToOpenDirectory': 'open 디렉터리 실패',
@@ -998,8 +998,22 @@ export const dict: Record<I18nKey, string> = {
"directoryExplorerDialog.toggle.showHidden": "Mostrar ocultos", "directoryExplorerDialog.toggle.showHidden": "Mostrar ocultos",
"directoryExplorerDialog.pathInput.placeholder": "Digite o caminho ou selecione na árvore...", "directoryExplorerDialog.pathInput.placeholder": "Digite o caminho ou selecione na árvore...",
"directoryExplorerDialog.actions.cancel": "Cancelar", "directoryExplorerDialog.actions.cancel": "Cancelar",
"directoryExplorerDialog.actions.openingFinder": "Abrindo...",
"directoryExplorerDialog.actions.openInFinder": "Abrir no Finder",
"directoryExplorerDialog.actions.adding": "Adicionando...", "directoryExplorerDialog.actions.adding": "Adicionando...",
"directoryExplorerDialog.actions.addProject": "Adicionar projeto", "directoryExplorerDialog.actions.addProject": "Adicionar projeto",
"directoryExplorerDialog.actions.createAndAdd": "Criar e adicionar",
"directoryExplorerDialog.actions.alreadyAdded": "Já adicionado",
"directoryExplorerDialog.browse.directories": "Diretórios",
"directoryExplorerDialog.browse.loading": "Carregando diretórios...",
"directoryExplorerDialog.browse.empty": "Nenhum diretório correspondente.",
"directoryExplorerDialog.browse.parentDirectory": "Diretório pai",
"directoryExplorerDialog.browse.addedBadge": "Adicionado",
"directoryExplorerDialog.footer.navigate": "Navegar",
"directoryExplorerDialog.footer.select": "Selecionar",
"directoryExplorerDialog.footer.add": "Adicionar",
"directoryExplorerDialog.footer.close": "Fechar",
"directoryExplorerDialog.shortcut.enter": "Enter",
"directoryExplorerDialog.toast.unableToAccessDirectory": "Não é possível acessar o diretório", "directoryExplorerDialog.toast.unableToAccessDirectory": "Não é possível acessar o diretório",
"directoryExplorerDialog.toast.desktopDeniedAccess": "O desktop negou o acesso ao diretório.", "directoryExplorerDialog.toast.desktopDeniedAccess": "O desktop negou o acesso ao diretório.",
"directoryExplorerDialog.toast.failedToOpenDirectory": "Não foi possível abrir o diretório", "directoryExplorerDialog.toast.failedToOpenDirectory": "Não foi possível abrir o diretório",
+14
View File
@@ -998,8 +998,22 @@ export const dict: Record<I18nKey, string> = {
"directoryExplorerDialog.toggle.showHidden": "Показати приховані", "directoryExplorerDialog.toggle.showHidden": "Показати приховані",
"directoryExplorerDialog.pathInput.placeholder": "Введіть шлях або виберіть із дерева...", "directoryExplorerDialog.pathInput.placeholder": "Введіть шлях або виберіть із дерева...",
"directoryExplorerDialog.actions.cancel": "Скасувати", "directoryExplorerDialog.actions.cancel": "Скасувати",
"directoryExplorerDialog.actions.openingFinder": "Відкриття...",
"directoryExplorerDialog.actions.openInFinder": "Відкрити у Finder",
"directoryExplorerDialog.actions.adding": "Додавання...", "directoryExplorerDialog.actions.adding": "Додавання...",
"directoryExplorerDialog.actions.addProject": "Додати проєкт", "directoryExplorerDialog.actions.addProject": "Додати проєкт",
"directoryExplorerDialog.actions.createAndAdd": "Створити й додати",
"directoryExplorerDialog.actions.alreadyAdded": "Уже додано",
"directoryExplorerDialog.browse.directories": "Каталоги",
"directoryExplorerDialog.browse.loading": "Завантаження каталогів...",
"directoryExplorerDialog.browse.empty": "Немає відповідних каталогів.",
"directoryExplorerDialog.browse.parentDirectory": "Батьківський каталог",
"directoryExplorerDialog.browse.addedBadge": "Додано",
"directoryExplorerDialog.footer.navigate": "Навігація",
"directoryExplorerDialog.footer.select": "Вибрати",
"directoryExplorerDialog.footer.add": "Додати",
"directoryExplorerDialog.footer.close": "Закрити",
"directoryExplorerDialog.shortcut.enter": "Enter",
"directoryExplorerDialog.toast.unableToAccessDirectory": "Неможливо отримати доступ до каталогу", "directoryExplorerDialog.toast.unableToAccessDirectory": "Неможливо отримати доступ до каталогу",
"directoryExplorerDialog.toast.desktopDeniedAccess": "Десктопному застосунку заборонено доступ до каталогу.", "directoryExplorerDialog.toast.desktopDeniedAccess": "Десктопному застосунку заборонено доступ до каталогу.",
"directoryExplorerDialog.toast.failedToOpenDirectory": "Не вдалося відкрити каталог", "directoryExplorerDialog.toast.failedToOpenDirectory": "Не вдалося відкрити каталог",
@@ -998,8 +998,22 @@ export const dict: Record<I18nKey, string> = {
'directoryExplorerDialog.toggle.showHidden': '显示隐藏项', 'directoryExplorerDialog.toggle.showHidden': '显示隐藏项',
'directoryExplorerDialog.pathInput.placeholder': '输入路径或从树中选择...', 'directoryExplorerDialog.pathInput.placeholder': '输入路径或从树中选择...',
'directoryExplorerDialog.actions.cancel': '取消', 'directoryExplorerDialog.actions.cancel': '取消',
'directoryExplorerDialog.actions.openingFinder': '正在打开...',
'directoryExplorerDialog.actions.openInFinder': '在 Finder 中打开',
'directoryExplorerDialog.actions.adding': '添加中...', 'directoryExplorerDialog.actions.adding': '添加中...',
'directoryExplorerDialog.actions.addProject': '添加项目', 'directoryExplorerDialog.actions.addProject': '添加项目',
'directoryExplorerDialog.actions.createAndAdd': '创建并添加',
'directoryExplorerDialog.actions.alreadyAdded': '已添加',
'directoryExplorerDialog.browse.directories': '目录',
'directoryExplorerDialog.browse.loading': '正在加载目录...',
'directoryExplorerDialog.browse.empty': '没有匹配的目录。',
'directoryExplorerDialog.browse.parentDirectory': '上级目录',
'directoryExplorerDialog.browse.addedBadge': '已添加',
'directoryExplorerDialog.footer.navigate': '导航',
'directoryExplorerDialog.footer.select': '选择',
'directoryExplorerDialog.footer.add': '添加',
'directoryExplorerDialog.footer.close': '关闭',
'directoryExplorerDialog.shortcut.enter': 'Enter',
'directoryExplorerDialog.toast.unableToAccessDirectory': '无法访问目录', 'directoryExplorerDialog.toast.unableToAccessDirectory': '无法访问目录',
'directoryExplorerDialog.toast.desktopDeniedAccess': '桌面端拒绝了目录访问。', 'directoryExplorerDialog.toast.desktopDeniedAccess': '桌面端拒绝了目录访问。',
'directoryExplorerDialog.toast.failedToOpenDirectory': '打开目录失败', 'directoryExplorerDialog.toast.failedToOpenDirectory': '打开目录失败',