fix: resolve workspace fallback directory issue causing files not to save when single file is opened (v1.0.32)

This commit is contained in:
Jay
2026-04-14 03:51:20 +09:00
parent b2ac61b848
commit e1a46f524b
2 changed files with 12 additions and 7 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "connect-ai-lab",
"displayName": "Connect AI",
"description": "100% 로컬 AI 코딩 에이전트 — 파일 생성, 코드 편집, 터미널 실행을 오프라인으로. Ollama + Gemma/Llama/DeepSeek 지원.",
"version": "1.0.31",
"version": "1.0.32",
"publisher": "connectailab",
"license": "MIT",
"icon": "assets/icon.png",
+11 -6
View File
@@ -819,18 +819,23 @@ class SidebarChatProvider implements vscode.WebviewViewProvider {
// --------------------------------------------------------
private _executeActions(aiMessage: string): string[] {
const report: string[] = [];
const rootPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
let rootPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
// Fallback to active editor directory if no workspace folder is open
if (!rootPath && vscode.window.activeTextEditor && vscode.window.activeTextEditor.document.uri.scheme === 'file') {
rootPath = path.dirname(vscode.window.activeTextEditor.document.uri.fsPath);
}
if (!rootPath) {
const hasActions = /<create_file|<edit_file|<run_command/.test(aiMessage);
const hasActions = /<(?:create_file|edit_file|run_command|file)/i.test(aiMessage);
if (hasActions) {
report.push('❌ 폴더가 열려있지 않습니다. File → Open Folder로 폴더를 먼저 열어주세요.');
report.push('❌ 폴더가 열려있지 않습니다. File → Open Folder로 폴더를 열거나 파일을 열어주세요.');
}
return report;
}
// ACTION 1: Create files
const createRegex = /<create_file\s+path=['"]?([^'">]+)['"]?[^>]*>([\s\S]*?)<\/create_file>/gi;
const createRegex = /<(?:create_file|file)\s+(?:path|file|name)=['"]?([^'">]+)['"]?[^>]*>([\s\S]*?)<\/(?:create_file|file)>/gi;
let match: RegExpExecArray | null;
let firstCreatedFile = '';
@@ -866,7 +871,7 @@ class SidebarChatProvider implements vscode.WebviewViewProvider {
}
// ACTION 2: Edit files
const editRegex = /<edit_file\s+path=['"]?([^'">]+)['"]?[^>]*>([\s\S]*?)<\/edit_file>/gi;
const editRegex = /<(?:edit_file|edit)\s+(?:path|file|name)=['"]?([^'">]+)['"]?[^>]*>([\s\S]*?)<\/(?:edit_file|edit)>/gi;
while ((match = editRegex.exec(aiMessage)) !== null) {
const relPath = match[1].trim();
const body = match[2];
@@ -906,7 +911,7 @@ class SidebarChatProvider implements vscode.WebviewViewProvider {
}
// ACTION 3: Run commands
const cmdRegex = /<run_command>([\s\S]*?)<\/run_command>/gi;
const cmdRegex = /<(?:run_command|command|bash|terminal)>([\s\S]*?)<\/(?:run_command|command|bash|terminal)>/gi;
while ((match = cmdRegex.exec(aiMessage)) !== null) {
let cmd = match[1].trim();
// Clean up if AI outputs markdown inside