refactor(edit): improve field labels and enhance fallback message handling

This commit is contained in:
mlogclub
2026-04-18 11:29:49 +08:00
parent f7eee62721
commit fe50149677
@@ -32,6 +32,12 @@ import {
} from "@/components/ui/popover"; } from "@/components/ui/popover";
import { Textarea } from "@/components/ui/textarea"; import { Textarea } from "@/components/ui/textarea";
import { import {
fetchAIAgent,
fetchAIConfigsAll,
fetchAgentTeamsAll,
fetchKnowledgeBasesAll,
fetchMCPCatalog,
fetchSkillDefinitionsAll,
type AIAgent, type AIAgent,
type AIConfig, type AIConfig,
type AdminAgentTeam, type AdminAgentTeam,
@@ -40,13 +46,8 @@ import {
type MCPToolCatalogItem, type MCPToolCatalogItem,
type MCPToolSourceType, type MCPToolSourceType,
type SkillDefinition, type SkillDefinition,
fetchAIAgent,
fetchAIConfigsAll,
fetchAgentTeamsAll,
fetchMCPCatalog,
fetchKnowledgeBasesAll,
fetchSkillDefinitionsAll,
} from "@/lib/api/admin"; } from "@/lib/api/admin";
import { getEnumOptions } from "@/lib/enums";
import { import {
AIAgentHandoffMode, AIAgentHandoffMode,
AIAgentHandoffModeLabels, AIAgentHandoffModeLabels,
@@ -55,8 +56,6 @@ import {
IMConversationServiceModeLabels, IMConversationServiceModeLabels,
Status, Status,
} from "@/lib/generated/enums"; } from "@/lib/generated/enums";
import { getEnumOptions } from "@/lib/enums";
import { FieldDescription } from "@base-ui/react";
type DirectToolItem = CreateAIAgentPayload["directTools"][number]; type DirectToolItem = CreateAIAgentPayload["directTools"][number];
@@ -731,7 +730,7 @@ function EditDialogBody({
</Field> </Field>
<Field data-invalid={!!errors.remark}> <Field data-invalid={!!errors.remark}>
<FieldLabel htmlFor="ai-agent-remark"></FieldLabel> <FieldLabel htmlFor="ai-agent-remark"></FieldLabel>
<FieldContent> <FieldContent>
<Textarea id="ai-agent-remark" rows={3} {...register("remark")} /> <Textarea id="ai-agent-remark" rows={3} {...register("remark")} />
<FieldError errors={[errors.remark]} /> <FieldError errors={[errors.remark]} />
@@ -807,7 +806,7 @@ function EditDialogBody({
<div className="mb-4 text-xs text-muted-foreground"> <div className="mb-4 text-xs text-muted-foreground">
{selectedHandoffModeLabel} {selectedHandoffModeLabel}
{handoffMode === {handoffMode ===
String(AIAgentHandoffMode.DefaultTeamPool) String(AIAgentHandoffMode.DefaultTeamPool)
? "。该模式要求至少配置一个客服组。" ? "。该模式要求至少配置一个客服组。"
: "。仅在涉及转人工时生效。"} : "。仅在涉及转人工时生效。"}
</div> </div>
@@ -872,19 +871,19 @@ function EditDialogBody({
</FieldContent> </FieldContent>
</Field> </Field>
<Field data-invalid={!!errors.fallbackMessage}> <Field data-invalid={!!errors.fallbackMessage}>
<FieldLabel htmlFor="ai-agent-fallback-message"> <FieldLabel htmlFor="ai-agent-fallback-message">
</FieldLabel> </FieldLabel>
<FieldContent> <FieldContent>
<div className="text-xs text-muted-foreground mb-1"> <div className="text-xs text-muted-foreground mb-1">
使 AI Graph Tool 使 AI Graph Tool
</div> </div>
<Textarea <Textarea
id="ai-agent-fallback-message" id="ai-agent-fallback-message"
rows={5} rows={5}
{...register("fallbackMessage")} {...register("fallbackMessage")}
/> />
<FieldError errors={[errors.fallbackMessage]} /> <FieldError errors={[errors.fallbackMessage]} />
</FieldContent> </FieldContent>
</Field> </Field>
@@ -1234,14 +1233,14 @@ function SectionCard({
children, children,
}: { }: {
title: string; title: string;
description: string; description?: string;
children: ReactNode; children: ReactNode;
}) { }) {
return ( return (
<section className="rounded-lg border bg-card p-5"> <section className="rounded-lg border bg-card p-5">
<div className="mb-3"> <div className="mb-3">
<div className="text-base font-semibold">{title}</div> <div className="text-base font-semibold">{title}</div>
<div className="mt-1 text-sm text-muted-foreground">{description}</div> {description && <div className="mt-1 text-sm text-muted-foreground">{description}</div>}
</div> </div>
<div className="space-y-4">{children}</div> <div className="space-y-4">{children}</div>
</section> </section>