Skip to content

Commit 0b5a2cf

Browse files
committed
test: udpate tests for ai snapshot
1 parent b884a05 commit 0b5a2cf

2 files changed

Lines changed: 229 additions & 28 deletions

File tree

src/core-ai/AIChatPanel.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ define(function (require, exports, module) {
241241
_hasReceivedContent = false;
242242
_currentEdits = [];
243243
_firstEditInResponse = true;
244+
SnapshotStore.startTracking();
244245
_appendThinkingIndicator();
245246

246247
// Remove restore highlights from previous interactions
@@ -370,6 +371,23 @@ define(function (require, exports, module) {
370371
"file=" + (data.toolInput && data.toolInput.file_path || "?").split("/").pop(),
371372
"streamEvents=" + streamCount);
372373
_updateToolIndicator(data.toolId, data.toolName, data.toolInput);
374+
375+
// Capture content of files the AI reads (for snapshot delete tracking)
376+
if (data.toolName === "Read" && data.toolInput && data.toolInput.file_path) {
377+
const filePath = data.toolInput.file_path;
378+
const vfsPath = SnapshotStore.realToVfsPath(filePath);
379+
const openDoc = DocumentManager.getOpenDocumentForPath(vfsPath);
380+
if (openDoc) {
381+
SnapshotStore.recordFileRead(filePath, openDoc.getText());
382+
} else {
383+
const file = FileSystem.getFileForPath(vfsPath);
384+
file.read(function (err, readData) {
385+
if (!err && readData) {
386+
SnapshotStore.recordFileRead(filePath, readData);
387+
}
388+
});
389+
}
390+
}
373391
}
374392

375393
function _onToolStream(_event, data) {
@@ -586,7 +604,7 @@ define(function (require, exports, module) {
586604
// Don't stop streaming — the node side may continue (partial results)
587605
}
588606

589-
function _onComplete(_event, data) {
607+
async function _onComplete(_event, data) {
590608
console.log("[AI UI]", "Complete. textChunks=" + _traceTextChunks,
591609
"toolStreams=" + JSON.stringify(_traceToolStreamCounts));
592610
// Reset trace counters for next query
@@ -595,18 +613,19 @@ define(function (require, exports, module) {
595613

596614
// Append edit summary if there were edits (finalizeResponse called inside)
597615
if (_currentEdits.length > 0) {
598-
_appendEditSummary();
616+
await _appendEditSummary();
599617
}
600618

619+
SnapshotStore.stopTracking();
601620
_setStreaming(false);
602621
}
603622

604623
/**
605624
* Append a compact summary card showing all files modified during this response.
606625
*/
607-
function _appendEditSummary() {
626+
async function _appendEditSummary() {
608627
// Finalize snapshot and get the after-snapshot index
609-
const afterIndex = SnapshotStore.finalizeResponse();
628+
const afterIndex = await SnapshotStore.finalizeResponse();
610629
_undoApplied = false;
611630

612631
// Aggregate per-file stats

0 commit comments

Comments
 (0)