fix: change MCP config components to better handle servers without customUserVars

- removes the subtle reinitialize button from config components of servers without customUserVars or OAuth
- adds a placeholder message for components where servers have no customUserVars configured
This commit is contained in:
Dustin Healy 2025-07-28 22:47:33 -07:00
parent 37701d3e9b
commit f68c61d148
5 changed files with 21 additions and 4 deletions

View file

@ -114,9 +114,13 @@ export default function CustomUserVarsSection({
reset();
};
// Don't render if no fields to configure
// Show message if no fields to configure
if (!fields || Object.keys(fields).length === 0) {
return null;
return (
<div className="p-4 text-center text-sm text-gray-500">
{localize('com_sidepanel_mcp_no_custom_vars', { '0': serverName })}
</div>
);
}
return (

View file

@ -132,6 +132,7 @@ export default function MCPConfigDialog({
<ServerInitializationSection
serverName={serverName}
requiresOAuth={serverStatus?.requiresOAuth || false}
hasCustomUserVars={fieldsSchema && Object.keys(fieldsSchema).length > 0}
/>
</OGDialogContent>
</OGDialog>

View file

@ -7,11 +7,13 @@ import { useLocalize } from '~/hooks';
interface ServerInitializationSectionProps {
serverName: string;
requiresOAuth: boolean;
hasCustomUserVars?: boolean;
}
export default function ServerInitializationSection({
serverName,
requiresOAuth,
hasCustomUserVars = false,
}: ServerInitializationSectionProps) {
const localize = useLocalize();
@ -39,8 +41,8 @@ export default function ServerInitializationSection({
cancelOAuthFlow(serverName);
}, [cancelOAuthFlow, serverName]);
// Show subtle reinitialize option if connected
if (isConnected) {
// Show subtle reinitialize option if connected AND server has OAuth or custom user vars
if (isConnected && (requiresOAuth || hasCustomUserVars)) {
return (
<div className="flex justify-start">
<button
@ -55,6 +57,11 @@ export default function ServerInitializationSection({
);
}
// Don't show anything for connected servers that don't need OAuth or custom vars
if (isConnected) {
return null;
}
return (
<div className="rounded-lg border border-[#991b1b] bg-[#2C1315] p-4">
<div className="flex items-center justify-between">

View file

@ -146,6 +146,10 @@ function MCPPanelContent() {
<ServerInitializationSection
serverName={selectedServerNameForEditing}
requiresOAuth={serverStatus?.requiresOAuth || false}
hasCustomUserVars={
serverBeingEdited.config.customUserVars &&
Object.keys(serverBeingEdited.config.customUserVars).length > 0
}
/>
</div>

View file

@ -506,6 +506,7 @@
"com_sidepanel_hide_panel": "Hide Panel",
"com_sidepanel_manage_files": "Manage Files",
"com_sidepanel_mcp_no_servers_with_vars": "No MCP servers with configurable variables.",
"com_sidepanel_mcp_no_custom_vars": "No custom user variables set for {{0}}",
"com_sidepanel_mcp_variables_for": "MCP Variables for {{0}}",
"com_sidepanel_parameters": "Parameters",
"com_sources_image_alt": "Search result image",