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): 修复 Host-capability 插件芯片在发送时被忽略

Shinku1157384e4235
diff --git a/apps/desktop/src/renderer/__tests__/chatInputSessionFocus.test.ts b/apps/desktop/src/renderer/__tests__/chatInputSessionFocus.test.ts
index bac8e65c5f..0ae348677b 100644
--- a/apps/desktop/src/renderer/__tests__/chatInputSessionFocus.test.ts
+++ b/apps/desktop/src/renderer/__tests__/chatInputSessionFocus.test.ts
@@ -134,10 +134,11 @@ describe('ChatInput session switch focus contract', () => {
),
).toHaveLength(1);
expect(capabilitySelectionBlock).toContain("selectedItem.type === 'plugin-command'");
- expect(capabilitySelectionBlock).toContain('!ghost?.enabled');
+expect(capabilitySelectionBlock).toContain('!ghost?.enabled');
expect(capabilitySelectionBlock).toContain(
'placeGhostAtComposerStart(editor, ghost, installedGhostsRef.current);',
);
+ expect(capabilitySelectionBlock).toContain('placeHostCapabilityAtComposerStart(editor, ghost, installedGhostsRef.current);');
expect(capabilitySelectionBlock).toContain('closeAtPanel();');
expect(capabilitySelectionBlock).not.toContain('focusIOSSimulatorPanel');
expect(chatInputSource).toContain('focusComposerEndNextFrame(editor);');
diff --git a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
index 49995145a0..11bd14a3da 100644
--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
@@ -141,6 +141,7 @@ import {
import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';
import { PermissionSelector } from './PermissionSelector';
import { ExtraDirsButton, type CollaborationMenuConfig } from './ExtraDirsButton';
+import { expandHostCapabilityInvocation } from '../../cindy-brain/hostCapabilityInvocation';
import { focusComposerEndNextFrame, hostCapabilityForGhost, placeGhostAtComposerStart, placeHostCapabilityAtComposerStart } from './ghostComposerPlacement';
import { NewGoalDialog } from './NewGoalDialog';
import { PlanModeIndicator } from './PlanModeIndicator';
@@ -4606,6 +4607,7 @@ export function ChatInput({
agentReferences: serializedAgentReferences,
pastedTextRanges,
slashCommandRanges,
+ hostCapability,
} = serializedContent;
let agentReferences = serializedAgentReferences;
const attachmentsForSend = optimisticallyClearRemoteComposer
@@ -4660,8 +4662,9 @@ export function ChatInput({
// (截图在下方并入 filesToSend,与文本块里的 "attached as a labeled image"
// caption 对应)。
const text = formatBrowserCommentsForSend(commentsForSend, editorText);
- // Allow send if there is text OR attachments(纯引用 / 纯评论无输入也可发送)
- if (!text && attachmentsForSend.length === 0) return;
+ // Allow send if there is text, attachments, or a host-capability chip
+ // (host-capability chips carry routing metadata but no visible text).
+ if (!text && attachmentsForSend.length === 0 && !hostCapability) return;
// device-link 模型清单未结算或真实读取失败时禁止发送。模型选择器会同步显示
// loading / error;这里兜住快捷键、语音等间接派发入口,避免旧快照继续路由。
@@ -4752,6 +4755,9 @@ export function ChatInput({
? findGhostByCommand(eligibleGhosts, ghostCommandWord)
: null;
const textToSend = expandGhostCommand(text, eligibleGhosts);
+ const routedText = hostCapability
+ ? expandHostCapabilityInvocation(textToSend, hostCapability, hostCapability.name)
+ : textToSend;
const sendSnapshot = captureComposerSendSnapshot(
editor.getJSON(),
latestAttachmentsRef.current,
@@ -5095,7 +5101,7 @@ export function ChatInput({
effortForSend = coordinator.getCommittedEffort(sessionId) ?? activeEffort;
}
result = await onSend(
- textToSend,
+ routedText,
activeModel,
effortForSend,
activePermissionMode,