Add Restore Default Claude CLI button to settings page
Co-authored-by: simon-ami <102378134+simon-ami@users.noreply.github.com>
This commit is contained in:
@@ -18,7 +18,7 @@ import { fileURLToPath } from 'url';
|
||||
import express from 'express';
|
||||
import { getPublicConfig, saveConfig, config } from '../config.js';
|
||||
import { DEFAULT_PORT, ACCOUNT_CONFIG_PATH } from '../constants.js';
|
||||
import { readClaudeConfig, updateClaudeConfig, getClaudeConfigPath } from '../utils/claude-config.js';
|
||||
import { readClaudeConfig, updateClaudeConfig, replaceClaudeConfig, getClaudeConfigPath } from '../utils/claude-config.js';
|
||||
import { logger } from '../utils/logger.js';
|
||||
import { getAuthorizationUrl, completeOAuthFlow, startCallbackServer } from '../auth/oauth.js';
|
||||
import { loadAccounts, saveAccounts } from '../account-manager/storage.js';
|
||||
@@ -438,6 +438,41 @@ export function mountWebUI(app, dirname, accountManager) {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* POST /api/claude/config/restore - Restore Claude CLI to default (remove proxy settings)
|
||||
*/
|
||||
app.post('/api/claude/config/restore', async (req, res) => {
|
||||
try {
|
||||
const claudeConfig = await readClaudeConfig();
|
||||
|
||||
// Remove proxy-related environment variables to restore defaults
|
||||
if (claudeConfig.env) {
|
||||
delete claudeConfig.env.ANTHROPIC_BASE_URL;
|
||||
delete claudeConfig.env.ANTHROPIC_AUTH_TOKEN;
|
||||
delete claudeConfig.env.ANTHROPIC_MODEL;
|
||||
delete claudeConfig.env.CLAUDE_CODE_SUBAGENT_MODEL;
|
||||
delete claudeConfig.env.ANTHROPIC_DEFAULT_OPUS_MODEL;
|
||||
delete claudeConfig.env.ANTHROPIC_DEFAULT_SONNET_MODEL;
|
||||
delete claudeConfig.env.ANTHROPIC_DEFAULT_HAIKU_MODEL;
|
||||
delete claudeConfig.env.ENABLE_EXPERIMENTAL_MCP_CLI;
|
||||
}
|
||||
|
||||
// Use replaceClaudeConfig to completely overwrite the config (not merge)
|
||||
const newConfig = await replaceClaudeConfig(claudeConfig);
|
||||
|
||||
logger.info(`[WebUI] Restored Claude CLI config to defaults at ${getClaudeConfigPath()}`);
|
||||
|
||||
res.json({
|
||||
status: 'ok',
|
||||
config: newConfig,
|
||||
message: 'Claude CLI configuration restored to defaults'
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error('[WebUI] Error restoring Claude config:', error);
|
||||
res.status(500).json({ status: 'error', error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* POST /api/models/config - Update model configuration (hidden/pinned/alias)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user