zed-industries/zed · error

No active repository

Error message

No active repository

What it means

In BranchDiffView::deploy_branch_diff: the action was invoked but project.read(cx).active_repository() returned None, so there is no repository to compute the branch diff for. This happens when the diff action is dispatched with no active project repository.

Source

Thrown at crates/git_ui/src/branch_diff.rs:91

        workspace.register_action(|workspace, _: &DeployBranchDiff, window, cx| {
            Self::deploy_branch_diff(workspace, window, cx)
        });
        workspace.register_action(Self::compare_with_branch);
        workspace::register_serializable_item::<Self>(cx);
    }

    pub(crate) fn deploy_branch_diff(
        workspace: &mut Workspace,
        window: &mut Window,
        cx: &mut Context<Workspace>,
    ) {
        telemetry::event!("Git Branch Diff Opened");
        let project = workspace.project().clone();
        let Some(intended_repo) = project.read(cx).active_repository(cx) else {
            let workspace = cx.entity().downgrade();
            window
                .spawn(cx, async |_cx| {
                    let result: Result<()> = Err(anyhow!("No active repository"));
                    result
                })
                .detach_and_notify_err(workspace, window, cx);
            return;
        };

        let default_branch = intended_repo.update(cx, |repo, _| repo.default_branch(true));
        let workspace = cx.entity();
        let workspace_weak = workspace.downgrade();
        window
            .spawn(cx, async move |cx| {
                let base_ref = default_branch.await??;
                workspace.update_in(cx, |workspace, window, cx| {
                    let git_store = project.read(cx).git_store().clone();
                    let Some(base_ref) = base_ref else {
                        ProjectDiff::deploy_at(workspace, None, window, cx);
                        return;
                    };

View on GitHub (pinned to f4178619ac)

Solutions

  1. Exit early without deploying the branch diff view
  2. Optionally show a 'no repository' status toast to explain the no-op
  3. Ensure the action is only registered/dispatched in workspaces containing git repositories
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/git_ui/src/branch_diff.rs:91 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/ae7eb5d056b59e78. Report an issue: GitHub.