Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix: let orca lead return home and surface remote catalog errors
PraiseZhuc033445bf407
diff --git a/apps/desktop/src/main/maker-ipc/sessionAgentSwitchHandler.ts b/apps/desktop/src/main/maker-ipc/sessionAgentSwitchHandler.tsindex df9b369e5f..6bd476daa8 100644--- a/apps/desktop/src/main/maker-ipc/sessionAgentSwitchHandler.ts+++ b/apps/desktop/src/main/maker-ipc/sessionAgentSwitchHandler.ts@@ -23,6 +23,7 @@* 上述回落再降级)。** 边界:远程会话(remoteHostId)与 Orca 协同会话不支持切换(UNSUPPORTED_CAPABILITY);+ * 例外:Orca Lead 从另一台电脑显式切回本机(agentDeviceId=null)允许登记/落地;* turn 进行中登记 pending 推迟到下一条消息发送时刻执行。** 远程 Agent 换电脑(agentDeviceId 变化,null = 任务所在电脑):原生会话记录在原来运行 Agent@@ -630,7 +631,12 @@ export async function performSessionAgentSwitch(params.applyNow === true &&normalizeDbAgentKind(row.agentKind) === makerToDbAgentKind(targetAgentKind) &&row.model === model;- if (row.orcaRole && !providerGroupRelocationOnly) {+ // Orca Lead 的 Agent 在另一台电脑时允许显式切回本机(null)。跨电脑、Worker、换引擎入口仍拒。+ const orcaLeadReturnHome =+ row.orcaRole === 'lead' &&+ (row.agentDeviceId ?? null) !== null &&+ requestedAgentDeviceId === null;+ if (row.orcaRole && !providerGroupRelocationOnly && !orcaLeadReturnHome) {// Orca lead/worker:协同运行时对 agent 形态有独立契约(docs/dev-rules/orca-team-architecture.md),不掺和。throwIpcError('UNSUPPORTED_CAPABILITY', 'agent switch is not supported for Orca sessions');}diff --git a/apps/desktop/src/renderer/__tests__/orcaLeadOfflineModelPanel.test.ts b/apps/desktop/src/renderer/__tests__/orcaLeadOfflineModelPanel.test.tsindex da4efaaf5a..e231274471 100644--- a/apps/desktop/src/renderer/__tests__/orcaLeadOfflineModelPanel.test.ts+++ b/apps/desktop/src/renderer/__tests__/orcaLeadOfflineModelPanel.test.ts@@ -102,7 +102,7 @@ describe('ChatInput 接线', () => {const chatInput = read('../components/new-chat/ChatInput.tsx');expect(chatInput).toContain('orcaLeadLocalFallbackOpen(');expect(chatInput).toContain('sessionRemoteAgentDevicesForOrcaFallback(');- expect(chatInput).toContain('sessionAgentSwitchSupported({');+ expect(chatInput).toContain('sessionAgentSwitchSupportedOf({');});});diff --git a/apps/desktop/src/renderer/__tests__/sessionAgentSwitchRemoteRouting.test.ts b/apps/desktop/src/renderer/__tests__/sessionAgentSwitchRemoteRouting.test.tsindex e099c16dad..075efac85e 100644--- a/apps/desktop/src/renderer/__tests__/sessionAgentSwitchRemoteRouting.test.ts+++ b/apps/desktop/src/renderer/__tests__/sessionAgentSwitchRemoteRouting.test.ts@@ -909,7 +909,8 @@ describe('ChatInput 的入口门控与调用路由', () => {});it('Orca 与角色未加载会话都 fail-closed:只有完整元数据确认非协同后开放入口', () => {- expect(source).toContain('sessionOrcaRole === null &&');+ expect(source).toContain('sessionAgentSwitchSupportedOf({');+ expect(source).toContain('orcaLeadLocalFallbackOpen(');// 会话视图必须保留 undefined 未知态,不能在完整 session 回流前冒充「非协同」。const viewSource = readFileSync(resolve(process.cwd(), 'src/renderer/features/cc-agent/CCAgentSessionView.tsx'),diff --git a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsxindex 2319f2fdbb..b7e5528dee 100644--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx@@ -128,6 +128,11 @@ import {type RemoteAgentSelectorOptions,type UnifiedSelectionAgentDevice,} from './ModelSelector';+import {+ orcaLeadLocalFallbackOpen,+ sessionAgentSwitchSupported as sessionAgentSwitchSupportedOf,+ sessionRemoteAgentDevicesForOrcaFallback,+} from './sessionAgentSwitchGate';import {enqueueEffortChange,getEffortChangeCoordinator,@@ -1866,8 +1871,9 @@ export function ChatInput({// 一个会随机吞掉模型重选的入口。本机会话恒可用——main 与 renderer 同版本,不能因// capabilities 还没加载完而闪掉入口。// SSH 远程(remoteHostId)是另一套引擎生命周期,继续不支持,由调用点单独排除。- // Orca 会话(lead / worker)同样排除:被控端 handler 对带 orcaRole 的会话一律拒- // UNSUPPORTED_CAPABILITY。角色未加载(undefined)也 fail-closed,避免冷启动短暂露出入口。+ // Orca 会话默认排除:被控端 handler 对带 orcaRole 的会话拒 UNSUPPORTED_CAPABILITY。+ // 例外:Lead 的 Agent 在另一台电脑且目录读取失败时,只开放切回本机。角色未加载(undefined)+ // 也 fail-closed,避免冷启动短暂露出入口。// 切换事务与 SET_MODEL 都由**任务所在的被控电脑**执行,这两个能力位按它判定,不跟着模型目录// 走:Agent 在第三台电脑(目录读那台)且那台离线时,仍要能在这里把 Agent 改回被控电脑。// 目录本就在被控电脑时与上面同一份缓存;本机会话不读(下面 !deviceLinkDeviceId 直接放行)。@@ -1891,9 +1897,8 @@ export function ChatInput({const remoteAtomicModelSelectionSupported =hostCcCaps.capabilities?.supportsSessionAgentSwitchCas === true ||hostCodexCaps.capabilities?.supportsSessionAgentSwitchCas === true;- const sessionAgentSwitchSupported =- sessionOrcaRole === null &&- (!deviceLinkDeviceId || ccSupportsSessionAgentSwitch || codexSupportsSessionAgentSwitch);+ const hostAgentSwitchCapable =+ !deviceLinkDeviceId || ccSupportsSessionAgentSwitch || codexSupportsSessionAgentSwitch;// 切换写入的串行链与写序号都按 session 存在**模块级**协调层(agentSwitchCoordinator),// 不放组件 ref:用户切走再切回时旧组件已卸载但 invoke 仍在飞,新组件若另起空队列 /@@ -2015,6 +2020,16 @@ export function ChatInput({pi: piCaps,providers: remoteProviders,});+ const orcaLeadLocalFallback = orcaLeadLocalFallbackOpen({+ sessionOrcaRole,+ agentDeviceId: effectiveAgentDeviceId,+ remoteCatalogStatus: remoteModelListStatus,+ });+ const sessionAgentSwitchSupported = sessionAgentSwitchSupportedOf({+ sessionOrcaRole,+ hostSwitchCapable: hostAgentSwitchCapable,+ orcaLeadLocalFallback,+ });const providersLoading = catalogDeviceId? remoteModelListStatus === 'loading': sshCodexHostId ? sshCodexProviders.status === 'loading' : localProvidersLoading;@@ -7221,7 +7236,10 @@ export function ChatInput({return undefined;}return {- devices: remoteAgentDevices,+ devices: sessionRemoteAgentDevicesForOrcaFallback(+ remoteAgentDevices,+ orcaLeadLocalFallback,+ ),selectedDeviceId: effectiveAgentDeviceId,// 被控电脑上的任务:没在浏览其他电脑时列被控电脑自己的目录与它的镜像记忆。...(deviceLinkDeviceId ? { homeDeviceId: deviceLinkDeviceId } : {}),@@ -7255,6 +7273,7 @@ export function ChatInput({remoteAgentDevices,effectiveAgentDeviceId,intentAgentDeviceId,+ orcaLeadLocalFallback,confirmAgentRelocation,]);diff --git a/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx b/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsxindex e03ff02cc9..40efe0bee1 100644--- a/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx+++ b/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx@@ -3511,6 +3511,17 @@ function ModelSelectorContentView({</div>{localCatalogNotice && <div className="shrink-0 p-2">{localCatalogNotice}</div>}<UnifiedModelPanel+ {...(!remoteAgent && deviceId && (remoteModelListStatus === 'loading' || remoteModelListStatus === 'error')+ ? {+ catalogNotice: (+ <RemoteModelLoadNotice+ status={remoteModelListStatus}+ onRetry={retryRemoteModels}+ message={remoteFailureMessage}+ />+ ),+ }+ : {})}deviceId={deviceId}providerUsage={providerUsageScope}providerGroupUsage={providerGroupUsage}diff --git a/apps/desktop/src/renderer/components/new-chat/UnifiedModelPanel.tsx b/apps/desktop/src/renderer/components/new-chat/UnifiedModelPanel.tsxindex fb1b488c4a..aaceb353cb 100644--- a/apps/desktop/src/renderer/components/new-chat/UnifiedModelPanel.tsx+++ b/apps/desktop/src/renderer/components/new-chat/UnifiedModelPanel.tsx@@ -17,6 +17,10 @@ import {import { toast } from '@/lib/toast';import { matchesModelName } from '@/lib/modelDisplayNames';import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react';+import {+ favoritesSyncFailureI18nKey,+ favoritesSyncFailureKind,+} from './sessionAgentSwitchGate';import { Check, Loader2, TriangleAlert } from 'lucide-react';import { useTranslation } from 'react-i18next';@@ -281,6 +285,8 @@ export interface UnifiedModelPanelProps {/** 面板容器元素(浮层按它的左 / 右外侧定位)。 */panelElement: HTMLElement | null;overlayClassName?: string;+ /** deviceId 目录读取中/失败时取代「没有匹配的模型」。 */+ catalogNotice?: ReactNode;/*** 远程 Agent(仅新任务草稿):左侧栏在本机供应商之后列出其他电脑上的供应商。选中那台* 电脑上的模型 = Agent 在那台电脑运行,任务和文件仍在本机。@@ -397,6 +403,7 @@ export function UnifiedModelPanel({panelElement,overlayClassName,panelWidthFluid = false,+ catalogNotice,remoteSources,}: UnifiedModelPanelProps) {const { t } = useTranslation();@@ -1374,7 +1381,10 @@ export function UnifiedModelPanel({</span></div>)}- {favoritesListDeviceId && remoteFavorites.error ? <div role="status" className="px-3 py-2 text-13 text-[var(--text-secondary)]">{t('newChat.modelSelector.unified.favoritesSyncFailed')}</div> : null}+ {favoritesListDeviceId && remoteFavorites.error ? <div role="status" className="px-3 py-2 text-13 text-[var(--text-secondary)]">{t(favoritesSyncFailureI18nKey(favoritesSyncFailureKind({+ deviceId: favoritesListDeviceId,+ unavailableDeviceIds: remoteSources?.unavailableDeviceIds,+ })))}</div> : null}{remoteListPending ? (remoteSources?.failure ?? (<div@@ -1385,6 +1395,8 @@ export function UnifiedModelPanel({{t('newChat.modelSelector.unified.remoteLoading')}</div>)+ ) : catalogNotice ? (+ catalogNotice) : !hasRows ? (<div className="px-3 py-6 text-center text-13 text-[var(--text-tertiary)]">{/* ★ 视图的空态是引导语,不是「没有匹配」(设计稿 favEmpty;★ 常驻后必经)。 */}diff --git a/apps/desktop/src/renderer/components/new-chat/sessionAgentSwitchGate.ts b/apps/desktop/src/renderer/components/new-chat/sessionAgentSwitchGate.tsnew file mode 100644index 0000000000..827b32b4ff--- /dev/null+++ b/apps/desktop/src/renderer/components/new-chat/sessionAgentSwitchGate.ts@@ -0,0 +1,58 @@+/**+ * 会话换 Agent / 换电脑的入口门控。+ *+ * 协同任务默认不开放跨电脑切换(handler 对 orcaRole 拒 UNSUPPORTED_CAPABILITY)。+ * 唯一产品例外:Orca Lead 的 Agent 落在另一台电脑、且那台目录读取失败时,只开放切回本机。+ */++export type RemoteCatalogStatus = 'idle' | 'loading' | 'error' | 'ready';++export function orcaLeadLocalFallbackOpen(input: {+ sessionOrcaRole: string | null | undefined;+ agentDeviceId: string | null | undefined;+ remoteCatalogStatus: RemoteCatalogStatus | undefined;+}): boolean {+ return (+ input.sessionOrcaRole === 'lead' &&+ typeof input.agentDeviceId === 'string' &&+ input.agentDeviceId.length > 0 &&+ input.remoteCatalogStatus === 'error'+ );+}++export function sessionAgentSwitchSupported(input: {+ sessionOrcaRole: string | null | undefined;+ hostSwitchCapable: boolean;+ orcaLeadLocalFallback: boolean;+}): boolean {+ if (!input.hostSwitchCapable) return false;+ if (input.sessionOrcaRole === null) return true;+ return input.orcaLeadLocalFallback;+}++/** 离线回落只露出本机格,不把其它电脑列进左栏。 */+export function sessionRemoteAgentDevicesForOrcaFallback<T>(+ devices: readonly T[] | undefined,+ fallbackOpen: boolean,+): readonly T[] {+ if (fallbackOpen) return [];+ return devices ?? [];+}++export function favoritesSyncFailureKind(input: {+ deviceId: string | undefined;+ unavailableDeviceIds?: readonly string[];+}): 'unreachable' | 'unsupported' {+ if (!input.deviceId) return 'unreachable';+ if (!input.unavailableDeviceIds) return 'unreachable';+ if (input.unavailableDeviceIds.includes(input.deviceId)) return 'unreachable';+ return 'unsupported';+}++export function favoritesSyncFailureI18nKey(+ kind: 'unreachable' | 'unsupported',+): 'newChat.modelSelector.unified.favoritesSyncFailedUnreachable' | 'newChat.modelSelector.unified.favoritesSyncFailedUnsupported' {+ return kind === 'unsupported'+ ? 'newChat.modelSelector.unified.favoritesSyncFailedUnsupported'+ : 'newChat.modelSelector.unified.favoritesSyncFailedUnreachable';+}diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 897cc47c19..34c317617b 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -9911,7 +9911,9 @@"effortEndSmart": "Smarter","railSameEngine": "{{agent}} only","crossEngineWarning": "Switching engines rebuilds context and may lose content",- "favoritesSyncFailed": "Favorites could not sync. Reopen the picker to retry; the remote computer may need an update.",+ "favoritesSyncFailed": "Favorites could not sync. Reopen the picker to retry.",+ "favoritesSyncFailedUnreachable": "Favorites could not sync: the computer is unreachable. Check the connection and try again.",+ "favoritesSyncFailedUnsupported": "Favorites could not sync: this computer's Cindy version does not support favorites sync.","railRemoteProviderGroup": "{{provider}} · {{device}} · {{group}}","providerGroupLabel": "{{provider}} · {{group}}","providerGroupRunningOn": "Running on {{device}}",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex ebaba8cc00..f1ed5e9d7f 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -9874,7 +9874,9 @@"effortEndSmart": "高精度","railSameEngine": "{{agent}} のみ","crossEngineWarning": "エンジンを切り替えるとコンテキストが再構築され、内容が失われる場合があります",- "favoritesSyncFailed": "お気に入りを同期できません。選択画面を開き直してください。接続先の更新が必要な場合があります。",+ "favoritesSyncFailed": "お気に入りを同期できません。選択画面を開き直してください。",+ "favoritesSyncFailedUnreachable": "お気に入りを同期できません。接続先に到達できません。接続を確認して再試行してください。",+ "favoritesSyncFailedUnsupported": "お気に入りを同期できません。接続先の Cindy バージョンがお気に入り同期に対応していません。","railRemoteProviderGroup": "{{provider}} · {{device}} · {{group}}","providerGroupLabel": "{{provider}} · {{group}}","providerGroupRunningOn": "現在 {{device}} で実行中",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex bbcf607ffa..71af1ea6c0 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -9874,7 +9874,9 @@"effortEndSmart": "더 똑똑하게","railSameEngine": "{{agent}} 전용","crossEngineWarning": "엔진을 전환하면 컨텍스트가 다시 구성되어 내용이 사라질 수 있습니다",- "favoritesSyncFailed": "즐겨찾기를 동기화할 수 없습니다. 선택 화면을 다시 여세요. 원격 컴퓨터를 업데이트해야 할 수 있습니다.",+ "favoritesSyncFailed": "즐겨찾기를 동기화할 수 없습니다. 선택 화면을 다시 여세요.",+ "favoritesSyncFailedUnreachable": "즐겨찾기를 동기화할 수 없습니다. 연결할 수 없습니다. 연결을 확인한 후 다시 시도하세요.",+ "favoritesSyncFailedUnsupported": "즐겨찾기를 동기화할 수 없습니다. 해당 컴퓨터의 Cindy 버전이 즐겨찾기 동기화를 지원하지 않습니다.","railRemoteProviderGroup": "{{provider}} · {{device}} · {{group}}","providerGroupLabel": "{{provider}} · {{group}}","providerGroupRunningOn": "현재 {{device}}에서 실행 중",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 3ef7a29b9e..096257b126 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -9874,7 +9874,9 @@"effortEndSmart": "更智能","railSameEngine": "仅 {{agent}}","crossEngineWarning": "切换引擎会重建上下文,可能丢失内容",- "favoritesSyncFailed": "收藏未能同步。请重新打开重试;被控电脑可能需要更新。",+ "favoritesSyncFailed": "收藏未能同步。请重新打开重试。",+ "favoritesSyncFailedUnreachable": "收藏未能同步:连接不可达。请检查连接后重试。",+ "favoritesSyncFailedUnsupported": "收藏未能同步:该电脑上的 Cindy 版本不支持收藏同步。","railRemoteProviderGroup": "{{provider}} · {{device}} · {{group}}","providerGroupLabel": "{{provider}} · {{group}}","providerGroupRunningOn": "当前在 {{device}} 上运行",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 96178b42e5..412b70d077 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -9873,7 +9873,9 @@"effortEndSmart": "更聰明","railSameEngine": "僅 {{agent}}","crossEngineWarning": "切換引擎會重建上下文,可能遺失內容",- "favoritesSyncFailed": "收藏未能同步。請重新開啟重試;被控電腦可能需要更新。",+ "favoritesSyncFailed": "收藏未能同步。請重新開啟重試。",+ "favoritesSyncFailedUnreachable": "收藏未能同步:連線不可達。請檢查連線後重試。",+ "favoritesSyncFailedUnsupported": "收藏未能同步:該電腦上的 Cindy 版本不支援收藏同步。","railRemoteProviderGroup": "{{provider}} · {{device}} · {{group}}","providerGroupLabel": "{{provider}} · {{group}}","providerGroupRunningOn": "目前在 {{device}} 上執行",