perf(useLocalGitInfo): consolidate git probe into single bash round-trip#792
Conversation
Replace the former probeGitInfoAtDir + probeNestedRepoInDir pair (which issued 2-3 serial bash WebSocket round-trips per poll cycle) with a single GIT_INFO_COMMAND shell script that handles both the root and nested-repo cases in one run() call. The script outputs two newline-separated lines: <remote-url>\n<branch>. The new probeGitInfo function runs the script and splits on the first newline to recover the same LocalGitInfo struct as before. Co-authored-by: openhands <openhands@all-hands.dev>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
all-hands-bot
left a comment
There was a problem hiding this comment.
🟢 Good taste - Elegant solution to a real performance problem.
This PR consolidates 2-3 serial bash WebSocket round-trips into a single shell script, significantly improving polling efficiency. The implementation preserves the public API while optimizing internal execution. The shell script correctly handles both root and nested repo cases, and the parsing logic properly handles all edge cases (empty values, single values, both values present).
[RISK ASSESSMENT]
- [Overall PR]
⚠️ Risk Assessment: 🟢 LOW
This is a well-scoped performance optimization that changes internal implementation without affecting the public API. The behavior remains identical, just more efficient. Tests have been updated to verify the single round-trip behavior, and the script properly handles edge cases like paths with spaces through correct variable quoting.
VERDICT:
✅ Worth merging: Clean performance optimization addressing a real inefficiency (issue #776).
KEY INSIGHT:
Collapsing serial WebSocket calls into a single bash script demonstrates good pragmatism—solving real latency without adding architectural complexity.
Was this automated review useful? React with 👍 or 👎 to this review to help us measure review quality.
Workflow run: https://github.com/OpenHands/agent-canvas/actions/runs/26477651018
Co-authored-by: openhands <openhands@all-hands.dev>
📸 Snapshot Test Report✅ No baseline found on main — all 1 snapshot are new and will become the baseline once this PR merges.
🆕 New snapshots (1)These snapshots have no baseline on main and will become the new baseline once this PR merges.
|

Summary
Addresses the polling inefficiency noted in #776 by collapsing the 2–3 serial bash WebSocket round-trips that
useLocalGitInfoissued on every 10-second tick into a single round-trip.Changes
src/hooks/query/use-local-git-info.tsReplaced
probeGitInfoAtDir+probeNestedRepoInDir(which issuedPromise.allof 2 bash calls, then conditionally a 3rdfind+ 2 more calls for nested repos) with:GIT_INFO_COMMAND— a single multi-line shell script that handles both the root and nested-repo cases in onerun()call. It outputs two newline-separated lines:<remote-url>\n<branch>.probeGitInfo— a single replacement function that sends the script and splits the two-line output on the first\n.queryFn— simplified from the old two-step conditional chain toreturn probeGitInfo(run, workingDir).__tests__/hooks/query/use-local-git-info.test.tsxUpdated the “local backend” test to:
runCommandMockcall returning"git@github.com:acme/widgets.git\nmain"(new two-line format)toHaveBeenCalledTimes(1)(was previously two chained mock calls)expect.stringContaining("git remote get-url origin")so the test confirms the git operations are still present without hard-coding the full scriptBefore / After
remote+branchin parallel)find→remote+branch)findonly)This PR was created by an AI agent (OpenHands) on behalf of the user.
🐳 Docker images for this PR
• GHCR package: https://github.com/OpenHands/agent-canvas/pkgs/container/agent-canvas
ghcr.io/openhands/agent-canvasghcr.io/openhands/agent-server:1.23.1-pythonopenhands-automation==1.0.0a5d92ca3ee7fa6e2e95606aa943eb476d97a8a22fcPull (multi-arch manifest)
# Multi-arch manifest — Docker automatically pulls the correct architecture docker pull ghcr.io/openhands/agent-canvas:sha-d92ca3eRun
All tags pushed for this build
About Multi-Architecture Support
sha-d92ca3e) is a multi-arch manifest supporting both amd64 and arm64sha-d92ca3e-amd64) are also available if needed