refactor: replace skill code with skill ID across the application
- Updated skill handling to use skill IDs instead of skill codes in various components, services, and models. - Modified tests to reflect changes in skill identification. - Removed references to skill codes in favor of skill IDs for consistency and clarity. - Updated localization files to remove skill code references and adjust error messages accordingly.
This commit is contained in:
@@ -33,7 +33,7 @@ import { useI18n } from "@/i18n/provider"
|
||||
|
||||
type DebugDialogProps = {
|
||||
open: boolean
|
||||
skillCode: string
|
||||
skillDefinitionId: number
|
||||
skillName: string
|
||||
onOpenChange: (open: boolean) => void
|
||||
}
|
||||
@@ -96,7 +96,7 @@ function ResultBlock({
|
||||
|
||||
export function DebugDialog({
|
||||
open,
|
||||
skillCode,
|
||||
skillDefinitionId,
|
||||
skillName,
|
||||
onOpenChange,
|
||||
}: DebugDialogProps) {
|
||||
@@ -106,9 +106,9 @@ export function DebugDialog({
|
||||
|
||||
return (
|
||||
<DebugDialogBody
|
||||
key={skillCode}
|
||||
key={skillDefinitionId}
|
||||
open={open}
|
||||
skillCode={skillCode}
|
||||
skillDefinitionId={skillDefinitionId}
|
||||
skillName={skillName}
|
||||
onOpenChange={onOpenChange}
|
||||
/>
|
||||
@@ -117,12 +117,12 @@ export function DebugDialog({
|
||||
|
||||
function DebugDialogBody({
|
||||
open,
|
||||
skillCode,
|
||||
skillDefinitionId,
|
||||
skillName,
|
||||
onOpenChange,
|
||||
}: DebugDialogProps) {
|
||||
const t = useI18n()
|
||||
const formId = `skill-debug-form-${skillCode}`
|
||||
const formId = `skill-debug-form-${skillDefinitionId}`
|
||||
const [running, setRunning] = useState(false)
|
||||
const [resuming, setResuming] = useState(false)
|
||||
const [aiAgents, setAiAgents] = useState<AIAgent[]>([])
|
||||
@@ -198,7 +198,7 @@ function DebugDialogBody({
|
||||
async function onSubmit(values: DebugForm) {
|
||||
const payload: SkillDebugRunPayload = {
|
||||
aiAgentId: Number(values.aiAgentId),
|
||||
skillCode,
|
||||
skillDefinitionId,
|
||||
userMessage: values.userMessage.trim(),
|
||||
}
|
||||
const conversationId = Number(values.conversationId)
|
||||
@@ -256,7 +256,7 @@ function DebugDialogBody({
|
||||
<ProjectDialog
|
||||
open={open}
|
||||
onOpenChange={onOpenChange}
|
||||
title={t("skillDefinition.debugTitle", { name: skillName || skillCode })}
|
||||
title={t("skillDefinition.debugTitle", { name: skillName })}
|
||||
description={t("skillDefinition.debugDescription")}
|
||||
size="xl"
|
||||
allowFullscreen
|
||||
@@ -322,7 +322,7 @@ function DebugDialogBody({
|
||||
<Field>
|
||||
<FieldLabel>Skill</FieldLabel>
|
||||
<FieldContent>
|
||||
<Input value={skillCode} disabled />
|
||||
<Input value={skillName} disabled />
|
||||
</FieldContent>
|
||||
</Field>
|
||||
<Field>
|
||||
@@ -359,7 +359,7 @@ function DebugDialogBody({
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3 text-sm">
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Badge variant="outline">{result?.skillCode || skillCode}</Badge>
|
||||
<Badge variant="outline">{result?.skillName || skillName}</Badge>
|
||||
{result?.graphToolCode ? (
|
||||
<Badge variant="secondary">{result.graphToolCode}</Badge>
|
||||
) : null}
|
||||
@@ -522,7 +522,7 @@ function DebugDialogBody({
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3 text-sm">
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Badge variant="outline">{resumeResult.skillCode || skillCode}</Badge>
|
||||
<Badge variant="outline">{resumeResult.skillName || skillName}</Badge>
|
||||
{resumeResult.graphToolCode ? (
|
||||
<Badge variant="secondary">{resumeResult.graphToolCode}</Badge>
|
||||
) : null}
|
||||
|
||||
@@ -37,7 +37,6 @@ type SkillEditDialogProps = {
|
||||
};
|
||||
|
||||
const emptyForm: EditForm = {
|
||||
code: "",
|
||||
name: "",
|
||||
description: "",
|
||||
instruction: "",
|
||||
@@ -47,21 +46,15 @@ const emptyForm: EditForm = {
|
||||
|
||||
function createSkillFormSchema(t: TFunction) {
|
||||
return z.object({
|
||||
code: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1, t("skillDefinition.codeRequired"))
|
||||
.regex(/^[a-zA-Z0-9_-]+$/, t("skillDefinition.codeInvalid")),
|
||||
name: z.string().trim().min(1, t("skillDefinition.nameRequired")),
|
||||
description: z.string().trim(),
|
||||
instruction: z.string().trim().min(1, t("skillDefinition.instructionRequired")),
|
||||
examplesText: z.string().trim(),
|
||||
remark: z.string().trim(),
|
||||
name: z.string().trim().min(1, t("skillDefinition.nameRequired")),
|
||||
description: z.string().trim(),
|
||||
instruction: z.string().trim().min(1, t("skillDefinition.instructionRequired")),
|
||||
examplesText: z.string().trim(),
|
||||
remark: z.string().trim(),
|
||||
});
|
||||
}
|
||||
|
||||
type EditForm = {
|
||||
code: string;
|
||||
name: string;
|
||||
description: string;
|
||||
instruction: string;
|
||||
@@ -75,7 +68,6 @@ function buildForm(item: SkillDefinition | null): EditForm {
|
||||
}
|
||||
|
||||
return {
|
||||
code: item.code,
|
||||
name: item.name,
|
||||
description: item.description ?? "",
|
||||
instruction: item.instruction ?? "",
|
||||
@@ -89,7 +81,6 @@ function buildPayload(
|
||||
toolWhitelist: string[],
|
||||
): CreateSkillDefinitionPayload {
|
||||
return {
|
||||
code: form.code.trim(),
|
||||
name: form.name.trim(),
|
||||
description: form.description.trim(),
|
||||
instruction: form.instruction.trim(),
|
||||
@@ -276,32 +267,18 @@ function SkillEditDialogBody({
|
||||
onSubmit={handleSubmit(onFormSubmit)}
|
||||
className="space-y-4"
|
||||
>
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<Field data-invalid={!!errors.code}>
|
||||
<FieldLabel htmlFor="skill-code">{t("skillDefinition.code")}</FieldLabel>
|
||||
<FieldContent>
|
||||
<Input
|
||||
id="skill-code"
|
||||
placeholder={t("skillDefinition.codePlaceholder")}
|
||||
aria-invalid={!!errors.code}
|
||||
{...register("code")}
|
||||
/>
|
||||
<FieldError errors={[errors.code]} />
|
||||
</FieldContent>
|
||||
</Field>
|
||||
<Field data-invalid={!!errors.name}>
|
||||
<FieldLabel htmlFor="skill-name">{t("skillDefinition.name")}</FieldLabel>
|
||||
<FieldContent>
|
||||
<Input
|
||||
id="skill-name"
|
||||
placeholder={t("skillDefinition.namePlaceholder")}
|
||||
aria-invalid={!!errors.name}
|
||||
{...register("name")}
|
||||
/>
|
||||
<FieldError errors={[errors.name]} />
|
||||
</FieldContent>
|
||||
</Field>
|
||||
</div>
|
||||
<Field data-invalid={!!errors.name}>
|
||||
<FieldLabel htmlFor="skill-name">{t("skillDefinition.name")}</FieldLabel>
|
||||
<FieldContent>
|
||||
<Input
|
||||
id="skill-name"
|
||||
placeholder={t("skillDefinition.namePlaceholder")}
|
||||
aria-invalid={!!errors.name}
|
||||
{...register("name")}
|
||||
/>
|
||||
<FieldError errors={[errors.name]} />
|
||||
</FieldContent>
|
||||
</Field>
|
||||
|
||||
<Field data-invalid={!!errors.description}>
|
||||
<FieldLabel htmlFor="skill-description">{t("skillDefinition.description")}</FieldLabel>
|
||||
|
||||
Reference in New Issue
Block a user