zed-industries/zed · error

no active repository

Error message

no active repository

What it means

confirm_mention_for_git_diff asks the project for its active git repository via project.active_repository(cx). None means no repository is currently marked active — none of the open worktrees is a git repo, or git detection has not completed/selected one yet — so there is nothing to diff against.

Source

Thrown at crates/agent_ui/src/mention_set.rs:685

                .unwrap_or_else(|| "No diagnostics found.".into());
            Ok(Mention::Text {
                content,
                tracked_buffers: Vec::new(),
            })
        })
    }

    pub fn confirm_mention_for_git_diff(
        &self,
        base_ref: SharedString,
        cx: &mut Context<Self>,
    ) -> Task<Result<Mention>> {
        let Some(project) = self.project.upgrade() else {
            return Task::ready(Err(anyhow!("project not found")));
        };

        let Some(repo) = project.read(cx).active_repository(cx) else {
            return Task::ready(Err(anyhow!("no active repository")));
        };

        let diff_receiver = repo.update(cx, |repo, cx| {
            repo.diff(
                git::repository::DiffType::MergeBase { base_ref: base_ref },
                cx,
            )
        });

        cx.spawn(async move |_, _| {
            let diff_text = diff_receiver.await??;
            if diff_text.is_empty() {
                Ok(Mention::Text {
                    content: "No changes found in branch diff.".into(),
                    tracked_buffers: Vec::new(),
                })
            } else {
                Ok(Mention::Text {

View on GitHub (pinned to bc538def45)

Solutions

  1. Open the project at a git repository root (or a subdirectory of one).
  2. Wait a moment for git detection to complete, then retry the mention.
  3. In multi-repo projects, interact with the source-control panel once so an active repository is selected.
  4. Surface 'no git repository in this project' in the editor instead of a generic error.
Defensive patterns

Strategy: validation

Validate before calling

let has_active_repo = project.read(cx).active_repository(cx).is_some();
if !has_active_repo {
    // hide or disable the git-diff mention suggestion
}

Try / catch

match confirm_task.await {
    Ok(mention) => { /* attach */ }
    Err(err) if err.to_string() == "no active repository" => {
        show_user("Open a project with a git repository to use diff mentions")
    }
    Err(err) => return Err(err),
}

Prevention

When it happens

Trigger: Using a git-diff mention (diff against a base ref) in a folder that is not a git repository; right after opening a project before git status detection finishes; a multi-worktree project where no active repository has been set.

Common situations: Plain folders without .git; freshly opened clones before detection completes; remote projects with pending repo detection; worktrees whose .git link is broken so no repo registers.

Related errors


AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16). Data as JSON: /api/errors/253939178d1240cf. Report an issue: GitHub.