fix(desktop): recover from macOS directory permission failures

This commit is contained in:
deatheros
2026-08-07 01:49:44 +03:00
parent 7e0e22f6e2
commit d8518bf053
30 changed files with 497 additions and 106 deletions
+7 -2
View File
@@ -531,6 +531,10 @@ export const isDesktopShell = (): boolean => {
return isElectronShell();
};
export const canRequestNativeDirectoryAccess = (): boolean => (
isDesktopShell() && hasDesktopInvoke() && isDesktopLocalOriginActive()
);
export const startDesktopWindowDrag = async (): Promise<boolean> => {
if (!isDesktopShell()) {
return false;
@@ -586,12 +590,13 @@ export const requestDirectoryAccess = async (
directoryPath: string
): Promise<{ success: boolean; path?: string; projectId?: string; error?: string }> => {
// Desktop shell on local instance: use native folder picker.
if (hasDesktopInvoke() && isDesktopLocalOriginActive()) {
if (canRequestNativeDirectoryAccess()) {
try {
const selected = await getDesktopBridge()?.openDialog?.({
directory: true,
multiple: false,
title: 'Select Working Directory',
...(directoryPath ? { defaultPath: directoryPath } : {}),
});
if (!selected || typeof selected !== 'string') {
return { success: false, error: 'Directory selection cancelled' };
@@ -603,7 +608,7 @@ export const requestDirectoryAccess = async (
}
}
return { success: true, path: directoryPath };
return { success: false, error: 'Native directory picker not available' };
};
const isDesktopFileGrantResult = (