{"record":{"id":"e34cad2861ca399c","repo":"zed-industries/zed","slug":"no-window-handle-available-for-workspace-creation","errorCode":null,"errorMessage":"No window handle available for workspace creation","messagePattern":"No window handle available for workspace creation","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/git_ui_core/src/worktree_service.rs","lineNumber":1164,"sourceCode":"\n/// Core workspace opening logic shared by both create and switch flows.\n/// Returns the newly opened workspace entity so callers can do post-open\n/// work (e.g., the `create_thread` agent tool spawns a thread inside it).\nasync fn open_worktree_workspace(\n    all_paths: Vec<PathBuf>,\n    path_remapping: Vec<(PathBuf, PathBuf)>,\n    non_git_paths: Vec<PathBuf>,\n    has_non_git: bool,\n    previous_state: PreviousWorkspaceState,\n    workspace: WeakEntity<Workspace>,\n    window_handle: Option<gpui::WindowHandle<MultiWorkspace>>,\n    remote_connection_options: Option<RemoteConnectionOptions>,\n    operation: WorktreeOperation,\n    activate: bool,\n    cx: &mut AsyncWindowContext,\n) -> anyhow::Result<Entity<Workspace>> {\n    let window_handle = window_handle\n        .ok_or_else(|| anyhow!(\"No window handle available for workspace creation\"))?;\n\n    let focused_dock = previous_state.focused_dock;\n\n    let is_creating_new_worktree = matches!(operation, WorktreeOperation::Create);\n\n    // When `activate` is false the new workspace is opened in the background\n    // (e.g. the agent's `create_thread` tool), so it should be a clean\n    // checkout rather than inheriting the source workspace's open files and\n    // dock layout. The state transfer only applies when we're foregrounding\n    // a freshly-created worktree for the user.\n    let transfer_state = is_creating_new_worktree && activate;\n\n    let source_for_transfer = if transfer_state {\n        Some(workspace.clone())\n    } else {\n        None\n    };\n","sourceCodeStart":1146,"sourceCodeEnd":1182,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/git_ui_core/src/worktree_service.rs#L1146-L1182","documentation":"In open_worktree_workspace: the caller passed a None window handle, but opening the new worktree workspace requires a WindowHandle<MultiWorkspace> to create/present the window. Fires when the create/switch flow loses its window reference before the open step.","triggerScenarios":"Thrown at crates/git_ui_core/src/worktree_service.rs:1164 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the worktree create/switch action from an active application window","Avoid triggering workspace creation after the originating window has been closed","If reproducible, capture the call path — a caller is dropping the window handle prematurely"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}