Feat/provider individual config (#663)

* refactor(ui): simplify UpdateBadge to minimal dot indicator

* feat(provider): add individual test and proxy config for providers

Add support for provider-specific model test and proxy configurations:

- Add ProviderTestConfig and ProviderProxyConfig types in Rust and TypeScript
- Create ProviderAdvancedConfig component with collapsible panels
- Update stream_check service to merge provider config with global config
- Proxy config UI follows global proxy style (single URL input)

Provider-level configs stored in meta field, no database schema changes needed.

* feat(ui): add failover toggle and improve proxy controls

- Add FailoverToggle component with slide animation
- Simplify ProxyToggle style to match FailoverToggle
- Add usage statistics button when proxy is active
- Fix i18n parameter passing for failover messages
- Add missing failover translation keys (inQueue, addQueue, priority)
- Replace AboutSection icon with app logo

* fix(proxy): support system proxy fallback and provider-level proxy config

- Remove no_proxy() calls in http_client.rs to allow system proxy fallback
- Add get_for_provider() to build HTTP client with provider-specific proxy
- Update forwarder.rs and stream_check.rs to use provider proxy config
- Fix EditProviderDialog.tsx to include provider.meta in useMemo deps
- Add useEffect in ProviderAdvancedConfig.tsx to sync expand state

Fixes #636
Fixes #583

* fix(ui): sync toast theme with app setting

* feat(settings): add log config management

Fixes #612
Fixes #514

* fix(proxy): increase request body size limit to 200MB

Fixes #666

* docs(proxy): update timeout config descriptions and defaults

Fixes #612

* fix(proxy): filter x-goog-api-key header to prevent duplication

* fix(proxy): prevent proxy recursion when system proxy points to localhost

Detect if HTTP_PROXY, HTTPS_PROXY, or ALL_PROXY environment variables
point to loopback addresses (localhost, 127.0.0.1), and bypass system
proxy in such cases to avoid infinite request loops.

* fix(i18n): add providerAdvanced i18n keys and fix failover toast parameter

- Add providerAdvanced.* i18n keys to en.json, zh.json, and ja.json
- Fix failover toggleFailed toast to pass detail parameter
- Remove Chinese fallback text from UI for English/Japanese users

* fix(tray): restore tray-provider events and enable Auto failover properly

- Emit provider-switched event on tray provider click (backward compatibility)
- Auto button now: starts proxy, takes over live config, enables failover

* fix(log): enable dynamic log level and single file mode

- Initialize log at Trace level for dynamic adjustment
- Change rotation strategy to KeepSome(1) for single file
- Set max file size to 1GB
- Delete old log file on startup for clean start

* fix(tray): fix clippy uninlined format args warning

Use inline format arguments: {app_type_str} instead of {}

* fix(provider): allow typing :// in endpoint URL inputs

Change input type from "url" to "text" to prevent browser
URL validation from blocking :// input.

Closes #681

* fix(stream-check): use Gemini native streaming API format

- Change endpoint from OpenAI-compatible to native streamGenerateContent
- Add alt=sse parameter for SSE format response
- Use x-goog-api-key header instead of Bearer token
- Convert request body to Gemini contents/parts format

* feat(proxy): add request logging for debugging

Add debug logs for outgoing requests including URL and body content
with byte size, matching the existing response logging format.

* fix(log): prevent usize underflow in KeepSome rotation strategy

KeepSome(n) internally computes n-2, so n=1 causes underflow.
Use KeepSome(2) as the minimum safe value.
This commit is contained in:
Dex Miller
2026-01-20 21:02:44 +08:00
committed by GitHub
parent 7bb458eecb
commit e7badb1a24
46 changed files with 2008 additions and 331 deletions
+64 -20
View File
@@ -15,6 +15,7 @@ import {
RefreshCw,
Search,
Download,
BarChart2,
} from "lucide-react";
import type { Provider } from "@/types";
import type { EnvConflict } from "@/types/env";
@@ -42,6 +43,7 @@ import { SettingsPage } from "@/components/settings/SettingsPage";
import { UpdateBadge } from "@/components/UpdateBadge";
import { EnvWarningBanner } from "@/components/env/EnvWarningBanner";
import { ProxyToggle } from "@/components/proxy/ProxyToggle";
import { FailoverToggle } from "@/components/proxy/FailoverToggle";
import UsageScriptModal from "@/components/UsageScriptModal";
import UnifiedMcpPanel from "@/components/mcp/UnifiedMcpPanel";
import PromptPanel from "@/components/prompts/PromptPanel";
@@ -376,7 +378,10 @@ function App() {
};
// Generate a unique provider key for OpenCode duplication
const generateUniqueOpencodeKey = (originalKey: string, existingKeys: string[]): string => {
const generateUniqueOpencodeKey = (
originalKey: string,
existingKeys: string[],
): string => {
const baseKey = `${originalKey}-copy`;
if (!existingKeys.includes(baseKey)) {
@@ -397,7 +402,9 @@ function App() {
const newSortIndex =
provider.sortIndex !== undefined ? provider.sortIndex + 1 : undefined;
const duplicatedProvider: Omit<Provider, "id" | "createdAt"> & { providerKey?: string } = {
const duplicatedProvider: Omit<Provider, "id" | "createdAt"> & {
providerKey?: string;
} = {
name: `${provider.name} copy`,
settingsConfig: JSON.parse(JSON.stringify(provider.settingsConfig)), // 深拷贝
websiteUrl: provider.websiteUrl,
@@ -413,7 +420,10 @@ function App() {
// OpenCode: generate unique provider key (used as ID)
if (activeApp === "opencode") {
const existingKeys = Object.keys(providers);
duplicatedProvider.providerKey = generateUniqueOpencodeKey(provider.id, existingKeys);
duplicatedProvider.providerKey = generateUniqueOpencodeKey(
provider.id,
existingKeys,
);
}
// 2️⃣ 如果原供应商有 sortIndex,需要将后续所有供应商的 sortIndex +1
@@ -522,7 +532,12 @@ function App() {
/>
);
case "skillsDiscovery":
return <SkillsPage ref={skillsPageRef} initialApp={activeApp === "opencode" ? "claude" : activeApp} />;
return (
<SkillsPage
ref={skillsPageRef}
initialApp={activeApp === "opencode" ? "claude" : activeApp}
/>
);
case "mcp":
return (
<UnifiedMcpPanel
@@ -656,7 +671,7 @@ function App() {
}
>
<div
className="flex h-full items-center justify-between gap-2 px-6"
className="mx-auto flex h-full max-w-[56rem] items-center justify-between gap-2 px-4"
data-tauri-drag-region
style={{ WebkitAppRegion: "drag" } as any}
>
@@ -695,8 +710,8 @@ function App() {
</h1>
</div>
) : (
<>
<div className="flex items-center gap-2">
<div className="flex items-center gap-2">
<div className="relative inline-flex items-center">
<a
href="https://github.com/farion1231/cc-switch"
target="_blank"
@@ -710,31 +725,48 @@ function App() {
>
CC Switch
</a>
<UpdateBadge
onClick={() => {
setSettingsDefaultTab("about");
setCurrentView("settings");
}}
className="absolute -top-4 -right-4"
/>
</div>
<Button
variant="ghost"
size="icon"
onClick={() => {
setSettingsDefaultTab("general");
setCurrentView("settings");
}}
title={t("common.settings")}
className="hover:bg-black/5 dark:hover:bg-white/5"
>
<Settings className="w-4 h-4" />
</Button>
{isCurrentAppTakeoverActive && (
<Button
variant="ghost"
size="icon"
onClick={() => {
setSettingsDefaultTab("general");
setSettingsDefaultTab("usage");
setCurrentView("settings");
}}
title={t("common.settings")}
title={t("settings.usage.title", {
defaultValue: "使用统计",
})}
className="hover:bg-black/5 dark:hover:bg-white/5"
>
<Settings className="w-4 h-4" />
<BarChart2 className="w-4 h-4" />
</Button>
</div>
<UpdateBadge
onClick={() => {
setSettingsDefaultTab("about");
setCurrentView("settings");
}}
/>
</>
)}
</div>
)}
</div>
<div
className="flex items-center gap-2 h-[32px]"
className="flex items-center gap-1.5 h-[32px]"
style={{ WebkitAppRegion: "no-drag" } as any}
>
{currentView === "prompts" && (
@@ -817,7 +849,19 @@ function App() {
{currentView === "providers" && (
<>
{activeApp !== "opencode" && (
<ProxyToggle activeApp={activeApp} />
<>
<ProxyToggle activeApp={activeApp} />
<div
className={cn(
"transition-all duration-300 ease-in-out overflow-hidden",
isCurrentAppTakeoverActive
? "opacity-100 max-w-[100px] scale-100"
: "opacity-0 max-w-0 scale-75 pointer-events-none",
)}
>
<FailoverToggle activeApp={activeApp} />
</div>
</>
)}
<AppSwitcher activeApp={activeApp} onSwitch={setActiveApp} />