From 2c7559c61c6e44f633cc83b5f3f717032dfe52b6 Mon Sep 17 00:00:00 2001 From: Federico Jaramillo Martinez Date: Fri, 8 May 2026 14:38:12 +0200 Subject: [PATCH] Improve project folder creation --- src/client/src/api/clients.ts | 3 +- src/client/src/appState.ts | 2 + src/client/src/components/PiWebApp.ts | 6 +- src/client/src/components/ProjectDialog.ts | 139 ++++++++++++++++++ .../src/controllers/projectController.ts | 9 +- src/server/index.ts | 11 +- src/server/projects/directorySuggestions.ts | 36 +++++ src/server/projects/projectService.ts | 9 +- 8 files changed, 203 insertions(+), 12 deletions(-) create mode 100644 src/client/src/components/ProjectDialog.ts create mode 100644 src/server/projects/directorySuggestions.ts diff --git a/src/client/src/api/clients.ts b/src/client/src/api/clients.ts index 3a6b3a6..22588d5 100644 --- a/src/client/src/api/clients.ts +++ b/src/client/src/api/clients.ts @@ -24,7 +24,8 @@ import { gitDiffUrl, messageUrl } from "./urls"; export const projectsApi = { projects: () => request("/api/projects", arrayOf(parseProject)), - addProject: (path: string, name?: string) => request("/api/projects", parseProject, { method: "POST", body: JSON.stringify({ path, name }) }), + addProject: (path: string, name?: string, create?: boolean) => request("/api/projects", parseProject, { method: "POST", body: JSON.stringify({ path, name, create }) }), + projectDirectories: (query: string) => request(`/api/project-directories?q=${encodeURIComponent(query)}`, arrayOf(parseFileSuggestion)), }; export const workspacesApi = { diff --git a/src/client/src/appState.ts b/src/client/src/appState.ts index a56dfc5..d1df640 100644 --- a/src/client/src/appState.ts +++ b/src/client/src/appState.ts @@ -18,6 +18,7 @@ export interface AppState { sessionActivities: Record; commandDialog: Extract | undefined; actionPaletteOpen: boolean; + projectDialogOpen: boolean; workspaceTool: "files" | "git"; mainView: "chat" | "files" | "git"; fileTree: FileTreeEntry[]; @@ -51,6 +52,7 @@ export function initialAppState(): AppState { sessionActivities: {}, commandDialog: undefined, actionPaletteOpen: false, + projectDialogOpen: false, workspaceTool: "files", mainView: "chat", fileTree: [], diff --git a/src/client/src/components/PiWebApp.ts b/src/client/src/components/PiWebApp.ts index a935a29..76ec104 100644 --- a/src/client/src/components/PiWebApp.ts +++ b/src/client/src/components/PiWebApp.ts @@ -21,6 +21,7 @@ import type { PromptEditor } from "./PromptEditor"; import "./StatusBar"; import "./CommandPicker"; import "./ActionPalette"; +import "./ProjectDialog"; import "./WorkspacePanel"; import { appStyles } from "./shared"; @@ -181,7 +182,7 @@ export class PiWebApp extends LitElement { state: this.state, openActionPalette: () => { this.setState({ actionPaletteOpen: true }); }, focusPrompt: () => { this.promptEditor?.focusInput(); }, - addProject: () => this.projects.addProject(), + addProject: () => { this.setState({ projectDialogOpen: true }); }, selectMainView: (view) => { this.selectMainView(view); }, refreshFiles: () => this.files.refreshFiles(), refreshGit: () => this.git.refreshGit(), @@ -202,7 +203,7 @@ export class PiWebApp extends LitElement {