Skip to content

Comments

chore: snapshot andd restore points for ai changes#2689

Open
abose wants to merge 8 commits intomainfrom
z
Open

chore: snapshot andd restore points for ai changes#2689
abose wants to merge 8 commits intomainfrom
z

Conversation

@abose
Copy link
Member

@abose abose commented Feb 20, 2026

No description provided.

Move AISnapshotStore content from unbounded in-memory _contentStore to
disk-backed storage under <appSupportDir>/instanceData/<instanceId>/aiSnap/.
Content stays in _memoryBuffer during an AI turn and flushes to disk at
finalizeResponse() time. Reads check memory first, then fall back to disk.

Add per-instance heartbeat (60s interval) and garbage collection that
removes stale instance directories (>20 min without heartbeat) on startup.
Add integration tests covering snapshot data consistency: content-
addressable dedup, snapshot building/back-fill, multi-response
restore, file creation/deletion flows, and reset behavior. Expose
AISnapshotStore via brackets.test for test window access.
Store raw content in _readFiles instead of eagerly hashing on every
recordFileRead call. Content is only hashed when promoted to a snapshot
(on FS delete/rename), saving CPU and memory for the common read-only case.

Also fixes three resilience issues:
- _readContent: use hasOwnProperty for _memoryBuffer lookup so empty
  string content is not missed by the falsy check
- _closeAndDeleteFile: treat "file already gone" as success instead of
  rejecting, so restores don't report spurious errors
- _createOrUpdateFile: await CMD_OPEN completion before resolving to
  prevent race conditions with subsequent restore operations
Extract ~42 hardcoded English strings from AIChatPanel.js into
src/nls/root/strings.js using AI_CHAT_* keys. Replace all in-code
literals with Strings.* constants and StringUtils.format() for
parameterized text.

Fix a locale-sensitive bug where the Undo button click handler
compared $(this).text() against English "Undo" — now uses
data-action attributes instead.

Pass brackets.getLocale() to the Claude agent so non-English users
get responses in their display language.

Add i18n guidance section to CLAUDE.md.
When a tool (e.g. Write) streams slowly, the "receiving N bytes..."
preview would freeze. After 2s of no updates, rotate through
"Working...", "Writing...", "Processing..." every 3s so the user
sees the operation is still in progress. Timers are cleaned up
when tool info arrives.
Fix race condition in expectFileDeleted test helper where fileExists()
was fired on every awaitsFor poll but the result was checked before the
promise resolved, causing one-poll-behind behavior and timeouts.

Make _createOrUpdateFile resilient to stale FileSystem cache: when
file.exists() returns true but getDocumentForPath fails (e.g. after a
delete+recreate cycle), fall back to creating the file on disk and retry.
Two root causes identified and fixed:

1. expectFileDeleted used file.exists() which checks the _stat cache.
   After unlink, _handleDirectoryChange re-reads the parent dir and
   can repopulate _stat on the deleted File object from a racing
   readdir. Switch to FileSystem.existsAsync() which bypasses the
   cached _stat and goes directly to the impl.

2. _createOrUpdateFile could fail with NotFound when file.exists()
   returned stale true after a delete+recreate cycle. Add fallback:
   if getDocumentForPath fails, create the file on disk and retry.
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant