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";
|
} from "@/core/i18n/locales/types";
|
||||||
import { POST_MESSAGE_TYPES, sendToParent } from "@/core/iframe-messages";
|
import { POST_MESSAGE_TYPES, sendToParent } from "@/core/iframe-messages";
|
||||||
import { useModels } from "@/core/models/hooks";
|
import { useModels } from "@/core/models/hooks";
|
||||||
|
import { bootstrapRemoteSkill } from "@/core/skills/api";
|
||||||
import type { AgentThreadContext } from "@/core/threads";
|
import type { AgentThreadContext } from "@/core/threads";
|
||||||
import { useIframeSkill } from "@/hooks/use-iframe-skill";
|
import { useIframeSkill } from "@/hooks/use-iframe-skill";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
@ -428,6 +429,7 @@ export function InputBox({
|
||||||
|
|
||||||
{showWelcomeStyle && !hasSubmitted && searchParams.get("mode") !== "skill" && (
|
{showWelcomeStyle && !hasSubmitted && searchParams.get("mode") !== "skill" && (
|
||||||
<SuggestionListContainer
|
<SuggestionListContainer
|
||||||
|
threadId={threadId}
|
||||||
sendSelectSkill={iframeSkill.sendSelectSkill}
|
sendSelectSkill={iframeSkill.sendSelectSkill}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
@ -492,26 +494,31 @@ export function InputBox({
|
||||||
|
|
||||||
// SuggestionList 容器
|
// SuggestionList 容器
|
||||||
function SuggestionListContainer({
|
function SuggestionListContainer({
|
||||||
|
threadId,
|
||||||
sendSelectSkill,
|
sendSelectSkill,
|
||||||
}: {
|
}: {
|
||||||
|
threadId: string;
|
||||||
sendSelectSkill: (selectedSkills: SelectedSkillPayloadItem[]) => void;
|
sendSelectSkill: (selectedSkills: SelectedSkillPayloadItem[]) => void;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="absolute right-0 bottom-0 left-0 z-0 flex translate-y-full items-center justify-center pt-4">
|
<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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 快速选择skillbutton
|
// 快速选择skillbutton
|
||||||
function SuggestionList({
|
function SuggestionList({
|
||||||
|
threadId,
|
||||||
sendSelectSkill,
|
sendSelectSkill,
|
||||||
}: {
|
}: {
|
||||||
|
threadId: string;
|
||||||
sendSelectSkill: (selectedSkills: SelectedSkillPayloadItem[]) => void;
|
sendSelectSkill: (selectedSkills: SelectedSkillPayloadItem[]) => void;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
const { textInput } = usePromptInputController();
|
const { textInput } = usePromptInputController();
|
||||||
const suggestions =t.inputBox.suggestions
|
const suggestions = t.inputBox.suggestions;
|
||||||
const promptSuggestions = suggestions.filter(
|
const promptSuggestions = suggestions.filter(
|
||||||
(
|
(
|
||||||
suggestion,
|
suggestion,
|
||||||
|
|
@ -528,6 +535,28 @@ function SuggestionList({
|
||||||
suggestion: string;
|
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 发送给宿主页
|
// 优先从 children 中提取 skill_id 数组,转换为 selectedSkills 发送给宿主页
|
||||||
const childSkillIds = (suggestion.children ?? [])
|
const childSkillIds = (suggestion.children ?? [])
|
||||||
.map((item) => String(item.id).trim())
|
.map((item) => String(item.id).trim())
|
||||||
|
|
@ -539,6 +568,7 @@ function SuggestionList({
|
||||||
name: suggestion.suggestion,
|
name: suggestion.suggestion,
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
bootstrapByIds(childSkillIds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (suggestion.skill_id && suggestion.skill_id.length > 0) {
|
if (suggestion.skill_id && suggestion.skill_id.length > 0) {
|
||||||
|
|
@ -548,6 +578,7 @@ function SuggestionList({
|
||||||
name: suggestion.suggestion,
|
name: suggestion.suggestion,
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
bootstrapByIds(suggestion.skill_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 原有逻辑
|
// 原有逻辑
|
||||||
|
|
@ -567,7 +598,7 @@ function SuggestionList({
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
},
|
},
|
||||||
[textInput, sendSelectSkill],
|
[textInput, sendSelectSkill, threadId, searchParams],
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<Suggestions className="min-h-16 w-fit items-start" data-testid="welcome-suggestions">
|
<Suggestions className="min-h-16 w-fit items-start" data-testid="welcome-suggestions">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue