Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0c696d1

Browse files
committed
enhance the snapshot backward compatibility issue
Signed-off-by: ChengZi <[email protected]>
1 parent 8a63f72 commit 0c696d1

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

packages/mcp/src/snapshot.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ export class SnapshotManager {
7272
this.indexedCodebases = validCodebases;
7373
this.indexingCodebases = new Map(); // Reset indexing codebases since they were interrupted
7474
this.codebaseFileCount = new Map(); // No file count info in v1 format
75+
76+
// Populate codebaseInfoMap for v1 indexed codebases (with minimal info)
77+
this.codebaseInfoMap = new Map();
78+
const now = new Date().toISOString();
79+
for (const codebasePath of validCodebases) {
80+
const info: CodebaseInfoIndexed = {
81+
status: 'indexed',
82+
indexedFiles: 0, // Unknown in v1 format
83+
totalChunks: 0, // Unknown in v1 format
84+
indexStatus: 'completed', // Assume completed for v1 format
85+
lastUpdated: now
86+
};
87+
this.codebaseInfoMap.set(codebasePath, info);
88+
}
7589
}
7690

7791
/**
@@ -225,6 +239,14 @@ export class SnapshotManager {
225239
*/
226240
public addIndexingCodebase(codebasePath: string, progress: number = 0): void {
227241
this.indexingCodebases.set(codebasePath, progress);
242+
243+
// Also update codebaseInfoMap for v2 compatibility
244+
const info: CodebaseInfoIndexing = {
245+
status: 'indexing',
246+
indexingPercentage: progress,
247+
lastUpdated: new Date().toISOString()
248+
};
249+
this.codebaseInfoMap.set(codebasePath, info);
228250
}
229251

230252
/**
@@ -233,6 +255,14 @@ export class SnapshotManager {
233255
public updateIndexingProgress(codebasePath: string, progress: number): void {
234256
if (this.indexingCodebases.has(codebasePath)) {
235257
this.indexingCodebases.set(codebasePath, progress);
258+
259+
// Also update codebaseInfoMap for v2 compatibility
260+
const info: CodebaseInfoIndexing = {
261+
status: 'indexing',
262+
indexingPercentage: progress,
263+
lastUpdated: new Date().toISOString()
264+
};
265+
this.codebaseInfoMap.set(codebasePath, info);
236266
}
237267
}
238268

@@ -241,6 +271,8 @@ export class SnapshotManager {
241271
*/
242272
public removeIndexingCodebase(codebasePath: string): void {
243273
this.indexingCodebases.delete(codebasePath);
274+
// Also remove from codebaseInfoMap for v2 compatibility
275+
this.codebaseInfoMap.delete(codebasePath);
244276
}
245277

246278
/**
@@ -253,6 +285,16 @@ export class SnapshotManager {
253285
if (fileCount !== undefined) {
254286
this.codebaseFileCount.set(codebasePath, fileCount);
255287
}
288+
289+
// Also update codebaseInfoMap for v2 compatibility
290+
const info: CodebaseInfoIndexed = {
291+
status: 'indexed',
292+
indexedFiles: fileCount || 0,
293+
totalChunks: 0, // Unknown in v1 method
294+
indexStatus: 'completed',
295+
lastUpdated: new Date().toISOString()
296+
};
297+
this.codebaseInfoMap.set(codebasePath, info);
256298
}
257299

258300
/**
@@ -261,6 +303,8 @@ export class SnapshotManager {
261303
public removeIndexedCodebase(codebasePath: string): void {
262304
this.indexedCodebases = this.indexedCodebases.filter(path => path !== codebasePath);
263305
this.codebaseFileCount.delete(codebasePath);
306+
// Also remove from codebaseInfoMap for v2 compatibility
307+
this.codebaseInfoMap.delete(codebasePath);
264308
}
265309

266310
/**

0 commit comments

Comments
 (0)