mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5359] [GUI] recover chat revisions after an index write failure #5402
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5402
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/5359
Author: @zapabob
Created: 11/5/2026
Status: 🔄 Open
Base:
main← Head:codex/fix-chat-revision-recovery📝 Commits (1)
85e899ffix(gui): recover chat revisions from committed files📊 Changes
2 files changed (+53 additions, -7 deletions)
View changed files
📝
apps/host/server/chat-store.mjs(+4 -7)📝
apps/host/tests/chat-store.test.mjs(+49 -0)📄 Description
Problem and result
If a chat file is committed but the following index write fails, the save succeeds and the existing index remains valid JSON with the previous revision. On restart, the host trusts that stale entry for an already indexed chat. A second window saving with the old base revision can then overwrite the newer chat without preserving it as a conflict.
Recover the revision and list metadata from every committed chat envelope at startup. The same recovery also reports an indexed file that has become unreadable, without modifying its bytes.
Related discussion
Related chat-persistence history: #5192. Searched open and closed issues and pull requests for chat-store revision and index recovery; no matching fix found. This is a focused persistence bug fix, with no new feature, dependency or storage-format change.
Approach
Treat the individual chat files as authoritative and rebuild the in-memory index from them. Reuse the existing envelope validation, metadata extraction and damaged-file reporting. Atomic writes, conflict retention and the on-disk format remain unchanged.
Two regression tests cover an injected ENOSPC affecting only the index write after a successful chat commit, and corruption of a file already present in a valid index. The first also checks that restart recovers revision 2 and that an old window's subsequent save becomes revision 3 while preserving revision 2 in conflicts.
Validation
Windows x64, Node v24.22.2. Upstream base:
9f7d977d220e9fdf2ec53cf2620cdadac1cfb24e. Submitted code:85e899f9a71c18f9194c3b0cba733d938b760f21.Passed:
node --test apps/host/tests/chat-store.test.mjs: 13 passed, 0 failed after the fix. Includes the existing greater-than-10-MB restart fixture.node --test --test-timeout=90000 apps/host/tests/chat-store-api.test.mjs: 3 passed, 0 failed. Starts the real host with temporary profiles; covers a 12-MB chat across host restart, chat routes, and events between windows.node --check apps/host/server/chat-store.mjs,node --check apps/host/tests/chat-store.test.mjs, andgit diff --check: passed.Failed:
Not run:
Limits
Startup now reads and parses each chat file, so its cost grows with the total saved chat history. The existing large-chat tests exercise correctness but are not a startup performance benchmark. This prevents future revision recovery failures; it cannot recover a chat that was already overwritten without a retained conflict copy.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.