fix: connect session shows task.md titles + auto-connect option for new projects
This commit is contained in:
@@ -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 => ({
|
||||
.map(d => {
|
||||
const fullPath = path.join(brainPath, d);
|
||||
return {
|
||||
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)
|
||||
.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 })[] = [];
|
||||
|
||||
const items = dirs.map(d => ({
|
||||
label: d.name.substring(0, 8),
|
||||
description: d.name,
|
||||
detail: `수정: ${new Date(d.mtime).toLocaleString()}`,
|
||||
// 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 selected = await vscode.window.showQuickPick(items, {
|
||||
placeHolder: `프로젝트 "${projectName}"에 연결할 세션을 선택하세요`,
|
||||
});
|
||||
|
||||
if (selected) {
|
||||
if (!selected) { return; }
|
||||
|
||||
if (!('convId' in selected) || !selected.convId) {
|
||||
// Auto-connect mode
|
||||
vscode.window.showInformationMessage(
|
||||
`🔄 ${projectName}: 다음 대화가 자동으로 연결됩니다`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
registerConversation(selected.convId);
|
||||
vscode.window.showInformationMessage(
|
||||
`✅ ${selected.label} → ${projectName} 연결됨`
|
||||
`✅ ${selected.description} → ${projectName} 연결됨`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user