Provide a way to open app folder in finder (#42)

This commit is contained in:
Will Chen
2025-04-28 22:57:13 -07:00
committed by GitHub
parent 7ab1aab9b0
commit 674dc6aeb0
4 changed files with 54 additions and 5 deletions

View File

@@ -22,4 +22,24 @@ export function registerShellHandlers() {
return { success: false, error: (error as Error).message }; return { success: false, error: (error as Error).message };
} }
}); });
ipcMain.handle("show-item-in-folder", async (_event, fullPath: string) => {
try {
// Validate that a path was provided
if (!fullPath) {
logger.error("Attempted to show item with empty path");
return {
success: false,
error: "No file path provided.",
};
}
shell.showItemInFolder(fullPath);
logger.debug("Showed item in folder:", fullPath);
return { success: true };
} catch (error) {
logger.error(`Failed to show item in folder ${fullPath}:`, error);
return { success: false, error: (error as Error).message };
}
});
} }

View File

@@ -292,8 +292,22 @@ export class IpcClient {
return result as { success: boolean; error?: string }; return result as { success: boolean; error?: string };
} catch (error) { } catch (error) {
showError(error); showError(error);
// Ensure a consistent return type even on invoke error throw error;
return { success: false, error: (error as Error).message }; }
}
public async showItemInFolder(
fullPath: string
): Promise<{ success: boolean; error?: string }> {
try {
const result = await this.ipcRenderer.invoke(
"show-item-in-folder",
fullPath
);
return result as { success: boolean; error?: string };
} catch (error) {
showError(error);
throw error;
} }
} }

View File

@@ -12,6 +12,7 @@ import {
MessageCircle, MessageCircle,
Pencil, Pencil,
Github, Github,
Folder,
} from "lucide-react"; } from "lucide-react";
import { import {
Popover, Popover,
@@ -159,6 +160,8 @@ export default function AppDetailsPage() {
); );
} }
const fullAppPath = appBasePath.replace("$APP_BASE_PATH", selectedApp.path);
return ( return (
<div className="relative min-h-screen p-4 w-full"> <div className="relative min-h-screen p-4 w-full">
<Button <Button
@@ -232,9 +235,20 @@ export default function AppDetailsPage() {
<span className="block text-gray-500 dark:text-gray-400 mb-0.5 text-xs"> <span className="block text-gray-500 dark:text-gray-400 mb-0.5 text-xs">
Path Path
</span> </span>
<span className="text-sm break-all"> <div className="flex items-center gap-1">
{appBasePath.replace("$APP_BASE_PATH", selectedApp.path)} <span className="text-sm break-all">{fullAppPath}</span>
</span> <Button
variant="ghost"
size="sm"
className="p-0.5 h-auto cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
onClick={() => {
IpcClient.getInstance().showItemInFolder(fullAppPath);
}}
title="Show in folder"
>
<Folder className="h-3.5 w-3.5" />
</Button>
</div>
</div> </div>
</div> </div>
<div className="mt-4 flex flex-col gap-2"> <div className="mt-4 flex flex-col gap-2">

View File

@@ -30,6 +30,7 @@ const validInvokeChannels = [
"set-user-settings", "set-user-settings",
"get-env-vars", "get-env-vars",
"open-external-url", "open-external-url",
"show-item-in-folder",
"reset-all", "reset-all",
"nodejs-status", "nodejs-status",
"install-node", "install-node",