Hmbown/CodeWhale · error · anyhow::Error

workspace cannot be changed while the thread has an active t

Error message

workspace cannot be changed while the thread has an active turn

What it means

Concurrency guard in the thread update path: the request changes the thread's workspace while that thread currently has an active turn. The running engine is bound to the old workspace; letting the change through mid-turn would make file operations land in two different roots, so the update is refused.

Source

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

                    changes.insert("system_prompt".to_string(), json!(new_sys));
                }
            }
            if let Some(workspace) = req.workspace
                && thread.workspace != workspace
            {
                changes.insert("workspace".to_string(), json!(workspace));
                thread.workspace = workspace;
            }

            let workspace_changed = changes.contains_key("workspace");
            if workspace_changed
                && active
                    .engines
                    .get(id)
                    .and_then(|state| state.active_turn.as_ref())
                    .is_some()
            {
                bail!("workspace cannot be changed while the thread has an active turn");
            }

            // A posture/mode edit must reach the live engine even while a
            // turn is running. EngineHandle publishes the authority snapshot
            // before queueing ChangeMode; the turn loop applies that pending
            // update before the next tool batch.
            let posture_changed = changes.contains_key("auto_approve")
                || changes.contains_key("permission_posture")
                || changes.contains_key("trust_mode")
                || changes.contains_key("allow_shell")
                || changes.contains_key("mode");

            let evicted_engine = if changes.is_empty() {
                None
            } else {
                thread.updated_at = Utc::now();
                self.store.save_thread(&thread)?;
                if workspace_changed {

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Wait for or interrupt the active turn
  2. Then retry the workspace change
Defensive patterns

Strategy: validation

When it happens

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

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/4e1e6ad2c73d0deb. Report an issue: GitHub.