Skip to content

feat(desktop): add optional periodic full-session snapshot - #9720

Open
P-dawn wants to merge 3 commits into
esengine:main-v2from
P-dawn:feat/periodic-session-snapshot
Open

feat(desktop): add optional periodic full-session snapshot#9720
P-dawn wants to merge 3 commits into
esengine:main-v2from
P-dawn:feat/periodic-session-snapshot

Conversation

@P-dawn

@P-dawn P-dawn commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Add an opt‑in periodic full‑session snapshot engine for the desktop app, as a safety net for the existing TurnDone‑only autosave.
Currently, sessions are persisted only when event.TurnDone fires (tabEventSink.EmitscheduleTabSnapshottabSnapshotLoop). A long in‑flight turn, a crash before TurnDone, or a version‑upgrade migration can therefore lose data that never reached disk. This PR adds a configurable ticker that calls the existing snapshotAllTabs() on an interval, so a force‑kill loses at most interval seconds of work instead of an entire in‑flight turn.
Default behaviour is unchanged: the engine is disabled unless REASONIX_ENABLE_PERIODIC_SNAPSHOT=1 is set. No config‑system, migration, or UI changes.

Issues

Addresses the data‑loss class of issues where in‑flight turns are lost on crash or before the TurnDone event persists the session. This PR lays the groundwork for later pre‑update snapshots and JSON export (both out of scope here).

Verification

  • Run unit tests:

    cd desktop
    go test -run "TestPeriodicSnapshot|TestResolvePeriodic" -v ./...
    go vet ./...
  • Enable the feature and observe periodic snapshots:

    • On Windows: set REASONIX_ENABLE_PERIODIC_SNAPSHOT=1 && reasonix-desktop.exe

    • Verify logs or disk writes occur at the configured interval (default 30s, clamped to 5s min).

  • Ensure existing tests pass unchanged when the env var is absent (no‑op behaviour).

Documentation impact

Documentation-impact: none - This feature is opt-in and disabled by default; it only adds two environment variables, so no configuration file schema, migration, or UI changes are required.

Cache impact

Cache-impact: none - This change does not touch system prompt construction, memory prefix, output styles, skill index, tool schemas, provider request serialization, compaction, or MCP/tool registration. It only schedules calls to the existing snapshotAllTabs() path.

Cache-guard: Existing autosave tests in app_autosave_test.go cover the snapshot path; this PR adds persistence_enhancer_test.go with test cases covering env‑var parsing, interval clamping, and lifecycle (Start/Stop idempotency, stop‑before‑start safety). The engine is disabled by default, so no existing cache‑sensitive test path is affected.

System-prompt-review: N/A

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) labels Sep 2, 2026
@P-dawn P-dawn changed the title 新增 persistence_enhancer.go 文件,通过环境变量控制,实现定时全量落盘 + 定时 JSON 快照导出 + 更新前自动快照。不需要修改现有业务逻辑,纯增量增强。feat(desktop): add optional periodic full-session snapshot feat(desktop): add optional periodic full-session snapshot Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

1 participant