diff --git a/packages/app/src/i18n/resources/ar.ts b/packages/app/src/i18n/resources/ar.ts index 36ffc325e..7e73a009e 100644 --- a/packages/app/src/i18n/resources/ar.ts +++ b/packages/app/src/i18n/resources/ar.ts @@ -1410,6 +1410,7 @@ export const ar: TranslationResources = { }, }, newWorkspace: { + defaultBase: "الفرع الافتراضي", title: "مساحة عمل جديدة", create: "يخلق", isolation: { diff --git a/packages/app/src/i18n/resources/en.ts b/packages/app/src/i18n/resources/en.ts index 8d1582d88..31c4141ec 100644 --- a/packages/app/src/i18n/resources/en.ts +++ b/packages/app/src/i18n/resources/en.ts @@ -1421,6 +1421,7 @@ export const en = { }, }, newWorkspace: { + defaultBase: "Default branch", title: "New workspace", create: "Create", isolation: { diff --git a/packages/app/src/i18n/resources/es.ts b/packages/app/src/i18n/resources/es.ts index 62e57dca0..e10cbf778 100644 --- a/packages/app/src/i18n/resources/es.ts +++ b/packages/app/src/i18n/resources/es.ts @@ -1447,6 +1447,7 @@ export const es: TranslationResources = { }, }, newWorkspace: { + defaultBase: "Rama predeterminada", title: "Nuevo espacio de trabajo", create: "Crear", isolation: { diff --git a/packages/app/src/i18n/resources/fr.ts b/packages/app/src/i18n/resources/fr.ts index 79824b9b6..f8208e141 100644 --- a/packages/app/src/i18n/resources/fr.ts +++ b/packages/app/src/i18n/resources/fr.ts @@ -1440,6 +1440,7 @@ export const fr: TranslationResources = { }, }, newWorkspace: { + defaultBase: "Branche par défaut", title: "Nouvel espace de travail", create: "Créer", isolation: { diff --git a/packages/app/src/i18n/resources/ja.ts b/packages/app/src/i18n/resources/ja.ts index da2f2df0d..7cb9b1776 100644 --- a/packages/app/src/i18n/resources/ja.ts +++ b/packages/app/src/i18n/resources/ja.ts @@ -1425,6 +1425,7 @@ export const ja: TranslationResources = { }, }, newWorkspace: { + defaultBase: "デフォルトブランチ", title: "新しいワークスペース", create: "作成", isolation: { diff --git a/packages/app/src/i18n/resources/ko.ts b/packages/app/src/i18n/resources/ko.ts index 41cac266f..cc09fb2bf 100644 --- a/packages/app/src/i18n/resources/ko.ts +++ b/packages/app/src/i18n/resources/ko.ts @@ -1417,6 +1417,7 @@ export const ko: TranslationResources = { }, }, newWorkspace: { + defaultBase: "기본 브랜치", title: "새 워크스페이스", create: "생성", isolation: { diff --git a/packages/app/src/i18n/resources/pt-BR.ts b/packages/app/src/i18n/resources/pt-BR.ts index 0bcdb09f8..b08e9fd8a 100644 --- a/packages/app/src/i18n/resources/pt-BR.ts +++ b/packages/app/src/i18n/resources/pt-BR.ts @@ -1437,6 +1437,7 @@ export const ptBR: TranslationResources = { }, }, newWorkspace: { + defaultBase: "Branch padrão", title: "Novo workspace", create: "Criar", isolation: { diff --git a/packages/app/src/i18n/resources/ru.ts b/packages/app/src/i18n/resources/ru.ts index 5782e57aa..23c804abd 100644 --- a/packages/app/src/i18n/resources/ru.ts +++ b/packages/app/src/i18n/resources/ru.ts @@ -1430,6 +1430,7 @@ export const ru: TranslationResources = { }, }, newWorkspace: { + defaultBase: "Ветка по умолчанию", title: "Новое рабочее пространство", create: "Создать", isolation: { diff --git a/packages/app/src/i18n/resources/zh-CN.ts b/packages/app/src/i18n/resources/zh-CN.ts index 9062bf6c0..dba32d58d 100644 --- a/packages/app/src/i18n/resources/zh-CN.ts +++ b/packages/app/src/i18n/resources/zh-CN.ts @@ -1399,6 +1399,7 @@ export const zhCN: TranslationResources = { }, }, newWorkspace: { + defaultBase: "默认分支", title: "新建 workspace", create: "创建", isolation: { diff --git a/packages/app/src/screens/new-workspace-picker-item.test.ts b/packages/app/src/screens/new-workspace-picker-item.test.ts index 6ef493cec..2d67c7067 100644 --- a/packages/app/src/screens/new-workspace-picker-item.test.ts +++ b/packages/app/src/screens/new-workspace-picker-item.test.ts @@ -405,9 +405,19 @@ describe("defaultBasePickerItem", () => { }); }); - it("has no default for detached HEAD", () => { + it("has no default for detached HEAD without a repository base", () => { expect(defaultBasePickerItem({ currentBranch: null })).toBeNull(); }); + + it("names the repository's base on a detached HEAD instead of guessing", () => { + expect( + defaultBasePickerItem({ + currentBranch: null, + baseRef: "master", + baseRefExact: "refs/remotes/origin/master", + }), + ).toMatchObject({ kind: "branch", name: "master", refName: "refs/remotes/origin/master" }); + }); }); describe("starting-ref search", () => { diff --git a/packages/app/src/screens/new-workspace-picker-item.ts b/packages/app/src/screens/new-workspace-picker-item.ts index a8f6ae4d4..3b577803c 100644 --- a/packages/app/src/screens/new-workspace-picker-item.ts +++ b/packages/app/src/screens/new-workspace-picker-item.ts @@ -137,6 +137,9 @@ export function buildBranchPickerItems(details: readonly BranchPickerDetail[]): export interface BaseRefCheckoutStatus { currentBranch: string | null; upstreamRef?: string | null; + baseRef?: string | null; + baseRefExact?: string | null; + comparisonBaseRef?: string | null; } // Display only. The exact ref is what every request carries; this is just how a ref reads in @@ -162,6 +165,13 @@ function refQualifier(refName: string): string | null { return null; } +function repositoryBasePickerItem(status: BaseRefCheckoutStatus): PickerItem | null { + const refName = status.baseRefExact ?? status.comparisonBaseRef ?? status.baseRef; + if (!refName) return null; + const name = branchNameFromRef(refName); + return { kind: "branch", name, refName, accessibilityLabel: name }; +} + // The one owner of "what do we branch off when the user picked nothing". The checkmarked // row, the trigger label, and the created ref all read this; computing it twice is how the // picker once showed local main while branching off something else. @@ -171,7 +181,9 @@ function refQualifier(refName: string): string | null { // than a remote name, so a fork tracking upstream/main branches from upstream/main. export function defaultBasePickerItem(status: BaseRefCheckoutStatus): PickerItem | null { const currentBranch = status.currentBranch; - if (!currentBranch) return null; + // On a detached HEAD there is no branch to follow; name the base the daemon would use + // anyway, so the picker shows what will actually be created from. + if (!currentBranch) return repositoryBasePickerItem(status); // COMPAT(checkoutUpstreamRef): added in v0.2.6, remove after 2027-02-01 once the daemon // floor sends upstreamRef. Daemons that predate it omit the field, which lands on the // local ref — the base those daemons always used. diff --git a/packages/app/src/screens/new-workspace-screen.tsx b/packages/app/src/screens/new-workspace-screen.tsx index 3db430d57..529668578 100644 --- a/packages/app/src/screens/new-workspace-screen.tsx +++ b/packages/app/src/screens/new-workspace-screen.tsx @@ -1213,8 +1213,8 @@ export function NewWorkspaceScreen({ ); const triggerLabel = useMemo(() => { const displayItem = itemById.get(selectedOptionId); - return displayItem ? pickerItemLabel(displayItem) : "main"; - }, [itemById, selectedOptionId]); + return displayItem ? pickerItemLabel(displayItem) : t("newWorkspace.defaultBase"); + }, [itemById, selectedOptionId, t]); const selectPickerItem = useCallback( (item: PickerItem) => { setup.chooseRef(item);