debug: add diagnostic logging to settings UI rendering

Add try-catch blocks and console logging to identify where settings UI
stops rendering. This will help diagnose why API key and config sections
are not appearing after authentication was made mandatory.

Diagnostic additions:
- Wrap auth description section in try-catch
- Wrap API key section in try-catch
- Log encryption availability status
- Log API key length
- Log successful section rendering
- Display user-friendly error messages if rendering fails
This commit is contained in:
2025-10-25 23:43:23 -04:00
parent 1a42f0f88e
commit f6234c54b0

View File

@@ -61,6 +61,7 @@ export class MCPServerSettingTab extends PluginSettingTab {
// Authentication (Always Enabled)
containerEl.createEl('h3', {text: 'Authentication'});
try {
const authDesc = containerEl.createEl('p', {
text: 'Authentication is required for all requests. Your API key is encrypted and stored securely using your system\'s credential storage.'
});
@@ -69,16 +70,30 @@ export class MCPServerSettingTab extends PluginSettingTab {
authDesc.style.marginBottom = '16px';
// Show encryption status
const encryptionAvailable = isEncryptionAvailable();
console.log('[Settings] Encryption available:', encryptionAvailable);
const encryptionStatus = containerEl.createEl('p', {
text: isEncryptionAvailable()
text: encryptionAvailable
? '🔒 Encryption: Available (using system keychain)'
: '⚠️ Encryption: Unavailable (API key stored in plaintext)'
});
encryptionStatus.style.fontSize = '0.85em';
encryptionStatus.style.marginBottom = '12px';
encryptionStatus.style.fontStyle = 'italic';
} catch (error) {
console.error('[Settings] Error in auth description section:', error);
containerEl.createEl('p', {
text: '⚠️ Error displaying authentication section: ' + (error instanceof Error ? error.message : String(error)),
cls: 'mod-error'
});
}
// API Key Display (always show - auth is always enabled)
console.log('[Settings] About to render API key section');
console.log('[Settings] API key length:', (this.plugin.settings.apiKey || '').length);
try {
new Setting(containerEl)
.setName('API Key Management')
.setDesc('Use this key in the Authorization header as Bearer token');
@@ -126,6 +141,15 @@ export class MCPServerSettingTab extends PluginSettingTab {
keyDisplayContainer.style.marginBottom = '16px';
keyDisplayContainer.textContent = this.plugin.settings.apiKey || '';
console.log('[Settings] API key section rendered successfully');
} catch (error) {
console.error('[Settings] Error rendering API key section:', error);
containerEl.createEl('p', {
text: '⚠️ Error displaying API key: ' + (error instanceof Error ? error.message : String(error)),
cls: 'mod-error'
});
}
// MCP Client Configuration (show always, regardless of auth)
containerEl.createEl('h3', {text: 'MCP Client Configuration'});