Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 分离侧栏硬上限 + 按钮回退 disabled
Shinkufb0c854b2d33
diff --git a/apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsx b/apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsxindex e42834c414..72194412d7 100644--- a/apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsx@@ -105,9 +105,9 @@ export function OrcaWorkerPanel({// 硬上限时 + 按钮不再只是 disabled no-op,而是跳转到协同设置去调高上限(codex P1 逃生口)。// 但分离侧栏窗口固定在 /sidebar-window 壳路由,本地 navigate 会把辅助窗口整壳替换成主设置- // 路由,故侧栏窗口下不接线跳转(与 CreateWorkerPopover 的 onNavigateToProviders 同口径)。+ // 路由,故侧栏窗口下不接线跳转(onOpenSettings 传 undefined,+ 按钮回退为 disabled,+ // 与 CreateWorkerPopover 的 onNavigateToProviders 同口径)。const handleOpenSettings = useCallback(() => {- if (isSidebarWindow()) return;navigate('/settings?section=collaboration');}, [navigate]);@@ -173,7 +173,7 @@ export function OrcaWorkerPanel({hardLimit={hardLimit}onSwitchFocus={handleSwitchFocus}onOpenCreate={() => void handleOpenCreate()}- onOpenSettings={handleOpenSettings}+ onOpenSettings={isSidebarWindow() ? undefined : handleOpenSettings}onArchiveWorker={handleArchiveWorker}clearAttentionWhenVisible={viewVisible}/>diff --git a/apps/desktop/src/renderer/features/cc-agent/RolePillDropdown.tsx b/apps/desktop/src/renderer/features/cc-agent/RolePillDropdown.tsxindex dbd66818e8..b122515e02 100644--- a/apps/desktop/src/renderer/features/cc-agent/RolePillDropdown.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/RolePillDropdown.tsx@@ -313,7 +313,8 @@ export interface RolePillDropdownProps {export interface WorkerListToolbarProps extends RolePillDropdownProps {trailingActions?: ReactNode;- onOpenSettings: () => void;+ /** 硬上限时 + 按钮跳转协同设置的逃生口;分离侧栏窗口无法导航到设置路由,传 undefined 表示不接线。 */+ onOpenSettings?: () => void;}// 菜单经 top-full + mt-1 从锚点下方定位。按锚点实际 viewport 位置计算下方可用高度,@@ -659,40 +660,50 @@ function CreateWorkerTabButton({softLimit: number;hardLimit: number;onOpenCreate: () => void;- onOpenSettings: () => void;+ onOpenSettings?: () => void;}) {const { t } = useTranslation();const shortcutKey = useAppShortcutDisplay('new-maker');const hardDisabled = activeCount >= hardLimit;+ // 硬上限时 + 按钮提供「跳转协同设置」逃生口;但分离侧栏窗口无法导航到设置路由+ // (onOpenSettings 未接线),此时退回旧的 disabled 行为,避免呈现一个点了没反应的按钮。+ const hardSettingsAction = hardDisabled && !!onOpenSettings;+ const hardBlocked = hardDisabled && !onOpenSettings;const softWarn = !hardDisabled && activeCount >= softLimit;- const tooltip = hardDisabled+ const tooltip = hardSettingsAction? t('orca.rolePill.hardLimitSettingsHint', { count: hardLimit })- : softWarn- ? t('orca.rolePill.softLimitHint', { count: softLimit })- : shortcutKey- ? `${t('orca.rolePill.createWorker')} (${shortcutKey})`- : t('orca.rolePill.createWorker');+ : hardBlocked+ ? t('orca.rolePill.hardLimitHint', { count: hardLimit })+ : softWarn+ ? t('orca.rolePill.softLimitHint', { count: softLimit })+ : shortcutKey+ ? `${t('orca.rolePill.createWorker')} (${shortcutKey})`+ : t('orca.rolePill.createWorker');return (<Tip text={tooltip} side="bottom" delay={250}><buttontype="button"aria-label={- hardDisabled+ hardSettingsAction? t('orca.rolePill.settingsCollaboration'): t('orca.rolePill.createWorker')}+ aria-disabled={hardBlocked || undefined}className={cn('inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-[var(--border-default)]','bg-[var(--surface-elevated)] text-[var(--text-secondary)] transition-colors','hover:bg-[var(--surface-chip)] hover:text-[var(--text-primary)]',- (softWarn || hardDisabled) && 'text-[var(--status-bar-accent)]',+ (softWarn || hardSettingsAction) && 'text-[var(--status-bar-accent)]',+ hardBlocked &&+ 'cursor-not-allowed opacity-40 hover:bg-[var(--surface-elevated)] hover:text-[var(--text-secondary)]',)}onClick={() => {- if (hardDisabled) {- onOpenSettings();+ if (hardSettingsAction) {+ onOpenSettings?.();return;}+ if (hardBlocked) return;onOpenCreate();}}>diff --git a/apps/desktop/src/renderer/features/cc-agent/__tests__/RolePillDropdown.settings.test.tsx b/apps/desktop/src/renderer/features/cc-agent/__tests__/RolePillDropdown.settings.test.tsxindex d96869ab6b..6d016c76c4 100644--- a/apps/desktop/src/renderer/features/cc-agent/__tests__/RolePillDropdown.settings.test.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/__tests__/RolePillDropdown.settings.test.tsx@@ -106,4 +106,28 @@ describe('RolePillDropdown collaboration settings entry', () => {expect(onOpenSettings).toHaveBeenCalledTimes(1);expect(onOpenCreate).not.toHaveBeenCalled();});++ it('keeps the + button disabled at hard limit when settings navigation is unavailable (detached sidebar)', () => {+ const onOpenCreate = vi.fn();+ render(+ <WorkerListToolbar+ worker={null}+ workers={[]}+ selectedWorkerId={null}+ activeWorkerCount={8}+ softLimit={5}+ hardLimit={8}+ onSwitchFocus={vi.fn()}+ onOpenCreate={onOpenCreate}+ // onOpenSettings 省略 → 分离侧栏窗口无法导航到设置路由。+ onArchiveWorker={vi.fn()}+ />,+ );++ // 无设置跳转入口时,硬上限 + 按钮回退为 disabled no-op:不再是「设置 · 协同」,也不触发新建。+ const button = screen.getByRole('button', { name: 'orca.rolePill.createWorker' });+ expect(button.getAttribute('aria-disabled')).toBe('true');+ fireEvent.click(button);+ expect(onOpenCreate).not.toHaveBeenCalled();+ });});