feat: persist project selection

This commit is contained in:
Dave
2025-12-24 17:46:27 +00:00
parent 4e2d7416e8
commit e229f2efa8
10 changed files with 192 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
import { useState } from "react";
import { useState, useEffect } from "react";
import { invoke } from "@tauri-apps/api/core";
import { open } from "@tauri-apps/plugin-dialog";
import { Chat } from "./components/Chat";
@@ -8,6 +8,23 @@ function App() {
const [projectPath, setProjectPath] = useState<string | null>(null);
const [errorMsg, setErrorMsg] = useState<string | null>(null);
useEffect(() => {
invoke<string | null>("get_current_project")
.then((path) => {
if (path) setProjectPath(path);
})
.catch((e) => console.error(e));
}, []);
async function closeProject() {
try {
await invoke("close_project");
setProjectPath(null);
} catch (e) {
console.error(e);
}
}
async function selectProject() {
try {
setErrorMsg(null);
@@ -57,9 +74,20 @@ function App() {
background: "#f0f0f0",
borderRadius: "4px",
color: "#333",
display: "flex",
justifyContent: "space-between",
alignItems: "center",
}}
>
<strong>Active Project:</strong> {projectPath}
<span>
<strong>Active Project:</strong> {projectPath}
</span>
<button
onClick={closeProject}
style={{ padding: "5px 10px", fontSize: "0.9em" }}
>
Close
</button>
</div>
<hr style={{ margin: "20px 0" }} />
<Chat />