Goal
Let users "pick up where they left off" when restarting TRX.
Description
Save and restore session state so TRX opens in the same context the user left it:
State to persist (~/.local/state/trx/state.toml):
- Current tab (
Tab enum variant)
- Last search query (
input string)
- Package list scroll position (
selected index)
- Details scroll offset (
details_scroll)
Implementation:
- Define a
SessionState struct deriving Serialize/Deserialize
- On
App::new(), attempt to load state.toml; apply the state after the first render
- On exit (the main loop's cleanup path), serialize and write the current state
Handle migration gracefully: if the schema changes, fall back to defaults rather than crashing.
Tech
Rust, Serde (serde_toml)
Difficulty
Level 3 – Advanced
Goal
Let users "pick up where they left off" when restarting TRX.
Description
Save and restore session state so TRX opens in the same context the user left it:
State to persist (
~/.local/state/trx/state.toml):Tabenum variant)inputstring)selectedindex)details_scroll)Implementation:
SessionStatestruct derivingSerialize/DeserializeApp::new(), attempt to loadstate.toml; apply the state after the first renderHandle migration gracefully: if the schema changes, fall back to defaults rather than crashing.
Tech
Rust, Serde (
serde_toml)Difficulty
Level 3 – Advanced