Hmbown/CodeWhale · error

Failed to persist fork

Error message

Failed to persist fork: {persistence_error}; cleanup also failed: {}

What it means

Thread fork persistence failed and the best-effort cleanup (removing the partially written thread, turns, and items) also failed; the chained error reports both so the operator knows the store may hold partial fork state needing manual recovery.

Solutions

  1. Free or fix the storage issue that made the initial persist fail, then fork again; the half-written fork was cleaned up (or cleanup errors are listed in the message).
  2. If cleanup also failed, manually remove the partial thread/turn/item rows named by the cleanup errors before retrying.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/tui/src/runtime_threads.rs:8609 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/d78e43c4cc293190. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/runtime_threads.rs:8609

        if let Err(persistence_error) = persistence {
            let mut cleanup_errors = Vec::new();
            if let Err(error) = self.store.remove_thread(&thread.id) {
                cleanup_errors.push(format!("remove thread: {error}"));
            }
            for turn_id in saved_turn_ids.iter().rev() {
                if let Err(error) = self.store.remove_turn(turn_id) {
                    cleanup_errors.push(format!("remove turn {turn_id}: {error}"));
                }
            }
            for item_id in saved_item_ids.iter().rev() {
                if let Err(error) = self.store.remove_item(item_id) {
                    cleanup_errors.push(format!("remove item {item_id}: {error}"));
                }
            }
            if cleanup_errors.is_empty() {
                return Err(persistence_error);
            }
            bail!(
                "Failed to persist fork: {persistence_error}; cleanup also failed: {}",
                cleanup_errors.join("; ")
            );
        }
        Ok(())
    }

    /// Seed a thread with messages from a saved session so subsequent turns
    /// continue with the prior conversation context.
    ///
    /// Unlike the old text-only implementation, this preserves all content
    /// block types (thinking, tool_use, tool_result, etc.) as separate turn
    /// items so that `loadHistory` in the GUI can reconstruct the full
    /// conversation including process information.
    pub async fn seed_thread_from_messages(
        &self,
        thread_id: &str,
        messages: &[Message],

View on GitHub (pinned to 73e0f67d83)