Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(web): hide duplicate connection mode control
  • Loading branch information
fdc310 committed Sep 30, 2026
commit abd1a1a9baabbd2300323028855d9efc42d88ab2
9 changes: 9 additions & 0 deletions web/src/app/home/bots/components/bot-form/BotForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@

useEffect(() => {
setBotFormValues();
}, [initBotId, loadAttempt]);

Check warning on line 329 in web/src/app/home/bots/components/bot-form/BotForm.tsx

View workflow job for this annotation

GitHub Actions / Frontend Lint

React Hook useEffect has a missing dependency: 'setBotFormValues'. Either include it or remove the dependency array

function setBotFormValues() {
setInitialDataLoaded(false);
Expand Down Expand Up @@ -552,6 +552,14 @@
[adapterNameToDynamicConfigMap, currentAdapter],
);

const connectionModeControllerNames = useMemo(() => {
if (supportedConnectionModes.length <= 1) return [];
const webhookField = dynamicFormConfigList.find(
(item) => item.type === DynamicFormItemType.WEBHOOK_URL,
);
return webhookField?.show_if?.field ? [webhookField.show_if.field] : [];
}, [dynamicFormConfigList, supportedConnectionModes.length]);

const botGuideSteps = useMemo<GuidedTourStep[]>(() => {
const steps: GuidedTourStep[] = [];

Expand Down Expand Up @@ -1140,6 +1148,7 @@
<div data-guide="bot-adapter-parameters">
<DynamicFormComponent
itemConfigList={dynamicFormConfigList}
hiddenItemNames={connectionModeControllerNames}
initialValues={currentAdapterConfig}
onSubmit={(values) => {
form.setValue('adapter_config', values, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ export default function DynamicFormComponent({
systemContext,
onValidate,
renderItem,
hiddenItemNames,
}: {
itemConfigList: IDynamicFormItemSchema[];
onSubmit?: (val: object) => unknown;
Expand All @@ -463,6 +464,8 @@ export default function DynamicFormComponent({
formValues: Record<string, unknown>;
setFormValue: (name: string, value: unknown) => void;
}) => ReactNode | undefined;
/** Fields retained in form state but omitted from the rendered form. */
hiddenItemNames?: readonly string[];
}) {
const isInitialMount = useRef(true);
const previousInitialValues = useRef(initialValues);
Expand Down Expand Up @@ -647,6 +650,8 @@ export default function DynamicFormComponent({
/>

{itemConfigList.map((config, index) => {
if (hiddenItemNames?.includes(config.name)) return null;

// Create a normalized config with type converted to frontend format
const normalizedConfig = {
...config,
Expand Down
24 changes: 24 additions & 0 deletions web/tests/unit/oss-cloud-ui-privacy.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const homeSidebarSource = readSource(
const botFormSource = readSource(
'src/app/home/bots/components/bot-form/BotForm.tsx',
);
const dynamicFormSource = readSource(
'src/app/home/components/dynamic-form/DynamicFormComponent.tsx',
);
const kbFormSource = readSource(
'src/app/home/knowledge/components/kb-form/KBForm.tsx',
);
Expand Down Expand Up @@ -52,6 +55,27 @@ test('keeps bot forms spaced with responsive setup and detail columns', () => {
assert.match(kbFormSource, /<form[\s\S]*?className="space-y-6"/);
});

test('hides the manifest connection switch behind the dedicated selector', () => {
assert.match(
botFormSource,
/webhookField\?\.show_if\?\.field\s*\?\s*\[webhookField\.show_if\.field\]/,
);
assert.match(
botFormSource,
/hiddenItemNames=\{connectionModeControllerNames\}/,
);
assert.match(
dynamicFormSource,
/if \(hiddenItemNames\?\.includes\(config\.name\)\) return null/,
);
assert.doesNotMatch(
dynamicFormSource.match(
/const editableItems = useMemo\([\s\S]*?\n \);/,
)?.[0] ?? '',
/hiddenItemNames/,
);
});

test('does not expose storage analysis in Cloud settings or via a deep link', () => {
assert.match(
homeSidebarSource,
Expand Down
Loading