Desktop: - No Custom Headers field for custom OpenAI-compatible providers (#6681)

Signed-off-by: Lymah123 <fimihanodunola625@gmail.com>
Co-authored-by: Zane Staggs <zane@squareup.com>
This commit is contained in:
Lymah
2026-02-12 01:20:56 +01:00
committed by GitHub
parent 153872a47c
commit f96d38e382
7 changed files with 246 additions and 25 deletions
@@ -156,6 +156,19 @@ export default function ExtensionModal({
};
const handleHeaderChange = (index: number, field: 'key' | 'value', value: string) => {
if (field === 'key') {
if (value.includes(' ')) {
return;
}
const trimmedNewKey = value.trim();
const normalizedNewKey = trimmedNewKey.toLowerCase();
const isDuplicate = formData.headers.some(
(h, i) => i !== index && h.key.trim().toLowerCase() === normalizedNewKey,
);
if (isDuplicate && trimmedNewKey !== '') {
return;
}
}
const newHeaders = [...formData.headers];
newHeaders[index][field] = value;
@@ -44,6 +44,10 @@ export default function HeadersSection({
const keyEmpty = !newKey.trim();
const valueEmpty = !newValue.trim();
const keyHasSpaces = newKey.includes(' ');
const normalizedNewKey = newKey.trim().toLowerCase();
const isDuplicate = headers.some(
h => h.key.trim().toLowerCase() === normalizedNewKey
);
if (keyEmpty || valueEmpty) {
setInvalidFields({
@@ -63,6 +67,15 @@ export default function HeadersSection({
return;
}
if (isDuplicate) {
setInvalidFields({
key: true,
value: false,
});
setValidationError('A header with this name already exists');
return;
}
setValidationError(null);
setInvalidFields({ key: false, value: false });
onAdd(newKey, newValue);
@@ -100,8 +100,8 @@ export function extensionToFormData(extension: FixedExtensionEntry): ExtensionFo
description: extension.description || '',
type:
extension.type === 'frontend' ||
extension.type === 'inline_python' ||
extension.type === 'platform'
extension.type === 'inline_python' ||
extension.type === 'platform'
? 'stdio'
: extension.type,
cmd: extension.type === 'stdio' ? quoteShell([extension.cmd, ...extension.args]) : undefined,
@@ -155,7 +155,7 @@ export function createExtensionConfig(formData: ExtensionFormData): ExtensionCon
timeout: formData.timeout,
uri: formData.endpoint || '',
...(env_keys.length > 0 ? { env_keys } : {}),
...(Object.keys(headers).length > 0 ? { headers } : {}),
headers,
};
} else {
// For other types