mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-04-03 14:36:44 +08:00
feat: restore model health check (stream check) UI
Re-enable the stream check feature that was hidden in v3.11.0. All backend code, database schema, and i18n keys were preserved; only the frontend UI needed uncommenting across 4 files. OpenCode and OpenClaw are excluded as the backend does not support them.
This commit is contained in:
@@ -3,12 +3,12 @@ import {
|
||||
Check,
|
||||
Copy,
|
||||
Edit,
|
||||
// Loader2, // Hidden: stream check feature disabled
|
||||
Loader2,
|
||||
Minus,
|
||||
Play,
|
||||
Plus,
|
||||
Terminal,
|
||||
// TestTube2, // Hidden: stream check feature disabled
|
||||
TestTube2,
|
||||
Trash2,
|
||||
Zap,
|
||||
} from "lucide-react";
|
||||
@@ -45,13 +45,13 @@ export function ProviderActions({
|
||||
appId,
|
||||
isCurrent,
|
||||
isInConfig = false,
|
||||
isTesting: _isTesting, // Hidden: stream check feature disabled
|
||||
isTesting,
|
||||
isProxyTakeover = false,
|
||||
isOmo = false,
|
||||
onSwitch,
|
||||
onEdit,
|
||||
onDuplicate,
|
||||
onTest: _onTest, // Hidden: stream check feature disabled
|
||||
onTest,
|
||||
onConfigureUsage,
|
||||
onDelete,
|
||||
onRemoveFromConfig,
|
||||
@@ -246,7 +246,6 @@ export function ProviderActions({
|
||||
<Copy className="h-4 w-4" />
|
||||
</Button>
|
||||
|
||||
{/* Hidden: stream check feature disabled
|
||||
{onTest && (
|
||||
<Button
|
||||
size="icon"
|
||||
@@ -263,7 +262,6 @@ export function ProviderActions({
|
||||
)}
|
||||
</Button>
|
||||
)}
|
||||
*/}
|
||||
|
||||
<Button
|
||||
size="icon"
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
useOpenClawLiveProviderIds,
|
||||
useOpenClawDefaultModel,
|
||||
} from "@/hooks/useOpenClaw";
|
||||
// import { useStreamCheck } from "@/hooks/useStreamCheck"; // 测试功能已隐藏
|
||||
import { useStreamCheck } from "@/hooks/useStreamCheck";
|
||||
import { ProviderCard } from "@/components/providers/ProviderCard";
|
||||
import { ProviderEmptyState } from "@/components/providers/ProviderEmptyState";
|
||||
import {
|
||||
@@ -86,6 +86,7 @@ export function ProviderList({
|
||||
onSetAsDefault,
|
||||
}: ProviderListProps) {
|
||||
const { t } = useTranslation();
|
||||
const { checkProvider, isChecking } = useStreamCheck(appId);
|
||||
const { sortedProviders, sensors, handleDragEnd } = useDragSort(
|
||||
providers,
|
||||
appId,
|
||||
@@ -176,6 +177,13 @@ export function ProviderList({
|
||||
const [isSearchOpen, setIsSearchOpen] = useState(false);
|
||||
const searchInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const handleTest = useCallback(
|
||||
(provider: Provider) => {
|
||||
checkProvider(provider.id, provider.name);
|
||||
},
|
||||
[checkProvider],
|
||||
);
|
||||
|
||||
// Import current live config as default provider
|
||||
const queryClient = useQueryClient();
|
||||
const importMutation = useMutation({
|
||||
@@ -306,7 +314,12 @@ export function ProviderList({
|
||||
onConfigureUsage={onConfigureUsage}
|
||||
onOpenWebsite={onOpenWebsite}
|
||||
onOpenTerminal={onOpenTerminal}
|
||||
isTesting={false} // isChecking(provider.id) - 测试功能已隐藏
|
||||
onTest={
|
||||
appId !== "opencode" && appId !== "openclaw"
|
||||
? handleTest
|
||||
: undefined
|
||||
}
|
||||
isTesting={isChecking(provider.id)}
|
||||
isProxyRunning={isProxyRunning}
|
||||
isProxyTakeover={isProxyTakeover}
|
||||
isAutoFailoverEnabled={isFailoverModeActive}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useState, useEffect } from "react";
|
||||
import {
|
||||
ChevronDown,
|
||||
ChevronRight,
|
||||
// FlaskConical, // Hidden: stream check feature disabled
|
||||
FlaskConical,
|
||||
Globe,
|
||||
Coins,
|
||||
Eye,
|
||||
@@ -87,16 +87,15 @@ function parseProxyUrl(url: string): Partial<ProviderProxyConfig> {
|
||||
}
|
||||
|
||||
export function ProviderAdvancedConfig({
|
||||
testConfig: _testConfig, // Hidden: stream check feature disabled
|
||||
testConfig,
|
||||
proxyConfig,
|
||||
pricingConfig,
|
||||
onTestConfigChange: _onTestConfigChange, // Hidden: stream check feature disabled
|
||||
onTestConfigChange,
|
||||
onProxyConfigChange,
|
||||
onPricingConfigChange,
|
||||
}: ProviderAdvancedConfigProps) {
|
||||
const { t } = useTranslation();
|
||||
// Hidden: stream check feature disabled
|
||||
// const [isTestConfigOpen, setIsTestConfigOpen] = useState(testConfig.enabled);
|
||||
const [isTestConfigOpen, setIsTestConfigOpen] = useState(testConfig.enabled);
|
||||
const [isProxyConfigOpen, setIsProxyConfigOpen] = useState(
|
||||
proxyConfig.enabled,
|
||||
);
|
||||
@@ -111,10 +110,9 @@ export function ProviderAdvancedConfig({
|
||||
// 标记是否为用户主动输入(用于区分外部更新和用户输入)
|
||||
const [isUserTyping, setIsUserTyping] = useState(false);
|
||||
|
||||
// Hidden: stream check feature disabled
|
||||
// useEffect(() => {
|
||||
// setIsTestConfigOpen(testConfig.enabled);
|
||||
// }, [testConfig.enabled]);
|
||||
useEffect(() => {
|
||||
setIsTestConfigOpen(testConfig.enabled);
|
||||
}, [testConfig.enabled]);
|
||||
|
||||
// 同步外部 proxyConfig.enabled 变化到展开状态
|
||||
useEffect(() => {
|
||||
@@ -168,7 +166,6 @@ export function ProviderAdvancedConfig({
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{/* Hidden: stream check feature disabled — model test config panel
|
||||
<div className="rounded-lg border border-border/50 bg-muted/20">
|
||||
<button
|
||||
type="button"
|
||||
@@ -344,7 +341,6 @@ export function ProviderAdvancedConfig({
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
*/}
|
||||
|
||||
{/* 代理配置 */}
|
||||
<div className="rounded-lg border border-border/50 bg-muted/20">
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
Cloud,
|
||||
ScrollText,
|
||||
HardDriveDownload,
|
||||
FlaskConical,
|
||||
} from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
@@ -38,8 +39,7 @@ import { BackupListSection } from "@/components/settings/BackupListSection";
|
||||
import { WebdavSyncSection } from "@/components/settings/WebdavSyncSection";
|
||||
import { AboutSection } from "@/components/settings/AboutSection";
|
||||
import { ProxyTabContent } from "@/components/settings/ProxyTabContent";
|
||||
// Hidden: stream check feature disabled
|
||||
// import { ModelTestConfigPanel } from "@/components/usage/ModelTestConfigPanel";
|
||||
import { ModelTestConfigPanel } from "@/components/usage/ModelTestConfigPanel";
|
||||
import { UsageDashboard } from "@/components/usage/UsageDashboard";
|
||||
import { LogConfigPanel } from "@/components/settings/LogConfigPanel";
|
||||
import { useSettings } from "@/hooks/useSettings";
|
||||
@@ -384,6 +384,28 @@ export function SettingsPage({
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
|
||||
<AccordionItem
|
||||
value="test"
|
||||
className="rounded-xl glass-card overflow-hidden"
|
||||
>
|
||||
<AccordionTrigger className="px-6 py-4 hover:no-underline hover:bg-muted/50 data-[state=open]:bg-muted/50">
|
||||
<div className="flex items-center gap-3">
|
||||
<FlaskConical className="h-5 w-5 text-emerald-500" />
|
||||
<div className="text-left">
|
||||
<h3 className="text-base font-semibold">
|
||||
{t("modelTest.title")}
|
||||
</h3>
|
||||
<p className="text-sm text-muted-foreground font-normal">
|
||||
{t("modelTest.description")}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</AccordionTrigger>
|
||||
<AccordionContent className="px-6 pb-6 pt-4 border-t border-border/50">
|
||||
<ModelTestConfigPanel />
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
|
||||
<AccordionItem
|
||||
value="logConfig"
|
||||
className="rounded-xl glass-card overflow-hidden"
|
||||
|
||||
Reference in New Issue
Block a user