From 3c84cf5b4b96d81c0300e622dde18f476c487ff3 Mon Sep 17 00:00:00 2001 From: CD Date: Sat, 7 Mar 2026 14:20:01 +0900 Subject: [PATCH] fix: connect session shows task.md titles + auto-connect option for new projects --- extension/src/extension.ts | 78 +++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/extension/src/extension.ts b/extension/src/extension.ts index 9d444cf..d758bf0 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -381,8 +381,28 @@ function registerConversation(conversationId: string) { console.log(`Gravity Bridge [${projectName}]: registered ${conversationId.substring(0, 8)}`); } +/** + * Read the title (first # heading) from a conversation's task.md or implementation_plan.md. + */ +function getConversationTitle(convDir: string): string { + for (const fname of ['task.md', 'implementation_plan.md']) { + const fpath = path.join(convDir, fname); + if (fs.existsSync(fpath)) { + try { + const lines = fs.readFileSync(fpath, 'utf-8').split('\n').slice(0, 5); + for (const line of lines) { + const match = line.match(/^#\s+(.+)/); + if (match) { return match[1].trim().substring(0, 50); } + } + } catch { /* ignore */ } + } + } + return ''; +} + /** * Manual connect: scan brain/ for recent conversations and let user pick. + * Shows task.md titles for readability. Offers auto-connect for new projects. */ async function connectSession() { const brainPath = path.join(os.homedir(), '.gemini', 'antigravity', 'brain'); @@ -397,35 +417,57 @@ async function connectSession() { const fullPath = path.join(brainPath, d); return fs.statSync(fullPath).isDirectory() && d.includes('-'); }) - .map(d => ({ - name: d, - mtime: fs.statSync(path.join(brainPath, d)).mtimeMs, - })) + .map(d => { + const fullPath = path.join(brainPath, d); + return { + name: d, + mtime: fs.statSync(fullPath).mtimeMs, + title: getConversationTitle(fullPath), + }; + }) .sort((a, b) => b.mtime - a.mtime) - .slice(0, 10); // Show top 10 + .slice(0, 10); - if (dirs.length === 0) { - vscode.window.showInformationMessage('활성 세션이 없습니다.'); - return; + // Build QuickPick items + const items: (vscode.QuickPickItem & { convId?: string })[] = []; + + // Always offer auto-connect option first + items.push({ + label: '$(sync) 새 대화 자동 연결', + description: '다음에 시작하는 대화가 자동으로 이 프로젝트에 연결됩니다', + detail: `프로젝트: ${projectName}`, + }); + + // Add conversation items with titles + for (const d of dirs) { + const titleLabel = d.title || '(제목 없음)'; + const timeStr = new Date(d.mtime).toLocaleString(); + items.push({ + label: `$(comment-discussion) ${titleLabel}`, + description: d.name.substring(0, 8), + detail: `${d.name} · ${timeStr}`, + convId: d.name, + } as any); } - const items = dirs.map(d => ({ - label: d.name.substring(0, 8), - description: d.name, - detail: `수정: ${new Date(d.mtime).toLocaleString()}`, - convId: d.name, - })); - const selected = await vscode.window.showQuickPick(items, { placeHolder: `프로젝트 "${projectName}"에 연결할 세션을 선택하세요`, }); - if (selected) { - registerConversation(selected.convId); + if (!selected) { return; } + + if (!('convId' in selected) || !selected.convId) { + // Auto-connect mode vscode.window.showInformationMessage( - `✅ ${selected.label} → ${projectName} 연결됨` + `🔄 ${projectName}: 다음 대화가 자동으로 연결됩니다` ); + return; } + + registerConversation(selected.convId); + vscode.window.showInformationMessage( + `✅ ${selected.description} → ${projectName} 연결됨` + ); } /**