diff --git a/src/app/api/open-directory/route.ts b/src/app/api/open-directory/route.ts
new file mode 100644
index 00000000..97867561
--- /dev/null
+++ b/src/app/api/open-directory/route.ts
@@ -0,0 +1,49 @@
+
+import { NextRequest, NextResponse } from "next/server";
+import { exec } from "child_process";
+import { promisify } from "util";
+import os from "os";
+
+const execAsync = promisify(exec);
+
+export async function POST(req: NextRequest) {
+ try {
+ const body = await req.json();
+ const { path } = body;
+
+ if (!path) {
+ return NextResponse.json(
+ { success: false, error: "Path is required" },
+ { status: 400 }
+ );
+ }
+
+ let command = "";
+ const platform = os.platform();
+
+ switch (platform) {
+ case "darwin":
+ command = `open "${path}"`;
+ break;
+ case "win32":
+ command = `explorer "${path}"`;
+ break;
+ case "linux":
+ command = `xdg-open "${path}"`;
+ break;
+ default:
+ // Fallback for other Unix-like systems, might not work everywhere
+ command = `xdg-open "${path}"`;
+ }
+
+ await execAsync(command);
+
+ return NextResponse.json({ success: true });
+ } catch (error) {
+ console.error("Failed to open directory:", error);
+ return NextResponse.json(
+ { success: false, error: "Failed to open directory" },
+ { status: 500 }
+ );
+ }
+}
diff --git a/src/components/Header.tsx b/src/components/Header.tsx
index 9c0e7224..81823089 100644
--- a/src/components/Header.tsx
+++ b/src/components/Header.tsx
@@ -77,6 +77,22 @@ export function Header() {
}, 50);
};
+ const handleOpenDirectory = async () => {
+ if (!saveDirectoryPath) return;
+
+ try {
+ await fetch("/api/open-directory", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ path: saveDirectoryPath }),
+ });
+ } catch (error) {
+ console.error("Failed to open directory:", error);
+ }
+ };
+
return (
<>
)}
+