fix(projects): open draft after adding project

This commit is contained in:
Bohdan Triapitsyn
2026-08-10 16:10:03 +03:00
parent bd4e7668fb
commit f9595cb80b
7 changed files with 94 additions and 10 deletions
+19 -1
View File
@@ -1701,7 +1701,7 @@ class OpencodeService {
// File System Operations
async createDirectory(
dirPath: string,
options?: { allowOutsideWorkspace?: boolean }
options?: { allowOutsideWorkspace?: boolean; asProject?: boolean }
): Promise<{ success: boolean; path: string }> {
const desktopFiles = getDesktopFilesApi();
if (desktopFiles?.createDirectory) {
@@ -1713,6 +1713,24 @@ class OpencodeService {
}
}
if (options?.asProject) {
const response = await runtimeFetch(`${this.baseUrl}/opencode/directory`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ path: dirPath, create: true }),
});
if (!response.ok) {
const error = await response.json().catch(() => ({ error: 'Failed to create project directory' }));
throw new Error(error.error || 'Failed to create project directory');
}
const result = await response.json();
return { success: true, path: result.path };
}
const payload = {
path: dirPath,
...(options?.allowOutsideWorkspace ? { allowOutsideWorkspace: true } : {}),