refactor(web): make description optional and remove default values for bot, pipeline, and knowledge base

- Remove .min(1) validation on description field, replace with .optional().default('')
- Remove pre-filled default description text from all three create forms
- Remove required asterisk (*) marker from description labels
- No backend changes needed: Bot/Pipeline DB accepts empty string, KB DB allows null
This commit is contained in:
Junyan Qin
2026-03-27 18:00:48 +08:00
parent 244e16c491
commit af0d00e5e9
3 changed files with 9 additions and 26 deletions

View File

@@ -53,9 +53,7 @@ import { CustomApiError } from '@/app/infra/entities/common';
const getFormSchema = (t: (key: string) => string) =>
z.object({
name: z.string().min(1, { message: t('bots.botNameRequired') }),
description: z
.string()
.min(1, { message: t('bots.botDescriptionRequired') }),
description: z.string().optional().default(''),
adapter: z.string().min(1, { message: t('bots.adapterRequired') }),
adapter_config: z.record(z.string(), z.any()),
enable: z.boolean().optional(),
@@ -80,7 +78,7 @@ export default function BotForm({
resolver: zodResolver(formSchema),
defaultValues: {
name: '',
description: t('bots.defaultDescription'),
description: '',
adapter: '',
adapter_config: {},
enable: true,
@@ -427,10 +425,7 @@ export default function BotForm({
name="description"
render={({ field }) => (
<FormItem>
<FormLabel>
{t('bots.botDescription')}
<span className="text-destructive">*</span>
</FormLabel>
<FormLabel>{t('bots.botDescription')}</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>

View File

@@ -46,9 +46,7 @@ import { UUID } from 'uuidjs';
const getFormSchema = (t: (key: string) => string) =>
z.object({
name: z.string().min(1, { message: t('knowledge.kbNameRequired') }),
description: z
.string()
.min(1, { message: t('knowledge.kbDescriptionRequired') }),
description: z.string().optional().default(''),
emoji: z.string().optional(),
ragEngineId: z
.string()
@@ -115,7 +113,7 @@ export default function KBForm({
resolver: zodResolver(formSchema),
defaultValues: {
name: '',
description: t('knowledge.defaultDescription'),
description: '',
emoji: '📚',
ragEngineId: '',
},
@@ -373,10 +371,7 @@ export default function KBForm({
name="description"
render={({ field }) => (
<FormItem>
<FormLabel>
{t('knowledge.kbDescription')}
<span className="text-destructive">*</span>
</FormLabel>
<FormLabel>{t('knowledge.kbDescription')}</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>

View File

@@ -80,9 +80,7 @@ export default function PipelineFormComponent({
? z.object({
basic: z.object({
name: z.string().min(1, { message: t('pipelines.nameRequired') }),
description: z
.string()
.min(1, { message: t('pipelines.descriptionRequired') }),
description: z.string().optional().default(''),
emoji: z.string().optional(),
}),
ai: z.record(z.string(), z.any()),
@@ -93,9 +91,7 @@ export default function PipelineFormComponent({
: z.object({
basic: z.object({
name: z.string().min(1, { message: t('pipelines.nameRequired') }),
description: z
.string()
.min(1, { message: t('pipelines.descriptionRequired') }),
description: z.string().optional().default(''),
emoji: z.string().optional(),
}),
ai: z.record(z.string(), z.any()).optional(),
@@ -563,10 +559,7 @@ export default function PipelineFormComponent({
name="basic.description"
render={({ field }) => (
<FormItem>
<FormLabel>
{t('common.description')}
<span className="text-destructive">*</span>
</FormLabel>
<FormLabel>{t('common.description')}</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>