zed-industries/zed · error

No window handle available for workspace creation

Error message

No window handle available for workspace creation

What it means

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.

Source

Thrown at crates/git_ui_core/src/worktree_service.rs:1164

/// Core workspace opening logic shared by both create and switch flows.
/// Returns the newly opened workspace entity so callers can do post-open
/// work (e.g., the `create_thread` agent tool spawns a thread inside it).
async fn open_worktree_workspace(
    all_paths: Vec<PathBuf>,
    path_remapping: Vec<(PathBuf, PathBuf)>,
    non_git_paths: Vec<PathBuf>,
    has_non_git: bool,
    previous_state: PreviousWorkspaceState,
    workspace: WeakEntity<Workspace>,
    window_handle: Option<gpui::WindowHandle<MultiWorkspace>>,
    remote_connection_options: Option<RemoteConnectionOptions>,
    operation: WorktreeOperation,
    activate: bool,
    cx: &mut AsyncWindowContext,
) -> anyhow::Result<Entity<Workspace>> {
    let window_handle = window_handle
        .ok_or_else(|| anyhow!("No window handle available for workspace creation"))?;

    let focused_dock = previous_state.focused_dock;

    let is_creating_new_worktree = matches!(operation, WorktreeOperation::Create);

    // When `activate` is false the new workspace is opened in the background
    // (e.g. the agent's `create_thread` tool), so it should be a clean
    // checkout rather than inheriting the source workspace's open files and
    // dock layout. The state transfer only applies when we're foregrounding
    // a freshly-created worktree for the user.
    let transfer_state = is_creating_new_worktree && activate;

    let source_for_transfer = if transfer_state {
        Some(workspace.clone())
    } else {
        None
    };

View on GitHub (pinned to f4178619ac)

Solutions

  1. Retry the worktree create/switch action from an active application window
  2. Avoid triggering workspace creation after the originating window has been closed
  3. If reproducible, capture the call path — a caller is dropping the window handle prematurely
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/git_ui_core/src/worktree_service.rs:1164 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/e34cad2861ca399c. Report an issue: GitHub.