From cb5c0453f5c4de44df4a86ffc973517123da1454 Mon Sep 17 00:00:00 2001 From: QuentinHsu Date: Tue, 2 Jun 2026 12:31:32 +0800 Subject: [PATCH] fix(channels): avoid expanding advanced settings for model mapping - remove model mapping from advanced settings error detection so visible model configuration errors do not expand the advanced panel. - update the edit-time advanced settings auto-expand check to only depend on fields actually rendered in the advanced section. - add regression coverage to verify model_mapping errors are not classified as advanced settings errors. --- .../components/drawers/channel-mutate-drawer.tsx | 1 - .../features/channels/lib/channel-form-errors.test.ts | 11 +++++++++++ .../src/features/channels/lib/channel-form-errors.ts | 1 - 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx b/web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx index 5c6c53de..25258d92 100644 --- a/web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx +++ b/web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx @@ -205,7 +205,6 @@ function readAdvancedSettingsPreference(): boolean { function hasAdvancedSettingsValues(values: ChannelFormValues): boolean { return Boolean( - values.model_mapping?.trim() || values.param_override?.trim() || values.header_override?.trim() || values.status_code_mapping?.trim() || diff --git a/web/default/src/features/channels/lib/channel-form-errors.test.ts b/web/default/src/features/channels/lib/channel-form-errors.test.ts index c5be0bcd..286b8d5c 100644 --- a/web/default/src/features/channels/lib/channel-form-errors.test.ts +++ b/web/default/src/features/channels/lib/channel-form-errors.test.ts @@ -49,6 +49,17 @@ describe('channel form errors', () => { assert.equal(hasAdvancedSettingsErrors(errors), false) }) + test('does not treat model mapping errors as advanced settings errors', () => { + const errors = { + model_mapping: { + type: 'custom', + message: 'Invalid model mapping', + }, + } satisfies FieldErrors + + assert.equal(hasAdvancedSettingsErrors(errors), false) + }) + test('classifies schema errors from invalid advanced JSON fields', () => { const result = channelFormSchema.safeParse({ ...CHANNEL_FORM_DEFAULT_VALUES, diff --git a/web/default/src/features/channels/lib/channel-form-errors.ts b/web/default/src/features/channels/lib/channel-form-errors.ts index 68de4b8d..5f3a5bfd 100644 --- a/web/default/src/features/channels/lib/channel-form-errors.ts +++ b/web/default/src/features/channels/lib/channel-form-errors.ts @@ -30,7 +30,6 @@ const ADVANCED_SETTINGS_FIELDS = new Set>([ 'auto_ban', 'tag', 'remark', - 'model_mapping', 'param_override', 'header_override', 'status_code_mapping',