Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import React, { useState } from 'react';
interface ExtensionInfoFieldsProps {
name: string;
type: 'stdio' | 'sse' | 'builtin';
description: string;
onChange: (key: string, value: any) => void;
submitAttempted: boolean;
}

export default function ExtensionInfoFields({
name,
type,
description,
onChange,
submitAttempted,
}: ExtensionInfoFieldsProps) {
Expand All @@ -20,38 +22,55 @@ export default function ExtensionInfoFields({
};

return (
<div className="flex justify-between gap-4 mb-6">
<div className="flex-1">
<label className="text-sm font-medium mb-2 block text-textStandard">Extension Name</label>
<div className="flex flex-col gap-4 mb-6">
{/* Top row with Name and Type side by side */}
<div className="flex justify-between gap-4">
<div className="flex-1">
<label className="text-sm font-medium mb-2 block text-textStandard">Extension Name</label>
<div className="relative">
<Input
value={name}
onChange={(e) => onChange('name', e.target.value)}
placeholder="Enter extension name..."
className={`${!submitAttempted || isNameValid() ? 'border-borderSubtle' : 'border-red-500'} text-textStandard focus:border-borderStandard`}
/>
{submitAttempted && !isNameValid() && (
<div className="absolute text-xs text-red-500 mt-1">Name is required</div>
)}
</div>
</div>

{/* Type Dropdown */}
<div className="w-[200px]">
<label className="text-sm font-medium mb-2 block text-textStandard">Type</label>
<Select
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lily-de @alexhancock There is a Select in ui/Select that is themed for Settings V2.

value={{ value: type, label: type.toUpperCase() }}
onChange={(option: { value: string; label: string } | null) => {
if (option) {
onChange('type', option.value);
}
}}
options={[
{ value: 'stdio', label: 'Standard IO (STDIO)' },
{ value: 'sse', label: 'Security Service Edge (SSE)' },
]}
isSearchable={false}
/>
</div>
</div>

{/* Bottom row with Description spanning full width */}
<div className="w-full">
<label className="text-sm font-medium mb-2 block text-textStandard">Description</label>
<div className="relative">
<Input
value={name}
onChange={(e) => onChange('name', e.target.value)}
placeholder="Enter extension name..."
className={`${!submitAttempted || isNameValid() ? 'border-borderSubtle' : 'border-red-500'} text-textStandard focus:border-borderStandard`}
value={description}
onChange={(e) => onChange('description', e.target.value)}
placeholder="Optional description..."
className={`text-textStandard focus:border-borderStandard`}
/>
{submitAttempted && !isNameValid() && (
<div className="absolute text-xs text-red-500 mt-1">Name is required</div>
)}
</div>
</div>
{/* Type Dropdown */}
<div className="w-[200px]">
<label className="text-sm font-medium mb-2 block text-textStandard">Type</label>
<Select
value={{ value: type, label: type.toUpperCase() }}
onChange={(option: { value: string; label: string } | null) => {
if (option) {
onChange('type', option.value);
}
}}
options={[
{ value: 'stdio', label: 'Standard IO (STDIO)' },
{ value: 'sse', label: 'Security Service Edge (SSE)' },
]}
isSearchable={false}
/>
</div>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export default function ExtensionModal({
<ExtensionInfoFields
name={formData.name}
type={formData.type}
description={formData.description}
onChange={(key, value) => setFormData({ ...formData, [key]: value })}
submitAttempted={submitAttempted}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ export function getSubtitle(config: ExtensionConfig): string {
}
if (config.type === 'stdio') {
const full_command = combineCmdAndArgs(config.cmd, config.args);
return `STDIO extension${full_command ? `\n${full_command}` : ''}`;
return `STDIO extension${config.description ? `: ${config.description}` : ''}${full_command ? `\n${full_command}` : ''}`;
}
if (config.type === 'sse') {
return `SSE extension${config.uri ? ` (${config.uri})` : ''}`;
return `SSE extension${config.description ? `: ${config.description}` : ''}${config.uri ? ` (${config.uri})` : ''}`;
}
return `Unknown type of extension`;
}
6 changes: 6 additions & 0 deletions ui/desktop/src/components/settings_v2/extensions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ExtensionConfig } from '../../../api/types.gen';

export interface ExtensionFormData {
name: string;
description: string;
type: 'stdio' | 'sse' | 'builtin';
cmd?: string;
endpoint?: string;
Expand All @@ -13,6 +14,7 @@ export interface ExtensionFormData {
export function getDefaultFormData(): ExtensionFormData {
return {
name: '',
description: '',
type: 'stdio',
cmd: '',
endpoint: '',
Expand All @@ -35,6 +37,8 @@ export function extensionToFormData(extension: FixedExtensionEntry): ExtensionFo

return {
name: extension.name,
description:
extension.type === 'stdio' || extension.type === 'sse' ? extension.description : undefined,
type: extension.type,
cmd: extension.type === 'stdio' ? combineCmdAndArgs(extension.cmd, extension.args) : undefined,
endpoint: extension.type === 'sse' ? extension.uri : undefined,
Expand All @@ -61,6 +65,7 @@ export function createExtensionConfig(formData: ExtensionFormData): ExtensionCon
return {
type: 'stdio',
name: formData.name,
description: formData.description,
cmd: cmd,
args: args,
...(Object.keys(envs).length > 0 ? { envs } : {}),
Expand All @@ -69,6 +74,7 @@ export function createExtensionConfig(formData: ExtensionFormData): ExtensionCon
return {
type: 'sse',
name: formData.name,
description: formData.description,
uri: formData.endpoint, // Assuming endpoint maps to uri for SSE type
...(Object.keys(envs).length > 0 ? { envs } : {}),
};
Expand Down
Loading