Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(projects): clear stale branch when repository URL changes (#10889)

LAN6c8a74bb466f
diff --git a/apps/docs/content/docs/project-resources.fr.mdx b/apps/docs/content/docs/project-resources.fr.mdx
index c016cdf504..f17f642a71 100644
--- a/apps/docs/content/docs/project-resources.fr.mdx
+++ b/apps/docs/content/docs/project-resources.fr.mdx
@@ -30,7 +30,7 @@ Un répertoire local ne s'applique qu'au daemon auquel il est lié. Lorsque le d
Ouvrez le projet et cliquez sur **Ajouter un dépôt** dans **Ressources → Dépôts**. Recherchez un dépôt rattaché à l'espace de travail ou collez une URL Git. Les dépôts de l'espace de travail se gèrent dans **Paramètres → Code** ; une fois GitHub connecté, la même page propose **Choisir depuis GitHub** pour importer les dépôts auxquels la GitHub App a accès.
-Coller une URL de branche GitHub (`https://github.com/owner/repo/tree/branch`) renseigne séparément l’URL du dépôt et la branche de départ. Les noms de branche encodés dans l’URL sont décodés ; les paramètres de requête et les ancres de page sont exclus. Vérifiez la branche de départ avant d’ajouter le dépôt.
+Coller une URL de branche GitHub (`https://github.com/owner/repo/tree/branch`) renseigne séparément l’URL du dépôt et la branche de départ. Les noms de branche encodés dans l’URL sont décodés ; les paramètres de requête et les ancres de page sont exclus. Vérifiez la branche de départ avant d’ajouter le dépôt. Modifier l’URL du dépôt efface la branche de départ précédente, sauf si la nouvelle URL en précise une.
Les dépôts ne se limitent pas à GitHub : toute URL Git accessible par le runtime fonctionne comme ressource de dépôt. Une instance Multica auto-hébergée peut aussi connecter des instances Forgejo, Gitea ou GitLab auto-hébergées dans **Paramètres → Code** ; voir [Fournisseurs Git auto-hébergés](/vcs-integration).
diff --git a/apps/docs/content/docs/project-resources.ja.mdx b/apps/docs/content/docs/project-resources.ja.mdx
index 7007885c3e..ee8e3dcf93 100644
--- a/apps/docs/content/docs/project-resources.ja.mdx
+++ b/apps/docs/content/docs/project-resources.ja.mdx
@@ -30,7 +30,7 @@ import { LocalDirModeDemo } from "@/components/demos/local-dir-mode-demo";
プロジェクトの **リソース → リポジトリ** で **リポジトリを追加** をクリックします。ワークスペースに紐づけ済みのリポジトリを検索するか、Git URL を貼り付けます。ワークスペースのリポジトリは **設定 → コード** で管理します。GitHub を接続すると、同じページの **GitHub から選択** で、App が認可済みのリポジトリをインポートできます。
-GitHub のブランチ URL(`https://github.com/owner/repo/tree/branch`)を貼り付けると、リポジトリ URL と開始ブランチが別々に入力されます。URL エンコードされたブランチ名はデコードされ、クエリパラメータやページ内アンカーは除外されます。リポジトリを追加する前に開始ブランチを確認してください。
+GitHub のブランチ URL(`https://github.com/owner/repo/tree/branch`)を貼り付けると、リポジトリ URL と開始ブランチが別々に入力されます。URL エンコードされたブランチ名はデコードされ、クエリパラメータやページ内アンカーは除外されます。リポジトリを追加する前に開始ブランチを確認してください。リポジトリ URL を変更すると、以前の開始ブランチはクリアされます。新しい URL にブランチが含まれる場合は、そのブランチが入力されます。
リポジトリは GitHub に限定されません。ランタイムがアクセスできる Git URL であれば、どれでもリポジトリリソースとして使えます。セルフホストの Multica では、**設定 → コード** でセルフホストの Forgejo、Gitea、GitLab も接続できます。詳細は[セルフホスト Git ホスティング](/vcs-integration)を参照してください。
diff --git a/apps/docs/content/docs/project-resources.ko.mdx b/apps/docs/content/docs/project-resources.ko.mdx
index 0d48769ac5..cbd56d9d41 100644
--- a/apps/docs/content/docs/project-resources.ko.mdx
+++ b/apps/docs/content/docs/project-resources.ko.mdx
@@ -30,7 +30,7 @@ import { LocalDirModeDemo } from "@/components/demos/local-dir-mode-demo";
프로젝트의 **리소스 → 저장소**에서 **저장소 추가**를 클릭합니다. 워크스페이스에 연결된 저장소를 검색하거나 Git URL을 붙여 넣습니다. 워크스페이스 저장소는 **설정 → 코드**에서 관리합니다. GitHub를 연결한 뒤 같은 페이지에서 **GitHub에서 선택**을 통해 App에 승인된 저장소를 가져올 수 있습니다.
-GitHub 브랜치 URL(`https://github.com/owner/repo/tree/branch`)을 붙여 넣으면 저장소 URL과 시작 브랜치가 각각 입력됩니다. URL로 인코딩된 브랜치 이름은 디코딩되며, 쿼리 매개변수와 페이지 앵커는 제외됩니다. 저장소를 추가하기 전에 시작 브랜치를 확인하세요.
+GitHub 브랜치 URL(`https://github.com/owner/repo/tree/branch`)을 붙여 넣으면 저장소 URL과 시작 브랜치가 각각 입력됩니다. URL로 인코딩된 브랜치 이름은 디코딩되며, 쿼리 매개변수와 페이지 앵커는 제외됩니다. 저장소를 추가하기 전에 시작 브랜치를 확인하세요. 저장소 URL을 변경하면 이전 시작 브랜치가 지워집니다. 새 URL에 브랜치가 포함되어 있으면 해당 브랜치가 입력됩니다.
저장소는 GitHub로 제한되지 않습니다. 런타임이 접근할 수 있는 Git URL이라면 모두 저장소 리소스로 사용할 수 있습니다. 자체 배포한 Multica에서는 **설정 → 코드**에서 자체 호스팅 Forgejo, Gitea, GitLab을 연결할 수도 있습니다. [자체 호스팅 Git 코드 호스팅](/vcs-integration)을 참고하세요.
diff --git a/apps/docs/content/docs/project-resources.mdx b/apps/docs/content/docs/project-resources.mdx
index b140341c49..8082e7d8ec 100644
--- a/apps/docs/content/docs/project-resources.mdx
+++ b/apps/docs/content/docs/project-resources.mdx
@@ -30,7 +30,7 @@ A local directory only applies to the daemon it is bound to. When the daemon exe
Open the project and click **Add repository** in **Resources → Repositories**. Search for a repository already linked to the workspace, or paste a Git URL. Workspace repositories are managed in **Settings → Code**; once GitHub is connected, the same page offers **Pick from GitHub** to import repositories the App is authorized for.
-Pasting a GitHub branch URL (`https://github.com/owner/repo/tree/branch`) fills in the repository URL and starting branch separately. URL-encoded branch names are decoded; query parameters and page anchors are excluded. Check the starting branch before adding the repository.
+Pasting a GitHub branch URL (`https://github.com/owner/repo/tree/branch`) fills in the repository URL and starting branch separately. URL-encoded branch names are decoded; query parameters and page anchors are excluded. Check the starting branch before adding the repository. Changing the repository URL clears the previous starting branch unless the new URL specifies one.
Repositories are not limited to GitHub: any Git URL the runtime can reach works as a repository resource. Self-hosted Multica can also connect self-hosted Forgejo, Gitea, or GitLab under **Settings → Code**; see [Self-hosted Git hosting](/vcs-integration).
diff --git a/apps/docs/content/docs/project-resources.zh-Hant.mdx b/apps/docs/content/docs/project-resources.zh-Hant.mdx
index 0d020f0383..9033ab6784 100644
--- a/apps/docs/content/docs/project-resources.zh-Hant.mdx
+++ b/apps/docs/content/docs/project-resources.zh-Hant.mdx
@@ -30,7 +30,7 @@ import { LocalDirModeDemo } from "@/components/demos/local-dir-mode-demo";
開啟專案,在 **資源 → 倉庫** 中點選 **新增倉庫**。搜尋已關聯到工作區的倉庫,或貼上 Git URL。工作區倉庫在 **設定 → 程式碼** 中維護;連線 GitHub 後,可在同一頁面透過 **從 GitHub 選擇** 匯入 App 已授權的倉庫。
-貼上 GitHub 分支頁面的 URL(`https://github.com/owner/repo/tree/branch`)時,倉庫位址和起始分支會分別填入。經過 URL 編碼的分支名稱會還原,查詢參數和頁面錨點不會算入分支名稱。新增倉庫前請檢查起始分支。
+貼上 GitHub 分支頁面的 URL(`https://github.com/owner/repo/tree/branch`)時,倉庫位址和起始分支會分別填入。經過 URL 編碼的分支名稱會還原,查詢參數和頁面錨點不會算入分支名稱。新增倉庫前請檢查起始分支。修改倉庫位址時,原來的起始分支會清空;如果新位址包含分支,則改用該分支。
倉庫不限於 GitHub:任何執行時能訪問的 Git URL 都可以作為倉庫資源。自部署的 Multica 還可以在 **設定 → 程式碼** 連線自託管的 Forgejo、Gitea 或 GitLab,見[自託管 Git 程式碼託管](/vcs-integration)。
diff --git a/apps/docs/content/docs/project-resources.zh.mdx b/apps/docs/content/docs/project-resources.zh.mdx
index 51ff223909..936195bd88 100644
--- a/apps/docs/content/docs/project-resources.zh.mdx
+++ b/apps/docs/content/docs/project-resources.zh.mdx
@@ -30,7 +30,7 @@ import { LocalDirModeDemo } from "@/components/demos/local-dir-mode-demo";
打开项目,在 **资源 → 仓库** 中点击 **添加仓库**。搜索已关联到工作区的仓库,或粘贴 Git URL。工作区仓库在 **设置 → 代码** 中维护;连接 GitHub 后,可在同一页面通过 **从 GitHub 选择** 导入 App 已授权的仓库。
-粘贴 GitHub 分支页面的 URL(`https://github.com/owner/repo/tree/branch`)时,仓库地址和起始分支会分别填入。经过 URL 编码的分支名会还原,查询参数和页面锚点不会算入分支名。添加仓库前请检查起始分支。
+粘贴 GitHub 分支页面的 URL(`https://github.com/owner/repo/tree/branch`)时,仓库地址和起始分支会分别填入。经过 URL 编码的分支名会还原,查询参数和页面锚点不会算入分支名。添加仓库前请检查起始分支。修改仓库地址时,原来的起始分支会清空;如果新地址包含分支,则改用该分支。
仓库不限于 GitHub:任何运行时能访问的 Git URL 都可以作为仓库资源。自部署的 Multica 还可以在 **设置 → 代码** 连接自托管的 Forgejo、Gitea 或 GitLab,见[自托管 Git 代码托管](/vcs-integration)。
diff --git a/packages/views/projects/components/project-resources-github-ref.test.tsx b/packages/views/projects/components/project-resources-github-ref.test.tsx
index a947596bf0..07722e750e 100644
--- a/packages/views/projects/components/project-resources-github-ref.test.tsx
+++ b/packages/views/projects/components/project-resources-github-ref.test.tsx
@@ -348,6 +348,31 @@ describe("ProjectResourcesSection — github_repo checkout ref", () => {
});
});
+ it.each([
+ "https://github.com/multica-ai/one.git",
+ "https://github.com/multica-ai/two",
+ "[email protected]:multica-ai/two.git",
+ ])("clears the previous branch when replacing a browse URL with %s", async (url) => {
+ renderWithI18n(<ProjectResourcesSection projectId="p1" />);
+
+ fireEvent.click(screen.getByRole("button", { name: /add repository/i }));
+ const input = screen.getByLabelText(/paste a github url/i);
+ fireEvent.change(input, {
+ target: { value: "https://github.com/multica-ai/one/tree/release/2026-09" },
+ });
+ expect((screen.getByLabelText(/starting branch/i) as HTMLInputElement).value).toBe("release/2026-09");
+
+ fireEvent.change(input, { target: { value: url } });
+ expect((screen.getByLabelText(/starting branch/i) as HTMLInputElement).value).toBe("");
+ fireEvent.keyDown(input, { key: "Enter" });
+
+ await waitFor(() => expect(createMock).toHaveBeenCalledTimes(1));
+ expect(createMock.mock.calls[0]?.[0]).toEqual({
+ resource_type: "github_repo",
+ resource_ref: { url },
+ });
+ });
+
it("omits the ref key entirely when the field is left empty", async () => {
renderWithI18n(<ProjectResourcesSection projectId="p1" />);
diff --git a/packages/views/projects/components/project-resources-section.tsx b/packages/views/projects/components/project-resources-section.tsx
index a1756279a6..2c712fc3c2 100644
--- a/packages/views/projects/components/project-resources-section.tsx
+++ b/packages/views/projects/components/project-resources-section.tsx
@@ -361,9 +361,8 @@ function AddRepositoryPanel({
// Someone who wants a branch copies it out of the address bar, so a pasted
// .../tree/<branch> URL is split into its two halves rather than stored
- // whole as a clone URL that does not exist. A pasted pair always wins the
- // branch field: it only shows while a URL is present, so a value already in
- // it came from the previous URL rather than from something typed ahead.
+ // whole as a clone URL that does not exist. Changing the URL also replaces
+ // the branch field, so a plain clone URL cannot inherit the previous ref.
const handleQueryChange = (next: string) => {
if (!looksLikeRepoUrl(next)) {
setQuery(next);
@@ -372,7 +371,7 @@ function AddRepositoryPanel({
}
const split = splitGithubUrlRef(next);
setQuery(split.url);
- if (split.ref) setRef(split.ref);
+ setRef(split.ref ?? "");
};
const submitUrl = async () => {