Skip to content

Refac/state management#54

Draft
Keshav-writes-code wants to merge 20 commits intodevfrom
refac/state_management
Draft

Refac/state management#54
Keshav-writes-code wants to merge 20 commits intodevfrom
refac/state_management

Conversation

@Keshav-writes-code
Copy link
Copy Markdown
Owner

closes #53

this pr implement a custom persistent layer for storing and retrieving application state, replacing the previous use of tauri-plugin-store all written in rust.
and exposes 2 tauri command for js

  • get_persistent_states : to read, migrate the states stored on disk
  • save_persistent_states : to save states to disk

It also refactors state management across the Svelte frontend to use the new persistent state, updates workspace management logic, and cleans up related dependencies and permissions. The most important changes are grouped below:

Changes

Persistency Layer Implementation and Integration:

  • Added a new Rust module (src/features/persistency) implementing AppPersistentStates, including schema versioning, serialization, and migration scaffolding. This module provides Tauri commands for loading and saving persistent state (get_persistent_states, save_persistent_states). [1] [2] [3] [4] [5]
  • Registered the new Tauri commands and initialized persistent state setup in the Tauri app entrypoint. [1] [2]
  • Removed tauri-plugin-store from dependencies, permissions, and plugin setup, as it is no longer used. [1] [2] [3]

Frontend State Refactor:

  • Introduced a new Svelte store for persistent state (persistent_states), and refactored components to use it for managing recent workspaces and app configuration. [1] [2] [3]
  • Updated workspace selector logic to use the new persistent state structure, including reading, updating, and clearing recent workspaces, and integrating with workspace initialization. [1] [2] [3]
  • Added UI controls in app settings for loading and saving persistent state, and displaying its JSON representation for debugging.

Codebase and Dependency Cleanup:

  • Removed unused imports, refactored state imports to use new session/persistent state modules, and cleaned up legacy logic in Svelte components. [1] [2] [3] [4]
  • Updated and reordered dependencies in package.json to reflect removal of unused libraries and addition of new ones.
  • Added chrono (with serde feature) as a Rust dependency for timestamp serialization in persistent state.

These changes collectively provide a more robust, versioned, and extensible approach to application state persistence, and streamline state management across the app.

Architecture

get_persistent_states

this function has the responsibilty to

  • read and parse the config.json
    • if config.json not found, initalize a default one
  • run migrations and update the config.json
  • return the final data to frontend

save_persistent_states

this function is responsible for

  • simply saving to disk

Other notes

  • all config is stored in a config.json file in the programs config directory according to the OS (eg ~/.config/io.github.keshav-writes-code.cherit for linux)
  • the frontend and backend communication uses the same schema of data as to what is saved in the config.json
  • eveytime the state is passed from frontend to backend, it is passed as as the full object, instead of a partial object
  • on calling the tauri commands from js, in rust, a new object of type AppPersistentStates is created for the operations and releeased and nothing is mainted in memory

@Keshav-writes-code Keshav-writes-code added this to the 0.1.0 milestone Apr 21, 2026
@Keshav-writes-code Keshav-writes-code self-assigned this Apr 21, 2026
@Keshav-writes-code Keshav-writes-code added the enhancement New feature or request label Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant