fix: track ALL trajectories, detect new conversations, summary fallback per-traj
This commit is contained in:
Binary file not shown.
@@ -282,13 +282,15 @@ function activate(context) {
|
||||
});
|
||||
}
|
||||
let pollFailCount = 0;
|
||||
let pollCount = 0;
|
||||
async function pollConversations() {
|
||||
if (!lsPort) {
|
||||
return;
|
||||
}
|
||||
if (pollFailCount > 3) {
|
||||
if (pollFailCount > 10) {
|
||||
return;
|
||||
} // stop after repeated failures
|
||||
pollCount++;
|
||||
try {
|
||||
// Use getDiagnostics to get cascade-level conversation IDs
|
||||
const diag = await vscode.commands.executeCommand('antigravity.getDiagnostics');
|
||||
@@ -302,33 +304,46 @@ function activate(context) {
|
||||
}
|
||||
const isFirstPoll = Object.keys(lastStepIndex).length === 0;
|
||||
if (isFirstPoll) {
|
||||
console.log(`Gravity Bridge: [LS] ${trajectories.length} recent trajectories from getDiagnostics`);
|
||||
const latest = trajectories[trajectories.length - 1];
|
||||
console.log(`Gravity Bridge: [LS] latest: ${JSON.stringify(latest).substring(0, 400)}`);
|
||||
console.log(`Gravity Bridge: [LS] ${trajectories.length} trajectories from getDiagnostics`);
|
||||
}
|
||||
// Check the most recent trajectory for step count changes
|
||||
const latest = trajectories[trajectories.length - 1];
|
||||
const agentId = latest.googleAgentId || '';
|
||||
const trajId = latest.trajectoryId || '';
|
||||
const stepIdx = latest.lastStepIndex ?? 0;
|
||||
// Periodic debug every ~1 min (12 * 5s)
|
||||
if (pollCount % 12 === 0) {
|
||||
const summary = trajectories.map((t) => {
|
||||
const id = (t.googleAgentId || '').substring(0, 8);
|
||||
return `${id}:s${t.lastStepIndex ?? '?'}`;
|
||||
}).join(', ');
|
||||
console.log(`Gravity Bridge: [LS] poll#${pollCount} — ${trajectories.length} trajs: [${summary}]`);
|
||||
}
|
||||
// Check ALL trajectories for step count changes
|
||||
for (const traj of trajectories) {
|
||||
const agentId = traj.googleAgentId || '';
|
||||
const trajId = traj.trajectoryId || '';
|
||||
const stepIdx = traj.lastStepIndex ?? 0;
|
||||
const summary = traj.summary || '';
|
||||
if (!agentId && !trajId) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
const key = agentId || trajId;
|
||||
const prev = lastStepIndex[key];
|
||||
if (prev === undefined) {
|
||||
// First poll — initialize
|
||||
// First time seeing this trajectory — initialize
|
||||
lastStepIndex[key] = stepIdx;
|
||||
console.log(`Gravity Bridge: [LS] initialized ${key.substring(0, 8)} at step ${stepIdx}`);
|
||||
return;
|
||||
if (isFirstPoll) {
|
||||
console.log(`Gravity Bridge: [LS] init ${key.substring(0, 8)} at step ${stepIdx} "${summary.substring(0, 30)}"`);
|
||||
}
|
||||
else {
|
||||
// New trajectory appeared after first poll = new conversation!
|
||||
console.log(`Gravity Bridge: [LS] NEW trajectory ${key.substring(0, 8)} at step ${stepIdx} "${summary.substring(0, 40)}"`);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (stepIdx > prev) {
|
||||
// New steps detected! Try to fetch them
|
||||
console.log(`Gravity Bridge: [LS] ${key.substring(0, 8)} new steps: ${prev} → ${stepIdx}`);
|
||||
// New steps detected!
|
||||
console.log(`Gravity Bridge: [LS] ${key.substring(0, 8)} steps: ${prev} → ${stepIdx} "${summary.substring(0, 40)}"`);
|
||||
// Try RPC to get full step text
|
||||
const attempts = [
|
||||
{ method: 'GetCascadeTrajectorySteps', params: { googleAgentId: agentId, trajectoryId: trajId, startStepIndex: prev } },
|
||||
{ method: 'GetCascadeTrajectory', params: { googleAgentId: agentId, trajectoryId: trajId } },
|
||||
{ method: 'GetCascadeTrajectorySteps', params: { conversationId: agentId, trajectoryId: trajId } },
|
||||
];
|
||||
let stepsResult = null;
|
||||
for (const attempt of attempts) {
|
||||
@@ -350,18 +365,19 @@ function activate(context) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
// All attempts failed — try writing the summary as a fallback
|
||||
const summary = latest.summary || '';
|
||||
if (summary && summary !== lastStepIndex[key + '_summary']) {
|
||||
writeChatSnapshot(`[AI 대화 요약]\n\n${summary}\n\n(step ${prev} → ${stepIdx})`);
|
||||
lastStepIndex[key + '_summary'] = summary;
|
||||
console.log(`Gravity Bridge: [LS] relayed summary fallback: ${summary.substring(0, 100)}`);
|
||||
// Fallback: relay summary text
|
||||
const summaryKey = key + '_summary';
|
||||
if (summary && summary !== lastStepIndex[summaryKey]) {
|
||||
writeChatSnapshot(`[AI 응답 감지]\n\n**${summary}**\n\n(step ${prev} → ${stepIdx})`);
|
||||
lastStepIndex[summaryKey] = summary;
|
||||
console.log(`Gravity Bridge: [LS] relayed summary: "${summary.substring(0, 80)}"`);
|
||||
}
|
||||
pollFailCount++;
|
||||
}
|
||||
lastStepIndex[key] = stepIdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.log(`Gravity Bridge: [LS poll] error: ${e}`);
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -264,10 +264,12 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
}
|
||||
|
||||
let pollFailCount = 0;
|
||||
let pollCount = 0;
|
||||
|
||||
async function pollConversations() {
|
||||
if (!lsPort) { return; }
|
||||
if (pollFailCount > 3) { return; } // stop after repeated failures
|
||||
if (pollFailCount > 10) { return; } // stop after repeated failures
|
||||
pollCount++;
|
||||
try {
|
||||
// Use getDiagnostics to get cascade-level conversation IDs
|
||||
const diag: any = await vscode.commands.executeCommand('antigravity.getDiagnostics');
|
||||
@@ -279,37 +281,50 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
const isFirstPoll = Object.keys(lastStepIndex).length === 0;
|
||||
if (isFirstPoll) {
|
||||
console.log(`Gravity Bridge: [LS] ${trajectories.length} recent trajectories from getDiagnostics`);
|
||||
const latest = trajectories[trajectories.length - 1];
|
||||
console.log(`Gravity Bridge: [LS] latest: ${JSON.stringify(latest).substring(0, 400)}`);
|
||||
console.log(`Gravity Bridge: [LS] ${trajectories.length} trajectories from getDiagnostics`);
|
||||
}
|
||||
|
||||
// Check the most recent trajectory for step count changes
|
||||
const latest = trajectories[trajectories.length - 1];
|
||||
const agentId = latest.googleAgentId || '';
|
||||
const trajId = latest.trajectoryId || '';
|
||||
const stepIdx = latest.lastStepIndex ?? 0;
|
||||
// Periodic debug every ~1 min (12 * 5s)
|
||||
if (pollCount % 12 === 0) {
|
||||
const summary = trajectories.map((t: any) => {
|
||||
const id = (t.googleAgentId || '').substring(0, 8);
|
||||
return `${id}:s${t.lastStepIndex ?? '?'}`;
|
||||
}).join(', ');
|
||||
console.log(`Gravity Bridge: [LS] poll#${pollCount} — ${trajectories.length} trajs: [${summary}]`);
|
||||
}
|
||||
|
||||
if (!agentId && !trajId) { return; }
|
||||
// Check ALL trajectories for step count changes
|
||||
for (const traj of trajectories) {
|
||||
const agentId = traj.googleAgentId || '';
|
||||
const trajId = traj.trajectoryId || '';
|
||||
const stepIdx = traj.lastStepIndex ?? 0;
|
||||
const summary = traj.summary || '';
|
||||
|
||||
if (!agentId && !trajId) { continue; }
|
||||
|
||||
const key = agentId || trajId;
|
||||
const prev = lastStepIndex[key];
|
||||
|
||||
if (prev === undefined) {
|
||||
// First poll — initialize
|
||||
// First time seeing this trajectory — initialize
|
||||
lastStepIndex[key] = stepIdx;
|
||||
console.log(`Gravity Bridge: [LS] initialized ${key.substring(0, 8)} at step ${stepIdx}`);
|
||||
return;
|
||||
if (isFirstPoll) {
|
||||
console.log(`Gravity Bridge: [LS] init ${key.substring(0, 8)} at step ${stepIdx} "${summary.substring(0, 30)}"`);
|
||||
} else {
|
||||
// New trajectory appeared after first poll = new conversation!
|
||||
console.log(`Gravity Bridge: [LS] NEW trajectory ${key.substring(0, 8)} at step ${stepIdx} "${summary.substring(0, 40)}"`);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stepIdx > prev) {
|
||||
// New steps detected! Try to fetch them
|
||||
console.log(`Gravity Bridge: [LS] ${key.substring(0, 8)} new steps: ${prev} → ${stepIdx}`);
|
||||
// New steps detected!
|
||||
console.log(`Gravity Bridge: [LS] ${key.substring(0, 8)} steps: ${prev} → ${stepIdx} "${summary.substring(0, 40)}"`);
|
||||
|
||||
// Try RPC to get full step text
|
||||
const attempts = [
|
||||
{ method: 'GetCascadeTrajectorySteps', params: { googleAgentId: agentId, trajectoryId: trajId, startStepIndex: prev } },
|
||||
{ method: 'GetCascadeTrajectory', params: { googleAgentId: agentId, trajectoryId: trajId } },
|
||||
{ method: 'GetCascadeTrajectorySteps', params: { conversationId: agentId, trajectoryId: trajId } },
|
||||
];
|
||||
|
||||
let stepsResult: any = null;
|
||||
@@ -332,18 +347,19 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
extractAndRelaySteps(newSteps);
|
||||
}
|
||||
} else {
|
||||
// All attempts failed — try writing the summary as a fallback
|
||||
const summary = latest.summary || '';
|
||||
if (summary && summary !== lastStepIndex[key + '_summary']) {
|
||||
writeChatSnapshot(`[AI 대화 요약]\n\n${summary}\n\n(step ${prev} → ${stepIdx})`);
|
||||
lastStepIndex[key + '_summary'] = summary;
|
||||
console.log(`Gravity Bridge: [LS] relayed summary fallback: ${summary.substring(0, 100)}`);
|
||||
// Fallback: relay summary text
|
||||
const summaryKey = key + '_summary';
|
||||
if (summary && summary !== lastStepIndex[summaryKey]) {
|
||||
writeChatSnapshot(`[AI 응답 감지]\n\n**${summary}**\n\n(step ${prev} → ${stepIdx})`);
|
||||
lastStepIndex[summaryKey] = summary;
|
||||
console.log(`Gravity Bridge: [LS] relayed summary: "${summary.substring(0, 80)}"`);
|
||||
}
|
||||
pollFailCount++;
|
||||
}
|
||||
|
||||
lastStepIndex[key] = stepIdx;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(`Gravity Bridge: [LS poll] error: ${e}`);
|
||||
}
|
||||
@@ -351,6 +367,7 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
|
||||
|
||||
|
||||
function extractAndRelaySteps(steps: any[]) {
|
||||
const messages: string[] = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user