Skip to content

Commit 0133a80

Browse files
committed
Feat: Visual cue for tools of inactive servers and UI tweaks
1 parent d5c494e commit 0133a80

File tree

2 files changed

+64
-7
lines changed

2 files changed

+64
-7
lines changed

public/style.css

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,18 @@ button:disabled, .add-button:disabled {
272272
vertical-align: middle; /* Consistent vertical alignment */
273273
}
274274

275+
/* Styles for tools belonging to an inactive server */
276+
.tool-entry.tool-server-inactive .tool-header h3,
277+
.tool-entry.tool-server-inactive .tool-header .tool-exposed-name {
278+
color: #999; /* Gray out the text */
279+
cursor: not-allowed; /* Indicate non-interactivity */
280+
}
281+
.tool-entry.tool-server-inactive .tool-header .tool-enable-label {
282+
opacity: 0.6; /* Dim the checkbox label slightly */
283+
cursor: not-allowed;
284+
}
285+
286+
275287
/* Styles for server header (mostly covered by shared now) */
276288
.server-entry .server-header {
277289
/* display: flex; align-items: center; are shared */
@@ -575,6 +587,37 @@ footer { /* Basic footer style */
575587
margin-top: 2rem; /* Space above footer */
576588
}
577589

590+
/* Responsive adjustments for Tool Header on narrow screens */
591+
@media screen and (max-width: 768px) {
592+
.tool-entry .tool-header {
593+
flex-direction: column; /* Stack items vertically */
594+
align-items: flex-start; /* Align items to the left */
595+
}
596+
597+
.tool-entry .tool-header .tool-enable-label,
598+
.tool-entry .tool-header h3,
599+
.tool-entry .tool-header .tool-exposed-name {
600+
width: 100%; /* Make each item take full width in column layout */
601+
margin-left: 0;
602+
margin-right: 0;
603+
padding-right: 0; /* Reset padding that was for row layout */
604+
}
605+
606+
.tool-entry .tool-header .tool-enable-label {
607+
margin-bottom: 0.5rem; /* Space below checkbox label */
608+
}
609+
610+
.tool-entry .tool-header h3 {
611+
margin-bottom: 0.25rem; /* Space below H3 */
612+
/* flex-grow: 0; /* Not strictly necessary in column, but good for clarity */
613+
}
614+
615+
.tool-entry .tool-header .tool-exposed-name {
616+
/* font-size can remain as is or be adjusted if needed */
617+
/* margin-left was reset above */
618+
}
619+
}
620+
578621
footer p {
579622
margin: 0.25rem 0;
580623
}

public/tools.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,42 @@ function renderTools() {
6868
discoveredTools.forEach(tool => {
6969
const toolKey = `${tool.serverName}--${tool.name}`; // Unique key
7070
const config = currentToolConfig.tools[toolKey] || {}; // Get config or empty object
71-
renderToolEntry(toolKey, tool, config);
71+
// For discovered tools, their server is considered active by the proxy at connection time
72+
renderToolEntry(toolKey, tool, config, false, true); // isConfigOnly = false, isServerActive = true
7273
configuredToolKeys.delete(toolKey); // Remove from set as it's handled
7374
});
7475

75-
// Render any remaining configured tools that were not discovered (maybe disabled server?)
76+
// Render any remaining configured tools that were not discovered
7677
configuredToolKeys.forEach(toolKey => {
77-
console.warn(`Rendering configured tool "${toolKey}" which was not discovered (server might be inactive).`);
7878
const config = currentToolConfig.tools[toolKey];
79+
const serverKeyForConfigOnlyTool = toolKey.split('--')[0];
80+
let isServerActiveForConfigOnlyTool = true; // Default to true if server config not found or active flag is missing/true
81+
82+
if (window.currentServerConfig && window.currentServerConfig.mcpServers && window.currentServerConfig.mcpServers[serverKeyForConfigOnlyTool]) {
83+
const serverConf = window.currentServerConfig.mcpServers[serverKeyForConfigOnlyTool];
84+
if (serverConf.active === false || String(serverConf.active).toLowerCase() === 'false') {
85+
isServerActiveForConfigOnlyTool = false;
86+
}
87+
}
88+
console.warn(`Rendering configured tool "${toolKey}" which was not discovered. Associated server active status: ${isServerActiveForConfigOnlyTool}`);
7989
// We don't have the full tool definition here, just render based on config
80-
renderToolEntry(toolKey, null, config, true); // Pass flag indicating it's config-only
90+
renderToolEntry(toolKey, null, config, true, isServerActiveForConfigOnlyTool); // Pass isConfigOnly and determined server active status
8191
});
8292

8393
if (toolListDiv.innerHTML === '') {
8494
toolListDiv.innerHTML = '<p>No tools discovered or configured.</p>';
8595
}
8696
}
8797

88-
function renderToolEntry(toolKey, toolDefinition, toolConfig, isConfigOnly = false) {
98+
function renderToolEntry(toolKey, toolDefinition, toolConfig, isConfigOnly = false, isServerActive = true) { // Added isServerActive
8999
if (!toolListDiv) return; // Guard
90100
const entryDiv = document.createElement('div');
91101
entryDiv.classList.add('tool-entry');
92102
entryDiv.classList.add('collapsed'); // Add collapsed class by default
103+
if (!isServerActive) {
104+
entryDiv.classList.add('tool-server-inactive');
105+
entryDiv.title = 'This tool belongs to an inactive server. Enabling it will have no effect.';
106+
}
93107
entryDiv.dataset.toolKey = toolKey; // Store the original key
94108

95109
// Determine the name and description exposed to the model
@@ -106,9 +120,9 @@ function renderToolEntry(toolKey, toolDefinition, toolConfig, isConfigOnly = fal
106120
entryDiv.innerHTML = `
107121
<div class="tool-header">
108122
<label class="inline-label tool-enable-label" title="Enable/Disable Tool">
109-
<input type="checkbox" class="tool-enabled-input" ${isEnabled ? 'checked' : ''}>
123+
<input type="checkbox" class="tool-enabled-input" ${isEnabled ? 'checked' : ''} ${!isServerActive ? 'disabled' : ''}>
110124
</label>
111-
<h3>${toolKey}</h3>
125+
<h3 title="${!isServerActive ? 'Server is inactive' : ''}">${toolKey}</h3>
112126
<span class="tool-exposed-name">Exposed As: ${exposedName}</span>
113127
</div>
114128
<div class="tool-details">

0 commit comments

Comments
 (0)