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。

Merge remote-tracking branch 'upstream/main' into feat/issue-397-ios-simulator-native-framebuffer

JiangJiahaoe9e6dac31c12
diff --cc apps/desktop/src/renderer/__tests__/chatInputGhostSnapshot.test.ts
index 471821b967,3db13aafe7..f8374da3d5
--- a/apps/desktop/src/renderer/__tests__/chatInputGhostSnapshot.test.ts
+++ b/apps/desktop/src/renderer/__tests__/chatInputGhostSnapshot.test.ts
@@@ -31,19 -31,11 +31,25 @@@ describe('ChatInput Ghost snapshot cont
});
it('does not expose controller-local plugin rows in device-link sessions', () => {
+ expect(source).toContain('if (deviceLinkDeviceId) return [];');
expect(source).toContain(
- 'if (deviceLinkDeviceId) return [];',
+ '[deviceLinkDeviceId, pluginsForMenu, pluginAvailableIds, remoteHostId, t]',
);
+ });
+
+ it('revalidates Host capability chips as enabled and local at send time', () => {
expect(source).toContain(
- '[deviceLinkDeviceId, pluginsForMenu, pluginAvailableIds, t]',
+ 'const canUseLocalHostCapability = !remoteHostId && !deviceLinkDeviceId;',
+ );
+ expect(source).toMatch(
+ /serializedHostCapability && canUseLocalHostCapability[\s\S]*?candidate\.enabled &&[\s\S]*?candidate\.manifest\.id === serializedHostCapability\.ghostId/,
+ );
+ expect(source).toContain("toast.warning(t('newChat.pluginSetup.error.TARGET_UNAVAILABLE'));");
+ });
++
++ it('does not consume Host capability text as a local plan-mode command', () => {
++ expect(source).toMatch(
++ /if \(\s*!serializedHostCapability &&\s*isPlanModeComposerCommandText\(/,
+ );
+ });
});
diff --cc apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
index d603a476f4,1d2318264b..31a4a6a513
--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
@@@ -137,14 -137,15 +137,20 @@@ import
import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';
import { PermissionSelector } from './PermissionSelector';
import { ExtraDirsButton, type CollaborationMenuConfig } from './ExtraDirsButton';
-import { focusComposerEndNextFrame, placeGhostAtComposerStart } from './ghostComposerPlacement';
+import {
+ focusComposerEndNextFrame,
+ hostCapabilityForGhost,
+ placeGhostAtComposerStart,
+ placeHostCapabilityAtComposerStart,
+} from './ghostComposerPlacement';
import { NewGoalDialog } from './NewGoalDialog';
import { PlanModeIndicator } from './PlanModeIndicator';
+ import {
+ addPlanModeComposerCommand,
+ consumePlanModeComposerCommand,
+ isPlanModeComposerCommandText,
+ shouldPreservePlanModeComposerDraft,
+ } from './planModeComposerCommand';
import { PendingQueuePanel } from './PendingQueuePanel';
import { SendButton } from './SendButton';
import { FolderPickerPopover, addRecentFolder } from './FolderPickerPopover';
@@@ -4249,44 -4267,47 +4323,86 @@@ export function ChatInput(
const commentsForSend = optimisticallyClearRemoteComposer
? commentsBeforeOptimisticClear
: [...browserCommentsRef.current];
+ // Resolve the structured capability atom against the current enabled,
+ // workdir-scoped Plugin roster. Draft data is presentation state only;
+ // it cannot grant a Host route after the Plugin is disabled/uninstalled.
+ const eligibleGhosts = filterGhostsForWorkdir(
+ installedGhostsRef.current,
+ workingDirRef.current,
+ );
+ const canUseLocalHostCapability = !remoteHostId && !deviceLinkDeviceId;
+ const hostCapabilityGhost =
+ serializedHostCapability && canUseLocalHostCapability
+ ? (eligibleGhosts.find(
+ (candidate) =>
+ candidate.enabled &&
+ candidate.manifest.id === serializedHostCapability.ghostId &&
+ hostCapabilityForGhost(candidate) === serializedHostCapability.capability,
+ ) ?? null)
+ : null;
+ if (serializedHostCapability && !hostCapabilityGhost) {
+ toast.warning(t('newChat.pluginSetup.error.TARGET_UNAVAILABLE'));
+ return;
+ }
+ const hostCapability =
+ serializedHostCapability && hostCapabilityGhost
+ ? {
+ capability: serializedHostCapability.capability,
+ ghostId: hostCapabilityGhost.manifest.id,
+ name: hostCapabilityGhost.manifest.name,
+ }
+ : null;
+ // A capability chip is metadata, not an automatic visible prefix. Use
+ // the localized default only when the user sent the chip by itself;
+ // otherwise preserve their body byte-for-byte and avoid duplication.
+ if (hostCapability && !editorText.trim()) {
+ editorText =
+ hostCapability.capability === 'ios-simulator'
+ ? t('rightSidebar.iosSimulator.startPrompt')
+ : hostCapability.name;
+ }
+ if (
++ !serializedHostCapability &&
+ isPlanModeComposerCommandText(
+ editorText,
+ planModeEntry !== undefined,
+ slashCommandsReady ? mergedCommands : null,
+ )
+ ) {
+ planModeEntry?.onToggle(!planModeEntry.enabled);
+ isRestoringRef.current = true;
+ try {
+ editor.commands.clearContent(true);
+ } finally {
+ isRestoringRef.current = false;
+ }
+ historyIndexRef.current = -1;
+ hydratedHistoryDocumentRef.current = null;
+ draftRef.current = null;
+ if (sourceStorageKey) {
+ if (
+ shouldPreservePlanModeComposerDraft(
+ attachmentsForSend.length,
+ commentsForSend.length,
+ )
+ ) {
+ const existingDraft = getComposerDraft(sourceStorageKey);
+ saveComposerDraft(
+ sourceStorageKey,
+ {
+ text: editor.getJSON(),
+ attachments: attachmentsForSend,
+ quotes: existingDraft?.quotes ?? [],
+ browserComments: commentsForSend,
+ },
+ { silent: true },
+ );
+ } else {
+ clearComposerDraft(sourceStorageKey);
+ }
+ }
+ return;
+ }
// composerQuote 在其正文位置序列化成 markdown blockquote,支持引用与回复交错。
// browser-comment-chip:页面评论序列化为 `# Browser comments:` 段拼在正文后
// (截图在下方并入 filesToSend,与文本块里的 "attached as a labeled image"
@@@ -4797,6 -4808,7 +4913,9 @@@
remoteModelListStatus,
confirmDialog,
navigate,
++ slashCommandsReady,
++ mergedCommands,
+ planModeEntry,
],
);
useEffect(() => {
diff --cc apps/desktop/src/shared/ghost.ts
index e68a8e3836,aef80a4569..ef9d50f365
--- a/apps/desktop/src/shared/ghost.ts
+++ b/apps/desktop/src/shared/ghost.ts
@@@ -6723,8 -6178,13 +6723,10 @@@ export type GhostEventActivityData = Gh
/** 所有 did- 旁听事件共享的安全元数据载荷。 */
export type GhostDidEventData =
- | GhostEventTurnStartData
- | GhostEventTurnEndData
- | GhostEventSessionData
- | GhostEventActivityData;
+ GhostEventTurnStartData | GhostEventTurnEndData | GhostEventSessionData | GhostEventActivityData;
+ export type GhostMessageHookData = { sessionId: string; text: string; model?: string };
+
/**
* 下行:主机 → 意识的事件推送(经管子 onHostMessage 到达)。
* did- 分支带 topic/seq(每意识单调递增,可自查漏收;dropped = 上一段