Skip to content

feat: return ok=true with git_repo=false when bg status is run outside a git repo#898

Open
svarlamov wants to merge 2 commits intomainfrom
devin/1774978522-bg-status-no-repo
Open

feat: return ok=true with git_repo=false when bg status is run outside a git repo#898
svarlamov wants to merge 2 commits intomainfrom
devin/1774978522-bg-status-no-repo

Conversation

@svarlamov
Copy link
Copy Markdown
Member

@svarlamov svarlamov commented Mar 31, 2026

Summary

When git ai bg status is run outside a git repository, it previously returned ok: false with a git rev-parse error from the daemon. This change adds an early check in the client-side handle_status function: before contacting the daemon, it verifies the path is inside a git repo using find_repository_in_path. If not, it skips the family-level status query but still checks daemon health via daemon_is_up, returning:

{
  "ok": true,
  "git_repo": false,
  "daemon_running": true
}

Normal in-repo behavior is unchanged.

Review & Testing Checklist for Human

  • Response shape consistency: The early-return response ({ "ok": true, "git_repo": false, "daemon_running": bool }) is a different shape than the normal ControlResponse ({ "ok", "seq", "data", "error" }). Verify that all consumers of bg status output can handle this divergent schema, or decide if git_repo/daemon_running should be nested inside the standard ControlResponse structure instead.
  • Error conflation: find_repository_in_path(...).is_err() treats any error (permissions, git binary missing, corrupt repo, etc.) as "not a git repo." Consider whether some errors should still surface as failures rather than being silently mapped to git_repo: false.
  • Manual test: Run git ai bg status from / or /tmp (outside any repo) and confirm the new JSON output includes daemon_running. Then run it inside a repo and confirm normal behavior is unchanged.

Notes

  • daemon_is_up checks socket connectivity (control + trace sockets respond within 100ms); it does not issue a full control request.
  • No new tests were added for this path. The daemon integration tests don't cover the client-side early return.

Link to Devin session: https://app.devin.ai/sessions/37f5a9c05ad346f587f3cf512e4e58f5
Requested by: @svarlamov


Open with Devin

…e a git repo

Previously, running 'git ai bg status' outside of a git repository would
return ok=false with a git rev-parse error. Now it gracefully returns
ok=true with git_repo=false to indicate the command succeeded but the
current directory is not a git repository.

Co-Authored-By: Sasha Varlamov <sasha@sashavarlamov.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

The bg status response now includes daemon_running alongside git_repo=false
so the caller can confirm the daemon is alive even outside a git repository.

Co-Authored-By: Sasha Varlamov <sasha@sashavarlamov.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

Test Results

Tested locally by building the debug binary and running git ai bg status from different contexts.

Primary: bg status outside a git repo
Test Result
Outside a git repo (/tmp) PASSED — exit code 0, {"ok": true, "git_repo": false, "daemon_running": false}
--repo /tmp flag PASSED — exit code 0, same graceful response
Regression: bg status inside a git repo
Test Result
Inside a git repo (repos/git-ai) PASSED — exit code 1, daemon socket timeout error (confirms early return NOT triggered for valid repos)

CI Note: One flaky failure in subdirs::test_commit_with_mixed_files_with_c_flag_in_worktree (daemon session timeout) — unrelated to this change. All lint, format, coverage, and security checks pass.

Devin session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants