fix: connect session shows task.md titles + auto-connect option for new projects

This commit is contained in:
2026-03-07 14:20:01 +09:00
parent 98bb037c81
commit 3c84cf5b4b

View File

@@ -381,8 +381,28 @@ function registerConversation(conversationId: string) {
console.log(`Gravity Bridge [${projectName}]: registered ${conversationId.substring(0, 8)}`); 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. * 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() { async function connectSession() {
const brainPath = path.join(os.homedir(), '.gemini', 'antigravity', 'brain'); const brainPath = path.join(os.homedir(), '.gemini', 'antigravity', 'brain');
@@ -397,35 +417,57 @@ async function connectSession() {
const fullPath = path.join(brainPath, d); const fullPath = path.join(brainPath, d);
return fs.statSync(fullPath).isDirectory() && d.includes('-'); return fs.statSync(fullPath).isDirectory() && d.includes('-');
}) })
.map(d => ({ .map(d => {
const fullPath = path.join(brainPath, d);
return {
name: d, name: d,
mtime: fs.statSync(path.join(brainPath, d)).mtimeMs, mtime: fs.statSync(fullPath).mtimeMs,
})) title: getConversationTitle(fullPath),
};
})
.sort((a, b) => b.mtime - a.mtime) .sort((a, b) => b.mtime - a.mtime)
.slice(0, 10); // Show top 10 .slice(0, 10);
if (dirs.length === 0) { // Build QuickPick items
vscode.window.showInformationMessage('활성 세션이 없습니다.'); const items: (vscode.QuickPickItem & { convId?: string })[] = [];
return;
}
const items = dirs.map(d => ({ // Always offer auto-connect option first
label: d.name.substring(0, 8), items.push({
description: d.name, label: '$(sync) 새 대화 자동 연결',
detail: `수정: ${new Date(d.mtime).toLocaleString()}`, 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, convId: d.name,
})); } as any);
}
const selected = await vscode.window.showQuickPick(items, { const selected = await vscode.window.showQuickPick(items, {
placeHolder: `프로젝트 "${projectName}"에 연결할 세션을 선택하세요`, placeHolder: `프로젝트 "${projectName}"에 연결할 세션을 선택하세요`,
}); });
if (selected) { if (!selected) { return; }
if (!('convId' in selected) || !selected.convId) {
// Auto-connect mode
vscode.window.showInformationMessage(
`🔄 ${projectName}: 다음 대화가 자동으로 연결됩니다`
);
return;
}
registerConversation(selected.convId); registerConversation(selected.convId);
vscode.window.showInformationMessage( vscode.window.showInformationMessage(
`${selected.label}${projectName} 연결됨` `${selected.description}${projectName} 연결됨`
); );
}
} }
/** /**