diff --git a/src/app/api/open-directory/route.ts b/src/app/api/open-directory/route.ts
new file mode 100644
index 0000000..1b6ad73
--- /dev/null
+++ b/src/app/api/open-directory/route.ts
@@ -0,0 +1,54 @@
+
+import { NextRequest, NextResponse } from "next/server";
+import { execFile } from "child_process";
+import { promisify } from "util";
+import os from "os";
+
+const execFileAsync = promisify(execFile);
+
+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 = "";
+ let args: string[] = [];
+ const platform = os.platform();
+
+ switch (platform) {
+ case "darwin":
+ command = "open";
+ args = [path];
+ break;
+ case "win32":
+ command = "explorer";
+ args = [path];
+ break;
+ case "linux":
+ command = "xdg-open";
+ args = [path];
+ break;
+ default:
+ // Fallback for other Unix-like systems
+ command = "xdg-open";
+ args = [path];
+ }
+
+ await execFileAsync(command, args);
+
+ 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 9c0e722..86d1e45 100644
--- a/src/components/Header.tsx
+++ b/src/components/Header.tsx
@@ -77,6 +77,31 @@ export function Header() {
}, 50);
};
+ const handleOpenDirectory = async () => {
+ if (!saveDirectoryPath) return;
+
+ try {
+ const response = await fetch("/api/open-directory", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ path: saveDirectoryPath }),
+ });
+
+ const result = await response.json();
+
+ if (!response.ok || !result.success) {
+ console.error("Failed to open directory:", result.error);
+ alert(`Failed to open project folder: ${result.error || "Unknown error"}`);
+ return;
+ }
+ } catch (error) {
+ console.error("Failed to open directory:", error);
+ alert("Failed to open project folder. Please try again.");
+ }
+ };
+
return (
<>
)}
+ {saveDirectoryPath && (
+
+ )}