Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 收敛 deviceId 三态到 OrcaWorkerPanel 边界

Shinku1a1cc6f38465
diff --git a/apps/desktop/src/renderer/__tests__/orcaWorkflowRoute.test.ts b/apps/desktop/src/renderer/__tests__/orcaWorkflowRoute.test.ts
index c360ae03f2..caa05a556c 100644
--- a/apps/desktop/src/renderer/__tests__/orcaWorkflowRoute.test.ts
+++ b/apps/desktop/src/renderer/__tests__/orcaWorkflowRoute.test.ts
@@ -412,10 +412,10 @@ describe('OrcaWorkflowRoute source invariants', () => {
it('does not navigate the detached sidebar window to settings from the worker toolbar', () => {
// 硬上限时 + 按钮跳转到协同设置(codex P1 逃生口),但分离侧栏窗口与 device-link 受控面板
// 不能整壳替换成设置路由(前者固定 /sidebar-window 壳路由,后者上限走 device-link 远程路径)。
- // 实现用 onOpenSettings={isSidebarWindow() || deviceId ? undefined : handleOpenSettings} 在调用处守卫:
+ // 实现用 onOpenSettings={isSidebarWindow() || deviceId !== null ? undefined : handleOpenSettings} 在调用处守卫:
// 两类面板下传 undefined,+ 按钮回退为 disabled(不再呈现点了没反应的「设置 · 协同」按钮)。
expect(workerPanelSource).toContain("import { isSidebarWindow } from '@/lib/sidebarWindow';");
- expect(workerPanelSource).toContain('onOpenSettings={isSidebarWindow() || deviceId ? undefined : handleOpenSettings}');
+ expect(workerPanelSource).toContain('onOpenSettings={isSidebarWindow() || deviceId !== null ? undefined : handleOpenSettings}');
expect(workerPanelSource).toContain("navigate('/settings?section=collaboration')");
expect(workerPanelSource).not.toContain('settingsEnabled');
expect(workersTabBodySource).toContain("import { isSidebarWindow } from '@/lib/sidebarWindow';");
diff --git a/apps/desktop/src/renderer/__tests__/remoteWorkerCreationContext.test.ts b/apps/desktop/src/renderer/__tests__/remoteWorkerCreationContext.test.ts
index d40feb1f85..8b0c343b39 100644
--- a/apps/desktop/src/renderer/__tests__/remoteWorkerCreationContext.test.ts
+++ b/apps/desktop/src/renderer/__tests__/remoteWorkerCreationContext.test.ts
@@ -45,8 +45,8 @@ describe('remote Orca Worker creation context', () => {
);
expect(sessionView).toContain('deviceId={remoteDeviceId}');
- expect(workerPanel).toContain('deviceId={deviceId}');
- expect(workersTabBody).toContain('deviceId: leadSession?.deviceLinkDeviceId');
+ expect(workerPanel).toContain('deviceId={deviceId ?? undefined}');
+ expect(workersTabBody).toContain('deviceId: ctx.deviceLinkDeviceId');
});
it('never uses the controller API key to gate a remote model row', () => {
diff --git a/apps/desktop/src/renderer/features/cc-agent/CreateWorkerPopover.tsx b/apps/desktop/src/renderer/features/cc-agent/CreateWorkerPopover.tsx
index 476446c4af..0c66316dac 100644
--- a/apps/desktop/src/renderer/features/cc-agent/CreateWorkerPopover.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/CreateWorkerPopover.tsx
@@ -70,8 +70,8 @@ export interface CreateWorkerPopoverProps {
title?: string;
submitLabel?: string;
className?: string;
- /** device-link controlled device; omitted (or null) for a local Lead session. */
- deviceId?: string | null;
+ /** device-link controlled device; omitted for a local Lead session. */
+ deviceId?: string;
/**
* SSH 远程 Lead(session.remoteHostId 非空):模型清单按 SSH 口径过滤 ——
* 订阅直连(chatgpt/ / xai/)与 openai-chat 桥接 Codex 供应商的桥只挂在本地
@@ -135,7 +135,7 @@ export function CreateWorkerPopover({
return selectWorkerModels({
agent,
capabilities: activeCaps,
- deviceId: deviceId ?? undefined,
+ deviceId,
providers,
providersLoading,
providersError,
@@ -738,7 +738,7 @@ export function CreateWorkerPopover({
onModelChange={updateModel}
onEffortChange={updateEffort}
vendorKey={vendorKey}
- deviceId={deviceId ?? undefined}
+ deviceId={deviceId}
// SSH 远程 Lead:与 ChatInput 同口径藏掉仅本地可桥接的模型/来源
// (订阅直连接本地 compat-proxy,openai-chat 桥接 Codex 接本地
// codex-proxy,远端都不经翻译)—— 否则提交才被 main 侧 guard 拒绝。
@@ -813,7 +813,7 @@ export function CreateWorkerPopover({
void updateWorkerPermissionMode(mode as OrcaWorkerPermissionMode)
}
vendorKey={vendorKey}
- deviceId={deviceId ?? undefined}
+ deviceId={deviceId}
triggerVariant="field"
dense
ariaContext={t('orca.createWorker.permissionLabel')}
diff --git a/apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsx b/apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsx
index 1468b889bf..4f2482d080 100644
--- a/apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsx
@@ -84,7 +84,7 @@ export function OrcaWorkerPanel({
handleArchiveWorker,
} = useOrcaWorkerSelection({
leadSessionId,
- deviceId,
+ deviceId: deviceId ?? undefined,
viewVisible,
focusWorkerSessionId,
focusWorkerHintRevision,
@@ -209,7 +209,7 @@ export function OrcaWorkerPanel({
open={createOpen}
onClose={() => setCreateOpen(false)}
onCreate={handleCreateWorker}
- deviceId={deviceId}
+ deviceId={deviceId ?? undefined}
sshRemote={sshRemote}
/>
</div>
diff --git a/apps/desktop/src/renderer/features/cc-agent/hooks/useOrcaWorkerSelection.ts b/apps/desktop/src/renderer/features/cc-agent/hooks/useOrcaWorkerSelection.ts
index 3597fecab7..8fb58578cf 100644
--- a/apps/desktop/src/renderer/features/cc-agent/hooks/useOrcaWorkerSelection.ts
+++ b/apps/desktop/src/renderer/features/cc-agent/hooks/useOrcaWorkerSelection.ts
@@ -25,7 +25,7 @@ function parseSearchJump(state: unknown): ConversationSearchJump | null {
export interface UseOrcaWorkerSelectionOptions {
leadSessionId: string;
- deviceId?: string | null;
+ deviceId?: string;
/** Whether the worker conversation is actually visible to the user. */
viewVisible: boolean;
focusWorkerSessionId?: string | null;
diff --git a/apps/desktop/src/renderer/hooks/useAgentCapabilities.ts b/apps/desktop/src/renderer/hooks/useAgentCapabilities.ts
index 8b343e14ab..a1581b737c 100644
--- a/apps/desktop/src/renderer/hooks/useAgentCapabilities.ts
+++ b/apps/desktop/src/renderer/hooks/useAgentCapabilities.ts
@@ -301,7 +301,7 @@ function getDeviceLink(): DeviceLinkShape | null {
// 缓存按 (deviceId, agentKind) 隔离 —— 两台机器模型/能力配置可能不同,绝不能串。
// deviceId 省略 = 本机会话,走与改造前逐字节相同的本地路径(零回归)。
type CacheKey = string;
-function cacheKey(agentKind: AgentKind, deviceId?: string | null): CacheKey {
+function cacheKey(agentKind: AgentKind, deviceId?: string): CacheKey {
return `${deviceId ?? 'local'}:${agentKind}`;
}
@@ -355,7 +355,7 @@ export function subscribeDeviceCapabilities(
async function fetchCapabilities(
agentKind: AgentKind,
- deviceId?: string | null,
+ deviceId?: string,
): Promise<AgentCapabilities | null> {
const key = cacheKey(agentKind, deviceId);
const cached = cache.get(key);
@@ -430,7 +430,7 @@ export interface UseAgentCapabilitiesResult {
export function useAgentCapabilities(
agentKind: AgentKind | null | undefined,
- deviceId?: string | null,
+ deviceId?: string,
): UseAgentCapabilitiesResult {
const selectedKey = agentKind ? cacheKey(agentKind, deviceId) : null;
const initialCapabilities = selectedKey ? cache.get(selectedKey) : undefined;
diff --git a/apps/desktop/src/renderer/hooks/useDeviceProviders.ts b/apps/desktop/src/renderer/hooks/useDeviceProviders.ts
index dd706d39a0..fd748599c0 100644
--- a/apps/desktop/src/renderer/hooks/useDeviceProviders.ts
+++ b/apps/desktop/src/renderer/hooks/useDeviceProviders.ts
@@ -231,7 +231,7 @@ export interface UseDeviceProvidersResult {
unsupported: boolean;
}
-export function useDeviceProviders(deviceId?: string | null): UseDeviceProvidersResult {
+export function useDeviceProviders(deviceId?: string): UseDeviceProvidersResult {
const initialPayload = deviceId ? cache.get(deviceId) : undefined;
const [ownerDeviceId, setOwnerDeviceId] = useState<string | null>(
initialPayload ? (deviceId ?? null) : null,