diff --git a/frontend/src/components/workspace/input-box.tsx b/frontend/src/components/workspace/input-box.tsx index 9c9d4566..f7cea6d6 100644 --- a/frontend/src/components/workspace/input-box.tsx +++ b/frontend/src/components/workspace/input-box.tsx @@ -62,6 +62,7 @@ import type { } from "@/core/i18n/locales/types"; import { POST_MESSAGE_TYPES, sendToParent } from "@/core/iframe-messages"; import { useModels } from "@/core/models/hooks"; +import { bootstrapRemoteSkill } from "@/core/skills/api"; import type { AgentThreadContext } from "@/core/threads"; import { useIframeSkill } from "@/hooks/use-iframe-skill"; import { cn } from "@/lib/utils"; @@ -428,6 +429,7 @@ export function InputBox({ {showWelcomeStyle && !hasSubmitted && searchParams.get("mode") !== "skill" && ( )} @@ -492,26 +494,31 @@ export function InputBox({ // SuggestionList 容器 function SuggestionListContainer({ + threadId, sendSelectSkill, }: { + threadId: string; sendSelectSkill: (selectedSkills: SelectedSkillPayloadItem[]) => void; }) { return (
- +
); } // 快速选择skillbutton function SuggestionList({ + threadId, sendSelectSkill, }: { + threadId: string; sendSelectSkill: (selectedSkills: SelectedSkillPayloadItem[]) => void; }) { const { t } = useI18n(); + const searchParams = useSearchParams(); const { textInput } = usePromptInputController(); - const suggestions =t.inputBox.suggestions + const suggestions = t.inputBox.suggestions; const promptSuggestions = suggestions.filter( ( suggestion, @@ -528,6 +535,28 @@ function SuggestionList({ suggestion: string; }, ) => { + const languageTypeRaw = + searchParams.get("languageType")?.trim() ?? + searchParams.get("language_type")?.trim(); + const languageType = languageTypeRaw ? Number(languageTypeRaw) : 0; + const bootstrapByIds = (ids: string[]) => { + const content_ids = Array.from( + new Set( + ids + .map((id) => Number(id)) + .filter((id) => Number.isFinite(id) && id > 0), + ), + ); + if (!threadId || content_ids.length === 0) return; + void bootstrapRemoteSkill({ + thread_id: threadId, + content_ids, + language_type: languageType, + target_dir: "/mnt/user-data/uploads/skill", + clear_target: true, + }); + }; + // 优先从 children 中提取 skill_id 数组,转换为 selectedSkills 发送给宿主页 const childSkillIds = (suggestion.children ?? []) .map((item) => String(item.id).trim()) @@ -539,6 +568,7 @@ function SuggestionList({ name: suggestion.suggestion, })), ); + bootstrapByIds(childSkillIds); return; } if (suggestion.skill_id && suggestion.skill_id.length > 0) { @@ -548,6 +578,7 @@ function SuggestionList({ name: suggestion.suggestion, })), ); + bootstrapByIds(suggestion.skill_id); return; } // 原有逻辑 @@ -567,7 +598,7 @@ function SuggestionList({ } }, 500); }, - [textInput, sendSelectSkill], + [textInput, sendSelectSkill, threadId, searchParams], ); return (