Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 硬上限时 + 按钮跳转协同设置
Shinku53788f693b66
diff --git a/apps/desktop/src/renderer/__tests__/orcaWorkflowRoute.test.ts b/apps/desktop/src/renderer/__tests__/orcaWorkflowRoute.test.tsindex 623e3fc5e5..3d424c427f 100644--- a/apps/desktop/src/renderer/__tests__/orcaWorkflowRoute.test.ts+++ b/apps/desktop/src/renderer/__tests__/orcaWorkflowRoute.test.ts@@ -410,6 +410,12 @@ describe('OrcaWorkflowRoute source invariants', () => {});it('does not navigate the detached sidebar window to settings from the worker toolbar', () => {+ // 硬上限时 + 按钮跳转到协同设置(codex P1 逃生口),但分离侧栏窗口不能整壳替换成设置路由,+ // 因此 OrcaWorkerPanel 的 handleOpenSettings 用 isSidebarWindow() 守卫:侧栏窗口下不跳转。+ expect(workerPanelSource).toContain("import { isSidebarWindow } from '@/lib/sidebarWindow';");+ expect(workerPanelSource).toContain('if (isSidebarWindow()) return;');+ expect(workerPanelSource).toContain("navigate('/settings?section=collaboration')");+ expect(workerPanelSource).not.toContain('settingsEnabled');expect(workersTabBodySource).toContain("import { isSidebarWindow } from '@/lib/sidebarWindow';");expect(workersTabBodySource).toContain('<OrcaWorkerPanel {...workerPanelProps} />');expect(workersTabBodySource).toContain('<RoutedOrcaWorkerPanel {...workerPanelProps} />');diff --git a/apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsx b/apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsxindex c77b93aa91..e42834c414 100644--- a/apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsx@@ -8,10 +8,11 @@import { useCallback, useEffect, useRef } from 'react';import { useTranslation } from 'react-i18next';+import { useNavigate } from 'react-router-dom';import { isAgentIslandSupported } from '@/hooks/useAgentIslandSettings';-import { isSidebarWindow } from '@/lib/sidebarWindow';import { toast } from '@/lib/toast';+import { isSidebarWindow } from '@/lib/sidebarWindow';import { CCAgentSessionView } from './CCAgentSessionView';import { CreateWorkerPopover } from './CreateWorkerPopover';import { WorkerListToolbar } from './RolePillDropdown';@@ -36,8 +37,6 @@ export interface OrcaWorkerPanelProps {onFocusWorkerSessionIdConsumed?: (revision: number) => void;onSelectionIntentCleared?: (revision: number) => void;onSearchJumpConsumed?: () => void;- /** Main-window host navigation. Detached sidebar windows omit it and hide the settings action. */- onOpenSettings?: () => void;}function sameVisibleSessionPayload(@@ -61,9 +60,9 @@ export function OrcaWorkerPanel({onFocusWorkerSessionIdConsumed,onSelectionIntentCleared,onSearchJumpConsumed,- onOpenSettings,}: OrcaWorkerPanelProps) {const { t } = useTranslation();+ const navigate = useNavigate();const {workers,focusedWorker,@@ -104,6 +103,14 @@ export function OrcaWorkerPanel({setCreateOpen(true);}, [refreshCreationState, setCreateOpen, t]);+ // 硬上限时 + 按钮不再只是 disabled no-op,而是跳转到协同设置去调高上限(codex P1 逃生口)。+ // 但分离侧栏窗口固定在 /sidebar-window 壳路由,本地 navigate 会把辅助窗口整壳替换成主设置+ // 路由,故侧栏窗口下不接线跳转(与 CreateWorkerPopover 的 onNavigateToProviders 同口径)。+ const handleOpenSettings = useCallback(() => {+ if (isSidebarWindow()) return;+ navigate('/settings?section=collaboration');+ }, [navigate]);+useEffect(() => {if (!viewVisible) return;let active = true;@@ -166,8 +173,7 @@ export function OrcaWorkerPanel({hardLimit={hardLimit}onSwitchFocus={handleSwitchFocus}onOpenCreate={() => void handleOpenCreate()}- onOpenSettings={() => onOpenSettings?.()}- settingsEnabled={!isSidebarWindow() && Boolean(onOpenSettings)}+ onOpenSettings={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 2de775ddfb..dbd66818e8 100644--- a/apps/desktop/src/renderer/features/cc-agent/RolePillDropdown.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/RolePillDropdown.tsx@@ -313,6 +313,7 @@ export interface RolePillDropdownProps {export interface WorkerListToolbarProps extends RolePillDropdownProps {trailingActions?: ReactNode;+ onOpenSettings: () => void;}// 菜单经 top-full + mt-1 从锚点下方定位。按锚点实际 viewport 位置计算下方可用高度,@@ -652,18 +653,20 @@ function CreateWorkerTabButton({softLimit,hardLimit,onOpenCreate,+ onOpenSettings,}: {activeCount: number;softLimit: number;hardLimit: number;onOpenCreate: () => void;+ onOpenSettings: () => void;}) {const { t } = useTranslation();const shortcutKey = useAppShortcutDisplay('new-maker');const hardDisabled = activeCount >= hardLimit;const softWarn = !hardDisabled && activeCount >= softLimit;const tooltip = hardDisabled- ? t('orca.rolePill.hardLimitHint', { count: hardLimit })+ ? t('orca.rolePill.hardLimitSettingsHint', { count: hardLimit }): softWarn? t('orca.rolePill.softLimitHint', { count: softLimit }): shortcutKey@@ -674,18 +677,22 @@ function CreateWorkerTabButton({<Tip text={tooltip} side="bottom" delay={250}><buttontype="button"- aria-label={t('orca.rolePill.createWorker')}- aria-disabled={hardDisabled}+ aria-label={+ hardDisabled+ ? t('orca.rolePill.settingsCollaboration')+ : t('orca.rolePill.createWorker')+ }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 && 'text-[var(--status-bar-accent)]',- hardDisabled &&- 'cursor-not-allowed opacity-40 hover:bg-[var(--surface-elevated)] hover:text-[var(--text-secondary)]',+ (softWarn || hardDisabled) && 'text-[var(--status-bar-accent)]',)}onClick={() => {- if (hardDisabled) return;+ if (hardDisabled) {+ onOpenSettings();+ return;+ }onOpenCreate();}}>@@ -867,6 +874,7 @@ export function WorkerListToolbar({hardLimit,onSwitchFocus,onOpenCreate,+ onOpenSettings,onArchiveWorker,trailingActions,clearAttentionWhenVisible = true,@@ -892,6 +900,7 @@ export function WorkerListToolbar({softLimit={softLimit}hardLimit={hardLimit}onOpenCreate={onOpenCreate}+ onOpenSettings={onOpenSettings}/><WorkerLayoutMenulayout={layout}@@ -917,6 +926,7 @@ export function WorkerListToolbar({softLimit={softLimit}hardLimit={hardLimit}onOpenCreate={onOpenCreate}+ onOpenSettings={onOpenSettings}/><WorkerTabsListworkers={workers}@@ -933,6 +943,7 @@ export function WorkerListToolbar({softLimit={softLimit}hardLimit={hardLimit}onOpenCreate={onOpenCreate}+ onOpenSettings={onOpenSettings}/><div className="min-w-0 flex-1"><RolePillDropdowndiff --git a/apps/desktop/src/renderer/features/cc-agent/__tests__/RolePillDropdown.layoutMenu.test.tsx b/apps/desktop/src/renderer/features/cc-agent/__tests__/RolePillDropdown.layoutMenu.test.tsxindex 3463cd1141..83dfb9f683 100644--- a/apps/desktop/src/renderer/features/cc-agent/__tests__/RolePillDropdown.layoutMenu.test.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/__tests__/RolePillDropdown.layoutMenu.test.tsx@@ -50,6 +50,7 @@ function renderToolbar(overrides: Partial<Parameters<typeof WorkerListToolbar>[0hardLimit={8}onSwitchFocus={vi.fn()}onOpenCreate={vi.fn()}+ onOpenSettings={vi.fn()}onArchiveWorker={vi.fn()}{...overrides}/>,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 04b4cc2452..d96869ab6b 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@@ -74,6 +74,7 @@ describe('RolePillDropdown collaboration settings entry', () => {hardLimit={8}onSwitchFocus={vi.fn()}onOpenCreate={onOpenCreate}+ onOpenSettings={vi.fn()}onArchiveWorker={vi.fn()}/>,);@@ -81,4 +82,28 @@ describe('RolePillDropdown collaboration settings entry', () => {fireEvent.click(screen.getByRole('button', { name: 'orca.rolePill.createWorker' }));expect(onOpenCreate).toHaveBeenCalledTimes(1);});++ it('routes the + button to collaboration settings when at the hard limit', () => {+ const onOpenCreate = vi.fn();+ const onOpenSettings = vi.fn();+ render(+ <WorkerListToolbar+ worker={null}+ workers={[]}+ selectedWorkerId={null}+ activeWorkerCount={8}+ softLimit={5}+ hardLimit={8}+ onSwitchFocus={vi.fn()}+ onOpenCreate={onOpenCreate}+ onOpenSettings={onOpenSettings}+ onArchiveWorker={vi.fn()}+ />,+ );++ // 硬上限下 + 按钮不再 disabled no-op,而是以「设置 · 协同」为可访问名、点击跳转设置。+ fireEvent.click(screen.getByRole('button', { name: 'orca.rolePill.settingsCollaboration' }));+ expect(onOpenSettings).toHaveBeenCalledTimes(1);+ expect(onOpenCreate).not.toHaveBeenCalled();+ });});diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 876c21f01c..8b203918f9 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -9081,6 +9081,7 @@"archiveWorkerAria": "Archive worker {{name}}","createWorker": "Create new worker","hardLimitHint": "Hard limit reached: {{count}}. Archive an existing worker to create another one.",+ "hardLimitSettingsHint": "Hard limit reached: {{count}}. Click to adjust in collaboration settings.","softLimitHint": "Soft limit exceeded: {{count}}. More workers increase memory usage.","settingsCollaboration": "Settings · Collaboration","layoutMenuLabel": "Worker list layout",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 09390c0e21..011c4f98f0 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -9067,6 +9067,7 @@"archiveWorkerAria": "Worker {{name}} をアーカイブ","createWorker": "新しい Worker を作成","hardLimitHint": "ハード上限 {{count}} に達しました。既存 Worker をアーカイブすると追加できます。",+ "hardLimitSettingsHint": "ハード上限 {{count}} に達しました。クリックしてコラボレーション設定を調整します。","softLimitHint": "ソフト上限 {{count}} を超えています。Worker が多いほどメモリ使用量が増えます。","settingsCollaboration": "設定 · コラボレーション","layoutMenuLabel": "Worker リストの表示方式",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex eaf87e90a8..81878c784d 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -9067,6 +9067,7 @@"archiveWorkerAria": "Worker {{name}} 아카이브","createWorker": "새 Worker 만들기","hardLimitHint": "하드 제한 {{count}} 에 도달했습니다. 기존 Worker 를 아카이브하면 더 만들 수 있습니다.",+ "hardLimitSettingsHint": "하드 제한 {{count}} 에 도달했습니다. 클릭하여 협업 설정을 조정합니다.","softLimitHint": "소프트 제한 {{count}} 를 초과했습니다. Worker 가 많을수록 메모리 사용량이 늘어납니다.","settingsCollaboration": "설정 · 협업","layoutMenuLabel": "Worker 목록 표시 방식",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 3a5008ece1..9ba63a25d4 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -9067,6 +9067,7 @@"archiveWorkerAria": "归档 Worker {{name}}","createWorker": "创建新 Worker","hardLimitHint": "已达硬上限 {{count}} 个 · 归档现有 Worker 后可继续创建",+ "hardLimitSettingsHint": "已达硬上限 {{count}} 个 · 点击前往协同设置调整","softLimitHint": "已超过软上限 {{count}} 个 · Worker 过多会增加内存占用","settingsCollaboration": "设置 · 协同","layoutMenuLabel": "Worker 列表显示方式",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 161588a6ac..5553c9dddf 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -9067,6 +9067,7 @@"archiveWorkerAria": "歸檔 Worker {{name}}","createWorker": "建立新 Worker","hardLimitHint": "已達硬上限 {{count}} 個 · 歸檔現有 Worker 後可繼續建立",+ "hardLimitSettingsHint": "已達硬上限 {{count}} 個 · 點擊前往協同設定調整","softLimitHint": "已超過軟上限 {{count}} 個 · Worker 過多會增加記憶體佔用","settingsCollaboration": "設定 · 協同","layoutMenuLabel": "Worker 列表顯示方式",