mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-17 04:50:52 +00:00
Security: - Fix command injection in 15+ shell interpolation sites with shellQuote() - Add token-based authentication to MCP TCP server - Fix heredoc delimiter collision in SFTP write fallbacks - Add case-insensitive flag to mcpServerBridge command blocklist - Add exhaustive default case to createModelFromConfig Architecture: - Split aiBridge.cjs (1971→1483 lines) into 4 modules: shellUtils, codexHelpers, claudeHelpers, ptyExec - Split SettingsAITab.tsx (1480→520 lines) into 10 sub-components - Extract shared processCattyStream from AIChatSidePanel.tsx (-168 lines) - Consolidate duplicate PTY execution logic into shared ptyExec.cjs - Consolidate duplicate stripAnsi/toUnpackedAsarPath utilities Code quality: - Remove ~33 debug console.log statements from production code - Remove dead code: terminal_read_output stub, checkToolPermission, isCommandAllowed, READ_ONLY_TOOLS - Unify bridge type accessor in useAIState.ts (eliminate 15 unsafe casts) - Add localStorage session pruning (50 sessions / 200 messages cap) - Fix ModelSelector onBlur race condition (setTimeout → preventDefault) - Fix duplicate getShellEnv() calls in Codex helpers - Remove unused _config param from claudeAgentAdapter - Type claudeAgentAdapter bridge parameter directly as ClaudeBridge Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
import React, { useState } from "react";
|
|
import { ChevronDown, Plus } from "lucide-react";
|
|
import type { AIProviderId } from "../../../../infrastructure/ai/types";
|
|
import { PROVIDER_PRESETS } from "../../../../infrastructure/ai/types";
|
|
import { useI18n } from "../../../../application/i18n/I18nProvider";
|
|
import { Button } from "../../../ui/button";
|
|
import { cn } from "../../../../lib/utils";
|
|
import { ProviderIconBadge } from "./ProviderIconBadge";
|
|
|
|
export const AddProviderDropdown: React.FC<{
|
|
onAdd: (providerId: AIProviderId) => void;
|
|
}> = ({ onAdd }) => {
|
|
const { t } = useI18n();
|
|
const [isOpen, setIsOpen] = useState(false);
|
|
|
|
const providerIds = Object.keys(PROVIDER_PRESETS) as AIProviderId[];
|
|
|
|
return (
|
|
<div className="relative">
|
|
<Button
|
|
variant="outline"
|
|
size="sm"
|
|
onClick={() => setIsOpen(!isOpen)}
|
|
className="gap-1.5"
|
|
>
|
|
<Plus size={14} />
|
|
{t('ai.providers.add')}
|
|
<ChevronDown size={12} className={cn("transition-transform", isOpen && "rotate-180")} />
|
|
</Button>
|
|
|
|
{isOpen && (
|
|
<>
|
|
{/* Backdrop */}
|
|
<div className="fixed inset-0 z-[100]" onClick={() => setIsOpen(false)} />
|
|
{/* Menu */}
|
|
<div className="absolute top-full left-0 mt-1 z-[101] min-w-[200px] rounded-md border border-border bg-popover shadow-md py-1">
|
|
{providerIds.map((pid) => (
|
|
<button
|
|
key={pid}
|
|
onClick={() => {
|
|
onAdd(pid);
|
|
setIsOpen(false);
|
|
}}
|
|
className="w-full flex items-center gap-2.5 px-3 py-2 text-sm hover:bg-accent transition-colors text-left"
|
|
>
|
|
<ProviderIconBadge providerId={pid} size="sm" />
|
|
{PROVIDER_PRESETS[pid].name}
|
|
</button>
|
|
))}
|
|
</div>
|
|
</>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|