fix: suggest点击后按skill_id数组调用bootstrapRemoteSkill锁定技能
This commit is contained in:
parent
1243bd0aac
commit
dda131c5ea
|
|
@ -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" && (
|
||||
<SuggestionListContainer
|
||||
threadId={threadId}
|
||||
sendSelectSkill={iframeSkill.sendSelectSkill}
|
||||
/>
|
||||
)}
|
||||
|
|
@ -492,26 +494,31 @@ export function InputBox({
|
|||
|
||||
// SuggestionList 容器
|
||||
function SuggestionListContainer({
|
||||
threadId,
|
||||
sendSelectSkill,
|
||||
}: {
|
||||
threadId: string;
|
||||
sendSelectSkill: (selectedSkills: SelectedSkillPayloadItem[]) => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="absolute right-0 bottom-0 left-0 z-0 flex translate-y-full items-center justify-center pt-4">
|
||||
<SuggestionList sendSelectSkill={sendSelectSkill} />
|
||||
<SuggestionList threadId={threadId} sendSelectSkill={sendSelectSkill} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 快速选择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 (
|
||||
<Suggestions className="min-h-16 w-fit items-start" data-testid="welcome-suggestions">
|
||||
|
|
|
|||
Loading…
Reference in New Issue