From 4fef96e40719bd8e1563ab3dd2d8dfd777880a1b Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Oct 2025 08:20:44 +0000 Subject: [PATCH] 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> --- crates/story/src/themes.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/story/src/themes.rs b/crates/story/src/themes.rs index f70b915e..bd41ab6b 100644 --- a/crates/story/src/themes.rs +++ b/crates/story/src/themes.rs @@ -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();