mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5192] [CLOSED] [GUI] Hotfix: Fixed an issue where chats could be trimmed and not stored #5339
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#5339
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/5192
Author: @MohSakhaei
Created: 11/4/2026
Status: ❌ Closed
Base:
main← Head:hotfix/chat-store📝 Commits (1)
27b1e14Fixed an issue where chats could be trimmed and not stored📊 Changes
3 files changed (+74 additions, -46 deletions)
View changed files
📝
apps/host/src/lib/session-persist.ts(+35 -39)📝
apps/host/src/lib/store.ts(+1 -1)📝
apps/host/tests/session-persist.test.mjs(+38 -6)📄 Description
The title must start with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], for example "[Engine] fix decode stop on long prompts" or "[GUI] keep the model list after a tab switch".
Problem and result
a chat with agent tool calls that grew past 1.5M of saved JSON silently lost its
oldest messages after each restart, and an older chat could disappear from the list altogether. Since the
saved list is the only place the app keeps chats (the load reads the same
strata.sessions.v1key back),each restart trimmed the chat again: a three-question chat came back with one question and an answer whose
question was gone. Before this change
serializeSessiondropped the oldest messages in halves whenever achat passed
MAX_SESSION_CHARS, andflushleft whole chats out of the saved copy whenever the list passedMAX_TOTAL_CHARS. 0.2.9 wrote the list whole (a quota failure kept the last good write; nothing was deleted),so the loss is a 0.2.10 regression from the write-cap part of
1298a397(#3604, #3603). The coalescing andthe write-per-second that fixed the renderer growth (#3604, #3603) are kept; only the deleting part is
replaced: oversized fields (mostly tool results) are clipped, and if the whole list still does not fit, the
oldest unpinned chats' fields are clipped harder (20k). Messages and chats are never removed, and a failed
write still leaves the last good copy.
Related discussion
none
Approach
The trimmed copy looked like a cache in the comments ("the saved list is a cache, not the source
of truth"), but there is no other copy to fall back on, so shortening it is permanent loss. The bytes that
matter to a person — questions and answers — are small; tool results are what grow. So the saved copy now
loses field length instead of entries: 200k per field as before, then a hard 20k per field for the oldest
unpinned chats, and only while the list is over budget; pinned and newest chats shrink last. The stored
format is unchanged (still a JSON array under
strata.sessions.v1), so no migration is needed and olderbuilds still read it. Chats already trimmed by 0.2.10 cannot be restored by this change; the agent's own
session history under the data folder may still hold their text.
Validation
(Windows x64, Node v24.14.1, revision
27b1e14c; baseffa80d73= v0.2.10):Passed:
Failed:
chat-shell.test.mjs"native file actions use explicit argument arrays and reject traversal andsymlinks" and
model-directory.test.mjs"existing flat and Strata-layout weights are found…" —EPERM: symlink; this Windows setup cannot create symlinks. Both fail identically on the baserevision
ffa80d73without this change, so they are pre-existing and unrelated.Not run:
is that a live 0.2.9-upgraded profile reads back correctly after the change (the format is unchanged).
by clicking through the app.
Limits
chats already trimmed by 0.2.10 stay trimmed — this change prevents further loss, it does not
recover past ones. In an over-budget list the oldest chats' tool results can show
"[shortened in the saved copy]" after a restart; their questions and answers stay whole. If the whole list
still cannot fit after everything shrinks, the storage write throws, the quota catch keeps the last good
copy, and only the newest unsaved turn is at risk — as in 0.2.9.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.