story: Fix story panic when save state failed. (#1384)

Close #1383

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: huacnlee <5518+huacnlee@users.noreply.github.com>
This commit is contained in:
Copilot
2025-10-15 08:20:44 +00:00
committed by GitHub
parent 1bc5ff03df
commit 4fef96e407

View File

@@ -49,8 +49,10 @@ pub fn init(cx: &mut App) {
scrollbar_show: Some(cx.theme().scrollbar_show),
};
let json = serde_json::to_string_pretty(&state).unwrap();
std::fs::write(STATE_FILE, json).unwrap();
if let Ok(json) = serde_json::to_string_pretty(&state) {
// Ignore write errors - if STATE_FILE doesn't exist or can't be written, do nothing
let _ = std::fs::write(STATE_FILE, json);
}
})
.detach();