feat: Allow attaching/changing repository for existing conversations#12671
feat: Allow attaching/changing repository for existing conversations#12671hieptl merged 38 commits intoOpenHands:mainfrom
Conversation
Implements issue OpenHands#12628 - Allow users to change or attach a repository to an existing conversation. Backend changes: - Extend AppConversationUpdateRequest model with selected_repository, selected_branch, and git_provider fields (all optional) - Update service to only update fields that are explicitly provided (not None) Frontend changes: - Add updateConversationRepository API method to V1ConversationService - Create useUpdateConversationRepository mutation hook - Add ChangeRepositoryModal component for repository selection UI - Add 'Change Repository' / 'Attach Repository' button to GitControlBar - Add i18n keys for repository update messages Tests: - Add unit tests for useUpdateConversationRepository hook
There was a problem hiding this comment.
Hello @MkDev11,
We have created a Slack thread to discuss the UI aspects of this pull request:
#12671 (comment)
Before we proceed with the review and merging, we will need to wait for the UI feedback shared in that thread. This will help ensure we are aligned and that all UI considerations are properly addressed.
Thank you very much for your contribution and for taking the time to create this pull request. We truly appreciate your efforts! 🙏
|
Thank you for your contribution! Based on Hieptl's comment, I'm going to put this into draft since it's going to be work in progress. Once ready please set it to ready for review again. |
|
I will close this pr until the design is ready. |
all-hands-bot
left a comment
There was a problem hiding this comment.
Overall this is a well-implemented feature with good test coverage and i18n support. I found one breaking change and a few UX/type safety improvements to consider.
…sations - Add new OpenRepositoryModal component with repo and branch selection - Replace ChangeRepositoryModal with OpenRepositoryModal in GitControlBar - Fix duplicate 'No Repo Connected' badges with conditional rendering - Fix repository dropdown display by using correct value/repositoryName props - Add i18n keys for OPEN_REPOSITORY, SELECT_OR_INSERT_LINK, NO_REPO_CONNECTED
The test was failing in CI likely due to floating point precision issues when comparing accumulated costs. Using pytest.approx resolves this.
|
Hello @MkDev11, I noticed a few issues while testing the pull request locally and wanted to share them with you. Issue 1:
Note: It may be worth considering defining reusable components that can be shared between both views, rather than duplicating styling and components. This could help reduce duplication and improve consistency. Please refer to the images below for additional context: Issue 2:
Issue 3:
Please refer to the video below for additional context. issue3.movThank you! 🙏 |
- Fix modal styling to match home page (RepoForkedIcon, text-sm white text, gap-[10px]) - Add addRecentRepository call when launching repo from modal - Fix stale closure: use useRef for webSocketStatus in onSuccess callback
@hieptl 3 issues are fixed |
|
Hello @MkDev11, The third issue mentioned in my previous comment still occurs on my end. Please see the steps below for clarification:
Please refer to the video below for additional context: issue.movThank you very much! 🙏 |
The send function captured in onSuccess holds a stale v1Context.sendMessage that references a now-closed WebSocket. Using sendRef.current ensures we always call the latest send with the current WebSocket connection.
|
@hieptl can you please review the change again? |
Hello @MkDev11, The issue mentioned in my previous comment still occurs on my end. Please see the steps below for clarification: Step 1: Ask the agent to create a long-running task, such as “Create a Hello World app in React.” Please refer to the video below for additional context: issue.movThank you very much! 🙏 |
…dWebSocketStatus Also check conversation ID prefix (task-*) to handle cases where conversation data is temporarily undefined during query refetch.
|
@hieptl sorry for the mistake, I didn't push the latest changes. please review the changes and the video link. |
|
Hello @MkDev11, For your reference, the issue is still present. Please see the video below for additional details. You can reproduce it using the prompt “Create a hello world app in React.” There’s no need to wait for the agent to finish. According to the video, when it begins creating a new React project, you can try attaching an existing repository—you should then be able to observe the issue more clearly. issue.movThank you very much! 🙏 |
Use setOptimisticUserMessage() to show the clone command in the chat immediately, matching the behavior of regular user messages.
|
@hieptl fixed again. |
|
Hello @MkDev11, I found another issue while testing the pull request locally and wanted to share it for visibility. Steps to reproduce:
Current behavior: Expected behavior: Please feel free to refer to the video below for additional context. issue1.movPotential solution:
If GitLab is selected as the provider, the prompt could instead be structured like this (and similarly for other Git providers):
This is only a suggested approach, and we would need to test it carefully to ensure it behaves reliably across all supported scenarios. Thank you! 🙏 |
Add provider name (GitHub, GitLab, etc.) to clone prompt so agent clones from the correct source instead of defaulting to GitHub. Added unit tests for clone prompt format.
@hieptl Thanks for your another feedback. I fixed the issue as well, please review the screenshot and the changes.
|







Summary of PR
This PR implements the ability to attach or change a Git repository for existing conversations, addressing Issue #12628.
Changes
Backend:
AppConversationUpdateRequestmodel with optionalselected_repository,selected_branch, andgit_providerfieldsupdate_app_conversationservice method to use Pydantic'smodel_fields_setfor proper partial updates, allowing fields to be explicitly set toNone(to remove repository association)Frontend:
updateConversationRepositoryAPI method in the conversation serviceuseUpdateConversationRepositorymutation hook with optimistic updates and error handlingChangeRepositoryModalcomponent with repository dropdown for selecting/changing repositoriesGitControlBarUser Experience
Demo Screenshots/Videos
Change Type
Checklist
Fixes
Resolves #12628
Release Notes
Users can now attach or change the Git repository for existing conversations. A new "Change Repository" button in the conversation view allows selecting a different repository or attaching one to conversations that were started without a repository.