Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(worktree): 完善刷新文案复数与分叉状态说明
fmfsaisaif512dea3d61a
diff --git a/apps/desktop/scripts/fixtures/branch-sync/branch-sync-fixture.tsx b/apps/desktop/scripts/fixtures/branch-sync/branch-sync-fixture.tsxindex 65157cf2bd..dca4f0ba21 100644--- a/apps/desktop/scripts/fixtures/branch-sync/branch-sync-fixture.tsx+++ b/apps/desktop/scripts/fixtures/branch-sync/branch-sync-fixture.tsx@@ -36,9 +36,9 @@ mountPage({remote: 'origin',remoteBranch: 'main',remoteOnly: req.branch.startsWith('refs/'),- ahead: ctx.case === 'diverged' ? 2 : 0,- behind: 3,- dirtyFiles: 3,+ ahead: ['diverged', 'unchecked'].includes(ctx.case) ? 1 : 0,+ behind: ctx.case === 'unchecked' ? 0 : ctx.case === 'default' ? 3 : 1,+ dirtyFiles: ctx.case === 'diverged' ? 2 : ctx.case === 'default' ? 3 : 1,checkoutPath: '/projects/cindy',...(ctx.case === 'diverged' || ctx.case === 'conflict' ? { blocked: ctx.case } : {}),});@@ -51,7 +51,7 @@ mountPage({worktreeBranchSyncStatus: async (req: BranchSyncRequest) => read(req),worktreeSyncBranch: async (req: BranchSyncRequest) => ({status: { ...read(req), behind: 0 },- updated: 3,+ updated: ctx.case === 'unchecked' ? 0 : ctx.case === 'worker' ? 1 : 3,}),};},diff --git a/apps/desktop/scripts/fixtures/branch-sync/ui-page.mjs b/apps/desktop/scripts/fixtures/branch-sync/ui-page.mjsindex b3a8fa0ab2..0688378ff6 100644--- a/apps/desktop/scripts/fixtures/branch-sync/ui-page.mjs+++ b/apps/desktop/scripts/fixtures/branch-sync/ui-page.mjs@@ -57,6 +57,23 @@ export default {});assert.equal(await remote.count(), ['unchecked', 'old-host'].includes(ui.case) ? 0 : 1);await ui.capture('branches');+ if (ui.case === 'unchecked') {+ await page.keyboard.press('Escape');+ await page+ .getByRole('button', {+ name: await ui.t('newChat.branchSync.action', { remote: 'origin', remoteBranch: 'main' }),+ exact: false,+ })+ .click();+ const result = page.getByRole('button', {+ name: await ui.t('newChat.branchSync.keptAhead', { count: 1 }),+ exact: true,+ });+ await page.mouse.move(340, 350);+ await result.hover();+ await page.getByRole('tooltip').waitFor();+ await ui.capture('kept-ahead');+ }if (ui.case === 'default' || ui.case === 'worker') {await page.getByRole('combobox').fill('origin/main');assert.equal(await page.getByRole('option').count(), 2);@@ -72,10 +89,18 @@ export default {await action.click();await page.getByRole('button', {- name: await ui.t('newChat.branchSync.updated', { count: 3 }),+ name: await ui.t('newChat.branchSync.updated', { count: ui.case === 'worker' ? 1 : 3 }),exact: true,}).waitFor();+ await page.mouse.move(340, 350);+ await page+ .getByRole('button', {+ name: await ui.t('newChat.branchSync.updated', { count: ui.case === 'worker' ? 1 : 3 }),+ exact: true,+ })+ .hover();+ await page.getByRole('tooltip').waitFor();await ui.capture('updated');}},diff --git a/apps/desktop/src/renderer/components/new-chat/__tests__/BranchWorktreeChip.test.tsx b/apps/desktop/src/renderer/components/new-chat/__tests__/BranchWorktreeChip.test.tsxindex 955ce4c01c..4733de4ae7 100644--- a/apps/desktop/src/renderer/components/new-chat/__tests__/BranchWorktreeChip.test.tsx+++ b/apps/desktop/src/renderer/components/new-chat/__tests__/BranchWorktreeChip.test.tsx@@ -103,6 +103,28 @@ it('shares counts with the selected row and keeps full remote refs distinct durifireEvent.keyDown(screen.getByRole('combobox'), { key: 'Enter' });expect(props.onPick).toHaveBeenLastCalledWith('origin/main');});+// Product rule: diverged branch details name the remote once and retain dirty-file counts.+// Standard tier: exercise the real capsule with both counts positive; the existing case covers behind-only.+it('combines diverged counts into one status segment and keeps dirty files', async () => {+ status.mockResolvedValue({ ...baseStatus, ahead: 1, behind: 1, blocked: 'diverged' });+ render(<BranchWorktreeChip {...props} />);+ await waitFor(() => expect(status).toHaveBeenCalledOnce());+ await act(async () => {+ fireEvent.click(branchButton());+ });+ const expected = [+ mocks.t('newChat.branchSync.diverging', {+ remote: 'origin/main',+ ahead: 1,+ behind: 1,+ count: 1,+ }),+ mocks.t('newChat.branchSync.dirty', { count: 2 }),+ ].join(' · ');+ expect(screen.getByText(expected)).toBeTruthy();+ expect(screen.queryByText(/newChat.branchSync.ahead/)).toBeNull();+ expect(screen.queryByText(/newChat.branchSync.behind/)).toBeNull();+});it('shows remote sources only when worktree is checked or branchOnly is used', async () => {const view = render(<BranchWorktreeChip {...props} checked={false} />);await waitFor(() => expect(refreshButton().hasAttribute('disabled')).toBe(false));diff --git a/apps/desktop/src/renderer/hooks/useBranchSync.ts b/apps/desktop/src/renderer/hooks/useBranchSync.tsindex 0b4405be04..c57583c5e9 100644--- a/apps/desktop/src/renderer/hooks/useBranchSync.ts+++ b/apps/desktop/src/renderer/hooks/useBranchSync.ts@@ -156,15 +156,25 @@ export function useBranchSync(: t('newChat.branchSync.current');if (state.error) hint = t('newChat.branchSync.failed', { reason: errorText });if (state.busy) hint = t('newChat.branchSync.fetching', vars);+ const ahead = status?.ahead ?? 0;+ const behind = status?.behind ?? 0;+ const diverging = ahead > 0 && behind > 0;const details = [- status?.ahead- ? t('newChat.branchSync.ahead', {- ...vars,+ diverging+ ? t('newChat.branchSync.diverging', {remote: `${vars.remote}/${vars.remoteBranch}`,- count: status.ahead,+ ahead,+ behind,+ count: ahead,})- : '',- status?.behind+ : status?.ahead+ ? t('newChat.branchSync.ahead', {+ ...vars,+ remote: `${vars.remote}/${vars.remoteBranch}`,+ count: status.ahead,+ })+ : '',+ !diverging && status?.behind? t('newChat.branchSync.behind', {...vars,remote: `${vars.remote}/${vars.remoteBranch}`,diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 4c2e6b4014..40e9771f6c 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -11373,18 +11373,25 @@"remoteAction": "Pull the latest commits from {{remote}}/{{remoteBranch}}","checkedOut": "Also updates committed files on this branch; uncommitted changes are kept","fetching": "Pulling…",- "updated": "Updated by {{count}} commits",+ "updated_one": "Pulled {{count}} new commit",+ "updated_other": "Pulled {{count}} new commits","current": "Already up to date",- "keptAhead": "{{count}} unpushed local commits. No update needed",+ "keptAhead_one": "{{count}} unpushed local commit. No update needed",+ "keptAhead_other": "{{count}} unpushed local commits. No update needed","failed": "Pull failed: {{reason}}","diverged": "Local and {{remote}} have diverged. Cannot update automatically",- "conflict": "Local changes conflict with remote updates. Commit or stash first",+ "conflict": "Uncommitted changes conflict with remote updates. Commit or stash first","missing-remote": "{{remoteBranch}} does not exist on {{remote}}","no-remote": "No remote repository configured","not-local": "Select a local branch or the remote default branch",- "ahead": "{{count}} commits ahead of {{remote}}",- "behind": "{{count}} commits behind {{remote}}",- "dirty": "{{count}} uncommitted files",+ "ahead_one": "{{count}} commit ahead of {{remote}}",+ "ahead_other": "{{count}} commits ahead of {{remote}}",+ "behind_one": "{{count}} commit behind {{remote}}",+ "behind_other": "{{count}} commits behind {{remote}}",+ "dirty_one": "{{count}} uncommitted file",+ "dirty_other": "{{count}} uncommitted files",+ "diverging_one": "{{ahead}} ahead, {{behind}} behind {{remote}}",+ "diverging_other": "{{ahead}} ahead, {{behind}} behind {{remote}}","remoteGroup": "Remote","localGroup": "Local branches","errors": {diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 3d2e59b56e..0531a9d281 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -11338,18 +11338,19 @@"remoteAction": "{{remote}}/{{remoteBranch}} の最新コミットを取得","checkedOut": "現在のブランチのコミット済みファイルも更新します。未コミットの変更は保持されます","fetching": "取得中…",- "updated": "{{count}} コミット更新しました",+ "updated_other": "{{count}} 件のコミットを取り込みました","current": "すでに最新です",- "keptAhead": "未プッシュのコミットが {{count}} 件あります。更新は不要です",+ "keptAhead_other": "未プッシュのコミットが {{count}} 件あります。更新は不要です","failed": "取得失敗:{{reason}}","diverged": "ローカルと {{remote}} の両方に新しいコミットがあり、自動更新できません","conflict": "未コミットの変更がリモートの更新と競合しています。先にコミットまたは stash してください","missing-remote": "{{remote}} に {{remoteBranch}} がありません","no-remote": "リモートリポジトリが未設定です","not-local": "ローカルブランチまたはリモートの既定ブランチを選択してください",- "ahead": "{{remote}} より {{count}} コミット先行",- "behind": "{{remote}} より {{count}} コミット遅れ",- "dirty": "未コミットのファイル {{count}} 件",+ "ahead_other": "{{remote}} より {{count}} コミット先行",+ "behind_other": "{{remote}} より {{count}} コミット遅れ",+ "dirty_other": "未コミットのファイル {{count}} 件",+ "diverging_other": "{{ahead}} コミット先行、{{behind}} コミット遅れ({{remote}})","remoteGroup": "リモート","localGroup": "ローカルブランチ","errors": {diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 61b4cca2e5..6e06b44b5d 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -11338,18 +11338,19 @@"remoteAction": "{{remote}}/{{remoteBranch}}의 최신 커밋 가져오기","checkedOut": "현재 브랜치의 커밋된 파일도 업데이트됩니다. 커밋하지 않은 변경 사항은 유지됩니다","fetching": "가져오는 중…",- "updated": "커밋 {{count}}개 업데이트됨",+ "updated_other": "커밋 {{count}}개 업데이트됨","current": "이미 최신 상태입니다",- "keptAhead": "푸시하지 않은 로컬 커밋 {{count}}개. 업데이트가 필요 없습니다",+ "keptAhead_other": "푸시하지 않은 로컬 커밋 {{count}}개. 업데이트가 필요 없습니다","failed": "가져오기 실패: {{reason}}","diverged": "로컬과 {{remote}} 양쪽에 새 커밋이 있어 자동 업데이트할 수 없습니다","conflict": "커밋하지 않은 변경 사항이 원격 업데이트와 충돌합니다. 먼저 커밋하거나 stash 하세요","missing-remote": "{{remote}}에 {{remoteBranch}}이(가) 없습니다","no-remote": "원격 저장소가 설정되지 않았습니다","not-local": "로컬 브랜치 또는 원격 기본 브랜치를 선택하세요",- "ahead": "{{remote}}보다 커밋 {{count}}개 앞섬",- "behind": "{{remote}}보다 커밋 {{count}}개 뒤처짐",- "dirty": "커밋하지 않은 파일 {{count}}개",+ "ahead_other": "{{remote}}보다 커밋 {{count}}개 앞섬",+ "behind_other": "{{remote}}보다 커밋 {{count}}개 뒤처짐",+ "dirty_other": "커밋하지 않은 파일 {{count}}개",+ "diverging_other": "{{ahead}}개 커밋 앞섬, {{behind}}개 커밋 뒤처짐({{remote}})","remoteGroup": "원격","localGroup": "로컬 브랜치","errors": {diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 766f25324c..6d02d35635 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -11338,18 +11338,19 @@"remoteAction": "拉取 {{remote}}/{{remoteBranch}} 的最新提交","checkedOut": "会同步更新当前分支已提交的文件,未提交的改动会保留","fetching": "正在拉取…",- "updated": "已更新 {{count}} 个提交",+ "updated_other": "已更新 {{count}} 个提交","current": "已是最新",- "keptAhead": "本地有 {{count}} 个未推送的提交,无需更新",+ "keptAhead_other": "本地有 {{count}} 个未推送的提交,无需更新","failed": "拉取失败:{{reason}}","diverged": "本地与 {{remote}} 各有新提交,无法自动更新","conflict": "未提交的改动与远程更新冲突,请先提交或 stash","missing-remote": "{{remote}} 上没有 {{remoteBranch}}","no-remote": "未设置远程仓库","not-local": "请先选择本地分支或远程主分支",- "ahead": "领先 {{remote}} {{count}} 个提交",- "behind": "落后 {{remote}} {{count}} 个提交",- "dirty": "未提交 {{count}} 个文件",+ "ahead_other": "领先 {{remote}} {{count}} 个提交",+ "behind_other": "落后 {{remote}} {{count}} 个提交",+ "dirty_other": "未提交 {{count}} 个文件",+ "diverging_other": "领先 {{ahead}}、落后 {{behind}} 个提交({{remote}})","remoteGroup": "远程","localGroup": "本地分支","errors": {diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 89e27033c4..091b4d8a5f 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -11338,18 +11338,19 @@"remoteAction": "取得 {{remote}}/{{remoteBranch}} 的最新提交","checkedOut": "會同步更新目前分支已提交的檔案,未提交的變更會保留","fetching": "正在取得更新…",- "updated": "已更新 {{count}} 個提交",+ "updated_other": "已更新 {{count}} 個提交","current": "已是最新",- "keptAhead": "本機有 {{count}} 個尚未推送的提交,無需更新",+ "keptAhead_other": "本機有 {{count}} 個尚未推送的提交,無需更新","failed": "取得更新失敗:{{reason}}","diverged": "本機與 {{remote}} 各有新提交,無法自動更新","conflict": "尚未提交的變更與遠端更新衝突,請先提交或 stash","missing-remote": "{{remote}} 上沒有 {{remoteBranch}}","no-remote": "未設定遠端儲存庫","not-local": "請先選擇本機分支或遠端主分支",- "ahead": "領先 {{remote}} {{count}} 個提交",- "behind": "落後 {{remote}} {{count}} 個提交",- "dirty": "尚未提交 {{count}} 個檔案",+ "ahead_other": "領先 {{remote}} {{count}} 個提交",+ "behind_other": "落後 {{remote}} {{count}} 個提交",+ "dirty_other": "尚未提交 {{count}} 個檔案",+ "diverging_other": "領先 {{ahead}}、落後 {{behind}} 個提交({{remote}})","remoteGroup": "遠端","localGroup": "本機分支","errors": {