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): 协同设置跳转对 device-link 归属未解析 fail closed

Shinku4856b7b0a89d
diff --git a/apps/desktop/src/renderer/features/cc-agent/CreateWorkerPopover.tsx b/apps/desktop/src/renderer/features/cc-agent/CreateWorkerPopover.tsx
index 0c66316dac..476446c4af 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 for a local Lead session. */
- deviceId?: string;
+ /** device-link controlled device; omitted (or null) for a local Lead session. */
+ deviceId?: string | null;
/**
* SSH 远程 Lead(session.remoteHostId 非空):模型清单按 SSH 口径过滤 ——
* 订阅直连(chatgpt/ / xai/)与 openai-chat 桥接 Codex 供应商的桥只挂在本地
@@ -135,7 +135,7 @@ export function CreateWorkerPopover({
return selectWorkerModels({
agent,
capabilities: activeCaps,
- deviceId,
+ deviceId: deviceId ?? undefined,
providers,
providersLoading,
providersError,
@@ -738,7 +738,7 @@ export function CreateWorkerPopover({
onModelChange={updateModel}
onEffortChange={updateEffort}
vendorKey={vendorKey}
- deviceId={deviceId}
+ deviceId={deviceId ?? undefined}
// 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}
+ deviceId={deviceId ?? undefined}
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 9fe9a202fa..1468b889bf 100644
--- a/apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsx
@@ -23,8 +23,12 @@ import { isActiveWorkerStatus } from '../../../shared/orca-worker-status';
export interface OrcaWorkerPanelProps {
leadSessionId: string;
- /** device-link controlled device that owns the Lead and its Worker team. */
- deviceId?: string;
+ /**
+ * device-link 受控设备:string = 被控设备(远程),null = 已确认本机,undefined = 归属尚未解析。
+ * 本地设置跳转只在归属解析为 null(本机)时启用,未解析时 fail closed,
+ * 避免冷启动 / relay 重连竞态把远端上限误当成本机可调。
+ */
+ deviceId?: string | null;
/** SSH 远程 Lead:worker 创建面板的模型清单按 SSH 口径过滤(见 CreateWorkerPopover.sshRemote)。 */
sshRemote?: boolean;
/** tab active && RSB 未折叠 && 窗口可见。挂载但不可见时不能清红点 / ack 消息。 */
@@ -175,7 +179,7 @@ export function OrcaWorkerPanel({
hardLimit={hardLimit}
onSwitchFocus={handleSwitchFocus}
onOpenCreate={() => void handleOpenCreate()}
- onOpenSettings={isSidebarWindow() || deviceId ? undefined : handleOpenSettings}
+ onOpenSettings={isSidebarWindow() || deviceId !== null ? undefined : handleOpenSettings}
onArchiveWorker={handleArchiveWorker}
clearAttentionWhenVisible={viewVisible}
/>
diff --git a/apps/desktop/src/renderer/features/cc-agent/__tests__/OrcaWorkerPanel.test.tsx b/apps/desktop/src/renderer/features/cc-agent/__tests__/OrcaWorkerPanel.test.tsx
index 13542020e3..69919e0421 100644
--- a/apps/desktop/src/renderer/features/cc-agent/__tests__/OrcaWorkerPanel.test.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/__tests__/OrcaWorkerPanel.test.tsx
@@ -137,7 +137,12 @@ describe('OrcaWorkerPanel settings navigation wiring', () => {
});
it('wires settings navigation for local leads', () => {
- render(<OrcaWorkerPanel leadSessionId="lead-1" viewVisible />);
+ render(<OrcaWorkerPanel leadSessionId="lead-1" deviceId={null} viewVisible />);
expect(mocks.toolbarProps.onOpenSettings).toBeTypeOf('function');
});
+
+ it('fails closed for unresolved device ownership', () => {
+ render(<OrcaWorkerPanel leadSessionId="lead-1" viewVisible />);
+ expect(mocks.toolbarProps.onOpenSettings).toBeUndefined();
+ });
});
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 8fb58578cf..3597fecab7 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;
+ deviceId?: string | null;
/** Whether the worker conversation is actually visible to the user. */
viewVisible: boolean;
focusWorkerSessionId?: string | null;
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersTabBody.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersTabBody.tsx
index 2ae38ca474..52007e903c 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersTabBody.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersTabBody.tsx
@@ -108,8 +108,8 @@ export function OrcaWorkersTabBody({
const workerPanelProps = {
leadSessionId: ctx.sessionId,
- deviceId: leadSession?.deviceLinkDeviceId,
- sshRemote: !!leadSession?.remoteHostId,
+ deviceId: ctx.deviceLinkDeviceId,
+ sshRemote: !!ctx.remoteHostId,
viewVisible,
chatRealtime,
focusWorkerSessionId: state.focusWorkerSessionId,
diff --git a/apps/desktop/src/renderer/hooks/useAgentCapabilities.ts b/apps/desktop/src/renderer/hooks/useAgentCapabilities.ts
index a1581b737c..8b343e14ab 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): CacheKey {
+function cacheKey(agentKind: AgentKind, deviceId?: string | null): CacheKey {
return `${deviceId ?? 'local'}:${agentKind}`;
}
@@ -355,7 +355,7 @@ export function subscribeDeviceCapabilities(
async function fetchCapabilities(
agentKind: AgentKind,
- deviceId?: string,
+ deviceId?: string | null,
): 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,
+ deviceId?: string | null,
): 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 fd748599c0..dd706d39a0 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): UseDeviceProvidersResult {
+export function useDeviceProviders(deviceId?: string | null): UseDeviceProvidersResult {
const initialPayload = deviceId ? cache.get(deviceId) : undefined;
const [ownerDeviceId, setOwnerDeviceId] = useState<string | null>(
initialPayload ? (deviceId ?? null) : null,