fix(desktop): recover from macOS directory permission failures
This commit is contained in:
@@ -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 = (
|
||||
|
||||
Reference in New Issue
Block a user