fix(projects): open draft after adding project
This commit is contained in:
@@ -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 } : {}),
|
||||
|
||||
Reference in New Issue
Block a user