{"record":{"id":"4e1e6ad2c73d0deb","repo":"Hmbown/CodeWhale","slug":"workspace-cannot-be-changed-while-the-thread-has-a","errorCode":null,"errorMessage":"workspace cannot be changed while the thread has an active turn","messagePattern":"workspace cannot be changed while the thread has an active turn","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":4768,"sourceCode":"                    changes.insert(\"system_prompt\".to_string(), json!(new_sys));\n                }\n            }\n            if let Some(workspace) = req.workspace\n                && thread.workspace != workspace\n            {\n                changes.insert(\"workspace\".to_string(), json!(workspace));\n                thread.workspace = workspace;\n            }\n\n            let workspace_changed = changes.contains_key(\"workspace\");\n            if workspace_changed\n                && active\n                    .engines\n                    .get(id)\n                    .and_then(|state| state.active_turn.as_ref())\n                    .is_some()\n            {\n                bail!(\"workspace cannot be changed while the thread has an active turn\");\n            }\n\n            // A posture/mode edit must reach the live engine even while a\n            // turn is running. EngineHandle publishes the authority snapshot\n            // before queueing ChangeMode; the turn loop applies that pending\n            // update before the next tool batch.\n            let posture_changed = changes.contains_key(\"auto_approve\")\n                || changes.contains_key(\"permission_posture\")\n                || changes.contains_key(\"trust_mode\")\n                || changes.contains_key(\"allow_shell\")\n                || changes.contains_key(\"mode\");\n\n            let evicted_engine = if changes.is_empty() {\n                None\n            } else {\n                thread.updated_at = Utc::now();\n                self.store.save_thread(&thread)?;\n                if workspace_changed {","sourceCodeStart":4750,"sourceCodeEnd":4786,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/runtime_threads.rs#L4750-L4786","documentation":"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.","triggerScenarios":"Thrown at crates/tui/src/runtime_threads.rs:4768 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for or interrupt the active turn","Then retry the workspace change"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}