refactor: improve error handling and code formatting

- Enhanced error messages in Rust backend to include file paths
- Improved provider switching error handling with detailed messages
- Added MCP button placeholder in UI (functionality TODO)
- Applied code formatting across frontend components
- Extended error notification duration to 6s for better readability
This commit is contained in:
Jason
2025-10-08 21:22:56 +08:00
parent 6afc436946
commit e9833e9a57
20 changed files with 335 additions and 237 deletions

View File

@@ -16,7 +16,7 @@ interface ProviderListProps {
onNotify?: (
message: string,
type: "success" | "error",
duration?: number
duration?: number,
) => void;
}
@@ -154,7 +154,7 @@ const ProviderList: React.FC<ProviderListProps> = ({
<div
key={provider.id}
className={cn(
isCurrent ? cardStyles.selected : cardStyles.interactive
isCurrent ? cardStyles.selected : cardStyles.interactive,
)}
>
<div className="flex items-start justify-between">
@@ -167,7 +167,7 @@ const ProviderList: React.FC<ProviderListProps> = ({
<div
className={cn(
badgeStyles.success,
!isCurrent && "invisible"
!isCurrent && "invisible",
)}
>
<CheckCircle2 size={12} />
@@ -183,7 +183,9 @@ const ProviderList: React.FC<ProviderListProps> = ({
handleUrlClick(provider.websiteUrl!);
}}
className="inline-flex items-center gap-1 text-blue-500 dark:text-blue-400 hover:opacity-90 transition-colors"
title={t("providerForm.visitWebsite", { url: provider.websiteUrl })}
title={t("providerForm.visitWebsite", {
url: provider.websiteUrl,
})}
>
{provider.websiteUrl}
</button>
@@ -212,7 +214,7 @@ const ProviderList: React.FC<ProviderListProps> = ({
"inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-md transition-colors w-full whitespace-nowrap justify-center",
claudeApplied
? "border border-gray-300 text-gray-600 hover:border-red-300 hover:text-red-600 hover:bg-red-50 dark:border-gray-600 dark:text-gray-400 dark:hover:border-red-800 dark:hover:text-red-400 dark:hover:bg-red-900/20"
: "border border-gray-300 text-gray-700 hover:border-green-300 hover:text-green-600 hover:bg-green-50 dark:border-gray-600 dark:text-gray-300 dark:hover:border-green-700 dark:hover:text-green-400 dark:hover:bg-green-900/20"
: "border border-gray-300 text-gray-700 hover:border-green-300 hover:text-green-600 hover:bg-green-50 dark:border-gray-600 dark:text-gray-300 dark:hover:border-green-700 dark:hover:text-green-400 dark:hover:bg-green-900/20",
)}
title={
claudeApplied
@@ -234,7 +236,7 @@ const ProviderList: React.FC<ProviderListProps> = ({
"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-md transition-colors w-[90px] justify-center whitespace-nowrap",
isCurrent
? "bg-gray-100 text-gray-400 dark:bg-gray-800 dark:text-gray-500 cursor-not-allowed"
: "bg-blue-500 text-white hover:bg-blue-600 dark:bg-blue-600 dark:hover:bg-blue-700"
: "bg-blue-500 text-white hover:bg-blue-600 dark:bg-blue-600 dark:hover:bg-blue-700",
)}
>
{isCurrent ? <Check size={14} /> : <Play size={14} />}
@@ -256,7 +258,7 @@ const ProviderList: React.FC<ProviderListProps> = ({
buttonStyles.icon,
isCurrent
? "text-gray-400 cursor-not-allowed"
: "text-gray-500 hover:text-red-500 hover:bg-red-100 dark:text-gray-400 dark:hover:text-red-400 dark:hover:bg-red-500/10"
: "text-gray-500 hover:text-red-500 hover:bg-red-100 dark:text-gray-400 dark:hover:text-red-400 dark:hover:bg-red-500/10",
)}
title={t("provider.deleteProvider")}
>