Skip to content

Guard session snapshots against stale overwrites / 防止旧快照覆盖会话#5851

Merged
SivanCola merged 2 commits into
esengine:main-v2from
SivanCola:fix/session-snapshot-conflict
Jul 3, 2026
Merged

Guard session snapshots against stale overwrites / 防止旧快照覆盖会话#5851
SivanCola merged 2 commits into
esengine:main-v2from
SivanCola:fix/session-snapshot-conflict

Conversation

@SivanCola

@SivanCola SivanCola commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Closes #5783.

Summary

  • Add protected session save modes for normal snapshots and intentional history rewrites.
  • Reject stale controller snapshots that would overwrite a newer transcript already persisted on disk.
  • Allow explicit rewrites (compact, rewind, cold-resume pruning, interrupted-turn/cancel recovery) only when the controller still owns the current on-disk transcript baseline.
  • Let desktop session removal skip stale runtime snapshots while preserving the newer on-disk transcript for trash/removal flows.

Root cause

Normal controller snapshots rewrote the whole JSONL file. If an older tab/runtime still held a shorter in-memory session for the same session path, a later autosave or tab close could replace the newer JSONL with that stale snapshot, making messages appear to roll back or disappear.

Validation

  • go test ./internal/agent ./internal/control
  • cd desktop && go test .
  • git diff --check
  • go test ./internal/environment -run TestRunProbesUsesOverridePathAndFirstLine -count=1

Note: go test ./... was also attempted; the only failure was the same intermittent internal/environment probe timeout, and the focused probe test passed when rerun separately.

@SivanCola SivanCola requested a review from esengine as a code owner July 3, 2026 07:40
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) agent Core agent loop (internal/agent, internal/control) labels Jul 3, 2026
@SivanCola SivanCola merged commit 74b9dd7 into esengine:main-v2 Jul 3, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Core agent loop (internal/agent, internal/control) desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 出现了对话框吞了记录的情况

1 participant