mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
fix(panel): filter summaryless subagent DBs by real metadata tags
- Decode parentConversationId (fn 5), subagentSpec (fn 8), and nestingDepth (fn 17) in migratorDecodeMetaBlobLight instead of reading fn 9, and filter CORTEX_TRAJECTORY_SOURCE_SUBAGENT (source === 16) across summary and DB-fallback paths. - Reject non-root subagent and side-question sessions (non_root_session) at the migrateSessions execution boundary and drop obsolete fn 8 string UUID replacement branches.
This commit is contained in:
@@ -202,6 +202,8 @@ function migratorDecodeMetaBlobLight(rawBlob) {
|
|||||||
let workspaceUri = '';
|
let workspaceUri = '';
|
||||||
let projectId = '';
|
let projectId = '';
|
||||||
let parentConversationId = '';
|
let parentConversationId = '';
|
||||||
|
let nestingDepth = 0;
|
||||||
|
let hasSubagentSpec = false;
|
||||||
let createdMs = 0;
|
let createdMs = 0;
|
||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
if (field.fn === 7 && field.wt === 2 && !workspaceUri) {
|
if (field.fn === 7 && field.wt === 2 && !workspaceUri) {
|
||||||
@@ -212,8 +214,24 @@ function migratorDecodeMetaBlobLight(rawBlob) {
|
|||||||
if (fn1) workspaceUri = fn1.payload.toString('utf8').trim();
|
if (fn1) workspaceUri = fn1.payload.toString('utf8').trim();
|
||||||
} else if (field.fn === 18 && field.wt === 2) {
|
} else if (field.fn === 18 && field.wt === 2) {
|
||||||
projectId = field.payload.toString('utf8').trim();
|
projectId = field.payload.toString('utf8').trim();
|
||||||
} else if (field.fn === 9 && field.wt === 2) {
|
} else if (field.fn === 5 && field.wt === 2) {
|
||||||
parentConversationId = field.payload.toString('utf8').trim().toLowerCase();
|
parentConversationId = field.payload.toString('utf8').trim().toLowerCase();
|
||||||
|
} else if (field.fn === 8 && field.wt === 2 && field.payload.length > 0) {
|
||||||
|
const specFields = splitProtoRawFields(field.payload);
|
||||||
|
if (
|
||||||
|
specFields.some(
|
||||||
|
(sf) =>
|
||||||
|
(sf.fn === 1 || sf.fn === 2) &&
|
||||||
|
sf.wt === 2 &&
|
||||||
|
sf.payload.toString('utf8').trim().length > 0
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
hasSubagentSpec = true;
|
||||||
|
}
|
||||||
|
} else if (field.fn === 17 && field.wt === 0) {
|
||||||
|
const st = { off: 0 };
|
||||||
|
const depth = Number(BigInt.asIntN(32, readProtoVarint(field.payload, st, field.payload.length)));
|
||||||
|
if (Number.isFinite(depth) && depth > 0) nestingDepth = depth;
|
||||||
} else if (field.fn === 2 && field.wt === 2 && !createdMs) {
|
} else if (field.fn === 2 && field.wt === 2 && !createdMs) {
|
||||||
const tsFields = splitProtoRawFields(field.payload);
|
const tsFields = splitProtoRawFields(field.payload);
|
||||||
const secField = tsFields.find((item) => item.fn === 1 && item.wt === 0);
|
const secField = tsFields.find((item) => item.fn === 1 && item.wt === 0);
|
||||||
@@ -224,7 +242,55 @@ function migratorDecodeMetaBlobLight(rawBlob) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { workspaceUri, projectId, parentConversationId, createdMs };
|
return {
|
||||||
|
workspaceUri,
|
||||||
|
projectId,
|
||||||
|
parentConversationId,
|
||||||
|
nestingDepth,
|
||||||
|
hasSubagentSpec,
|
||||||
|
createdMs,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function migratorIsDbLightNonRoot(dbLight) {
|
||||||
|
if (!dbLight) return false;
|
||||||
|
return Boolean(
|
||||||
|
dbLight.trajectoryType === 22 ||
|
||||||
|
dbLight.sourceNum === 16 ||
|
||||||
|
dbLight.parentConversationId ||
|
||||||
|
Number(dbLight.nestingDepth || 0) > 0 ||
|
||||||
|
dbLight.hasSubagentSpec
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function migratorIsSummaryNonRoot(summary) {
|
||||||
|
if (!summary) return false;
|
||||||
|
const parentId = String(summary.parent_conversation_id || '').trim();
|
||||||
|
const depth = Number(summary.nesting_depth || 0);
|
||||||
|
const sourceStr = String(summary.source || '').trim();
|
||||||
|
if (parentId || depth > 0 || sourceStr === 'CORTEX_TRAJECTORY_SOURCE_SUBAGENT') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (summary.raw_summary) {
|
||||||
|
const rawFields = splitProtoRawFields(summary.raw_summary);
|
||||||
|
for (const f of rawFields) {
|
||||||
|
if (f.fn === 22 && f.wt === 0) {
|
||||||
|
const st = { off: 0 };
|
||||||
|
const ttVal = Number(BigInt.asUintN(32, readProtoVarint(f.payload, st, f.payload.length)));
|
||||||
|
if (ttVal === 22) return true; // 旁路提问
|
||||||
|
} else if (f.fn === 20 && f.wt === 0) {
|
||||||
|
const st = { off: 0 };
|
||||||
|
const srcVal = Number(BigInt.asUintN(32, readProtoVarint(f.payload, st, f.payload.length)));
|
||||||
|
if (srcVal === 16) return true; // CORTEX_TRAJECTORY_SOURCE_SUBAGENT
|
||||||
|
} else if (f.fn === 17 && f.wt === 2) {
|
||||||
|
const sumMeta = migratorDecodeMetaBlobLight(f.payload);
|
||||||
|
if (sumMeta.parentConversationId || sumMeta.nestingDepth > 0 || sumMeta.hasSubagentSpec) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function migratorInspectConversationDbLight(dbPath, { needPromptTitle = false } = {}) {
|
function migratorInspectConversationDbLight(dbPath, { needPromptTitle = false } = {}) {
|
||||||
@@ -271,7 +337,14 @@ function migratorInspectConversationDbLight(dbPath, { needPromptTitle = false }
|
|||||||
// 忽略步骤读取异常
|
// 忽略步骤读取异常
|
||||||
}
|
}
|
||||||
|
|
||||||
let metaBlobInfo = { workspaceUri: '', projectId: '', parentConversationId: '', createdMs: 0 };
|
let metaBlobInfo = {
|
||||||
|
workspaceUri: '',
|
||||||
|
projectId: '',
|
||||||
|
parentConversationId: '',
|
||||||
|
nestingDepth: 0,
|
||||||
|
hasSubagentSpec: false,
|
||||||
|
createdMs: 0,
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
const blobRow = db
|
const blobRow = db
|
||||||
.prepare("SELECT data FROM trajectory_metadata_blob WHERE id = 'main' LIMIT 1")
|
.prepare("SELECT data FROM trajectory_metadata_blob WHERE id = 'main' LIMIT 1")
|
||||||
@@ -488,20 +561,7 @@ function migratorListClientSessions(clientDef, clientRoot, summaryMap, runningSe
|
|||||||
if (sessions.length >= MIGRATOR_MAX_SESSIONS_PER_CLIENT) break;
|
if (sessions.length >= MIGRATOR_MAX_SESSIONS_PER_CLIENT) break;
|
||||||
const { cid, summary, info } = cand;
|
const { cid, summary, info } = cand;
|
||||||
|
|
||||||
if (summary) {
|
if (migratorIsSummaryNonRoot(summary)) continue;
|
||||||
const parentId = String(summary.parent_conversation_id || '').trim();
|
|
||||||
const depth = Number(summary.nesting_depth || 0);
|
|
||||||
if (parentId || depth > 0) continue;
|
|
||||||
if (summary.raw_summary) {
|
|
||||||
const rawFields = splitProtoRawFields(summary.raw_summary);
|
|
||||||
const ttField = rawFields.find((f) => f.fn === 22 && f.wt === 0);
|
|
||||||
if (ttField) {
|
|
||||||
const st = { off: 0 };
|
|
||||||
const ttVal = Number(BigInt.asUintN(32, readProtoVarint(ttField.payload, st, ttField.payload.length)));
|
|
||||||
if (ttVal === 22) continue; // 跳过旁路提问
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const annTitle = migratorReadAnnotationTitle(clientRoot, cid);
|
const annTitle = migratorReadAnnotationTitle(clientRoot, cid);
|
||||||
const sumTitle = String(summary?.title || '').trim();
|
const sumTitle = String(summary?.title || '').trim();
|
||||||
@@ -519,9 +579,7 @@ function migratorListClientSessions(clientDef, clientRoot, summaryMap, runningSe
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbLight) {
|
if (migratorIsDbLightNonRoot(dbLight)) continue;
|
||||||
if (dbLight.trajectoryType === 22 || dbLight.parentConversationId) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const stepCount =
|
const stepCount =
|
||||||
summaryStepCount >= 0 ? summaryStepCount : Math.max(0, Number(dbLight?.stepCount || 0));
|
summaryStepCount >= 0 ? summaryStepCount : Math.max(0, Number(dbLight?.stepCount || 0));
|
||||||
@@ -691,7 +749,7 @@ function migratorBuildWorkspaceSubmessage(rawUri, targetClientId) {
|
|||||||
|
|
||||||
function migratorBuildSummaryMetaBlob(
|
function migratorBuildSummaryMetaBlob(
|
||||||
sourceMetaBlob,
|
sourceMetaBlob,
|
||||||
{ srcCid = '', newCid, targetClientId, targetProjectId, rawUri, encodedUri }
|
{ newCid, targetClientId, targetProjectId, rawUri, encodedUri }
|
||||||
) {
|
) {
|
||||||
const wsBytes = migratorBuildWorkspaceSubmessage(rawUri, targetClientId);
|
const wsBytes = migratorBuildWorkspaceSubmessage(rawUri, targetClientId);
|
||||||
const primaryUri = targetClientId === 'cli' ? rawUri : encodedUri;
|
const primaryUri = targetClientId === 'cli' ? rawUri : encodedUri;
|
||||||
@@ -703,12 +761,6 @@ function migratorBuildSummaryMetaBlob(
|
|||||||
[18, encodeProtoStringField(18, targetProjectId)],
|
[18, encodeProtoStringField(18, targetProjectId)],
|
||||||
]);
|
]);
|
||||||
if (sourceMetaBlob && sourceMetaBlob.byteLength > 0) {
|
if (sourceMetaBlob && sourceMetaBlob.byteLength > 0) {
|
||||||
if (srcCid) {
|
|
||||||
const fn8 = splitProtoRawFields(sourceMetaBlob).find((f) => f.fn === 8 && f.wt === 2);
|
|
||||||
if (fn8 && fn8.payload.toString('utf8').trim().toLowerCase() === srcCid) {
|
|
||||||
replacements.set(8, encodeProtoStringField(8, newCid));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return patchProtoMessageFields(sourceMetaBlob, replacements);
|
return patchProtoMessageFields(sourceMetaBlob, replacements);
|
||||||
}
|
}
|
||||||
const parts = [];
|
const parts = [];
|
||||||
@@ -819,7 +871,6 @@ function migratorPatchGenMetadataOwnership(rawBlob, srcCid, newCid) {
|
|||||||
function migratorBuildPatchedRawSummary({
|
function migratorBuildPatchedRawSummary({
|
||||||
sourceRawSummary,
|
sourceRawSummary,
|
||||||
sourceMetaBlob,
|
sourceMetaBlob,
|
||||||
srcCid = '',
|
|
||||||
newCid,
|
newCid,
|
||||||
newTid,
|
newTid,
|
||||||
title,
|
title,
|
||||||
@@ -845,7 +896,6 @@ function migratorBuildPatchedRawSummary({
|
|||||||
const rawFields = splitProtoRawFields(sourceRawSummary);
|
const rawFields = splitProtoRawFields(sourceRawSummary);
|
||||||
const fn17 = rawFields.find((f) => f.fn === 17 && f.wt === 2);
|
const fn17 = rawFields.find((f) => f.fn === 17 && f.wt === 2);
|
||||||
const patchedFn17 = migratorBuildSummaryMetaBlob(fn17?.payload || sourceMetaBlob, {
|
const patchedFn17 = migratorBuildSummaryMetaBlob(fn17?.payload || sourceMetaBlob, {
|
||||||
srcCid,
|
|
||||||
newCid,
|
newCid,
|
||||||
targetClientId,
|
targetClientId,
|
||||||
targetProjectId,
|
targetProjectId,
|
||||||
@@ -875,7 +925,6 @@ function migratorBuildPatchedRawSummary({
|
|||||||
const createdTsBytes = encodeProtoTimestamp(createdMs || nowMs);
|
const createdTsBytes = encodeProtoTimestamp(createdMs || nowMs);
|
||||||
const lastUiTsBytes = encodeProtoTimestamp(lastUserInputMs || nowMs);
|
const lastUiTsBytes = encodeProtoTimestamp(lastUserInputMs || nowMs);
|
||||||
const synthMeta = migratorBuildSummaryMetaBlob(sourceMetaBlob, {
|
const synthMeta = migratorBuildSummaryMetaBlob(sourceMetaBlob, {
|
||||||
srcCid,
|
|
||||||
newCid,
|
newCid,
|
||||||
targetClientId,
|
targetClientId,
|
||||||
targetProjectId,
|
targetProjectId,
|
||||||
@@ -1100,6 +1149,10 @@ export function migrateSessions(params = {}, options = {}) {
|
|||||||
const dbLight = migratorInspectConversationDbLight(srcDbPath, {
|
const dbLight = migratorInspectConversationDbLight(srcDbPath, {
|
||||||
needPromptTitle: !annTitle && !srcSummary?.title && !srcSummary?.preview,
|
needPromptTitle: !annTitle && !srcSummary?.title && !srcSummary?.preview,
|
||||||
});
|
});
|
||||||
|
if (migratorIsSummaryNonRoot(srcSummary) || migratorIsDbLightNonRoot(dbLight)) {
|
||||||
|
results.push({ ok: false, sourceCascadeId: srcCid, error: 'non_root_session' });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const stepCount = Math.max(
|
const stepCount = Math.max(
|
||||||
0,
|
0,
|
||||||
Number(srcSummary?.step_count ?? dbLight?.stepCount ?? 0)
|
Number(srcSummary?.step_count ?? dbLight?.stepCount ?? 0)
|
||||||
@@ -1186,10 +1239,6 @@ export function migrateSessions(params = {}, options = {}) {
|
|||||||
[7, primaryMetaUri ? encodeProtoStringField(7, primaryMetaUri) : null],
|
[7, primaryMetaUri ? encodeProtoStringField(7, primaryMetaUri) : null],
|
||||||
[18, encodeProtoStringField(18, resolvedProjectId)],
|
[18, encodeProtoStringField(18, resolvedProjectId)],
|
||||||
]);
|
]);
|
||||||
const fn8 = splitProtoRawFields(sourceMetaBlob).find((f) => f.fn === 8 && f.wt === 2);
|
|
||||||
if (fn8 && fn8.payload.toString('utf8').trim().toLowerCase() === srcCid) {
|
|
||||||
metaReplacements.set(8, encodeProtoStringField(8, newCid));
|
|
||||||
}
|
|
||||||
const patchedMeta = patchProtoMessageFields(sourceMetaBlob, metaReplacements);
|
const patchedMeta = patchProtoMessageFields(sourceMetaBlob, metaReplacements);
|
||||||
dstDb
|
dstDb
|
||||||
.prepare("UPDATE trajectory_metadata_blob SET data = ? WHERE id = 'main'")
|
.prepare("UPDATE trajectory_metadata_blob SET data = ? WHERE id = 'main'")
|
||||||
@@ -1304,7 +1353,6 @@ export function migrateSessions(params = {}, options = {}) {
|
|||||||
const patchedRawSummary = migratorBuildPatchedRawSummary({
|
const patchedRawSummary = migratorBuildPatchedRawSummary({
|
||||||
sourceRawSummary: srcSummary?.raw_summary || null,
|
sourceRawSummary: srcSummary?.raw_summary || null,
|
||||||
sourceMetaBlob,
|
sourceMetaBlob,
|
||||||
srcCid,
|
|
||||||
newCid,
|
newCid,
|
||||||
newTid,
|
newTid,
|
||||||
title: finalTitle,
|
title: finalTitle,
|
||||||
|
|||||||
@@ -51,7 +51,24 @@ function initSummaryDb(dbPath) {
|
|||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createConvDb(dbPath, { cid, tid, source = 17, projectId = 'default-cli-project', wsUri = 'file:///C:/Users/Test', promptText = 'hello from cli', stepCount = 2, preserveTag15 = true }) {
|
function createConvDb(
|
||||||
|
dbPath,
|
||||||
|
{
|
||||||
|
cid,
|
||||||
|
tid,
|
||||||
|
trajectoryType = 4,
|
||||||
|
source = 17,
|
||||||
|
projectId = 'default-cli-project',
|
||||||
|
wsUri = 'file:///C:/Users/Test',
|
||||||
|
promptText = 'hello from cli',
|
||||||
|
stepCount = 2,
|
||||||
|
preserveTag15 = true,
|
||||||
|
parentConversationId = '',
|
||||||
|
rootConversationId = '',
|
||||||
|
nestingDepth = 0,
|
||||||
|
subagentSpec = null,
|
||||||
|
}
|
||||||
|
) {
|
||||||
const db = new DatabaseSync(dbPath);
|
const db = new DatabaseSync(dbPath);
|
||||||
db.exec(`
|
db.exec(`
|
||||||
CREATE TABLE trajectory_meta (
|
CREATE TABLE trajectory_meta (
|
||||||
@@ -84,16 +101,35 @@ function createConvDb(dbPath, { cid, tid, source = 17, projectId = 'default-cli-
|
|||||||
CREATE TABLE battle_mode_infos (idx integer PRIMARY KEY, data blob);
|
CREATE TABLE battle_mode_infos (idx integer PRIMARY KEY, data blob);
|
||||||
`);
|
`);
|
||||||
|
|
||||||
db.prepare('INSERT INTO trajectory_meta VALUES (?, ?, 4, ?)').run(tid, cid, source);
|
db.prepare('INSERT INTO trajectory_meta VALUES (?, ?, ?, ?)').run(
|
||||||
|
tid,
|
||||||
|
cid,
|
||||||
|
trajectoryType,
|
||||||
|
source
|
||||||
|
);
|
||||||
|
|
||||||
const wsSub = Buffer.concat([encodeProtoStringField(1, wsUri), encodeProtoStringField(3, '')]);
|
const wsSub = Buffer.concat([encodeProtoStringField(1, wsUri), encodeProtoStringField(3, '')]);
|
||||||
const metaParts = [
|
const metaParts = [
|
||||||
encodeProtoBytesField(1, wsSub),
|
encodeProtoBytesField(1, wsSub),
|
||||||
encodeProtoBytesField(2, encodeProtoTimestamp(1795000000000)),
|
encodeProtoBytesField(2, encodeProtoTimestamp(1795000000000)),
|
||||||
encodeProtoStringField(6, cid),
|
|
||||||
encodeProtoStringField(7, wsUri),
|
|
||||||
encodeProtoStringField(18, projectId),
|
|
||||||
];
|
];
|
||||||
|
if (parentConversationId) {
|
||||||
|
metaParts.push(encodeProtoStringField(5, parentConversationId));
|
||||||
|
}
|
||||||
|
metaParts.push(
|
||||||
|
encodeProtoStringField(6, rootConversationId || parentConversationId || cid),
|
||||||
|
encodeProtoStringField(7, wsUri)
|
||||||
|
);
|
||||||
|
if (subagentSpec && (subagentSpec.typeName || subagentSpec.role)) {
|
||||||
|
const specParts = [];
|
||||||
|
if (subagentSpec.typeName) specParts.push(encodeProtoStringField(1, subagentSpec.typeName));
|
||||||
|
if (subagentSpec.role) specParts.push(encodeProtoStringField(2, subagentSpec.role));
|
||||||
|
metaParts.push(encodeProtoBytesField(8, Buffer.concat(specParts)));
|
||||||
|
}
|
||||||
|
if (nestingDepth > 0) {
|
||||||
|
metaParts.push(encodeProtoVarintField(17, nestingDepth));
|
||||||
|
}
|
||||||
|
metaParts.push(encodeProtoStringField(18, projectId));
|
||||||
if (preserveTag15) {
|
if (preserveTag15) {
|
||||||
metaParts.push(encodeProtoBytesField(15, Buffer.from([0xde, 0xad, 0xbe, 0xef])));
|
metaParts.push(encodeProtoBytesField(15, Buffer.from([0xde, 0xad, 0xbe, 0xef])));
|
||||||
}
|
}
|
||||||
@@ -362,10 +398,18 @@ test('Cross-client session migration clones CLI/Legacy-IDE/Desktop SQLite sessio
|
|||||||
);
|
);
|
||||||
cliSum.close();
|
cliSum.close();
|
||||||
|
|
||||||
// Legacy IDE (.db without conversation_summaries.db)
|
// Legacy IDE (.db without conversation_summaries.db), including subagent & side-question .db files
|
||||||
const legacyRoot = join(geminiDir, 'antigravity-ide');
|
const legacyRoot = join(geminiDir, 'antigravity-ide');
|
||||||
mkdirSync(join(legacyRoot, 'conversations'), { recursive: true });
|
mkdirSync(join(legacyRoot, 'conversations'), { recursive: true });
|
||||||
const legacyCid = '33333333-3333-4333-8333-333333333331';
|
const legacyCid = '33333333-3333-4333-8333-333333333331';
|
||||||
|
const legacySubFn5Cid = '33333333-3333-4333-8333-333333333332';
|
||||||
|
const legacySubFn8Cid = '33333333-3333-4333-8333-333333333333';
|
||||||
|
const legacySubFn17Cid = '33333333-3333-4333-8333-333333333334';
|
||||||
|
const legacySubSrc16Cid = '33333333-3333-4333-8333-333333333335';
|
||||||
|
const legacySideQCid = '33333333-3333-4333-8333-333333333336';
|
||||||
|
const cliOrphanSubCid = '22222222-2222-4222-8222-222222222225';
|
||||||
|
const cliRawMetaSubCid = '22222222-2222-4222-8222-222222222226';
|
||||||
|
|
||||||
createConvDb(join(legacyRoot, 'conversations', `${legacyCid}.db`), {
|
createConvDb(join(legacyRoot, 'conversations', `${legacyCid}.db`), {
|
||||||
cid: legacyCid,
|
cid: legacyCid,
|
||||||
tid: 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbb1',
|
tid: 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbb1',
|
||||||
@@ -375,17 +419,145 @@ test('Cross-client session migration clones CLI/Legacy-IDE/Desktop SQLite sessio
|
|||||||
promptText: 'Refactor legacy sidebar',
|
promptText: 'Refactor legacy sidebar',
|
||||||
stepCount: 4,
|
stepCount: 4,
|
||||||
});
|
});
|
||||||
|
createConvDb(join(legacyRoot, 'conversations', `${legacySubFn5Cid}.db`), {
|
||||||
|
cid: legacySubFn5Cid,
|
||||||
|
tid: 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbb2',
|
||||||
|
source: 1,
|
||||||
|
parentConversationId: legacyCid,
|
||||||
|
promptText: 'Subagent via fn=5 parentConversationId',
|
||||||
|
stepCount: 2,
|
||||||
|
});
|
||||||
|
createConvDb(join(legacyRoot, 'conversations', `${legacySubFn8Cid}.db`), {
|
||||||
|
cid: legacySubFn8Cid,
|
||||||
|
tid: 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbb3',
|
||||||
|
source: 1,
|
||||||
|
subagentSpec: { typeName: 'research', role: 'Codebase Auditor' },
|
||||||
|
promptText: 'Subagent via fn=8 subagentSpec',
|
||||||
|
stepCount: 2,
|
||||||
|
});
|
||||||
|
createConvDb(join(legacyRoot, 'conversations', `${legacySubFn17Cid}.db`), {
|
||||||
|
cid: legacySubFn17Cid,
|
||||||
|
tid: 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbb4',
|
||||||
|
source: 1,
|
||||||
|
nestingDepth: 1,
|
||||||
|
promptText: 'Subagent via fn=17 nestingDepth',
|
||||||
|
stepCount: 2,
|
||||||
|
});
|
||||||
|
createConvDb(join(legacyRoot, 'conversations', `${legacySubSrc16Cid}.db`), {
|
||||||
|
cid: legacySubSrc16Cid,
|
||||||
|
tid: 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbb5',
|
||||||
|
source: 16,
|
||||||
|
promptText: 'Subagent via source=16 CORTEX_TRAJECTORY_SOURCE_SUBAGENT',
|
||||||
|
stepCount: 2,
|
||||||
|
});
|
||||||
|
createConvDb(join(legacyRoot, 'conversations', `${legacySideQCid}.db`), {
|
||||||
|
cid: legacySideQCid,
|
||||||
|
tid: 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbb6',
|
||||||
|
trajectoryType: 22,
|
||||||
|
source: 1,
|
||||||
|
promptText: 'Side question via trajectory_type=22',
|
||||||
|
stepCount: 2,
|
||||||
|
});
|
||||||
|
// Orphan subagent .db missing from CLI conversation_summaries.db
|
||||||
|
createConvDb(join(cliRoot, 'conversations', `${cliOrphanSubCid}.db`), {
|
||||||
|
cid: cliOrphanSubCid,
|
||||||
|
tid: 'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaa5',
|
||||||
|
source: 17,
|
||||||
|
parentConversationId: cliIdleCid,
|
||||||
|
subagentSpec: { typeName: 'research', role: 'Orphan Explorer' },
|
||||||
|
nestingDepth: 1,
|
||||||
|
promptText: 'Orphan CLI subagent without summary row',
|
||||||
|
stepCount: 2,
|
||||||
|
});
|
||||||
|
// Summary row with blank SQL parent_conversation_id/nesting_depth but subagentSpec in raw_summary.fn17
|
||||||
|
createConvDb(join(cliRoot, 'conversations', `${cliRawMetaSubCid}.db`), {
|
||||||
|
cid: cliRawMetaSubCid,
|
||||||
|
tid: 'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaa6',
|
||||||
|
source: 17,
|
||||||
|
subagentSpec: { typeName: 'browser', role: 'Page Inspector' },
|
||||||
|
promptText: 'CLI subagent flagged in raw_summary.fn17',
|
||||||
|
stepCount: 2,
|
||||||
|
});
|
||||||
|
const cliSumExtra = new DatabaseSync(join(cliRoot, 'conversation_summaries.db'));
|
||||||
|
cliSumExtra
|
||||||
|
.prepare(
|
||||||
|
`INSERT INTO conversation_summaries (
|
||||||
|
conversation_id, title, preview, step_count, last_modified_time,
|
||||||
|
workspace_uris, status, source, project_id, parent_conversation_id,
|
||||||
|
nesting_depth, not_fully_idle, killed, last_user_input_time,
|
||||||
|
last_user_input_step_index, app_data_dir, raw_summary
|
||||||
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||||
|
)
|
||||||
|
.run(
|
||||||
|
cliRawMetaSubCid,
|
||||||
|
'Browser Helper',
|
||||||
|
'Browser Helper',
|
||||||
|
2,
|
||||||
|
'2026-11-21 11:55:00.000000+00:00',
|
||||||
|
'["file:///C:/Users/Administrator"]',
|
||||||
|
'CASCADE_RUN_STATUS_IDLE',
|
||||||
|
'',
|
||||||
|
'default-cli-project',
|
||||||
|
'',
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
'2026-11-21 11:55:00.000000+00:00',
|
||||||
|
0,
|
||||||
|
'antigravity-cli',
|
||||||
|
Buffer.concat([
|
||||||
|
encodeProtoVarintField(2, 2),
|
||||||
|
encodeProtoBytesField(
|
||||||
|
17,
|
||||||
|
encodeProtoBytesField(
|
||||||
|
8,
|
||||||
|
Buffer.concat([
|
||||||
|
encodeProtoStringField(1, 'browser'),
|
||||||
|
encodeProtoStringField(2, 'Page Inspector'),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
),
|
||||||
|
])
|
||||||
|
);
|
||||||
|
cliSumExtra.close();
|
||||||
|
|
||||||
const cat = getSessionMigrationCatalog({ geminiDir });
|
const cat = getSessionMigrationCatalog({ geminiDir });
|
||||||
assert.equal(cat.available, true, 'Multi-client setup exposes migration catalog');
|
assert.equal(cat.available, true, 'Multi-client setup exposes migration catalog');
|
||||||
assert.equal(cat.sessionsByClient.cli.length, 2, 'Excludes subagent and 0-step empty CLI sessions');
|
assert.equal(
|
||||||
|
cat.sessionsByClient.cli.length,
|
||||||
|
2,
|
||||||
|
'Excludes summary-flagged, raw_summary.fn17-flagged, orphan .db subagent, and 0-step CLI sessions'
|
||||||
|
);
|
||||||
const idleItem = cat.sessionsByClient.cli.find((s) => s.cascadeId === cliIdleCid);
|
const idleItem = cat.sessionsByClient.cli.find((s) => s.cascadeId === cliIdleCid);
|
||||||
const runItem = cat.sessionsByClient.cli.find((s) => s.cascadeId === cliRunCid);
|
const runItem = cat.sessionsByClient.cli.find((s) => s.cascadeId === cliRunCid);
|
||||||
assert.equal(idleItem.title, 'Fix Braille progress bar width', 'Falls back to cleaned first user prompt title');
|
assert.equal(idleItem.title, 'Fix Braille progress bar width', 'Falls back to cleaned first user prompt title');
|
||||||
assert.equal(idleItem.isRunning, false);
|
assert.equal(idleItem.isRunning, false);
|
||||||
assert.equal(runItem.isRunning, true);
|
assert.equal(runItem.isRunning, true);
|
||||||
assert.equal(cat.sessionsByClient.ide_legacy.length, 1);
|
assert.equal(
|
||||||
|
cat.sessionsByClient.ide_legacy.length,
|
||||||
|
1,
|
||||||
|
'Excludes fn=5, fn=8, fn=17, source=16 subagents and trajectory_type=22 side-questions in summaryless ide_legacy'
|
||||||
|
);
|
||||||
|
assert.equal(cat.sessionsByClient.ide_legacy[0].cascadeId, legacyCid);
|
||||||
assert.equal(cat.sessionsByClient.ide_legacy[0].title, 'Refactor legacy sidebar');
|
assert.equal(cat.sessionsByClient.ide_legacy[0].title, 'Refactor legacy sidebar');
|
||||||
|
|
||||||
|
// Direct migrateSessions call rejects non-root subagent / side-question IDs even without summary DB
|
||||||
|
const nonRootMigRes = migrateSessions(
|
||||||
|
{
|
||||||
|
sourceClient: 'ide_legacy',
|
||||||
|
targetClient: 'desktop',
|
||||||
|
mode: 'clone',
|
||||||
|
cascadeIds: [legacySubFn5Cid, legacySubFn8Cid, legacySubFn17Cid, legacySubSrc16Cid, legacySideQCid],
|
||||||
|
},
|
||||||
|
{ geminiDir, backupDir }
|
||||||
|
);
|
||||||
|
assert.equal(nonRootMigRes.ok, false);
|
||||||
|
assert.equal(nonRootMigRes.migratedCount, 0);
|
||||||
|
assert.equal(nonRootMigRes.results.length, 5);
|
||||||
|
for (const r of nonRootMigRes.results) {
|
||||||
|
assert.equal(r.ok, false);
|
||||||
|
assert.equal(r.error, 'non_root_session');
|
||||||
|
}
|
||||||
assert.ok(cat.desktopProjects.some((p) => p.projectId === projId && p.name === 'antigravity-usage-monitor'));
|
assert.ok(cat.desktopProjects.some((p) => p.projectId === projId && p.name === 'antigravity-usage-monitor'));
|
||||||
assert.ok(cat.desktopProjects.some((p) => p.projectId === 'outside-of-project' && p.isOutsideProject));
|
assert.ok(cat.desktopProjects.some((p) => p.projectId === 'outside-of-project' && p.isOutsideProject));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user