Skip to content

Add async session persistence helpers for save/load state#112

Merged
ryanoneill merged 3 commits intomainfrom
feature/session-persistence
Mar 2, 2026
Merged

Add async session persistence helpers for save/load state#112
ryanoneill merged 3 commits intomainfrom
feature/session-persistence

Conversation

@ryanoneill
Copy link
Owner

Summary

  • Add async load_state<S: DeserializeOwned>(path) using tokio::fs::read_to_string for non-blocking file I/O
  • Add Command::save_state<S: Serialize>(state, path) using tokio::fs::write for async file writes
  • Both behind #[cfg(feature = "serialization")]
  • Uses structured EnvisionError::Config { field, reason } variant for deserialization errors
  • Add tokio "fs" feature and tokio-test dev-dependency
  • Module re-exported at envision::app::persistence and envision::app::load_state

Replaces #111.

Test plan

  • cargo test — all tests pass (6 async persistence tests)
  • cargo clippy -- -D warnings — clean
  • cargo check --no-default-features — compiles
  • cargo test --doc — 276 doc tests pass
  • cargo build --examples — compiles

🤖 Generated with Claude Code

ryanoneill and others added 3 commits March 1, 2026 20:57
Add load_state<S>(path) function that reads a JSON file and
deserializes into any DeserializeOwned type. Add Command::save_state()
that serializes state to JSON and writes to disk. Both behind the
serialization feature flag. Uses structured EnvisionError::Config
variant for deserialization errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add tokio "fs" feature to enable tokio::fs::write for async file I/O
in Command::save_state. File write errors are reported to the runtime's
error channel via try_perform_async.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
load_state now uses tokio::fs::read_to_string for non-blocking file I/O,
consistent with save_state's use of tokio::fs::write. All persistence
tests updated to #[tokio::test]. Added tokio-test dev-dependency for
async doc test support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ryanoneill ryanoneill merged commit 087bee6 into main Mar 2, 2026
8 of 12 checks passed
@ryanoneill ryanoneill deleted the feature/session-persistence branch March 2, 2026 04:58
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 53.84615% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.61%. Comparing base (f593789) to head (f8c8a79).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/app/command/mod.rs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #112      +/-   ##
==========================================
- Coverage   92.66%   92.61%   -0.06%     
==========================================
  Files          99      100       +1     
  Lines        9517     9530      +13     
==========================================
+ Hits         8819     8826       +7     
- Misses        698      704       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants