Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
59 lines
2.0 KiB
TypeScript
59 lines
2.0 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 ADD_PROVIDER_MENU_CLASS =
|
|
"absolute top-full right-0 mt-1 z-[101] min-w-[220px] max-w-[calc(100vw-2rem)] rounded-md border border-border bg-popover shadow-md py-1";
|
|
|
|
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={ADD_PROVIDER_MENU_CLASS}>
|
|
{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 hover:text-accent-foreground transition-colors text-left"
|
|
>
|
|
<ProviderIconBadge providerId={pid} size="sm" />
|
|
{PROVIDER_PRESETS[pid].name}
|
|
</button>
|
|
))}
|
|
</div>
|
|
</>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|