Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
Merge upstream/main into codex/worktree-contract-mobile-sync
Kafeifei3e02c534332d
diff --cc apps/desktop/src/renderer/__tests__/newMakerCreateAgentVisualContract.test.tsindex 5037d765c2,7f62984c08..6859dbb904--- a/apps/desktop/src/renderer/__tests__/newMakerCreateAgentVisualContract.test.ts+++ b/apps/desktop/src/renderer/__tests__/newMakerCreateAgentVisualContract.test.ts@@@ -330,12 -330,12 +330,12 @@@ describe('NewMakerDraftRoute CREATE AGEit('keeps the worktree control visible for a detached HEAD checkout', () => {// currentBranch=null 是合法的 detached HEAD,不等于“不是 git 仓库”。- // 未勾选时仍展示 HEAD,用户才能从这里开启 worktree / 选择源分支。+ // 未勾选时仍展示 HEAD;若环境后来失效但记忆为 ON,也必须保留关闭入口。expect(worktreeChipsRowSource).toContain(- "const branchLabel = sourceBranch || currentBranch || 'HEAD';",- ": (currentBranch ?? 'HEAD');",++ "const branchLabel = sourceBranch || branches.current || currentBranch || 'HEAD';",);expect(worktreeChipsRowSource).toContain(- 'const showBranchChip = !advancedHidden && !!detect.data?.isGitRepo;',+ 'const showBranchChip = !advancedHidden && (enabled || !!detect.data?.isGitRepo);',);expect(worktreeChipsRowSource).not.toContain('const showBranchChip = !advancedHidden && !!branchLabel',diff --cc apps/desktop/src/renderer/__tests__/newMakerProjectPicker.test.tsindex 2f7b12da35,97cc9cfa3e..c842944458--- a/apps/desktop/src/renderer/__tests__/newMakerProjectPicker.test.ts+++ b/apps/desktop/src/renderer/__tests__/newMakerProjectPicker.test.ts@@@ -331,14 -210,15 +331,21 @@@ describe('Shared create project picker'expect(worktreeChipsSource).toContain('function BranchWorktreeChip');expect(worktreeChipsSource).toContain('data-testid="create-agent-branch-worktree"');expect(worktreeChipsSource).toContain(- 'const branchInteractive = !(disabled || branchDisabled || environmentDisabled)',- 'const branchInteractive = !disabled && effectiveWorktreeEnabled && baseRepo !== null',++ '!(disabled || branchDisabled || environmentDisabled) && baseRepo !== null',);expect(worktreeChipsSource).toContain('aria-disabled={!branchInteractive}');expect(worktreeChipsSource).toContain('tabIndex={branchInteractive ? 0 : -1}');expect(worktreeChipsSource).not.toMatch(/\n\s+disabled=\{!branchInteractive\}/);expect(worktreeChipsSource).toContain(- "const branchLabel = sourceBranch || currentBranch || 'HEAD'",- "sourceBranch || branches.current || currentBranch || 'HEAD'",++ "const branchLabel = sourceBranch || branches.current || currentBranch || 'HEAD'",+ );++ expect(worktreeChipsSource).toContain(++ 'effectiveWorktreeEnabled || branchListWanted ? baseRepo : null',+ );- expect(worktreeChipsSource).toContain('checked\n ? t(\'newChat.branchChip.sourceTooltip\')');++ expect(worktreeChipsSource).not.toContain(++ 'useBranches(effectiveWorktreeEnabled ? baseRepo : null',++ );++ expect(worktreeChipsSource).toContain('checked || branchSourceSelected');expect(worktreeChipsSource).toContain('group-hover:opacity-0');expect(worktreeChipsSource).not.toContain('function BranchChip');expect(worktreeChipsSource).not.toContain('function WorktreeChip(');diff --cc apps/desktop/src/renderer/components/new-chat/WorktreeChipsRow.tsxindex 986517d390,f2219f1644..2eea19beeb--- a/apps/desktop/src/renderer/components/new-chat/WorktreeChipsRow.tsx+++ b/apps/desktop/src/renderer/components/new-chat/WorktreeChipsRow.tsx@@@ -160,22 -152,21 +158,23 @@@ export function WorktreeChipsRow(return null;}, [detect.data, detect.loading, t]);- const environmentDisabled = worktreeDisabled || !!cantUseReason || detect.loading || !cwd;- const switchDisabled = disabled || worktreeDisabled || !!cantUseReason || detect.loading || !cwd;++ const environmentDisabled =++ worktreeDisabled || !!cantUseReason || detect.loading || !cwd || baseRepo === null;+ const switchDisabled = disabled || checkboxDisabled || (environmentDisabled && !enabled);// 状态不变量:这里**没有**任何自动改写 enabled 的 effect——勾选状态只属于用户,- // 资格不满足只体现为 checkbox 禁用(switchDisabled)+发送侧「勾选 && 合格」降级。+ // 资格不满足时 OFF 不能开启;已 ON 必须仍能显式关闭,发送侧同时保留输入并阻塞创建。const effectiveWorktreeEnabled = enabled && !advancedHidden && !worktreeDisabled;- // 分支列表只在 worktree 开启后拉取;关闭态左半区仅展示当前 checkout 分支。- const branches = useBranches(effectiveWorktreeEnabled ? baseRepo : null, deviceLinkDeviceId);+ // 分支列表懒加载 latch:worktree 未开时不预拉,首次点开分支 chip 菜单才拉,+ // 之后保持订阅(baseRepo 变化由 hook 自身依赖触发重拉)。+ const [branchListWanted, setBranchListWanted] = useState(false);+ const branches = useBranches(+ effectiveWorktreeEnabled || branchListWanted ? baseRepo : null,+ deviceLinkDeviceId,+ );const suggested = useSuggestName(effectiveWorktreeEnabled ? baseRepo : null, deviceLinkDeviceId);- useEffect(() => {- if (!effectiveWorktreeEnabled || sourceBranch || !branches.current) return;- onSourceBranchChange(branches.current);- }, [effectiveWorktreeEnabled, sourceBranch, branches.current, onSourceBranchChange]);-const lastNameRef = useRef('');useEffect(() => {if (!effectiveWorktreeEnabled) {@@@ -205,12 -196,17 +204,13 @@@// ── 分支 chip 状态 ──const currentBranch = detect.data?.currentBranch ?? null;- // worktree ON 显源分支,列表加载失败/未返回时回退 'HEAD'(与发送管线的源分支- // 回退值一致,表示当前 checkout 而不是猜测 main)—— ON 状态下 chip 是唯一的- // 分支入口,绝不能因加载失败而消失。OFF 显仓库当前 HEAD 分支;detached HEAD- // 没有分支名时仍显示 HEAD,让默认未勾选用户保有开启 worktree 的入口。- const branchLabel = effectiveWorktreeEnabled- ? sourceBranch || branches.current || currentBranch || 'HEAD'- : (currentBranch ?? 'HEAD');- const showBranchChip = !advancedHidden && !!detect.data?.isGitRepo;- // 分支菜单只在 worktree 已勾时可交互(= 源分支选择器);未勾时分支区只读展示当前- // HEAD——选分支不再承担任何隐式开关语义(状态不变量,见文件头)。- const branchInteractive = !disabled && effectiveWorktreeEnabled && baseRepo !== null;+ // 分支与 checkbox 独立:未勾时也要回显用户刚选的源分支,否则菜单虽然可点、+ // 选择后却仍显示当前 HEAD,看起来像没有生效。首次未选择时回退当前 checkout。- const branchLabel = sourceBranch || currentBranch || 'HEAD';++ const branchLabel = sourceBranch || branches.current || currentBranch || 'HEAD';+ const showBranchChip = !advancedHidden && (enabled || !!detect.data?.isGitRepo);+ // 分支选择与 checkbox 是两条独立轴;仅环境不具备 worktree 资格或创建在途时禁用。- const branchInteractive = !(disabled || branchDisabled || environmentDisabled);++ const branchInteractive =++ !(disabled || branchDisabled || environmentDisabled) && baseRepo !== null;const handleBranchPick = useCallback((picked: string) => {