fix: Changes tab uses correct workspace directory after repo switch#1265
fix: Changes tab uses correct workspace directory after repo switch#1265HeyItsChloe wants to merge 1 commit into
Conversation
This fix addresses issues #1193 and #1182 where the Changes/Diffs tab was not displaying the correct workspace directory when switching repos. Root cause: getGitPath() prioritized workingDir over selectedRepository, but workingDir is updated asynchronously by the agent after cloning. During repo switches, workingDir would be stale while selectedRepository was immediately updated. Changes: - get-git-path.ts: Prioritize selectedRepository over workingDir when a repo is selected. This ensures the Changes tab uses the correct workspace immediately when a user selects a repository. - git-control-bar.tsx: Show repo button when localGitInfo detects a repository (even if selected_repository wasn't set via UI). This handles the case where the agent autonomously clones a repo. - Updated tests to reflect new priority behavior and added tests for localGitDetectedRepo functionality. Fixes #1193 Fixes #1182
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
PR Artifacts Notice This PR contains a
|
✅ Mock-LLM E2E Tests43/43 passed Commit:
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
🔶 Mock-LLM Docker E2E Test Results38/43 passed · 5 skipped Commit:
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
📸 Snapshot Test Report✅ All snapshots match the main branch baselines.
✅ Unchanged snapshots (74)
Generated by the Snapshot Tests workflow. This comment was created by an AI agent (OpenHands) on behalf of the repo maintainers. |
Why
The Changes/Diffs tab was not displaying the correct workspace directory when switching repositories or when the agent autonomously cloned a repository. The bug was in
getGitPath()which prioritizedworkingDiroverselectedRepository. However,workingDiris updated asynchronously by the agent after cloning completes, whileselectedRepositoryis set immediately when the user selects a repository.Summary
Fixed issues #1193 and #1182 by changing the priority in
getGitPath()to preferselectedRepositoryoverworkingDirwhen a repository is selected. Also addedlocalGitDetectedRepologic to show the repo button whenlocalGitInfodetects a repository even ifselected_repositorywasn't set via UI.Issue Number
** ScreenShots / Videos **
Screen.Recording.2026-06-08.at.2.44.48.PM.mov
How to Test
Type
Notes
This fix is correct vs PR #1261 because PR #1261 attempted to fix this by doing a fresh fetch inside the queryFn, but the queryKey still used the stale
gitPathcomputed from cached data. This fix correctly addresses the root cause by changing the priority ingetGitPath()itself.All tests pass:
__tests__/utils/get-git-path.test.ts- 9 tests__tests__/components/features/chat/git-control-bar.test.tsx- 11 tests (including 2 new tests forlocalGitDetectedRepo)🐳 Docker images for this PR
ghcr.io/openhands/agent-canvasghcr.io/openhands/agent-server:1.26.0-pythonopenhands-automation==1.0.0a605c7d87ce213dc798a9741f7500a982587e4bb11Pull (multi-arch manifest)