Fix token usage handling and developer proxy save UX (#704)
This commit is contained in:
@@ -323,6 +323,30 @@ export function Settings() {
|
||||
setProxyBypassRulesDraft(proxyBypassRules);
|
||||
}, [proxyBypassRules]);
|
||||
|
||||
const proxySettingsDirty = useMemo(() => {
|
||||
return (
|
||||
proxyEnabledDraft !== proxyEnabled
|
||||
|| proxyServerDraft.trim() !== proxyServer
|
||||
|| proxyHttpServerDraft.trim() !== proxyHttpServer
|
||||
|| proxyHttpsServerDraft.trim() !== proxyHttpsServer
|
||||
|| proxyAllServerDraft.trim() !== proxyAllServer
|
||||
|| proxyBypassRulesDraft.trim() !== proxyBypassRules
|
||||
);
|
||||
}, [
|
||||
proxyAllServer,
|
||||
proxyAllServerDraft,
|
||||
proxyBypassRules,
|
||||
proxyBypassRulesDraft,
|
||||
proxyEnabled,
|
||||
proxyEnabledDraft,
|
||||
proxyHttpServer,
|
||||
proxyHttpServerDraft,
|
||||
proxyHttpsServer,
|
||||
proxyHttpsServerDraft,
|
||||
proxyServer,
|
||||
proxyServerDraft,
|
||||
]);
|
||||
|
||||
const handleSaveProxySettings = async () => {
|
||||
setSavingProxy(true);
|
||||
try {
|
||||
@@ -612,9 +636,9 @@ export function Settings() {
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
data-testid="settings-dev-mode-switch"
|
||||
checked={devModeUnlocked}
|
||||
onCheckedChange={setDevModeUnlocked}
|
||||
data-testid="settings-dev-mode-switch"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -645,7 +669,7 @@ export function Settings() {
|
||||
</h2>
|
||||
<div className="space-y-8">
|
||||
{/* Gateway Proxy */}
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-4" data-testid="settings-proxy-section">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<Label className="text-[14px] font-medium text-foreground/80">Gateway Proxy</Label>
|
||||
@@ -656,9 +680,26 @@ export function Settings() {
|
||||
<Switch
|
||||
checked={proxyEnabledDraft}
|
||||
onCheckedChange={setProxyEnabledDraft}
|
||||
data-testid="settings-proxy-toggle"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-4">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={handleSaveProxySettings}
|
||||
disabled={savingProxy || !proxySettingsDirty}
|
||||
data-testid="settings-proxy-save-button"
|
||||
className="rounded-xl h-10 px-5 bg-transparent border-black/10 dark:border-white/10 hover:bg-black/5 dark:hover:bg-white/5"
|
||||
>
|
||||
<RefreshCw className={`h-4 w-4 mr-2${savingProxy ? ' animate-spin' : ''}`} />
|
||||
{savingProxy ? t('common:status.saving') : t('common:actions.save')}
|
||||
</Button>
|
||||
<p className="text-[12px] text-muted-foreground">
|
||||
{t('gateway.proxyRestartNote')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{proxyEnabledDraft && (
|
||||
<div className="space-y-4 pt-2">
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
@@ -733,20 +774,6 @@ export function Settings() {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-4 pt-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={handleSaveProxySettings}
|
||||
disabled={savingProxy}
|
||||
className="rounded-xl h-10 px-5 bg-transparent border-black/10 dark:border-white/10 hover:bg-black/5 dark:hover:bg-white/5"
|
||||
>
|
||||
<RefreshCw className={`h-4 w-4 mr-2${savingProxy ? ' animate-spin' : ''}`} />
|
||||
{savingProxy ? t('common:status.saving') : t('common:actions.save')}
|
||||
</Button>
|
||||
<p className="text-[12px] text-muted-foreground">
|
||||
{t('gateway.proxyRestartNote')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user