feat(webui): improve model and provider settings UX (#6145)
* feat(webui): improve model and provider settings UX * refactor(webui): organize provider forms and model picker interactions * fix(webui): separate OAuth credentials from provider configuration * fix(webui): stabilize shared combobox navigation * refactor(config): store provider connections as sparse entries * fix(webui): preserve provider validation and isolate catalog tests * refactor(config): manage explicit provider connections * refactor(webui): decouple settings UX from provider removal * fix(webui): select current combobox options during rapid input * feat(webui): refine model preset and provider management * style(webui): refine preset footer actions * fix(webui): align model settings with responsive layout rules * refactor(webui): finalize preset dialogs and simplify provider state * fix(webui): keep fallback heading stable while sorting presets Animate card dimensions without changing layout height and keep the section heading outside sortable cards. Remove proxy normalization from this PR. * docs: update WebUI model and provider setup instructions * docs: start model setup from new preset * docs: remove duplicate WebUI model setup instructions
This commit is contained in:
1 parent
8080ea843a
commit
9261e731ce
88 files changed
+2854
-1734
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { ChevronLeft, Loader2 } from "lucide-react";
|
||||
import { useCallback, useEffect, useState, type ReactNode } from "react";
|
||||
import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogLayoutContext, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import type { SettingsExitGuard } from "@/components/settings/contracts";
|
||||
@@ -18,8 +18,9 @@ import {
|
||||
import {
|
||||
ProviderOAuthLoginDialog,
|
||||
ProvidersSettings,
|
||||
providerFormFromRow,
|
||||
type ProviderSettingsEntry,
|
||||
} from "@/components/settings/models/ProviderSettings";
|
||||
import { providerFormFromRow } from "@/components/settings/models/providerForm";
|
||||
import { AboutSettings, AppearanceSettings, OverviewSettings } from "@/components/settings/overview/OverviewSettings";
|
||||
import { SettingsSidebar, standaloneSectionTitle } from "@/components/settings/SettingsSidebar";
|
||||
import {
|
||||
@@ -88,6 +89,12 @@ export function SettingsPage({
|
||||
}: SettingsPageProps) {
|
||||
const [dialogLayoutAnchor, setDialogLayoutAnchor] = useState<HTMLDivElement | null>(null);
|
||||
const [mcpSetupName, setMcpSetupName] = useState<string | null>(null);
|
||||
const presetDeletedCallback = useRef<(() => void) | null>(null);
|
||||
const [providerPanel, setProviderPanel] = useState<ProviderSettingsEntry | null>(null);
|
||||
const providerSetupOrigin = useRef<{
|
||||
trigger: HTMLButtonElement | null;
|
||||
onAdded?: (provider: string) => void;
|
||||
} | null>(null);
|
||||
const [pendingExit, setPendingExit] = useState<(() => void) | null>(null);
|
||||
const [automationDetailReturn, setAutomationDetailReturn] =
|
||||
useState<SessionAutomationJob | null>(null);
|
||||
@@ -118,10 +125,10 @@ export function SettingsPage({
|
||||
closeProviderOAuthFlow,
|
||||
completeProviderOAuthResponse,
|
||||
createCustomProvider,
|
||||
providerOperation,
|
||||
customMcpForm,
|
||||
editingProviderKeys,
|
||||
error,
|
||||
expandedProvider,
|
||||
featureCatalog,
|
||||
form,
|
||||
handleApiServiceAction,
|
||||
@@ -140,7 +147,7 @@ export function SettingsPage({
|
||||
handleMigrateModelConfigurations,
|
||||
handleNanobotFeatureAction,
|
||||
handleSaveCustomMcp,
|
||||
handleToggleProvider,
|
||||
resetProviderDraft,
|
||||
handleWebSearchProviderChange,
|
||||
hostEngineApplying,
|
||||
imageGenerationDirty,
|
||||
@@ -361,9 +368,22 @@ export function SettingsPage({
|
||||
orderSaving={modelCallOrderSaving || modelConfigurationSaving}
|
||||
migrationSaving={modelMigrationSaving}
|
||||
showBrandLogos={localPrefs.brandLogos}
|
||||
providerSaving={providerSaving}
|
||||
providerSaving={providerOperation?.action === "login" ? providerSaving : null}
|
||||
onChangeCallOrder={changeModelCallOrder}
|
||||
onProviderOAuthLogin={(provider) => runProviderOAuth(provider, "login")}
|
||||
onAddProvider={(trigger, onAdded) => {
|
||||
providerSetupOrigin.current = { trigger, onAdded };
|
||||
setProviderPanel({ kind: "add" });
|
||||
}}
|
||||
onConfigureProvider={(provider, trigger) => {
|
||||
providerSetupOrigin.current = { trigger };
|
||||
resetProviderDraft(provider);
|
||||
setProviderPanel({ kind: "edit", provider });
|
||||
}}
|
||||
onManageProviders={(trigger) => {
|
||||
providerSetupOrigin.current = { trigger };
|
||||
setProviderPanel({ kind: "manage" });
|
||||
}}
|
||||
onSave={saveModelSettings}
|
||||
onMigrate={handleMigrateModelConfigurations}
|
||||
onBeginCreate={beginModelPresetCreation}
|
||||
@@ -375,43 +395,54 @@ export function SettingsPage({
|
||||
setModelPresetNameError(null);
|
||||
modelPresetBeforeCreateRef.current = null;
|
||||
}}
|
||||
onDeleteConfiguration={setModelPresetPendingDelete}
|
||||
onDeleteConfiguration={(preset, onDeleted) => {
|
||||
presetDeletedCallback.current = onDeleted;
|
||||
setModelPresetPendingDelete(preset);
|
||||
}}
|
||||
/>
|
||||
<ProvidersSettings
|
||||
{providerPanel ? <ProvidersSettings
|
||||
entry={providerPanel}
|
||||
onClose={() => setProviderPanel(null)}
|
||||
onProviderAdded={providerSetupOrigin.current?.onAdded
|
||||
? (provider) => providerSetupOrigin.current?.onAdded?.(provider)
|
||||
: undefined}
|
||||
onCloseAutoFocus={(event) => {
|
||||
if (providerSetupOrigin.current) {
|
||||
event.preventDefault();
|
||||
providerSetupOrigin.current.trigger?.focus({ preventScroll: true });
|
||||
providerSetupOrigin.current = null;
|
||||
}
|
||||
}}
|
||||
settings={settings}
|
||||
nanobotFeatures={nanobotFeatures}
|
||||
featureAction={nanobotFeatureAction}
|
||||
capabilityError={nanobotFeaturesError}
|
||||
expandedProvider={expandedProvider}
|
||||
providerForms={providerForms}
|
||||
visibleProviderKeys={visibleProviderKeys}
|
||||
editingProviderKeys={editingProviderKeys}
|
||||
providerSaving={providerSaving}
|
||||
showBrandLogos={localPrefs.brandLogos}
|
||||
remoteBrowserAccess={remoteBrowserAccess}
|
||||
onToggleProvider={handleToggleProvider}
|
||||
onResetProviderDraft={resetProviderDraft}
|
||||
onToggleProviderKey={toggleProviderKeyVisibility}
|
||||
onToggleProviderKeyEditing={toggleProviderKeyEditing}
|
||||
onChangeProviderForm={(provider, value) =>
|
||||
onChangeProviderForm={(provider, value) => {
|
||||
const row = settings.providers.find((item) => item.name === provider);
|
||||
if (!row) return;
|
||||
setProviderForms((prev) => ({
|
||||
...prev,
|
||||
[provider]: {
|
||||
...(prev[provider] ?? providerFormFromRow(
|
||||
settings.providers.find((row) => row.name === provider) ?? {
|
||||
name: provider,
|
||||
label: provider,
|
||||
configured: false,
|
||||
},
|
||||
)),
|
||||
...(prev[provider] ?? providerFormFromRow(row)),
|
||||
...value,
|
||||
},
|
||||
}))
|
||||
}
|
||||
}));
|
||||
}}
|
||||
onSaveProvider={saveProvider}
|
||||
onCreateCustomProvider={createCustomProvider}
|
||||
providerOperation={providerOperation}
|
||||
onProviderOAuthLogin={(provider) => runProviderOAuth(provider, "login")}
|
||||
onProviderOAuthLogout={(provider) => runProviderOAuth(provider, "logout")}
|
||||
/>
|
||||
/> : null}
|
||||
</div>
|
||||
);
|
||||
case "image":
|
||||
@@ -678,9 +709,17 @@ export function SettingsPage({
|
||||
preset={modelPresetPendingDelete}
|
||||
deleting={saving}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setModelPresetPendingDelete(null);
|
||||
if (!open) {
|
||||
setModelPresetPendingDelete(null);
|
||||
presetDeletedCallback.current = null;
|
||||
}
|
||||
}}
|
||||
onConfirm={async () => {
|
||||
if (await handleDeleteModelConfiguration()) {
|
||||
presetDeletedCallback.current?.();
|
||||
presetDeletedCallback.current = null;
|
||||
}
|
||||
}}
|
||||
onConfirm={handleDeleteModelConfiguration}
|
||||
/>
|
||||
|
||||
<ProviderOAuthLoginDialog
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Disclosure } from "@/components/ui/disclosure";
|
||||
import { ExpandableText } from "@/components/ui/expandable-text";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SearchInput } from "@/components/ui/input";
|
||||
import { SegmentedControl } from "@/components/ui/segmented-control";
|
||||
import { Sheet, SheetContent, SheetDescription, SheetTitle } from "@/components/ui/sheet";
|
||||
import { SkillsMarketplace } from "@/components/settings/SkillsMarketplace";
|
||||
@@ -113,7 +113,7 @@ export function SkillsCatalogSettings({ skills, loading = false, error = false }
|
||||
className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"
|
||||
aria-hidden
|
||||
/>
|
||||
<Input
|
||||
<SearchInput
|
||||
value={installedQuery}
|
||||
onChange={(event) => setInstalledQuery(event.target.value)}
|
||||
placeholder={t("settings.skills.searchInstalled", {
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SearchInput } from "@/components/ui/input";
|
||||
import { SegmentedControl } from "@/components/ui/segmented-control";
|
||||
import {
|
||||
fetchMarketplaceSkillTrends,
|
||||
@@ -200,7 +200,7 @@ export function SkillsMarketplace({
|
||||
className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"
|
||||
aria-hidden
|
||||
/>
|
||||
<Input
|
||||
<SearchInput
|
||||
value={query}
|
||||
onChange={(event) => setQuery(event.target.value)}
|
||||
placeholder={t("settings.skills.marketplaceSearchPlaceholder", {
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import { ProviderIcon } from "@/components/settings/models/ProviderSettings";
|
||||
import { ProviderIcon } from "@/components/settings/shared/ProviderIcon";
|
||||
import { ModelAPIControl } from "@/components/settings/models/ModelAPIControl";
|
||||
import { useAutomaticModelAPI } from "@/components/settings/models/useAutomaticModelAPI";
|
||||
import { useModelPresetDrag } from "@/components/settings/models/useModelPresetDrag";
|
||||
import { ReasoningEffortPicker } from "@/components/settings/models/ReasoningEffortPicker";
|
||||
import { RemoveActionButton } from "@/components/settings/shared/RemoveActionButton";
|
||||
import { ToggleButton } from "@/components/settings/ToggleButton";
|
||||
import { useAutoSave } from "@/components/settings/shared/useAutoSave";
|
||||
import { useEffect, useId, useRef, useState, type Dispatch, type SetStateAction } from "react";
|
||||
import { DisclosureContent } from "@/components/ui/disclosure";
|
||||
import {
|
||||
GripVertical,
|
||||
ListOrdered,
|
||||
Loader2,
|
||||
Plus,
|
||||
Trash2,
|
||||
Pencil,
|
||||
} from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
@@ -33,7 +34,8 @@ import {
|
||||
StatusPill,
|
||||
} from "@/components/settings/shared/SettingsControls";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ControlChevron } from "@/components/ui/control-chevron";
|
||||
import { HoverHint } from "@/components/ui/hover-hint";
|
||||
import { TruncatedTextTooltip } from "@/components/ui/truncated-text-tooltip";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -41,6 +43,7 @@ import {
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { cn } from "@/lib/utils";
|
||||
@@ -200,6 +203,9 @@ export function ModelsSettings({
|
||||
providerSaving,
|
||||
onChangeCallOrder,
|
||||
onProviderOAuthLogin,
|
||||
onAddProvider,
|
||||
onConfigureProvider,
|
||||
onManageProviders,
|
||||
onSave,
|
||||
onMigrate,
|
||||
onBeginCreate,
|
||||
@@ -225,19 +231,23 @@ export function ModelsSettings({
|
||||
providerSaving: string | null;
|
||||
onChangeCallOrder: (order: string[]) => void;
|
||||
onProviderOAuthLogin: (provider: string) => void;
|
||||
onAddProvider: (trigger: HTMLButtonElement | null, onAdded: (provider: string) => void) => void;
|
||||
onConfigureProvider: (provider: string, trigger: HTMLButtonElement | null) => void;
|
||||
onManageProviders: (trigger: HTMLButtonElement) => void;
|
||||
onSave: () => void;
|
||||
onMigrate: () => void;
|
||||
onBeginCreate: () => void;
|
||||
onCancelCreate: () => void;
|
||||
onClearPresetNameError: () => void;
|
||||
onSelectConfiguration: (name: string) => void;
|
||||
onDeleteConfiguration: (preset: SettingsPayload["model_presets"][number]) => void;
|
||||
onDeleteConfiguration: (preset: SettingsPayload["model_presets"][number], onDeleted: () => void) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
useAutoSave(form, dirty, saving, onSave, !creating && !!form.model.trim());
|
||||
const tx = (key: string, fallback: string, values?: Record<string, unknown>) =>
|
||||
t(key, { defaultValue: fallback, ...(values ?? {}) });
|
||||
const [editorOpen, setEditorOpen] = useState(false);
|
||||
const [hideEditorReturnFocus, setHideEditorReturnFocus] = useState(false);
|
||||
const [advancedOpen, setAdvancedOpen] = useState(false);
|
||||
const resolvedAutomaticAPI = useAutomaticModelAPI({
|
||||
token,
|
||||
@@ -251,21 +261,17 @@ export function ModelsSettings({
|
||||
const editorTriggerRef = useRef<HTMLElement | null>(null);
|
||||
const presetNameInputRef = useRef<HTMLInputElement>(null);
|
||||
const suggestedPresetNameRef = useRef<string | null>(null);
|
||||
const presetContextInitializedRef = useRef(false);
|
||||
const [editorRowKey, setEditorRowKey] = useState<string | null>(null);
|
||||
const advancedId = useId();
|
||||
const [draggedCallOrderIndex, setDraggedCallOrderIndex] = useState<number | null>(null);
|
||||
const [dragOverCallOrderIndex, setDragOverCallOrderIndex] = useState<number | null>(null);
|
||||
const [draggedRowHeight, setDraggedRowHeight] = useState(0);
|
||||
const dragStartY = useRef(0);
|
||||
const pendingDrag = useRef<number | null>(null);
|
||||
const suppressDragClick = useRef(false);
|
||||
const [draggedOffset, setDraggedOffset] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (presetNameError) presetNameInputRef.current?.focus();
|
||||
}, [presetNameError]);
|
||||
useEffect(() => {
|
||||
if (!creating) suggestedPresetNameRef.current = null;
|
||||
if (!creating) {
|
||||
suggestedPresetNameRef.current = null;
|
||||
presetContextInitializedRef.current = false;
|
||||
}
|
||||
}, [creating]);
|
||||
const namedPresets = settings.model_presets.filter((preset) => !preset.is_default);
|
||||
const namedPresetsByName = new Map(namedPresets.map((preset) => [preset.name, preset]));
|
||||
@@ -311,6 +317,21 @@ export function ModelsSettings({
|
||||
const providerValue = providerOptions.some((provider) => provider.name === form.provider)
|
||||
? form.provider
|
||||
: "";
|
||||
const selectProvider = (provider: string) => {
|
||||
const clearSuggestedName =
|
||||
creating &&
|
||||
provider !== form.provider &&
|
||||
suggestedPresetNameRef.current !== null &&
|
||||
form.modelPreset === suggestedPresetNameRef.current;
|
||||
if (clearSuggestedName) suggestedPresetNameRef.current = null;
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
provider,
|
||||
model: provider === prev.provider ? prev.model : "",
|
||||
api: provider === prev.provider ? prev.api : null,
|
||||
modelPreset: clearSuggestedName ? "" : prev.modelPreset,
|
||||
}));
|
||||
};
|
||||
const selectedProviderNeedsSignIn =
|
||||
selectedProvider?.auth_type === "oauth" && !selectedProvider.configured;
|
||||
const selectedProviderSigningIn = providerSaving === selectedProvider?.name;
|
||||
@@ -323,17 +344,26 @@ export function ModelsSettings({
|
||||
!form.model.trim() ||
|
||||
!form.provider.trim() ||
|
||||
!form.modelPreset.trim() ||
|
||||
!Number.isSafeInteger(form.maxTokens) ||
|
||||
form.maxTokens <= 0 ||
|
||||
!Number.isSafeInteger(form.contextWindowTokens) ||
|
||||
form.contextWindowTokens <= 0 ||
|
||||
form.temperature < 0 ||
|
||||
form.temperature > 2;
|
||||
const selectedPresetReferenced = Boolean(
|
||||
selectedPreset && callOrder[0] === selectedPreset.name,
|
||||
);
|
||||
const callOrderBusy = orderSaving || saving;
|
||||
const presetDrag = useModelPresetDrag({
|
||||
keys: presetRows.filter((row) => row.orderIndex >= 0).map((row) => row.key),
|
||||
disabled: callOrderBusy,
|
||||
onReorder: (keys) => onChangeCallOrder(keys.map((key) => presetRows.find((row) => row.key === key)!.name)),
|
||||
});
|
||||
const selectPreset = (
|
||||
preset: SettingsPayload["model_presets"][number],
|
||||
rowKey: string,
|
||||
) => {
|
||||
setHideEditorReturnFocus(false);
|
||||
editorTriggerRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
||||
const toggleCurrentPreset =
|
||||
!creating && selectedPreset?.name === preset.name && activeEditorRowKey === rowKey;
|
||||
@@ -371,34 +401,11 @@ export function ModelsSettings({
|
||||
onChangeCallOrder(callOrder.filter((_, itemIndex) => itemIndex !== index));
|
||||
};
|
||||
|
||||
const dropCallOrderItem = (targetIndex: number) => {
|
||||
if (
|
||||
callOrderBusy ||
|
||||
draggedCallOrderIndex === null ||
|
||||
draggedCallOrderIndex === targetIndex
|
||||
) {
|
||||
setDraggedCallOrderIndex(null);
|
||||
setDragOverCallOrderIndex(null);
|
||||
return;
|
||||
}
|
||||
const next = [...callOrder];
|
||||
const moved = next.splice(draggedCallOrderIndex, 1)[0];
|
||||
if (!moved) {
|
||||
setDraggedCallOrderIndex(null);
|
||||
setDragOverCallOrderIndex(null);
|
||||
return;
|
||||
}
|
||||
next.splice(targetIndex, 0, moved);
|
||||
setDraggedCallOrderIndex(null);
|
||||
setDragOverCallOrderIndex(null);
|
||||
onChangeCallOrder(next);
|
||||
};
|
||||
|
||||
const renderPresetEditor = () => (
|
||||
<div
|
||||
id="model-preset-editor"
|
||||
data-testid="model-preset-editor"
|
||||
className="space-y-1 pb-4"
|
||||
className="space-y-1 pb-4 [&_.settings-row>div:first-child]:pl-3"
|
||||
>
|
||||
<SettingsRow
|
||||
title={tx("settings.models.presetName", "Preset name")}
|
||||
@@ -449,22 +456,9 @@ export function ModelsSettings({
|
||||
value={providerValue}
|
||||
emptyLabel={t("settings.byok.noConfiguredProviders")}
|
||||
showProviderLogos={showBrandLogos}
|
||||
onChange={(provider) => {
|
||||
const providerChanged = provider !== form.provider;
|
||||
const clearSuggestedName =
|
||||
creating &&
|
||||
providerChanged &&
|
||||
suggestedPresetNameRef.current !== null &&
|
||||
form.modelPreset === suggestedPresetNameRef.current;
|
||||
if (clearSuggestedName) suggestedPresetNameRef.current = null;
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
provider,
|
||||
model: provider === prev.provider ? prev.model : "",
|
||||
api: provider === prev.provider ? prev.api : null,
|
||||
modelPreset: clearSuggestedName ? "" : prev.modelPreset,
|
||||
}));
|
||||
}}
|
||||
onAddProvider={(trigger) => onAddProvider(trigger, selectProvider)}
|
||||
onConfigureProvider={selectedProvider ? onConfigureProvider : undefined}
|
||||
onChange={selectProvider}
|
||||
/>
|
||||
</SettingsRow>
|
||||
{selectedProviderNeedsSignIn ? (
|
||||
@@ -500,7 +494,11 @@ export function ModelsSettings({
|
||||
showProviderLogos={showBrandLogos}
|
||||
onProviderOAuthLogin={onProviderOAuthLogin}
|
||||
providerSigningIn={selectedProviderSigningIn}
|
||||
onChange={(model) => {
|
||||
onChange={(model, info) => {
|
||||
const contextWindow = info?.context_window;
|
||||
const initializeContext = creating && !presetContextInitializedRef.current
|
||||
&& typeof contextWindow === "number" && Number.isSafeInteger(contextWindow) && contextWindow > 0;
|
||||
if (creating) presetContextInitializedRef.current = true;
|
||||
const canSuggestName =
|
||||
creating &&
|
||||
(!form.modelPreset.trim() || form.modelPreset === suggestedPresetNameRef.current);
|
||||
@@ -511,65 +509,77 @@ export function ModelsSettings({
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
model,
|
||||
contextWindowTokens: initializeContext ? contextWindow : prev.contextWindowTokens,
|
||||
api: model === prev.model ? prev.api : null,
|
||||
modelPreset: canSuggestName ? suggestion : prev.modelPreset,
|
||||
}));
|
||||
}}
|
||||
/>
|
||||
</SettingsRow>
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={advancedOpen}
|
||||
aria-controls={advancedId}
|
||||
onClick={() => setAdvancedOpen((value) => !value)}
|
||||
className="settings-disclosure-row w-full text-left transition-colors settings-hover"
|
||||
>
|
||||
<span className="min-w-0">
|
||||
<span className="block text-[14px] font-medium text-foreground">
|
||||
{tx("settings.models.advancedOptions", "Advanced options")}
|
||||
</span>
|
||||
<span className="mt-0.5 flex flex-wrap gap-x-3 text-[12px] tabular-nums text-muted-foreground">
|
||||
<span>{tx("settings.models.contextSummary", "Context {{context}}", {
|
||||
context: Number.isFinite(form.contextWindowTokens) ? formatModelContextWindow(form.contextWindowTokens) : "—",
|
||||
})}</span>{" "}
|
||||
<span>{tx("settings.models.outputSummary", "Max {{max}} tokens", {
|
||||
max: formatContextWindow(form.maxTokens),
|
||||
})}</span>
|
||||
</span>
|
||||
</span>
|
||||
<span className="settings-control">
|
||||
<span className="control-layout justify-end border-transparent">
|
||||
<ControlChevron
|
||||
className={cn(
|
||||
"transition-transform duration-200 motion-reduce:transition-none",
|
||||
advancedOpen && "rotate-180",
|
||||
<SettingsRow title={tx("settings.models.reasoningEffort", "Reasoning effort")}>
|
||||
<ReasoningEffortPicker
|
||||
token={token}
|
||||
provider={selectedProvider ?? settings.providers.find((provider) => provider.name === selectedPreset?.resolved_provider)}
|
||||
model={form.model}
|
||||
savedValues={form.model === selectedPreset?.model && form.provider === selectedPreset.provider
|
||||
? selectedPreset.reasoning_effort_values : undefined}
|
||||
value={form.reasoningEffort}
|
||||
onChange={(reasoningEffort) => setForm((prev) => ({ ...prev, reasoningEffort }))}
|
||||
/>
|
||||
</SettingsRow>
|
||||
<Dialog open={advancedOpen} onOpenChange={setAdvancedOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="settings-disclosure-row w-full text-left transition-colors settings-hover"
|
||||
>
|
||||
<span className="min-w-0 pl-3">
|
||||
<span className="block text-[14px] font-medium text-foreground">
|
||||
{tx("settings.models.advancedOptions", "Advanced options")}
|
||||
</span>
|
||||
<span className="mt-0.5 flex flex-wrap gap-x-3 text-[12px] tabular-nums text-muted-foreground">
|
||||
<span>{tx("settings.models.contextSummary", "Context {{context}}", {
|
||||
context: Number.isFinite(form.contextWindowTokens) ? formatModelContextWindow(form.contextWindowTokens) : "—",
|
||||
})}</span>{" "}
|
||||
<span>{tx("settings.models.outputSummary", "Max {{max}} tokens", {
|
||||
max: Number.isFinite(form.maxTokens) ? formatContextWindow(form.maxTokens) : "—",
|
||||
})}</span>
|
||||
</span>
|
||||
</span>
|
||||
<span className="settings-control">
|
||||
<span className="control-layout justify-end border-transparent">
|
||||
<Pencil className="h-4 w-4 text-muted-foreground" aria-hidden />
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
</DialogTrigger>
|
||||
<DialogContent aria-describedby={undefined}
|
||||
className="max-h-[85dvh] w-[min(calc(100vw-2rem),40rem)] max-w-none gap-0 overflow-y-auto p-0">
|
||||
<DialogHeader className="px-6 pb-2 pt-6 pr-12 text-left">
|
||||
<DialogTitle>{tx("settings.models.advancedOptions", "Advanced options")}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="settings-grid !px-0 pb-4 [&_.settings-row>div:first-child]:pl-3">
|
||||
<ModelAPIControl
|
||||
provider={selectedProvider ?? settings.providers.find(
|
||||
(provider) => provider.name === (resolvedAutomaticAPI?.provider ?? selectedPreset?.resolved_provider),
|
||||
)}
|
||||
automaticAPI={resolvedAutomaticAPI?.api}
|
||||
value={form.api}
|
||||
onChange={(api) => setForm((prev) => ({ ...prev, api }))}
|
||||
/>
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
<DisclosureContent id={advancedId} open={advancedOpen}>
|
||||
<div className="bg-muted/12">
|
||||
<ModelAPIControl
|
||||
provider={selectedProvider ?? settings.providers.find(
|
||||
(provider) => provider.name === (resolvedAutomaticAPI?.provider ?? selectedPreset?.resolved_provider),
|
||||
)}
|
||||
automaticAPI={resolvedAutomaticAPI?.api}
|
||||
value={form.api}
|
||||
onChange={(api) => setForm((prev) => ({ ...prev, api }))}
|
||||
/>
|
||||
<div className="px-4 py-4 sm:px-5">
|
||||
<ModelAdvancedFields
|
||||
maxTokens={form.maxTokens}
|
||||
contextWindowTokens={form.contextWindowTokens}
|
||||
temperature={form.temperature}
|
||||
reasoningEffort={form.reasoningEffort}
|
||||
onChange={(value) => setForm((prev) => ({ ...prev, ...value }))}
|
||||
onChange={(value) => {
|
||||
if (creating && value.contextWindowTokens !== undefined) presetContextInitializedRef.current = true;
|
||||
setForm((prev) => ({ ...prev, ...value }));
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</DisclosureContent>
|
||||
<div className="flex min-h-[58px] flex-col gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:px-5">
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<div className="settings-list-inset flex min-h-[58px] flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between">
|
||||
{creating ? (
|
||||
<Button
|
||||
size="sm"
|
||||
@@ -585,27 +595,33 @@ export function ModelsSettings({
|
||||
</Button>
|
||||
) : selectedPreset ? (
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className="rounded-full text-muted-foreground hover:text-destructive"
|
||||
disabled={selectedPresetReferenced || saving || orderSaving}
|
||||
aria-describedby={
|
||||
selectedPresetReferenced ? "model-preset-delete-hint" : undefined
|
||||
}
|
||||
onClick={() => onDeleteConfiguration(selectedPreset)}
|
||||
<HoverHint
|
||||
enabled={selectedPresetReferenced}
|
||||
content={tx("settings.models.removeBeforeDelete", "Cannot delete the primary model")}
|
||||
>
|
||||
<Trash2 className="mr-1.5 h-3.5 w-3.5" aria-hidden />
|
||||
{tx("settings.actions.delete", "Delete")}
|
||||
</Button>
|
||||
<span className="inline-flex">
|
||||
<RemoveActionButton
|
||||
disabled={selectedPresetReferenced || saving || orderSaving}
|
||||
aria-describedby={
|
||||
selectedPresetReferenced ? "model-preset-delete-hint" : undefined
|
||||
}
|
||||
onClick={() => onDeleteConfiguration(selectedPreset, () => {
|
||||
setEditorOpen(false);
|
||||
setEditorRowKey(null);
|
||||
})}
|
||||
>
|
||||
{tx("settings.actions.delete", "Delete")}
|
||||
</RemoveActionButton>
|
||||
</span>
|
||||
</HoverHint>
|
||||
{selectedPresetReferenced ? (
|
||||
<span
|
||||
id="model-preset-delete-hint"
|
||||
className="text-[11px] leading-4 text-muted-foreground"
|
||||
className="sr-only"
|
||||
>
|
||||
{tx(
|
||||
"settings.models.removeBeforeDelete",
|
||||
"Choose another primary preset before deleting this one.",
|
||||
"Cannot delete the primary model",
|
||||
)}
|
||||
</span>
|
||||
) : null}
|
||||
@@ -634,15 +650,15 @@ export function ModelsSettings({
|
||||
</div>
|
||||
);
|
||||
|
||||
const showMigration = !settings.model_call_order_editable
|
||||
&& settings.model_configuration_migratable !== false;
|
||||
|
||||
return (
|
||||
<div className="settings-stack">
|
||||
<section>
|
||||
<SettingsSectionTitle>
|
||||
{tx("settings.models.presets", "Model presets")}
|
||||
</SettingsSectionTitle>
|
||||
<SettingsGroup>
|
||||
{!settings.model_call_order_editable &&
|
||||
settings.model_configuration_migratable !== false ? (
|
||||
<SettingsSectionTitle>{t("settings.models.presets")}</SettingsSectionTitle>
|
||||
{showMigration ? (
|
||||
<SettingsGroup>
|
||||
<div className="flex flex-col gap-4 px-4 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-5">
|
||||
<div className="flex min-w-0 items-start gap-3">
|
||||
<span className="grid h-9 w-9 shrink-0 place-items-center rounded-control bg-muted text-muted-foreground">
|
||||
@@ -675,227 +691,205 @@ export function ModelsSettings({
|
||||
: tx("settings.models.convertAction", "Convert to presets")}
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<div role="list">
|
||||
{presetRows.map(({ key, name, orderIndex, preset }) => {
|
||||
const ordered = orderIndex >= 0;
|
||||
const provider = preset
|
||||
? modelPresetProviderKey(preset, settings)
|
||||
: settings.agent.resolved_provider ?? settings.agent.provider;
|
||||
const presetConfigured = preset
|
||||
? settingsProviderConfigured(
|
||||
settings,
|
||||
preset.provider,
|
||||
preset.resolved_provider,
|
||||
)
|
||||
: true;
|
||||
let dragOffset = 0;
|
||||
const isDragging = ordered && draggedCallOrderIndex === orderIndex;
|
||||
if (ordered && draggedCallOrderIndex !== null && dragOverCallOrderIndex !== null) {
|
||||
if (isDragging) dragOffset = draggedOffset;
|
||||
if (orderIndex > draggedCallOrderIndex && orderIndex <= dragOverCallOrderIndex) dragOffset = -draggedRowHeight;
|
||||
if (orderIndex < draggedCallOrderIndex && orderIndex >= dragOverCallOrderIndex) dragOffset = draggedRowHeight;
|
||||
}
|
||||
const isSelected =
|
||||
editorOpen &&
|
||||
!creating &&
|
||||
activeEditorRowKey === key &&
|
||||
selectedPreset?.name === name;
|
||||
const presetRow = (
|
||||
<div
|
||||
tabIndex={ordered ? 0 : -1}
|
||||
onDragStart={(event) => event.preventDefault()}
|
||||
aria-label={
|
||||
ordered
|
||||
? `${name}. ${tx(
|
||||
"settings.models.dragToReorder",
|
||||
"Drag to reorder",
|
||||
)}`
|
||||
: name
|
||||
}
|
||||
data-testid={`model-call-order-row-${name}`}
|
||||
onPointerDown={(event) => {
|
||||
if (!ordered || callOrderBusy || event.button !== 0 || (event.target as HTMLElement).closest('[role="switch"]')) return;
|
||||
pendingDrag.current = orderIndex;
|
||||
suppressDragClick.current = false;
|
||||
dragStartY.current = event.clientY;
|
||||
setDraggedOffset(0);
|
||||
const wrapper = event.currentTarget.parentElement;
|
||||
setDraggedRowHeight(wrapper?.getBoundingClientRect().height || 60);
|
||||
}}
|
||||
onPointerMove={(event) => {
|
||||
if (!event.buttons) { pendingDrag.current = null; return; }
|
||||
if (pendingDrag.current !== orderIndex || callOrderBusy) return;
|
||||
const offset = event.clientY - dragStartY.current;
|
||||
if (draggedCallOrderIndex === null && Math.abs(offset) < 5) return;
|
||||
event.currentTarget.setPointerCapture(event.pointerId);
|
||||
suppressDragClick.current = true;
|
||||
setDraggedCallOrderIndex(orderIndex);
|
||||
const target = Math.max(0, Math.min(callOrder.length - 1, orderIndex + Math.round(offset / draggedRowHeight)));
|
||||
setDragOverCallOrderIndex(target);
|
||||
setDraggedOffset(Math.max(-orderIndex * draggedRowHeight, Math.min((callOrder.length - orderIndex - 1) * draggedRowHeight, offset)));
|
||||
}}
|
||||
onPointerUp={() => {
|
||||
pendingDrag.current = null;
|
||||
if (draggedCallOrderIndex !== null) dropCallOrderItem(dragOverCallOrderIndex ?? orderIndex);
|
||||
}}
|
||||
onPointerCancel={() => {
|
||||
pendingDrag.current = null;
|
||||
setDraggedCallOrderIndex(null);
|
||||
setDragOverCallOrderIndex(null);
|
||||
}}
|
||||
onClickCapture={(event) => {
|
||||
if (suppressDragClick.current) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
suppressDragClick.current = false;
|
||||
}
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (event.currentTarget !== event.target) return;
|
||||
if (ordered && event.key === "ArrowUp") {
|
||||
event.preventDefault();
|
||||
moveCallOrderItem(orderIndex, -1);
|
||||
} else if (ordered && event.key === "ArrowDown") {
|
||||
event.preventDefault();
|
||||
moveCallOrderItem(orderIndex, 1);
|
||||
} else if ((event.key === "Enter" || event.key === " ") && preset) {
|
||||
event.preventDefault();
|
||||
selectPreset(preset, key);
|
||||
}
|
||||
}}
|
||||
className={cn(
|
||||
"settings-list-row group relative flex select-none items-center gap-3 py-2 outline-none transition-colors duration-150",
|
||||
ordered &&
|
||||
(callOrderBusy
|
||||
? "cursor-wait"
|
||||
: "cursor-grab active:cursor-grabbing"),
|
||||
!isDragging && "settings-hover",
|
||||
isDragging && "bg-settings-surface shadow-md",
|
||||
isSelected && "bg-muted/45 settings-hover",
|
||||
"focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
|
||||
)}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
aria-pressed={selectedPreset?.name === name}
|
||||
aria-haspopup="dialog"
|
||||
disabled={!preset}
|
||||
onClick={() => preset && selectPreset(preset, key)}
|
||||
className="flex min-w-0 flex-1 items-center gap-3 rounded-control text-left outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
||||
>
|
||||
{presetConfigured ? (
|
||||
<ProviderIcon provider={provider} showBrandLogos={showBrandLogos} />
|
||||
) : (
|
||||
<span className="grid h-8 w-8 shrink-0 place-items-center">
|
||||
<ProviderPickerIcon provider={provider} showBrandLogos={showBrandLogos} unconfigured />
|
||||
</span>
|
||||
)}
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
<span className="truncate text-[14px] font-medium text-foreground">
|
||||
{name}
|
||||
</span>
|
||||
{orderIndex === 0 ? (
|
||||
<StatusPill tone="success">
|
||||
{tx("settings.models.primary", "Primary")}
|
||||
</StatusPill>
|
||||
) : null}
|
||||
{!presetConfigured ? (
|
||||
<span className="text-[11px] font-medium text-amber-700 dark:text-amber-300">
|
||||
{tx(
|
||||
"settings.models.providerSetupRequired",
|
||||
"Provider setup required",
|
||||
)}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
</span>
|
||||
<span className="shrink-0 px-2 py-1 text-[13px] font-normal leading-5 text-muted-foreground">
|
||||
{t("settings.configure")}
|
||||
</span>
|
||||
</button>
|
||||
{ordered ? (
|
||||
<GripVertical
|
||||
className="h-4 w-4 shrink-0 touch-none text-muted-foreground/40 transition-colors group-hover:text-muted-foreground"
|
||||
aria-hidden
|
||||
/>
|
||||
) : (
|
||||
<span className="h-4 w-4 shrink-0" aria-hidden />
|
||||
)}
|
||||
<ToggleButton
|
||||
checked={ordered}
|
||||
label={
|
||||
ordered
|
||||
? tx("settings.models.removeFromOrder", "Disable preset")
|
||||
: tx("settings.models.addToOrder", "Enable preset")
|
||||
}
|
||||
disabled={callOrderBusy || (ordered && callOrder.length <= 1)}
|
||||
onChange={() => {
|
||||
if (ordered) {
|
||||
removeCallOrderItem(orderIndex);
|
||||
} else if (preset) {
|
||||
onChangeCallOrder([...callOrder, preset.name]);
|
||||
</SettingsGroup>
|
||||
) : presetRows.length ? (
|
||||
<div ref={presetDrag.listRef} {...presetDrag.listProps} className="flex flex-col"
|
||||
role="list" aria-label={t("settings.models.callOrder")}>
|
||||
{callOrder.length > 0 && presetRows.length > 1 ? (
|
||||
<div role="presentation" className="order-1 mt-6">
|
||||
<SettingsSectionTitle>{t("settings.models.otherPresets")}</SettingsSectionTitle>
|
||||
</div>
|
||||
) : null}
|
||||
{/* Keep card nodes stable while previewing their order. */}
|
||||
{presetRows.map(({ key, name, preset }, rowIndex) => {
|
||||
const orderIndex = presetDrag.previewKeys.indexOf(key);
|
||||
const ordered = orderIndex >= 0;
|
||||
const primary = orderIndex === 0;
|
||||
const provider = preset ? modelPresetProviderKey(preset, settings) : "";
|
||||
const presetConfigured = preset
|
||||
? settingsProviderConfigured(settings, preset.provider, preset.resolved_provider)
|
||||
: true;
|
||||
const isDragging = key === presetDrag.draggedKey;
|
||||
const isSelected = editorOpen && !creating && activeEditorRowKey === key
|
||||
&& selectedPreset?.name === name;
|
||||
return (
|
||||
<div key={key} role="listitem" data-call-order-index={orderIndex} data-preset-sort-key={key}
|
||||
style={{ order: (ordered ? orderIndex : rowIndex) * 2 }} className={cn(!primary && "mb-2")}>
|
||||
<div data-preset-sort-surface={key}
|
||||
className={cn("relative origin-top-left rounded-panel", isDragging && "z-10 shadow-md ring-1 ring-border/50")}>
|
||||
<SettingsGroup>
|
||||
<div
|
||||
tabIndex={ordered ? 0 : -1}
|
||||
onDragStart={(event) => event.preventDefault()}
|
||||
aria-label={ordered ? `${name}. ${t("settings.models.dragToReorder")}` : name}
|
||||
data-testid={`model-call-order-row-${name}`}
|
||||
onPointerDown={(event) => {
|
||||
setHideEditorReturnFocus(false);
|
||||
presetDrag.start(event, key);
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key !== "Escape") setHideEditorReturnFocus(false);
|
||||
if (event.currentTarget !== event.target) return;
|
||||
if (ordered && event.key === "ArrowUp") {
|
||||
event.preventDefault();
|
||||
moveCallOrderItem(orderIndex, -1);
|
||||
} else if (ordered && event.key === "ArrowDown") {
|
||||
event.preventDefault();
|
||||
moveCallOrderItem(orderIndex, 1);
|
||||
} else if ((event.key === "Enter" || event.key === " ") && preset) {
|
||||
event.preventDefault();
|
||||
selectPreset(preset, key);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<div key={key} role="listitem" data-call-order-index={orderIndex}>
|
||||
<div className={cn("relative", isDragging ? "z-10" : "transition-transform duration-150 ease-out motion-reduce:transition-none")}
|
||||
style={{ transform: `translateY(${dragOffset}px)` }}>
|
||||
{presetRow}
|
||||
className={cn(
|
||||
"settings-list-inset group relative grid grid-cols-[auto_minmax(0,1fr)_auto_auto_auto] items-center gap-x-3 select-none outline-none transition-colors [transition-duration:240ms] motion-reduce:transition-none",
|
||||
primary ? "py-5 [--preset-title-size:1.375rem] sm:py-6 sm:[--preset-title-size:1.625rem]" : "py-4",
|
||||
ordered && (callOrderBusy ? "cursor-wait" : "cursor-grab active:cursor-grabbing"),
|
||||
!isDragging && "settings-hover",
|
||||
isSelected && "bg-muted/45",
|
||||
!hideEditorReturnFocus && "focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
|
||||
)}
|
||||
>
|
||||
<div className="contents">
|
||||
<button
|
||||
type="button"
|
||||
aria-pressed={selectedPreset?.name === name}
|
||||
aria-haspopup="dialog"
|
||||
disabled={!preset}
|
||||
onClick={() => preset && selectPreset(preset, key)}
|
||||
className={cn("col-span-2 grid min-w-0 grid-cols-subgrid items-center rounded-control text-left outline-none",
|
||||
!hideEditorReturnFocus && "focus-visible:ring-2 focus-visible:ring-ring")}
|
||||
>
|
||||
{presetConfigured ? (
|
||||
<span className={cn("relative aspect-square min-w-8", primary ? "w-[calc(var(--preset-title-size)*1.375+1.5rem)]" : "h-8")}>
|
||||
<span className="absolute inset-0">
|
||||
<ProviderIcon provider={provider} showBrandLogos={showBrandLogos} fill />
|
||||
</span>
|
||||
</span>
|
||||
) : (
|
||||
<span className="grid h-8 w-8 shrink-0 place-items-center">
|
||||
<ProviderPickerIcon provider={provider} showBrandLogos={showBrandLogos} unconfigured />
|
||||
</span>
|
||||
)}
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="flex min-w-0 items-center gap-x-2">
|
||||
<TruncatedTextTooltip text={name} className={cn("font-medium text-foreground",
|
||||
primary ? "text-[length:var(--preset-title-size)] leading-snug tracking-tight" : "text-[14px]")} />
|
||||
{primary ? (
|
||||
<span className="shrink-0 whitespace-nowrap"><StatusPill tone="success">{t("settings.models.primary")}</StatusPill></span>
|
||||
) : !ordered ? (
|
||||
<span className="text-[11px] leading-5 text-muted-foreground">
|
||||
{t("settings.models.disabled")}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
{preset ? (
|
||||
<TruncatedTextTooltip
|
||||
text={primary
|
||||
? `${preset.model} ${formatModelContextWindow(preset.context_window_tokens)} ${preset.reasoning_effort || t("settings.values.default")}`
|
||||
: preset.model}
|
||||
className={cn("mt-1 block whitespace-pre text-muted-foreground", primary ? "text-[13px] leading-5" : "text-[12px]")} />
|
||||
) : null}
|
||||
</span>
|
||||
</button>
|
||||
<Button type="button" variant="link" size="sm"
|
||||
className="h-auto px-0 text-[13px] font-normal text-muted-foreground hover:text-foreground hover:no-underline"
|
||||
disabled={!preset}
|
||||
onClick={() => preset && selectPreset(preset, key)}>
|
||||
<span className="sr-only sm:not-sr-only">{t("settings.configure")}</span>
|
||||
<Pencil className="h-4 w-4 sm:hidden" aria-hidden />
|
||||
</Button>
|
||||
{ordered ? (
|
||||
<GripVertical
|
||||
className="h-4 w-4 shrink-0 touch-none text-muted-foreground/40 transition-colors group-hover:text-muted-foreground"
|
||||
aria-hidden
|
||||
/>
|
||||
) : (
|
||||
<span className="h-4 w-4 shrink-0" aria-hidden />
|
||||
)}
|
||||
<ToggleButton
|
||||
checked={ordered}
|
||||
label={t(ordered ? "settings.models.removeFromOrder" : "settings.models.addToOrder")}
|
||||
disabled={callOrderBusy || (ordered && callOrder.length <= 1)}
|
||||
onChange={() => {
|
||||
if (ordered) removeCallOrderItem(orderIndex);
|
||||
else if (preset) onChangeCallOrder([...callOrder, preset.name]);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{!presetConfigured ? (
|
||||
<p className="col-[2/-1] mt-1 text-[11px] font-medium text-amber-700 dark:text-amber-300">
|
||||
{t("settings.models.providerSetupRequired")}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{!creating ? (
|
||||
<button
|
||||
type="button"
|
||||
className="flex min-h-[58px] w-full items-center justify-between gap-3 settings-list-inset py-3 text-left outline-none transition-colors settings-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
|
||||
disabled={callOrderBusy}
|
||||
onClick={(event) => {
|
||||
editorTriggerRef.current = event.currentTarget;
|
||||
setEditorRowKey(null);
|
||||
setEditorOpen(true);
|
||||
onBeginCreate();
|
||||
}}
|
||||
>
|
||||
<span className="inline-flex items-center gap-3 text-[14px] font-medium">
|
||||
<span className="grid w-10 shrink-0 place-items-center"><Plus className="h-5 w-5" aria-hidden /></span>
|
||||
{tx("settings.models.newPreset", "New model preset")}
|
||||
</span>
|
||||
{orderSaving ? (
|
||||
<SettingsStatusMessage>
|
||||
<span className="inline-flex items-center gap-1.5">
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />
|
||||
{tx("settings.actions.saving", "Saving...")}
|
||||
</span>
|
||||
</SettingsStatusMessage>
|
||||
) : null}
|
||||
</button>
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
</SettingsGroup>
|
||||
</SettingsGroup>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<SettingsGroup>
|
||||
<div className="settings-list-inset py-8">
|
||||
<p className="text-[14px] font-medium text-foreground">{t("settings.models.noPresets")}</p>
|
||||
<p className="mt-2 text-[13px] leading-5 text-muted-foreground">{t("settings.models.newPresetHelp")}</p>
|
||||
</div>
|
||||
</SettingsGroup>
|
||||
)}
|
||||
<div className="settings-footer flex flex-wrap justify-end gap-2">
|
||||
{orderSaving ? (
|
||||
<span role="status" className="order-last w-full text-[12px] text-muted-foreground">
|
||||
<SettingsStatusMessage>
|
||||
<span className="inline-flex items-center gap-1.5">
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />
|
||||
{t("settings.actions.saving")}
|
||||
</span>
|
||||
</SettingsStatusMessage>
|
||||
</span>
|
||||
) : null}
|
||||
{!showMigration ? (
|
||||
<Button
|
||||
type="button"
|
||||
variant="link"
|
||||
size="sm"
|
||||
className={cn("mr-auto h-11 gap-2 text-[13px] font-normal text-muted-foreground hover:font-semibold hover:text-orange-700 hover:no-underline dark:hover:text-orange-400 sm:h-9",
|
||||
hideEditorReturnFocus && "focus-visible:ring-0 focus-visible:ring-offset-0")}
|
||||
onKeyDown={(event) => { if (event.key !== "Escape") setHideEditorReturnFocus(false); }}
|
||||
disabled={callOrderBusy}
|
||||
onClick={(event) => {
|
||||
editorTriggerRef.current = event.currentTarget;
|
||||
setHideEditorReturnFocus(false);
|
||||
setEditorRowKey(null);
|
||||
setEditorOpen(true);
|
||||
onBeginCreate();
|
||||
}}
|
||||
>
|
||||
{tx("settings.models.newPreset", "New preset")}
|
||||
</Button>
|
||||
) : null}
|
||||
<Button type="button" variant="link" size="sm"
|
||||
className="h-11 shrink-0 text-[13px] font-normal text-muted-foreground hover:font-semibold hover:text-orange-700 hover:no-underline dark:hover:text-orange-400 sm:h-9"
|
||||
onClick={(event) => onManageProviders(event.currentTarget)}>
|
||||
{t("settings.providers.manageProviders")}
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
<Dialog open={editorOpen && (creating || selectedPreset !== null)} onOpenChange={(open) => {
|
||||
setEditorOpen(open);
|
||||
if (!open && creating) onCancelCreate();
|
||||
}}>
|
||||
<DialogContent aria-describedby={undefined}
|
||||
onEscapeKeyDown={() => setHideEditorReturnFocus(true)}
|
||||
className="relative max-h-[85dvh] w-[min(calc(100vw-2rem),40rem)] max-w-none gap-0 overflow-y-auto p-0"
|
||||
onCloseAutoFocus={(event) => {
|
||||
event.preventDefault();
|
||||
editorTriggerRef.current?.focus();
|
||||
}}>
|
||||
<DialogHeader className="px-6 pb-2 pt-5 pr-12">
|
||||
<DialogTitle>{creating ? tx("settings.models.newPreset", "New model preset") : selectedPreset?.name}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="settings-grid !px-0">{renderPresetEditor()}</div>
|
||||
<DialogTitle className="sr-only">
|
||||
{creating ? tx("settings.models.newPreset", "New model preset") : selectedPreset?.name}
|
||||
</DialogTitle>
|
||||
<div className="settings-grid !px-0 pt-8">{renderPresetEditor()}</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
@@ -906,107 +900,90 @@ function ModelAdvancedFields({
|
||||
maxTokens,
|
||||
contextWindowTokens,
|
||||
temperature,
|
||||
reasoningEffort,
|
||||
onChange,
|
||||
}: {
|
||||
maxTokens: number;
|
||||
contextWindowTokens: number;
|
||||
temperature: number;
|
||||
reasoningEffort: string;
|
||||
onChange: (
|
||||
value: Partial<
|
||||
Pick<
|
||||
AgentSettingsDraft,
|
||||
"maxTokens" | "contextWindowTokens" | "temperature" | "reasoningEffort"
|
||||
"maxTokens" | "contextWindowTokens" | "temperature"
|
||||
>
|
||||
>,
|
||||
) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
|
||||
const [contextDraft, setContextDraft] = useState<{ text: string; tokens: number } | null>(null);
|
||||
const contextWindowInputId = useId();
|
||||
const contextWindowHintId = `${contextWindowInputId}-hint`;
|
||||
const contextWindowValid = Number.isSafeInteger(contextWindowTokens) && contextWindowTokens > 0;
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
<label className="block">
|
||||
<span className="mb-1.5 block text-[12px] font-medium text-muted-foreground">
|
||||
{tx("settings.models.maxTokens", "Max output tokens")}
|
||||
</span>
|
||||
<Input
|
||||
type="number"
|
||||
min={1}
|
||||
step={1}
|
||||
value={maxTokens}
|
||||
onChange={(event) => {
|
||||
const value = Number(event.target.value);
|
||||
if (Number.isFinite(value)) onChange({ maxTokens: value });
|
||||
}}
|
||||
className="h-9 text-[13px]"
|
||||
/>
|
||||
</label>
|
||||
<label className="block">
|
||||
<span className="mb-1.5 block text-[12px] font-medium text-muted-foreground">
|
||||
{tx("settings.models.temperature", "Temperature")}
|
||||
</span>
|
||||
<Input
|
||||
type="number"
|
||||
min={0}
|
||||
max={2}
|
||||
step={0.1}
|
||||
value={temperature}
|
||||
onChange={(event) => {
|
||||
const value = Number(event.target.value);
|
||||
if (Number.isFinite(value)) onChange({ temperature: value });
|
||||
}}
|
||||
className="h-9 text-[13px]"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label htmlFor={contextWindowInputId} className="mb-1.5 block text-[12px] font-medium text-muted-foreground">
|
||||
{tx("settings.rows.contextWindow", "Context window")}
|
||||
</label>
|
||||
<>
|
||||
<ModelTokenBudgetRow
|
||||
label={tx("settings.models.maxTokens", "Max output tokens")}
|
||||
value={maxTokens}
|
||||
onChange={(value) => onChange({ maxTokens: value })}
|
||||
/>
|
||||
<SettingsRow title={tx("settings.models.temperature", "Temperature")}>
|
||||
<Input
|
||||
id={contextWindowInputId}
|
||||
aria-label={tx("settings.models.temperature", "Temperature")}
|
||||
type="number"
|
||||
min={0}
|
||||
max={2}
|
||||
step={0.1}
|
||||
value={temperature}
|
||||
onChange={(event) => {
|
||||
const value = Number(event.target.value);
|
||||
if (Number.isFinite(value)) onChange({ temperature: value });
|
||||
}}
|
||||
className="h-9 text-[13px]"
|
||||
/>
|
||||
</SettingsRow>
|
||||
<ModelTokenBudgetRow
|
||||
label={tx("settings.rows.contextWindow", "Context window")}
|
||||
value={contextWindowTokens}
|
||||
onChange={(value) => onChange({ contextWindowTokens: value })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ModelTokenBudgetRow({ label, value, onChange }: {
|
||||
label: string;
|
||||
value: number;
|
||||
onChange: (value: number) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [draft, setDraft] = useState<{ text: string; tokens: number } | null>(null);
|
||||
const hintId = useId();
|
||||
const valid = Number.isSafeInteger(value) && value > 0;
|
||||
const hint = valid
|
||||
? t("settings.models.contextWindowHint", { tokens: value.toLocaleString() })
|
||||
: t("settings.models.contextWindowError");
|
||||
return (
|
||||
<SettingsRow title={label} description={valid ? hint : undefined}>
|
||||
<div className="w-full">
|
||||
<Input
|
||||
aria-label={label}
|
||||
type="text"
|
||||
autoCapitalize="none"
|
||||
spellCheck={false}
|
||||
required
|
||||
value={contextDraft && Object.is(contextDraft.tokens, contextWindowTokens)
|
||||
? contextDraft.text : formatContextWindowInput(contextWindowTokens)}
|
||||
value={draft && Object.is(draft.tokens, value) ? draft.text : formatContextWindowInput(value)}
|
||||
onChange={(event) => {
|
||||
const text = event.target.value;
|
||||
const tokens = parseContextWindowTokens(text);
|
||||
setContextDraft({ text, tokens });
|
||||
onChange({ contextWindowTokens: tokens });
|
||||
setDraft({ text, tokens });
|
||||
onChange(tokens);
|
||||
}}
|
||||
aria-invalid={!contextWindowValid}
|
||||
aria-describedby={contextWindowHintId}
|
||||
aria-invalid={!valid}
|
||||
aria-describedby={hintId}
|
||||
className="h-9 text-[13px]"
|
||||
/>
|
||||
<p id={contextWindowHintId} className={cn("mt-1.5 text-[12px]", contextWindowValid ? "text-muted-foreground" : "text-destructive")}>
|
||||
{contextWindowValid
|
||||
? t("settings.models.contextWindowHint", { tokens: contextWindowTokens.toLocaleString(), defaultValue: "{{tokens}} tokens" })
|
||||
: tx("settings.models.contextWindowError", "Enter a positive token count, such as 200k, 1m, or 131072.")}
|
||||
<p id={hintId} className={valid ? "sr-only" : "mt-1.5 px-3 text-[12px] text-destructive"}>
|
||||
{hint}
|
||||
</p>
|
||||
</div>
|
||||
<label className="block">
|
||||
<span className="mb-1.5 block text-[12px] font-medium text-muted-foreground">
|
||||
{tx("settings.models.reasoningEffort", "Reasoning effort")}
|
||||
</span>
|
||||
<Input
|
||||
value={reasoningEffort}
|
||||
onChange={(event) => onChange({ reasoningEffort: event.target.value })}
|
||||
placeholder={tx("settings.values.default", "Default")}
|
||||
autoCapitalize="none"
|
||||
spellCheck={false}
|
||||
className="h-9 text-[13px]"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</SettingsRow>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ export function ProviderAPIControl({ value, onChange }: {
|
||||
const preferred = value?.preferred_api ?? supported[0];
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<fieldset className="space-y-3 rounded-xl border border-border/60 p-3">
|
||||
<fieldset className="space-y-3 rounded-floating border border-border/60 p-3">
|
||||
<legend className="px-1 text-[12px] font-medium text-muted-foreground">
|
||||
<SettingsHint description={t("settings.providers.supportedAPIsDescription")}>
|
||||
{t("settings.providers.supportedAPIs")}
|
||||
@@ -40,7 +40,7 @@ export function ProviderAPIControl({ value, onChange }: {
|
||||
})}
|
||||
</fieldset>
|
||||
<div className="space-y-1.5">
|
||||
<span className="text-[12px] font-medium text-muted-foreground">
|
||||
<span className="block px-3 text-[12px] font-medium text-muted-foreground">
|
||||
<SettingsHint description={t("settings.providers.defaultAPIDescription")}>
|
||||
{t("settings.providers.defaultAPI")}
|
||||
</SettingsHint>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import type { TFunction } from "i18next";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import {
|
||||
parseProviderObject,
|
||||
type ProviderAdvancedField,
|
||||
type ProviderForm,
|
||||
} from "@/components/settings/models/providerForm";
|
||||
import { SettingsTextEditor } from "@/components/settings/shared/SettingsTextEditor";
|
||||
|
||||
const PARAMETER_FIELDS = [
|
||||
{ field: "extra_headers", formKey: "extraHeaders", titleKey: "settings.providers.extraHeaders", placeholder: '{"X-Header":"value"}' },
|
||||
{ field: "extra_query", formKey: "extraQuery", titleKey: "settings.providers.extraQuery", placeholder: '{"api-version":"2024-02-01"}' },
|
||||
{ field: "extra_body", formKey: "extraBody", titleKey: "settings.providers.extraBody", placeholder: '{"service_tier":"priority"}' },
|
||||
] as const;
|
||||
|
||||
function parameterSummary(value: string, t: TFunction): string {
|
||||
if (!value.trim()) return t("settings.values.notConfigured");
|
||||
const parsed = parseProviderObject(value);
|
||||
return parsed
|
||||
? t("settings.providers.parameterCount", { count: Object.keys(parsed).length })
|
||||
: t("settings.values.configured");
|
||||
}
|
||||
|
||||
export function ProviderParameterFields({ fields, form, onChange }: {
|
||||
fields: ProviderAdvancedField[];
|
||||
form: ProviderForm;
|
||||
onChange: (value: Partial<ProviderForm>) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const visible = PARAMETER_FIELDS.filter((item) => fields.includes(item.field));
|
||||
if (!visible.length) return null;
|
||||
|
||||
return (
|
||||
<div className="min-w-0 overflow-hidden rounded-floating border border-border/60 md:col-span-2">
|
||||
{visible.map((item) => {
|
||||
const title = t(item.titleKey);
|
||||
return (
|
||||
<SettingsTextEditor key={item.field} title={title}
|
||||
value={form[item.formKey]} placeholder={item.placeholder}
|
||||
onSave={(value) => onChange({ [item.formKey]: value })}
|
||||
trigger={
|
||||
<button type="button" className="settings-hover flex min-h-12 w-full items-center gap-3 border-b border-border/60 px-3 py-3 text-left last:border-b-0">
|
||||
<span className="min-w-0 flex-1 text-[13px] font-medium">{title}</span>
|
||||
<span className="shrink-0 text-[12px] text-muted-foreground">{parameterSummary(form[item.formKey], t)}</span>
|
||||
<span className="shrink-0 text-[13px] text-muted-foreground">{t("settings.actions.edit")}</span>
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
import { useEffect, useId, useMemo, useRef } from "react";
|
||||
import { Plus, Search } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ProviderIcon } from "@/components/settings/shared/ProviderIcon";
|
||||
import { TruncatedTextTooltip } from "@/components/ui/tooltip";
|
||||
import { SearchInput } from "@/components/ui/input";
|
||||
import { ComboboxOption, useComboboxNavigation } from "@/components/ui/combobox";
|
||||
import { useMediaQuery } from "@/hooks/useMediaQuery";
|
||||
import type { SettingsPayload } from "@/lib/types";
|
||||
|
||||
const PROVIDER_GROUPS = [
|
||||
{ id: "oauth", labelKey: "settings.providers.providerGroupOAuth", label: "OAuth" },
|
||||
{ id: "api_key", labelKey: "settings.providers.providerGroupApiKey", label: "API Key" },
|
||||
{ id: "local", labelKey: "settings.providers.providerGroupLocal", label: "Local" },
|
||||
] as const;
|
||||
|
||||
|
||||
const PROVIDER_SEARCH_ALIASES: Record<string, string> = {
|
||||
anthropic: "claude 克劳德 克勞德",
|
||||
deepseek: "深度求索 深度探索",
|
||||
zhipu: "智谱 智譜 glm z.ai",
|
||||
dashscope: "阿里 通义 通義 千问 千問 qwen",
|
||||
moonshot: "月之暗面 kimi",
|
||||
kimi_coding: "月之暗面 kimi coding",
|
||||
volcengine: "火山引擎 豆包 doubao",
|
||||
volcengine_coding_plan: "火山引擎 豆包 doubao",
|
||||
minimax: "海螺 稀宇",
|
||||
minimax_anthropic: "海螺 稀宇",
|
||||
siliconflow: "硅基流动 矽基流動 硅基流動",
|
||||
stepfun: "阶跃星辰 階躍星辰",
|
||||
xiaomi_mimo: "小米 mimo",
|
||||
longcat: "美团 美團",
|
||||
qianfan: "百度 千帆 文心",
|
||||
ant_ling: "蚂蚁 螞蟻 百灵 百靈",
|
||||
};
|
||||
|
||||
export function ProviderSearchList({ providers, showBrandLogos, query, onQueryChange, onSelect, onCustom, onClose }: {
|
||||
providers: SettingsPayload["providers"];
|
||||
showBrandLogos: boolean;
|
||||
query: string;
|
||||
onQueryChange: (query: string) => void;
|
||||
onSelect: (name: string) => void;
|
||||
onCustom: () => void;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const mobile = useMediaQuery("(max-width: 639px)");
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const groupId = useId();
|
||||
useEffect(() => {
|
||||
if (!mobile) inputRef.current?.focus({ preventScroll: true });
|
||||
}, [mobile]);
|
||||
const filtered = useMemo(() => {
|
||||
const normalize = (value: string) => value.toLocaleLowerCase().replace(/[\s_.-]+/g, "");
|
||||
const normalizedQuery = normalize(query);
|
||||
return providers.filter((provider) => normalize(
|
||||
`${provider.name} ${provider.label} ${PROVIDER_SEARCH_ALIASES[provider.name] ?? ""}`,
|
||||
).includes(normalizedQuery));
|
||||
}, [providers, query]);
|
||||
const groups = useMemo(() => PROVIDER_GROUPS.map((group) => ({
|
||||
...group,
|
||||
providers: filtered.filter((provider) => providerGroup(provider) === group.id),
|
||||
})).filter((group) => group.providers.length > 0), [filtered]);
|
||||
const values = useMemo(
|
||||
() => groups.flatMap((group) => group.providers.map((provider) => provider.name)),
|
||||
[groups],
|
||||
);
|
||||
const { inputProps, listProps, getOptionProps } = useComboboxNavigation({
|
||||
open: true, values, onSelect, onClose,
|
||||
});
|
||||
const searchLabel = t("settings.providers.searchPlaceholder", { defaultValue: "Search providers" });
|
||||
return <>
|
||||
<div className="mb-3 shrink-0 overflow-y-auto px-5 scrollbar-thin scrollbar-track-transparent">
|
||||
<div className="relative">
|
||||
<Search className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden />
|
||||
<SearchInput {...inputProps} ref={inputRef} value={query} onChange={(event) => onQueryChange(event.target.value)}
|
||||
aria-label={searchLabel} placeholder={searchLabel}
|
||||
className="rounded-xl border-transparent bg-muted/60 pl-9" />
|
||||
</div>
|
||||
</div>
|
||||
<div {...listProps} aria-label={searchLabel}
|
||||
className="min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 pb-3 scrollbar-thin scrollbar-track-transparent">
|
||||
<div className="space-y-4">
|
||||
{groups.map((group) => (
|
||||
<div key={group.id} role="group" aria-labelledby={`${groupId}-${group.id}`}>
|
||||
<div id={`${groupId}-${group.id}`} className="px-2 pb-1 text-[11px] font-medium text-muted-foreground sm:px-3">
|
||||
{t(group.labelKey, { defaultValue: group.label })}
|
||||
</div>
|
||||
<div className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,9rem),1fr))] gap-x-2 gap-y-0.5">
|
||||
{group.providers.map((provider) => <ComboboxOption key={provider.name} {...getOptionProps(provider.name)}
|
||||
aria-label={provider.label}
|
||||
className="min-h-11 min-w-0 gap-2 rounded-xl px-2 py-2 text-[13px] font-normal sm:gap-3 sm:px-3 sm:text-sm">
|
||||
<ProviderIcon provider={provider.name} showBrandLogos={showBrandLogos} compact />
|
||||
<TruncatedTextTooltip text={provider.label} className="flex-1" />
|
||||
</ComboboxOption>)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{filtered.length === 0 ? <p role="status" className="px-3 py-12 text-center text-sm text-muted-foreground">
|
||||
{t("settings.providers.noMatches", { defaultValue: "No matching providers." })}
|
||||
</p> : null}
|
||||
</div>
|
||||
<div className="shrink-0 overflow-y-auto border-t border-border/50 px-5 py-3 scrollbar-thin scrollbar-track-transparent">
|
||||
<button type="button" onClick={onCustom}
|
||||
className="flex min-h-11 w-full items-center gap-3 rounded-xl px-3 text-left text-sm settings-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
|
||||
<Plus className="h-6 w-6 shrink-0 p-0.5 text-muted-foreground" aria-hidden />
|
||||
<span className="flex-1">{t("settings.providers.customProvider", { defaultValue: "Custom provider" })}</span>
|
||||
</button>
|
||||
</div>
|
||||
</>;
|
||||
}
|
||||
|
||||
function providerGroup(provider: SettingsPayload["providers"][number]): typeof PROVIDER_GROUPS[number]["id"] {
|
||||
if (provider.auth_type === "oauth") return "oauth";
|
||||
return provider.model_catalog === "local" ? "local" : "api_key";
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,103 @@
|
||||
import { useRef, useState } from "react";
|
||||
import { Check } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { ComboboxOption, useComboboxNavigation } from "@/components/ui/combobox";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Popover, PopoverAnchor, PopoverContent } from "@/components/ui/popover";
|
||||
import { useProviderModelCatalog } from "@/hooks/useProviderModelCatalog";
|
||||
import type { SettingsPayload } from "@/lib/types";
|
||||
|
||||
const NO_PROVIDER = {};
|
||||
const DEFAULT_VALUE = ":default";
|
||||
|
||||
export function ReasoningEffortPicker({ token, provider, model, savedValues, value, onChange }: {
|
||||
token: string;
|
||||
provider: SettingsPayload["providers"][number] | undefined;
|
||||
model: string;
|
||||
savedValues?: string[];
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [open, setOpen] = useState(false);
|
||||
const input = useRef<HTMLInputElement>(null);
|
||||
const typing = useRef(false);
|
||||
const restoreFocus = useRef(false);
|
||||
const { payload } = useProviderModelCatalog({
|
||||
revision: provider ?? NO_PROVIDER,
|
||||
token,
|
||||
provider: provider?.name ?? "",
|
||||
enabled: open && !!model && !!provider?.configured && provider.model_catalog !== "unsupported",
|
||||
});
|
||||
const efforts = payload?.models.find((entry) => entry.id === model)?.reasoning_efforts ?? savedValues ?? [];
|
||||
const values = [DEFAULT_VALUE, ...new Set(efforts.filter(Boolean))];
|
||||
const close = () => { restoreFocus.current = true; setOpen(false); };
|
||||
const navigation = useComboboxNavigation({
|
||||
open,
|
||||
values,
|
||||
selectedValue: value || DEFAULT_VALUE,
|
||||
onSelect: (selected) => { onChange(selected === DEFAULT_VALUE ? "" : selected); close(); },
|
||||
onClose: close,
|
||||
});
|
||||
return (
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverAnchor asChild>
|
||||
<div className="w-full">
|
||||
<Input
|
||||
ref={input}
|
||||
{...navigation.inputProps}
|
||||
aria-label={t("settings.models.reasoningEffort")}
|
||||
value={value}
|
||||
placeholder={t("settings.values.default")}
|
||||
autoComplete="off"
|
||||
autoCapitalize="none"
|
||||
spellCheck={false}
|
||||
onClick={() => { typing.current = false; setOpen(true); }}
|
||||
onChange={(event) => { typing.current = true; onChange(event.target.value); }}
|
||||
onKeyDown={(event) => {
|
||||
if (event.nativeEvent.isComposing) return;
|
||||
if (!open && ["ArrowDown", "ArrowUp", "Enter"].includes(event.key)) {
|
||||
event.preventDefault();
|
||||
typing.current = false;
|
||||
setOpen(true);
|
||||
return;
|
||||
}
|
||||
if (!open) return;
|
||||
if (event.key === "Enter" && typing.current) {
|
||||
event.preventDefault();
|
||||
close();
|
||||
return;
|
||||
}
|
||||
if (["ArrowDown", "ArrowUp"].includes(event.key)) typing.current = false;
|
||||
navigation.inputProps.onKeyDown(event);
|
||||
}}
|
||||
className="h-9 text-[13px]"
|
||||
/>
|
||||
</div>
|
||||
</PopoverAnchor>
|
||||
<PopoverContent
|
||||
align="end"
|
||||
className="w-[var(--radix-popover-trigger-width)] max-w-[calc(100vw-2rem)] p-1.5"
|
||||
onOpenAutoFocus={(event) => event.preventDefault()}
|
||||
onCloseAutoFocus={(event) => {
|
||||
event.preventDefault();
|
||||
if (restoreFocus.current) input.current?.focus({ preventScroll: true });
|
||||
restoreFocus.current = false;
|
||||
}}
|
||||
onEscapeKeyDown={() => { restoreFocus.current = true; }}
|
||||
onInteractOutside={(event) => { if (event.target === input.current) event.preventDefault(); }}
|
||||
>
|
||||
<div {...navigation.listProps}>
|
||||
{values.map((effort) => (
|
||||
<ComboboxOption key={effort} {...navigation.getOptionProps(effort)}
|
||||
className="flex items-center justify-between gap-2 px-3 py-2 text-[13px]">
|
||||
<span>{effort === DEFAULT_VALUE ? t("settings.values.default") : effort}</span>
|
||||
{effort === (value || DEFAULT_VALUE) ? <Check className="h-4 w-4" aria-hidden /> : null}
|
||||
</ComboboxOption>
|
||||
))}
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import type { ModelAPIConfig, SettingsPayload } from "@/lib/types";
|
||||
|
||||
export type ProviderAdvancedField = NonNullable<
|
||||
SettingsPayload["providers"][number]["advanced_fields"]
|
||||
>[number];
|
||||
export type ProviderForm = {
|
||||
displayName: string;
|
||||
apiKey: string;
|
||||
apiBase: string;
|
||||
api: ModelAPIConfig | null;
|
||||
proxy: string;
|
||||
extraHeaders: string;
|
||||
extraBody: string;
|
||||
extraQuery: string;
|
||||
thinkingStyle: string;
|
||||
region: string;
|
||||
profile: string;
|
||||
};
|
||||
export type CustomProviderDraft = ProviderForm & { name: string };
|
||||
export const CUSTOM_PROVIDER_CREATION_KEY = "__custom_provider__";
|
||||
|
||||
export function providerJsonValue(value: Record<string, unknown> | null | undefined): string {
|
||||
return value && Object.keys(value).length > 0 ? JSON.stringify(value, null, 2) : "";
|
||||
}
|
||||
|
||||
export function parseProviderObject(value: string): Record<string, unknown> | null {
|
||||
if (!value.trim()) return {};
|
||||
try {
|
||||
const parsed: unknown = JSON.parse(value);
|
||||
return parsed && typeof parsed === "object" && !Array.isArray(parsed)
|
||||
? parsed as Record<string, unknown>
|
||||
: null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function providerFormFromRow(
|
||||
provider: SettingsPayload["providers"][number],
|
||||
): ProviderForm {
|
||||
return {
|
||||
displayName: provider.is_custom ? provider.label : "",
|
||||
apiKey: "",
|
||||
apiBase: provider.api_base ?? provider.default_api_base ?? "",
|
||||
api: provider.api ?? null,
|
||||
proxy: provider.proxy ?? "",
|
||||
extraHeaders: providerJsonValue(provider.extra_headers),
|
||||
extraBody: providerJsonValue(provider.extra_body),
|
||||
extraQuery: providerJsonValue(provider.extra_query),
|
||||
thinkingStyle: provider.thinking_style ?? "",
|
||||
region: provider.region ?? "",
|
||||
profile: provider.profile ?? "",
|
||||
};
|
||||
}
|
||||
|
||||
export function emptyCustomProviderDraft(): CustomProviderDraft {
|
||||
return {
|
||||
name: "",
|
||||
displayName: "",
|
||||
apiKey: "",
|
||||
apiBase: "",
|
||||
api: { supported_apis: ["chat_completions"], preferred_api: "chat_completions" },
|
||||
proxy: "",
|
||||
extraHeaders: "",
|
||||
extraBody: "",
|
||||
extraQuery: "",
|
||||
thinkingStyle: "",
|
||||
region: "",
|
||||
profile: "",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
import { useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent, type MouseEvent, type PointerEvent } from "react";
|
||||
|
||||
interface PresetDrag {
|
||||
key: string;
|
||||
surface: HTMLElement;
|
||||
pointerId: number;
|
||||
startY: number;
|
||||
pointerY: number;
|
||||
grabOffset: number;
|
||||
active: boolean;
|
||||
keys: string[];
|
||||
}
|
||||
|
||||
export function useModelPresetDrag({
|
||||
keys, disabled, onReorder,
|
||||
}: {
|
||||
keys: string[];
|
||||
disabled: boolean;
|
||||
onReorder: (keys: string[]) => void;
|
||||
}) {
|
||||
const listRef = useRef<HTMLDivElement>(null);
|
||||
const drag = useRef<PresetDrag | null>(null);
|
||||
const frame = useRef<number>();
|
||||
const suppressClick = useRef(false);
|
||||
const positions = useRef<Map<string, DOMRect> | null>(null);
|
||||
const animations = useRef(new Map<string, Animation>());
|
||||
const [preview, setPreview] = useState<{ key: string; keys: string[] } | null>(null);
|
||||
|
||||
const surfaces = () => Array.from(
|
||||
listRef.current?.querySelectorAll<HTMLElement>("[data-preset-sort-surface]") ?? [],
|
||||
);
|
||||
const rememberPositions = () => {
|
||||
positions.current = new Map(surfaces().map((element) => [
|
||||
element.dataset.presetSortSurface!, element.getBoundingClientRect(),
|
||||
]));
|
||||
for (const animation of animations.current.values()) animation.cancel();
|
||||
animations.current.clear();
|
||||
};
|
||||
const followPointer = () => {
|
||||
const current = drag.current;
|
||||
if (!current?.active) return;
|
||||
const surface = current.surface;
|
||||
const top = surface.parentElement!.getBoundingClientRect().top;
|
||||
surface.style.transform = `translateY(${current.pointerY - current.grabOffset - top}px)`;
|
||||
};
|
||||
const trackPointer = () => {
|
||||
followPointer();
|
||||
frame.current = requestAnimationFrame(trackPointer);
|
||||
};
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const previous = positions.current;
|
||||
if (!previous) return;
|
||||
positions.current = null;
|
||||
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||
for (const element of surfaces()) {
|
||||
const key = element.dataset.presetSortSurface!;
|
||||
const dragging = key === drag.current?.key && drag.current.active;
|
||||
if (!dragging) element.style.transform = "";
|
||||
const before = previous.get(key);
|
||||
if (!before || reduceMotion || typeof element.animate !== "function") continue;
|
||||
const after = element.getBoundingClientRect();
|
||||
const offset = dragging ? 0 : before.top - after.top;
|
||||
const resized = Math.abs(before.height - after.height) >= 0.5;
|
||||
if (Math.abs(offset) < 0.5 && !resized) continue;
|
||||
// Animate visual size, not layout height, so section headings stay still.
|
||||
// Pointer tracking owns the dragged card's translation throughout.
|
||||
const from: Keyframe = { scale: `1 ${before.height / after.height}` };
|
||||
const to: Keyframe = { scale: "1 1" };
|
||||
if (!dragging) {
|
||||
from.transform = `translateY(${offset}px)`;
|
||||
to.transform = "translateY(0)";
|
||||
}
|
||||
const animation = element.animate(
|
||||
[from, to],
|
||||
{ duration: 240, easing: "cubic-bezier(0.2, 0, 0, 1)" },
|
||||
);
|
||||
animations.current.set(key, animation);
|
||||
animation.addEventListener("finish", () => {
|
||||
if (animations.current.get(key) === animation) animations.current.delete(key);
|
||||
}, { once: true });
|
||||
}
|
||||
followPointer();
|
||||
}, [preview]);
|
||||
|
||||
useEffect(() => () => {
|
||||
if (frame.current !== undefined) cancelAnimationFrame(frame.current);
|
||||
for (const animation of animations.current.values()) animation.cancel();
|
||||
}, []);
|
||||
|
||||
const finish = (save: boolean) => {
|
||||
const current = drag.current;
|
||||
if (!current) return;
|
||||
if (frame.current !== undefined) cancelAnimationFrame(frame.current);
|
||||
if (current.active) rememberPositions();
|
||||
drag.current = null;
|
||||
if (listRef.current?.hasPointerCapture(current.pointerId)) {
|
||||
listRef.current.releasePointerCapture(current.pointerId);
|
||||
}
|
||||
if (!current.active) return;
|
||||
setPreview(null);
|
||||
if (save && !disabled) onReorder(current.keys);
|
||||
};
|
||||
|
||||
return {
|
||||
listRef,
|
||||
previewKeys: preview?.keys ?? keys,
|
||||
draggedKey: preview?.key,
|
||||
start: (event: PointerEvent, key: string) => {
|
||||
if (disabled || event.button !== 0 || !keys.includes(key)
|
||||
|| (event.target as HTMLElement).closest('[role="switch"]')) return;
|
||||
const surface = surfaces().find((element) => element.dataset.presetSortSurface === key)!;
|
||||
drag.current = {
|
||||
key, surface, pointerId: event.pointerId, startY: event.clientY, pointerY: event.clientY,
|
||||
grabOffset: event.clientY - surface.getBoundingClientRect().top,
|
||||
active: false, keys,
|
||||
};
|
||||
},
|
||||
listProps: {
|
||||
onPointerDownCapture: () => { suppressClick.current = false; },
|
||||
onPointerMove: (event: PointerEvent<HTMLDivElement>) => {
|
||||
const current = drag.current;
|
||||
if (!current || current.pointerId !== event.pointerId || disabled) return;
|
||||
if (!event.buttons) { finish(false); return; }
|
||||
current.pointerY = event.clientY;
|
||||
if (!current.active) {
|
||||
if (Math.abs(current.pointerY - current.startY) < 5) return;
|
||||
rememberPositions();
|
||||
current.active = true;
|
||||
suppressClick.current = true;
|
||||
event.currentTarget.setPointerCapture(event.pointerId);
|
||||
setPreview({ key: current.key, keys: current.keys });
|
||||
trackPointer();
|
||||
}
|
||||
event.preventDefault();
|
||||
const otherRows = Array.from(event.currentTarget.querySelectorAll<HTMLElement>("[data-preset-sort-key]"))
|
||||
.filter((element) => element.dataset.presetSortKey !== current.key
|
||||
&& keys.includes(element.dataset.presetSortKey!));
|
||||
const index = otherRows.filter((element) => {
|
||||
const rect = element.getBoundingClientRect();
|
||||
return current.pointerY > rect.top + rect.height / 2;
|
||||
}).length;
|
||||
if (index !== current.keys.indexOf(current.key)) {
|
||||
rememberPositions();
|
||||
const next = current.keys.filter((key) => key !== current.key);
|
||||
next.splice(index, 0, current.key);
|
||||
current.keys = next;
|
||||
setPreview({ key: current.key, keys: next });
|
||||
}
|
||||
followPointer();
|
||||
},
|
||||
onPointerUp: () => finish(true),
|
||||
onPointerCancel: () => finish(false),
|
||||
onLostPointerCapture: () => finish(false),
|
||||
onClickCapture: (event: MouseEvent) => {
|
||||
if (!suppressClick.current) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
suppressClick.current = false;
|
||||
},
|
||||
onKeyDownCapture: (event: KeyboardEvent) => {
|
||||
suppressClick.current = false;
|
||||
if (event.key === "Escape" && drag.current?.active) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
finish(false);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
CUSTOM_PROVIDER_CREATION_KEY,
|
||||
providerFormFromRow,
|
||||
type CustomProviderDraft,
|
||||
} from "@/components/settings/models/ProviderSettings";
|
||||
} from "@/components/settings/models/providerForm";
|
||||
import type { ModelSettingsState } from "@/components/settings/models/useModelSettingsState";
|
||||
import { normalizeContextWindowTokens } from "@/components/settings/shared/ModelControls";
|
||||
import {
|
||||
@@ -90,7 +90,6 @@ export function useModelSettingsActions({
|
||||
return () => { oauthMounted.current = false; };
|
||||
}, []);
|
||||
const {
|
||||
expandedProvider,
|
||||
form,
|
||||
modelCallOrder,
|
||||
modelCallOrderSaving,
|
||||
@@ -107,7 +106,6 @@ export function useModelSettingsActions({
|
||||
providerSaving,
|
||||
saving,
|
||||
setEditingProviderKeys,
|
||||
setExpandedProvider,
|
||||
setForm,
|
||||
setModelCallOrder,
|
||||
setModelCallOrderSaving,
|
||||
@@ -122,7 +120,7 @@ export function useModelSettingsActions({
|
||||
setProviderOAuthDialogError,
|
||||
setProviderOAuthFlow,
|
||||
setProviderOAuthResponse,
|
||||
setProviderSaving,
|
||||
setProviderOperation,
|
||||
setSaving,
|
||||
setVisibleProviderKeys,
|
||||
visibleProviderKeys,
|
||||
@@ -161,6 +159,8 @@ export function useModelSettingsActions({
|
||||
saving ||
|
||||
modelCallOrderSaving ||
|
||||
modelConfigurationSaving ||
|
||||
!Number.isSafeInteger(form.maxTokens) ||
|
||||
form.maxTokens <= 0 ||
|
||||
!Number.isSafeInteger(form.contextWindowTokens) ||
|
||||
form.contextWindowTokens <= 0
|
||||
) {
|
||||
@@ -367,7 +367,7 @@ export function useModelSettingsActions({
|
||||
modelCallOrderSaving ||
|
||||
modelConfigurationSaving
|
||||
) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
@@ -375,33 +375,34 @@ export function useModelSettingsActions({
|
||||
applyPayload(payload);
|
||||
setModelPresetPendingDelete(null);
|
||||
setError(null);
|
||||
return true;
|
||||
} catch (err) {
|
||||
setError((err as Error).message);
|
||||
return false;
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
const saveProvider = async (providerName: string) => {
|
||||
if (providerSaving) return;
|
||||
const saveProvider = async (providerName: string): Promise<boolean> => {
|
||||
if (providerSaving) return false;
|
||||
const provider = settings?.providers.find((item) => item.name === providerName);
|
||||
if (!provider) return;
|
||||
if (!provider) return false;
|
||||
const isOauthProvider = provider.auth_type === "oauth";
|
||||
const providerForm = providerForms[providerName] ?? providerFormFromRow(provider);
|
||||
const apiKey = providerForm.apiKey.trim();
|
||||
const apiKeyRequired = provider.api_key_required ?? true;
|
||||
if (!isOauthProvider && !provider.configured && apiKeyRequired && !apiKey) {
|
||||
if (!isOauthProvider && !provider.configured && (provider.api_key_required ?? true) && !apiKey) {
|
||||
setError(t("settings.byok.apiKeyRequired"));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
setProviderSaving(providerName);
|
||||
setProviderOperation({ provider: providerName, action: "save" });
|
||||
try {
|
||||
const supportName = providerName === "bedrock"
|
||||
? "bedrock"
|
||||
: providerName === "azure_openai"
|
||||
? "azure"
|
||||
: null;
|
||||
if (supportName && !(await installCapabilities([supportName]))) return;
|
||||
if (supportName && !(await installCapabilities([supportName]))) return false;
|
||||
const update: ProviderSettingsUpdate = { provider: providerName };
|
||||
if (!isOauthProvider) {
|
||||
update.apiKey = apiKey || undefined;
|
||||
@@ -423,38 +424,31 @@ export function useModelSettingsActions({
|
||||
if (field === "profile") update.profile = providerForm.profile.trim();
|
||||
}
|
||||
const payload = await updateProviderSettings(client, update);
|
||||
applyPayload(payload);
|
||||
applyPayload(payload, { preserveAgentForm: true });
|
||||
if (payload.requires_restart) {
|
||||
setPendingRestartSections((prev) => ({ ...prev, image: true }));
|
||||
}
|
||||
await maybeRestartHostEngine(payload);
|
||||
setProviderForms((prev) => ({
|
||||
...prev,
|
||||
[providerName]: {
|
||||
...providerForm,
|
||||
displayName: providerForm.displayName.trim(),
|
||||
apiKey: "",
|
||||
apiBase: providerForm.apiBase.trim(),
|
||||
proxy: providerForm.proxy.trim(),
|
||||
thinkingStyle: providerForm.thinkingStyle.trim(),
|
||||
region: providerForm.region.trim(),
|
||||
profile: providerForm.profile.trim(),
|
||||
},
|
||||
}));
|
||||
setProviderForms((prev) => {
|
||||
const next = { ...prev };
|
||||
delete next[providerName];
|
||||
return next;
|
||||
});
|
||||
setVisibleProviderKeys((prev) => ({ ...prev, [providerName]: false }));
|
||||
setEditingProviderKeys((prev) => ({ ...prev, [providerName]: false }));
|
||||
if (!isOauthProvider) setExpandedProvider(null);
|
||||
setError(null);
|
||||
return true;
|
||||
} catch (err) {
|
||||
setError((err as Error).message);
|
||||
return false;
|
||||
} finally {
|
||||
setProviderSaving(null);
|
||||
setProviderOperation(null);
|
||||
}
|
||||
};
|
||||
|
||||
const createCustomProvider = async (draft: CustomProviderDraft): Promise<boolean> => {
|
||||
if (providerSaving) return false;
|
||||
setProviderSaving(CUSTOM_PROVIDER_CREATION_KEY);
|
||||
const createCustomProvider = async (draft: CustomProviderDraft): Promise<SettingsPayload | null> => {
|
||||
if (providerSaving) return null;
|
||||
setProviderOperation({ provider: CUSTOM_PROVIDER_CREATION_KEY, action: "create" });
|
||||
try {
|
||||
const payload = await createProviderSettings(client, {
|
||||
name: draft.name.trim(),
|
||||
@@ -467,15 +461,14 @@ export function useModelSettingsActions({
|
||||
extraQuery: draft.extraQuery.trim(),
|
||||
thinkingStyle: draft.thinkingStyle.trim(),
|
||||
});
|
||||
applyPayload(payload);
|
||||
setExpandedProvider(null);
|
||||
applyPayload(payload, { preserveAgentForm: true });
|
||||
setError(null);
|
||||
return true;
|
||||
return payload;
|
||||
} catch (err) {
|
||||
setError((err as Error).message);
|
||||
return false;
|
||||
return null;
|
||||
} finally {
|
||||
setProviderSaving(null);
|
||||
setProviderOperation(null);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -494,7 +487,7 @@ export function useModelSettingsActions({
|
||||
popup = null;
|
||||
}
|
||||
}
|
||||
setProviderSaving(providerName);
|
||||
setProviderOperation({ provider: providerName, action });
|
||||
try {
|
||||
const payload =
|
||||
action === "login"
|
||||
@@ -523,13 +516,13 @@ export function useModelSettingsActions({
|
||||
}
|
||||
popup?.close();
|
||||
closeProviderOAuthFlow(false);
|
||||
applyPayload(payload, { preserveAgentForm: action === "login" });
|
||||
applyPayload(payload, { preserveAgentForm: true });
|
||||
setError(null);
|
||||
} catch (err) {
|
||||
popup?.close();
|
||||
setError((err as Error).message);
|
||||
} finally {
|
||||
setProviderSaving(null);
|
||||
setProviderOperation(null);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -571,30 +564,21 @@ export function useModelSettingsActions({
|
||||
setEditingProviderKeys((prev) => ({ ...prev, [providerName]: false }));
|
||||
}, [settings]);
|
||||
|
||||
const handleToggleProvider = useCallback((providerName: string) => {
|
||||
if (expandedProvider) resetProviderDraft(expandedProvider);
|
||||
setExpandedProvider(expandedProvider === providerName ? null : providerName);
|
||||
}, [expandedProvider, resetProviderDraft]);
|
||||
|
||||
const toggleProviderKeyVisibility = (providerName: string) => {
|
||||
const isVisible = visibleProviderKeys[providerName];
|
||||
setVisibleProviderKeys((prev) => ({ ...prev, [providerName]: !isVisible }));
|
||||
};
|
||||
|
||||
const toggleProviderKeyEditing = (providerName: string) => {
|
||||
const provider = settings?.providers.find((row) => row.name === providerName);
|
||||
if (!provider) return;
|
||||
setEditingProviderKeys((prev) => {
|
||||
const nextEditing = !prev[providerName];
|
||||
if (!nextEditing) {
|
||||
setProviderForms((forms) => ({
|
||||
...forms,
|
||||
[providerName]: {
|
||||
...(forms[providerName] ?? providerFormFromRow(
|
||||
settings?.providers.find((provider) => provider.name === providerName) ?? {
|
||||
name: providerName,
|
||||
label: providerName,
|
||||
configured: false,
|
||||
},
|
||||
)),
|
||||
...(forms[providerName] ?? providerFormFromRow(provider)),
|
||||
apiKey: "",
|
||||
},
|
||||
}));
|
||||
@@ -612,7 +596,6 @@ export function useModelSettingsActions({
|
||||
createCustomProvider,
|
||||
handleDeleteModelConfiguration,
|
||||
handleMigrateModelConfigurations,
|
||||
handleToggleProvider,
|
||||
resetProviderDraft,
|
||||
runProviderOAuth,
|
||||
saveModelSettings,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, type Dispatch, type SetStateAction } from "react";
|
||||
|
||||
import type { ApplySettingsPayload } from "@/components/settings/contracts";
|
||||
import { providerFormFromRow } from "@/components/settings/models/ProviderSettings";
|
||||
import { providerFormFromRow } from "@/components/settings/models/providerForm";
|
||||
import type { ModelSettingsState } from "@/components/settings/models/useModelSettingsState";
|
||||
import { cancelProviderOAuth, completeProviderOAuth } from "@/lib/api";
|
||||
import type { NanobotClient } from "@/lib/nanobot-client";
|
||||
@@ -91,9 +91,9 @@ export function useProviderFormsSync(
|
||||
useEffect(() => {
|
||||
if (!settings) return;
|
||||
setProviderForms((prev) => {
|
||||
const next = { ...prev };
|
||||
const next: typeof prev = {};
|
||||
for (const provider of settings.providers) {
|
||||
next[provider.name] = next[provider.name] ?? providerFormFromRow(provider);
|
||||
next[provider.name] = prev[provider.name] ?? providerFormFromRow(provider);
|
||||
}
|
||||
return next;
|
||||
});
|
||||
|
||||
@@ -5,9 +5,14 @@ import {
|
||||
agentDraftFromPayload,
|
||||
type AgentSettingsDraft,
|
||||
} from "@/components/settings/models/ModelsSettings";
|
||||
import type { ProviderForm } from "@/components/settings/models/ProviderSettings";
|
||||
import type { ProviderForm } from "@/components/settings/models/providerForm";
|
||||
import type { ProviderOAuthAuthorizationRequired, SettingsPayload } from "@/lib/types";
|
||||
|
||||
export interface ProviderOperation {
|
||||
provider: string;
|
||||
action: "save" | "create" | "login" | "logout";
|
||||
}
|
||||
|
||||
export function useModelSettingsState(initialSettings: SettingsPayload | null) {
|
||||
const initialForm = initialSettings
|
||||
? agentDraftFromPayload(initialSettings)
|
||||
@@ -21,14 +26,14 @@ export function useModelSettingsState(initialSettings: SettingsPayload | null) {
|
||||
const [modelPresetPendingDelete, setModelPresetPendingDelete] =
|
||||
useState<SettingsPayload["model_presets"][number] | null>(null);
|
||||
const modelPresetBeforeCreateRef = useRef<string | null>(null);
|
||||
const [providerSaving, setProviderSaving] = useState<string | null>(null);
|
||||
const [providerOperation, setProviderOperation] = useState<ProviderOperation | null>(null);
|
||||
const providerSaving = providerOperation?.provider ?? null;
|
||||
const [providerOAuthFlow, setProviderOAuthFlow] =
|
||||
useState<ProviderOAuthAuthorizationRequired | null>(null);
|
||||
const providerOAuthFlowRef = useRef<ProviderOAuthAuthorizationRequired | null>(null);
|
||||
const [providerOAuthResponse, setProviderOAuthResponse] = useState("");
|
||||
const [providerOAuthCompleting, setProviderOAuthCompleting] = useState(false);
|
||||
const [providerOAuthDialogError, setProviderOAuthDialogError] = useState<string | null>(null);
|
||||
const [expandedProvider, setExpandedProvider] = useState<string | null>(null);
|
||||
const [providerForms, setProviderForms] = useState<Record<string, ProviderForm>>({});
|
||||
const [visibleProviderKeys, setVisibleProviderKeys] = useState<Record<string, boolean>>({});
|
||||
const [editingProviderKeys, setEditingProviderKeys] = useState<Record<string, boolean>>({});
|
||||
@@ -42,7 +47,6 @@ export function useModelSettingsState(initialSettings: SettingsPayload | null) {
|
||||
|
||||
return {
|
||||
editingProviderKeys,
|
||||
expandedProvider,
|
||||
form,
|
||||
modelCallOrder,
|
||||
modelCallOrderSaving,
|
||||
@@ -60,9 +64,9 @@ export function useModelSettingsState(initialSettings: SettingsPayload | null) {
|
||||
providerOAuthFlowRef,
|
||||
providerOAuthResponse,
|
||||
providerSaving,
|
||||
providerOperation,
|
||||
saving,
|
||||
setEditingProviderKeys,
|
||||
setExpandedProvider,
|
||||
setForm,
|
||||
setModelCallOrder,
|
||||
setModelCallOrderSaving,
|
||||
@@ -77,7 +81,7 @@ export function useModelSettingsState(initialSettings: SettingsPayload | null) {
|
||||
setProviderOAuthDialogError,
|
||||
setProviderOAuthFlow,
|
||||
setProviderOAuthResponse,
|
||||
setProviderSaving,
|
||||
setProviderOperation,
|
||||
setSaving,
|
||||
setVisibleProviderKeys,
|
||||
visibleProviderKeys,
|
||||
|
||||
@@ -1,41 +1,31 @@
|
||||
import { useEffect, useId, useMemo, useRef, useState, type ComponentProps } from "react";
|
||||
import {
|
||||
Bot,
|
||||
Brain,
|
||||
Check,
|
||||
CircleAlert,
|
||||
Cloud,
|
||||
Cpu,
|
||||
Database,
|
||||
Gem,
|
||||
Grid3X3,
|
||||
Hexagon,
|
||||
Layers,
|
||||
Loader2,
|
||||
Moon,
|
||||
Orbit,
|
||||
Pencil,
|
||||
Search,
|
||||
Sparkles,
|
||||
Triangle,
|
||||
Waves,
|
||||
Zap,
|
||||
type LucideIcon,
|
||||
Plus,
|
||||
} from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ControlChevron } from "@/components/ui/control-chevron";
|
||||
import { ComboboxOption, useComboboxNavigation } from "@/components/ui/combobox";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { Select, SelectContent, SelectItem, SelectSeparator, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { SearchInput } from "@/components/ui/input";
|
||||
import { Popover, PopoverAnchor, PopoverContent } from "@/components/ui/popover";
|
||||
import { useLogoFallback } from "@/hooks/useLogoFallback";
|
||||
import { fetchProviderModels } from "@/lib/api";
|
||||
import { useProviderModelCatalog } from "@/hooks/useProviderModelCatalog";
|
||||
import { formatContextWindow } from "@/lib/model-context-format";
|
||||
import { providerBrand } from "@/lib/provider-brand";
|
||||
import { PROVIDER_ICONS } from "@/lib/provider-icons";
|
||||
import type { ProviderModelsPayload, SettingsPayload } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export { formatContextWindow, formatModelContextWindow } from "@/lib/model-context-format";
|
||||
export { PROVIDER_ICONS } from "@/lib/provider-icons";
|
||||
|
||||
const DEFERRED_MODEL_LIST_PROVIDERS = new Set([
|
||||
"aihubmix",
|
||||
"atomic_chat",
|
||||
@@ -88,16 +78,10 @@ export function settingsProviderConfigured(
|
||||
provider: string | null | undefined,
|
||||
resolvedProvider?: string | null,
|
||||
): boolean {
|
||||
const row = settingsProviderRow(payload, provider);
|
||||
if (row) return row.configured;
|
||||
if (provider === "auto") {
|
||||
const resolvedRow = settingsProviderRow(
|
||||
payload,
|
||||
resolvedProvider ?? payload.agent.resolved_provider ?? payload.agent.provider,
|
||||
);
|
||||
if (resolvedRow) return resolvedRow.configured;
|
||||
}
|
||||
return payload.agent.has_api_key;
|
||||
const concreteProvider = provider === "auto"
|
||||
? resolvedProvider ?? payload.agent.resolved_provider ?? payload.agent.provider
|
||||
: provider;
|
||||
return settingsProviderRow(payload, concreteProvider)?.configured ?? false;
|
||||
}
|
||||
|
||||
export function ProviderPicker({
|
||||
@@ -107,6 +91,8 @@ export function ProviderPicker({
|
||||
emptyLabel,
|
||||
showProviderLogos = false,
|
||||
onChange,
|
||||
onAddProvider,
|
||||
onConfigureProvider,
|
||||
}: {
|
||||
providers: Array<{ name: string; label: string }>;
|
||||
value: string;
|
||||
@@ -114,13 +100,27 @@ export function ProviderPicker({
|
||||
emptyLabel: string;
|
||||
showProviderLogos?: boolean;
|
||||
onChange: (provider: string) => void;
|
||||
onAddProvider?: (trigger: HTMLButtonElement | null) => void;
|
||||
onConfigureProvider?: (provider: string, trigger: HTMLButtonElement | null) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const triggerRef = useRef<HTMLButtonElement>(null);
|
||||
const openingProviderSetup = useRef(false);
|
||||
const selectedProvider = providers.find((provider) => provider.name === value) ?? null;
|
||||
const disabled = !!triggerProps?.disabled || providers.length === 0;
|
||||
const disabled = !!triggerProps?.disabled || (providers.length === 0 && !onAddProvider);
|
||||
|
||||
return (
|
||||
<Select value={value} onValueChange={onChange} disabled={disabled}>
|
||||
<Select value={value} onValueChange={(provider) => {
|
||||
if (provider === ":add-provider") {
|
||||
openingProviderSetup.current = true;
|
||||
onAddProvider?.(triggerRef.current);
|
||||
} else if (provider === ":configure-provider") {
|
||||
openingProviderSetup.current = true;
|
||||
onConfigureProvider?.(value, triggerRef.current);
|
||||
} else onChange(provider);
|
||||
}} disabled={disabled}>
|
||||
<SelectTrigger
|
||||
ref={triggerRef}
|
||||
{...triggerProps}
|
||||
aria-label={triggerProps?.["aria-label"] ?? selectedProvider?.label ?? emptyLabel}
|
||||
type="button"
|
||||
@@ -141,7 +141,12 @@ export function ProviderPicker({
|
||||
<span className="truncate">{selectedProvider?.label ?? emptyLabel}</span>
|
||||
</span></SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectContent onCloseAutoFocus={(event) => {
|
||||
if (openingProviderSetup.current) {
|
||||
event.preventDefault();
|
||||
openingProviderSetup.current = false;
|
||||
}
|
||||
}}>
|
||||
{providers.map((provider) => {
|
||||
return (
|
||||
<SelectItem
|
||||
@@ -160,6 +165,21 @@ export function ProviderPicker({
|
||||
</SelectItem>
|
||||
);
|
||||
})}
|
||||
{onAddProvider || onConfigureProvider ? <>
|
||||
{providers.length > 0 ? <SelectSeparator className="my-1 h-px bg-border" /> : null}
|
||||
{onConfigureProvider && selectedProvider ? <SelectItem value=":configure-provider">
|
||||
<span className="flex items-center gap-2">
|
||||
<Pencil className="h-4 w-4 text-muted-foreground" aria-hidden />
|
||||
{t("settings.providers.configureProvider", { provider: selectedProvider.label })}
|
||||
</span>
|
||||
</SelectItem> : null}
|
||||
{onAddProvider ? <SelectItem value=":add-provider">
|
||||
<span className="flex items-center gap-2">
|
||||
<Plus className="h-4 w-4 text-muted-foreground" aria-hidden />
|
||||
{t("settings.providers.addProvider", { defaultValue: "Add provider" })}
|
||||
</span>
|
||||
</SelectItem> : null}
|
||||
</> : null}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
);
|
||||
@@ -190,19 +210,16 @@ export function ModelIdPicker({
|
||||
emptyMessage?: string;
|
||||
onProviderOAuthLogin?: (provider: string) => void;
|
||||
providerSigningIn?: boolean;
|
||||
onChange: (model: string) => void;
|
||||
onChange: (model: string, info?: ProviderModelsPayload["models"][number]) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
|
||||
const tokenRef = useRef(token);
|
||||
tokenRef.current = token;
|
||||
const [open, setOpen] = useState(false);
|
||||
const [query, setQuery] = useState("");
|
||||
const [payload, setPayload] = useState<ProviderModelsPayload | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const catalogNoticeId = useId();
|
||||
const catalogSignInRef = useRef<HTMLButtonElement>(null);
|
||||
const searchInputRef = useRef<HTMLInputElement>(null);
|
||||
const restoreInputOnClose = useRef(false);
|
||||
const effectiveProvider =
|
||||
provider === "auto" ? settings.agent.resolved_provider ?? provider : provider;
|
||||
const hasConcreteProvider = Boolean(effectiveProvider && effectiveProvider !== "auto");
|
||||
@@ -224,6 +241,17 @@ export function ModelIdPicker({
|
||||
!hasStaticModels &&
|
||||
hasConcreteProvider && providerConfigured && !providerUsesManualModelIds;
|
||||
const normalizedQuery = query.trim().toLowerCase();
|
||||
const defersModelList = DEFERRED_MODEL_LIST_PROVIDERS.has(effectiveProvider);
|
||||
const hasDeferredSearchQuery =
|
||||
normalizedQuery.length >= DEFERRED_MODEL_LIST_QUERY_MIN_LENGTH;
|
||||
const shouldFetchModels =
|
||||
canFetchModels && (!defersModelList || hasDeferredSearchQuery);
|
||||
const { payload, loading, refreshing, failed, needsSignIn, retry } = useProviderModelCatalog({
|
||||
revision: providerRow ?? settings,
|
||||
token,
|
||||
provider: effectiveProvider,
|
||||
enabled: open && shouldFetchModels,
|
||||
});
|
||||
const providerModels: ProviderModelsPayload["models"] = useMemo(
|
||||
() => hasStaticModels
|
||||
? (models?.map((id) => ({ id })) ?? [])
|
||||
@@ -241,15 +269,10 @@ export function ModelIdPicker({
|
||||
[normalizedQuery, providerModels],
|
||||
);
|
||||
const isCatalog = payload?.catalog_kind === "catalog";
|
||||
const defersModelList = DEFERRED_MODEL_LIST_PROVIDERS.has(effectiveProvider);
|
||||
const hasDeferredSearchQuery =
|
||||
normalizedQuery.length >= DEFERRED_MODEL_LIST_QUERY_MIN_LENGTH;
|
||||
const shouldFetchModels =
|
||||
canFetchModels && (!defersModelList || hasDeferredSearchQuery);
|
||||
const waitingForModelSearch =
|
||||
open && canFetchModels && defersModelList && !hasDeferredSearchQuery;
|
||||
const hasModelList = hasStaticModels || payload?.status === "available";
|
||||
const catalogNeedsSignIn = !hasStaticModels && payload?.error_kind === "auth_required";
|
||||
const catalogNeedsSignIn = !hasStaticModels && needsSignIn;
|
||||
const showModels = Boolean(
|
||||
!catalogNeedsSignIn && hasModelList
|
||||
&& (hasStaticModels || (payload && (!isCatalog || normalizedQuery))),
|
||||
@@ -262,50 +285,37 @@ export function ModelIdPicker({
|
||||
);
|
||||
const providerModelCount = payload?.model_count ?? providerModels.length;
|
||||
const modelUnconfigured = !value.trim() || !providerConfigured;
|
||||
const showCatalogNotice = payload && (catalogNeedsSignIn
|
||||
|| (!loading && payload.status === "available"
|
||||
&& (payload.source === "stale" || payload.source === "fallback")));
|
||||
const showCatalogNotice = !hasStaticModels && (catalogNeedsSignIn
|
||||
|| (open && shouldFetchModels && !refreshing && failed));
|
||||
|
||||
useEffect(() => {
|
||||
if (open && catalogNeedsSignIn && !loading) catalogSignInRef.current?.focus();
|
||||
if (!open || loading) return;
|
||||
if (catalogNeedsSignIn) catalogSignInRef.current?.focus();
|
||||
else searchInputRef.current?.focus();
|
||||
}, [open, catalogNeedsSignIn, loading]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
setQuery(providerUsesManualModelIds || !hasConcreteProvider ? value : "");
|
||||
}, [open, effectiveProvider, hasConcreteProvider, providerUsesManualModelIds, value]);
|
||||
}, [effectiveProvider, hasConcreteProvider, providerUsesManualModelIds, value]);
|
||||
|
||||
useEffect(() => {
|
||||
// Reopening does not restore authorization. Keep a confirmed rejection until
|
||||
// discovery completes, without carrying it into another provider's picker.
|
||||
setPayload((current) => shouldFetchModels && current?.provider === effectiveProvider
|
||||
&& current.error_kind === "auth_required" ? current : null);
|
||||
setError(null);
|
||||
setLoading(open && shouldFetchModels);
|
||||
if (!open || !shouldFetchModels) {
|
||||
return;
|
||||
const openPicker = (nextQuery?: string) => {
|
||||
if (nextQuery !== undefined || !open) {
|
||||
setQuery(nextQuery ?? (providerUsesManualModelIds || !hasConcreteProvider ? value : ""));
|
||||
}
|
||||
let cancelled = false;
|
||||
fetchProviderModels(tokenRef.current, effectiveProvider)
|
||||
.then((nextPayload) => {
|
||||
if (!cancelled) setPayload(nextPayload);
|
||||
})
|
||||
.catch((err) => {
|
||||
if (!cancelled) setError((err as Error).message);
|
||||
})
|
||||
.finally(() => {
|
||||
if (!cancelled) setLoading(false);
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
// Successful OAuth completion replaces the settings row even for the same account.
|
||||
}, [effectiveProvider, open, shouldFetchModels, providerRow]);
|
||||
restoreInputOnClose.current = false;
|
||||
setOpen(true);
|
||||
};
|
||||
|
||||
const selectModel = (model: string) => {
|
||||
onChange(model);
|
||||
const closePicker = (restoreFocus = false) => {
|
||||
restoreInputOnClose.current = restoreFocus;
|
||||
setOpen(false);
|
||||
};
|
||||
const selectModel = (model: string) => {
|
||||
const info = providerModels.find((entry) => entry.id === model);
|
||||
if (info) onChange(model, info);
|
||||
else onChange(model);
|
||||
closePicker(true);
|
||||
};
|
||||
const navigationValues = useMemo(
|
||||
() => [
|
||||
...(showModels ? visibleModels.map((model) => model.id) : []),
|
||||
@@ -318,7 +328,7 @@ export function ModelIdPicker({
|
||||
values: navigationValues,
|
||||
selectedValue: value,
|
||||
onSelect: selectModel,
|
||||
onClose: () => setOpen(false),
|
||||
onClose: () => closePicker(true),
|
||||
});
|
||||
|
||||
const renderModelRow = (
|
||||
@@ -360,59 +370,67 @@ export function ModelIdPicker({
|
||||
|
||||
return (
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="control"
|
||||
className={cn(
|
||||
"w-full justify-between rounded-full border-input bg-background text-[13px] font-normal shadow-none",
|
||||
"settings-hover focus-visible:ring-2 focus-visible:ring-ring",
|
||||
)}
|
||||
>
|
||||
<span className="flex min-w-0 items-center gap-2">
|
||||
<PopoverAnchor asChild>
|
||||
<div className="relative w-full">
|
||||
<span className="pointer-events-none absolute left-3 top-1/2 -translate-y-1/2">
|
||||
<ProviderPickerIcon
|
||||
provider={effectiveProvider}
|
||||
showBrandLogos={showProviderLogos}
|
||||
unconfigured={modelUnconfigured}
|
||||
/>
|
||||
<span
|
||||
className={cn(
|
||||
"min-w-0 truncate font-medium",
|
||||
value ? "text-foreground" : "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{value || emptyLabel || tx("settings.models.selectModel", "Select model")}
|
||||
</span>
|
||||
</span>
|
||||
<ControlChevron />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<SearchInput
|
||||
ref={searchInputRef}
|
||||
type="search"
|
||||
name="model-search"
|
||||
autoComplete="off"
|
||||
autoCapitalize="none"
|
||||
autoCorrect="off"
|
||||
spellCheck={false}
|
||||
value={open && !catalogNeedsSignIn ? query : value}
|
||||
readOnly={catalogNeedsSignIn}
|
||||
onClick={() => openPicker()}
|
||||
onChange={(event) => openPicker(event.target.value)}
|
||||
{...navigation.inputProps}
|
||||
onKeyDown={(event) => {
|
||||
if (event.nativeEvent.isComposing) return;
|
||||
if (!open && ["ArrowDown", "ArrowUp", "Enter"].includes(event.key)) {
|
||||
event.preventDefault();
|
||||
openPicker();
|
||||
return;
|
||||
}
|
||||
navigation.inputProps.onKeyDown(event);
|
||||
}}
|
||||
placeholder={open
|
||||
? searchPlaceholder || tx("settings.models.searchModels", "Search or type model ID")
|
||||
: emptyLabel || tx("settings.models.selectModel", "Select model")}
|
||||
aria-label={emptyLabel || tx("settings.models.selectModel", "Select model")}
|
||||
aria-expanded={open}
|
||||
aria-describedby={showCatalogNotice ? catalogNoticeId : undefined}
|
||||
className="h-9 appearance-none pl-9 pr-9 text-[13px] font-medium [&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none"
|
||||
/>
|
||||
<span className="pointer-events-none absolute right-3 top-1/2 -translate-y-1/2">
|
||||
<ControlChevron />
|
||||
</span>
|
||||
</div>
|
||||
</PopoverAnchor>
|
||||
<PopoverContent
|
||||
align="end"
|
||||
onOpenAutoFocus={(event) => event.preventDefault()}
|
||||
onCloseAutoFocus={(event) => {
|
||||
event.preventDefault();
|
||||
if (restoreInputOnClose.current) {
|
||||
restoreInputOnClose.current = false;
|
||||
searchInputRef.current?.focus({ preventScroll: true });
|
||||
}
|
||||
}}
|
||||
onEscapeKeyDown={() => { restoreInputOnClose.current = true; }}
|
||||
onInteractOutside={(event) => {
|
||||
if (event.target === searchInputRef.current) event.preventDefault();
|
||||
else restoreInputOnClose.current = false;
|
||||
}}
|
||||
className="w-[var(--radix-popover-trigger-width)] max-w-[calc(100vw-2rem)] p-1.5"
|
||||
>
|
||||
{!catalogNeedsSignIn ? <div className="p-1 pb-1.5">
|
||||
<div className="relative">
|
||||
<Search
|
||||
className="pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"
|
||||
aria-hidden
|
||||
/>
|
||||
<Input
|
||||
value={query}
|
||||
onChange={(event) => setQuery(event.target.value)}
|
||||
{...navigation.inputProps}
|
||||
placeholder={
|
||||
searchPlaceholder || tx("settings.models.searchModels", "Search or type model ID")
|
||||
}
|
||||
aria-label={
|
||||
searchPlaceholder || tx("settings.models.searchModels", "Search or type model ID")
|
||||
}
|
||||
aria-describedby={showCatalogNotice ? catalogNoticeId : undefined}
|
||||
className="h-8 rounded-full pl-8 pr-3 text-[12px]"
|
||||
/>
|
||||
</div>
|
||||
</div> : null}
|
||||
|
||||
{showCatalogNotice ? (
|
||||
<div className="mx-1 mb-1.5 flex items-start gap-2 rounded-control bg-muted/60 px-2.5 py-2 text-[11px] leading-4">
|
||||
@@ -425,12 +443,21 @@ export function ModelIdPicker({
|
||||
<p className="font-medium text-foreground">
|
||||
{catalogNeedsSignIn
|
||||
? tx("settings.models.catalogAuthRequired", "Authorization expired. Please sign in again.")
|
||||
: tx("settings.models.catalogUnavailable", "Could not refresh models. Try again later.")}
|
||||
: <button
|
||||
type="button"
|
||||
className="rounded-sm text-left underline decoration-foreground/30 underline-offset-2 hover:decoration-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
||||
onClick={() => {
|
||||
void retry();
|
||||
searchInputRef.current?.focus();
|
||||
}}
|
||||
>
|
||||
{tx("settings.models.catalogUnavailable", "Refresh failed. Click to retry")}
|
||||
</button>}
|
||||
</p>
|
||||
{!catalogNeedsSignIn ? <p className="mt-1 text-muted-foreground">
|
||||
{payload.source === "stale"
|
||||
? tx("settings.models.catalogStale", "Showing cached models; the list may be out of date.")
|
||||
: tx("settings.models.catalogFallback", "Showing built-in models; the list may be out of date.")}
|
||||
{!catalogNeedsSignIn && payload?.status === "available" ? <p className="mt-1 text-muted-foreground">
|
||||
{payload.source !== "fallback"
|
||||
? tx("settings.models.catalogStale", "Cached list may be out of date.")
|
||||
: tx("settings.models.catalogFallback", "Built-in list may be out of date.")}
|
||||
</p> : null}
|
||||
</div>
|
||||
{catalogNeedsSignIn && onProviderOAuthLogin && providerRow?.oauth_login_supported ? (
|
||||
@@ -443,7 +470,7 @@ export function ModelIdPicker({
|
||||
disabled={providerSigningIn}
|
||||
aria-describedby={catalogNoticeId}
|
||||
onClick={() => {
|
||||
setOpen(false);
|
||||
closePicker();
|
||||
onProviderOAuthLogin(effectiveProvider);
|
||||
}}
|
||||
>
|
||||
@@ -477,14 +504,20 @@ export function ModelIdPicker({
|
||||
{tx("settings.models.searchCatalog", "Search this provider’s model catalog.")}
|
||||
</div>
|
||||
) : loading ? (
|
||||
<div className="flex items-center gap-2 px-2 py-1.5 text-[11px] text-muted-foreground">
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />
|
||||
{tx("settings.models.loadingModels", "Loading models...")}
|
||||
</div>
|
||||
) : error || payload?.status === "error" ? (
|
||||
<div className="px-2 py-1.5 text-[11px] leading-4 text-muted-foreground">
|
||||
{payload?.message || error || tx("settings.models.loadFailed", "Model list unavailable.")}
|
||||
</div>
|
||||
<SkeletonStatus
|
||||
label={tx("settings.models.loadingModels", "Loading models...")}
|
||||
className="space-y-0.5 py-1"
|
||||
>
|
||||
{["w-3/5", "w-4/5", "w-1/2"].map((width) => (
|
||||
<div key={width} className="flex items-center gap-2 px-2 py-1.5">
|
||||
<div className="h-3.5 w-3.5 shrink-0 rounded-full bg-muted-foreground/20" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className={cn("h-3 rounded bg-muted-foreground/20", width)} />
|
||||
<div className="mt-1.5 h-2.5 w-2/5 rounded bg-muted-foreground/10" />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</SkeletonStatus>
|
||||
) : payload?.status === "not_configured" ? (
|
||||
<div className="px-2 py-1.5 text-[11px] leading-4 text-muted-foreground">
|
||||
{tx("settings.models.providerNotConfigured", "Configure this provider before loading models.")}
|
||||
@@ -507,7 +540,7 @@ export function ModelIdPicker({
|
||||
<div
|
||||
{...navigation.listProps}
|
||||
aria-label={searchPlaceholder || tx("settings.models.selectModel", "Select model")}
|
||||
className="max-h-[16rem] overflow-y-auto pr-0.5 scrollbar-thin scrollbar-track-transparent"
|
||||
className="max-h-[16rem] overflow-y-auto scrollbar-thin"
|
||||
>
|
||||
{showModels
|
||||
? visibleModels.map((model) =>
|
||||
@@ -545,25 +578,6 @@ export function ModelIdPicker({
|
||||
);
|
||||
}
|
||||
|
||||
export function formatContextWindow(tokens: number): string {
|
||||
if (tokens >= 1_000_000) {
|
||||
const value = tokens / 1_000_000;
|
||||
return `${Number.isInteger(value) ? value.toFixed(0) : value.toFixed(1)}M`;
|
||||
}
|
||||
if (tokens >= 1_000) {
|
||||
const value = tokens / 1_000;
|
||||
return `${Number.isInteger(value) ? value.toFixed(0) : value.toFixed(1)}K`;
|
||||
}
|
||||
return String(tokens);
|
||||
}
|
||||
|
||||
export function formatModelContextWindow(tokens: number): string {
|
||||
if (tokens === 65_536) return "64K";
|
||||
if (tokens === 262_144) return "256K";
|
||||
if (tokens === 1_048_576) return "1M";
|
||||
return formatContextWindow(tokens);
|
||||
}
|
||||
|
||||
export function ProviderPickerIcon({
|
||||
provider,
|
||||
showBrandLogos,
|
||||
@@ -659,47 +673,3 @@ export function optionRowsWithCurrent(
|
||||
return [{ name: value, label: value }, ...options];
|
||||
}
|
||||
|
||||
export const PROVIDER_ICONS: Record<string, LucideIcon> = {
|
||||
custom: Hexagon,
|
||||
openrouter: Sparkles,
|
||||
orcarouter: Sparkles,
|
||||
skywork: Sparkles,
|
||||
aihubmix: Triangle,
|
||||
anthropic: Brain,
|
||||
openai: Bot,
|
||||
deepseek: Waves,
|
||||
zhipu: Grid3X3,
|
||||
dashscope: Cloud,
|
||||
modelscope: Layers,
|
||||
moonshot: Moon,
|
||||
minimax: Zap,
|
||||
minimax_anthropic: Brain,
|
||||
groq: Cpu,
|
||||
huggingface: Layers,
|
||||
gemini: Gem,
|
||||
mistral: Orbit,
|
||||
siliconflow: Layers,
|
||||
volcengine: Cloud,
|
||||
volcengine_coding_plan: Cloud,
|
||||
byteplus: Cloud,
|
||||
byteplus_coding_plan: Cloud,
|
||||
qianfan: Database,
|
||||
ant_ling: Sparkles,
|
||||
azure_openai: Cloud,
|
||||
bedrock: Database,
|
||||
bocha: Search,
|
||||
brave: Search,
|
||||
duckduckgo: Search,
|
||||
exa: Search,
|
||||
jina: Search,
|
||||
kagi: Search,
|
||||
olostep: Search,
|
||||
searxng: Search,
|
||||
tavily: Search,
|
||||
vllm: Cpu,
|
||||
ollama: Cpu,
|
||||
lm_studio: Cpu,
|
||||
atomic_chat: Cpu,
|
||||
ovms: Cpu,
|
||||
nvidia: Zap,
|
||||
};
|
||||
@@ -0,0 +1,65 @@
|
||||
import { Hexagon } from "lucide-react";
|
||||
import { useLogoFallback } from "@/hooks/useLogoFallback";
|
||||
import { providerBrand } from "@/lib/provider-brand";
|
||||
import { PROVIDER_ICONS } from "@/lib/provider-icons";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function ProviderIcon({
|
||||
provider,
|
||||
showBrandLogos,
|
||||
compact = false,
|
||||
fill = false,
|
||||
}: {
|
||||
provider: string;
|
||||
showBrandLogos: boolean;
|
||||
compact?: boolean;
|
||||
fill?: boolean;
|
||||
}) {
|
||||
const brand = providerBrand(provider);
|
||||
const Icon = PROVIDER_ICONS[provider] ?? Hexagon;
|
||||
const { logoUrl, logoLoaded, onLogoError, onLogoLoad } = useLogoFallback(brand?.logoUrls);
|
||||
const showRemoteLogo = showBrandLogos && Boolean(logoUrl);
|
||||
const showLoadedLogo = showRemoteLogo && logoLoaded;
|
||||
const isLogoTile = brand?.logoLayout === "tile" && logoUrl === brand.logoUrl;
|
||||
|
||||
return (
|
||||
<span
|
||||
data-testid={`provider-logo-${provider}`}
|
||||
className={cn(
|
||||
"relative grid shrink-0 place-items-center overflow-hidden font-semibold text-muted-foreground",
|
||||
fill ? "h-full w-full rounded-[9px] text-[11px]" : compact ? "h-6 w-6 rounded-[7px] text-[9px]" : "h-8 w-8 rounded-[9px] text-[11px]",
|
||||
showLoadedLogo ? (isLogoTile ? "bg-transparent" : "bg-white") : "bg-muted",
|
||||
)}
|
||||
aria-hidden
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
"transition-opacity duration-150 motion-reduce:transition-none",
|
||||
fill && "grid h-3/4 w-3/4 place-items-center",
|
||||
showLoadedLogo ? "opacity-0" : "opacity-100",
|
||||
)}
|
||||
>
|
||||
{showBrandLogos && brand
|
||||
? brand.initials
|
||||
: <Icon className={fill ? "h-full w-full" : "h-5 w-5"} strokeWidth={2} />}
|
||||
</span>
|
||||
{showRemoteLogo ? (
|
||||
<img
|
||||
src={logoUrl}
|
||||
alt=""
|
||||
decoding="async"
|
||||
loading="lazy"
|
||||
referrerPolicy="no-referrer"
|
||||
draggable={false}
|
||||
className={cn(
|
||||
"absolute object-contain transition-opacity duration-150 motion-reduce:transition-none",
|
||||
fill ? (isLogoTile ? "h-full w-full" : "h-3/4 w-3/4") : isLogoTile ? (compact ? "h-6 w-6" : "h-8 w-8") : compact ? "h-[18px] w-[18px]" : "h-6 w-6",
|
||||
logoLoaded ? "opacity-100" : "opacity-0",
|
||||
)}
|
||||
onLoad={onLogoLoad}
|
||||
onError={onLogoError}
|
||||
/>
|
||||
) : null}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { ComponentProps } from "react";
|
||||
import { Trash2 } from "lucide-react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function RemoveActionButton({ children, className, ...props }: ComponentProps<typeof Button>) {
|
||||
return (
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
{...props}
|
||||
className={cn("rounded-full text-muted-foreground hover:text-destructive", className)}
|
||||
>
|
||||
<Trash2 className="mr-1.5 h-3.5 w-3.5" aria-hidden />
|
||||
{children}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { forwardRef, type ButtonHTMLAttributes, type ReactNode } from "react";
|
||||
import { Plus } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export const SettingsAddButton = forwardRef<HTMLButtonElement,
|
||||
ButtonHTMLAttributes<HTMLButtonElement> & { trailing?: ReactNode }
|
||||
>(({ children, trailing, className, type = "button", ...props }, ref) => (
|
||||
<button {...props} ref={ref} type={type}
|
||||
className={cn("settings-list-row flex w-full items-center gap-3 py-2.5 text-left transition-colors settings-hover disabled:cursor-not-allowed disabled:opacity-50", className)}>
|
||||
<span className="flex min-w-0 flex-1 items-center gap-3">
|
||||
<span className="grid h-8 w-8 shrink-0 place-items-center rounded-[9px] bg-muted text-muted-foreground">
|
||||
<Plus className="h-5 w-5" aria-hidden />
|
||||
</span>
|
||||
<span className="truncate text-[14px] font-medium text-foreground">{children}</span>
|
||||
</span>
|
||||
{trailing}
|
||||
</button>
|
||||
));
|
||||
SettingsAddButton.displayName = "SettingsAddButton";
|
||||
@@ -17,10 +17,8 @@ import { isNativeRuntime } from "@/lib/runtime";
|
||||
import type { NanobotFeatureInfo } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export const SETTINGS_SEARCH_INPUT_CLASS = cn(
|
||||
"border-border/45 bg-settings-surface transition-colors hover:border-border/70",
|
||||
"focus-visible:border-border/70 focus-visible:bg-background",
|
||||
);
|
||||
export const SETTINGS_SEARCH_INPUT_CLASS =
|
||||
"border-border/45 bg-settings-surface transition-colors hover:border-border/70";
|
||||
|
||||
export function CapabilityInstallNotice({
|
||||
title,
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import { useRef, useState } from "react";
|
||||
import { useRef, useState, type ReactElement } from "react";
|
||||
import { SquarePen } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { HoverHint } from "@/components/ui/tooltip";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
|
||||
|
||||
export function SettingsTextEditor({ id, title, description, value, placeholder, disabled, onSave }: {
|
||||
export function SettingsTextEditor({ id, title, description, value, placeholder, disabled, trigger, onSave }: {
|
||||
id?: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
value: string;
|
||||
placeholder?: string;
|
||||
disabled?: boolean;
|
||||
trigger?: ReactElement;
|
||||
onSave: (value: string) => void | Promise<void>;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
@@ -41,15 +42,14 @@ export function SettingsTextEditor({ id, title, description, value, placeholder,
|
||||
if (next) { setDraft(value); setError(""); }
|
||||
setOpen(next);
|
||||
}}>
|
||||
<TooltipProvider><Tooltip>
|
||||
<TooltipTrigger asChild><DialogTrigger asChild>
|
||||
{trigger ? <DialogTrigger asChild id={id} disabled={disabled}>{trigger}</DialogTrigger> : <HoverHint content={t("settings.actions.edit")}>
|
||||
<DialogTrigger asChild>
|
||||
<Button size="icon" id={id} type="button" variant="ghost" disabled={disabled} aria-label={title}
|
||||
className="ml-auto flex h-9 w-9 shrink-0 rounded-full p-0 text-muted-foreground">
|
||||
<SquarePen className="h-4 w-4" aria-hidden />
|
||||
</Button>
|
||||
</DialogTrigger></TooltipTrigger>
|
||||
<TooltipContent>{t("settings.actions.edit")}</TooltipContent>
|
||||
</Tooltip></TooltipProvider>
|
||||
</DialogTrigger>
|
||||
</HoverHint>}
|
||||
<DialogContent className="max-w-xl" showCloseButton={!saving}
|
||||
{...(hasDescription ? {} : { "aria-describedby": undefined })}
|
||||
onOpenAutoFocus={(event) => { event.preventDefault(); editor.current?.focus(); }}
|
||||
@@ -62,7 +62,7 @@ export function SettingsTextEditor({ id, title, description, value, placeholder,
|
||||
<Textarea ref={editor} aria-label={title} value={draft} placeholder={placeholder} disabled={saving}
|
||||
aria-invalid={Boolean(error)} spellCheck={false}
|
||||
onChange={(event) => { setDraft(event.target.value); setError(""); }}
|
||||
className="h-[min(40vh,280px)] min-h-24 resize-none rounded-xl font-mono text-[13px] leading-6" />
|
||||
className="h-[min(40vh,280px)] min-h-24 resize-none rounded-control font-mono text-[13px] leading-6" />
|
||||
{error && <p role="alert" className="break-words text-[13px] text-destructive">{error}</p>}
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="outline" disabled={saving} onClick={() => setOpen(false)}>{t("settings.actions.cancel")}</Button>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ComboboxOption, useComboboxNavigation } from "@/components/ui/combobox";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SearchInput } from "@/components/ui/input";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
|
||||
export function TimezonePicker({ value, onChange, ...triggerProps }: {
|
||||
@@ -48,7 +48,7 @@ export function TimezonePicker({ value, onChange, ...triggerProps }: {
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="end" className="w-80 max-w-[calc(100vw-2rem)] p-1.5">
|
||||
<Input {...navigation.inputProps} value={query} onChange={(event) => setQuery(event.target.value)}
|
||||
<SearchInput {...navigation.inputProps} value={query} onChange={(event) => setQuery(event.target.value)}
|
||||
aria-label={t("sidebar.searchAria")} placeholder={t("sidebar.searchPlaceholder")}
|
||||
className="mb-1.5 h-9 rounded-full" />
|
||||
<div {...navigation.listProps} aria-label={triggerProps["aria-label"]} className="max-h-64 overflow-y-auto">
|
||||
|
||||
@@ -50,7 +50,7 @@ import {
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Input, SearchInput } from "@/components/ui/input";
|
||||
import { SegmentedControl } from "@/components/ui/segmented-control";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { SettingsTextEditor } from "@/components/settings/shared/SettingsTextEditor";
|
||||
@@ -259,7 +259,7 @@ export function AppsCatalogSettings({
|
||||
<div className="flex flex-col gap-3 lg:flex-row lg:items-center">
|
||||
<div className="relative flex-1">
|
||||
<Search className="pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden />
|
||||
<Input
|
||||
<SearchInput
|
||||
value={query}
|
||||
onChange={(event) => onQueryChange(event.target.value)}
|
||||
placeholder={tx("settings.apps.searchPlaceholder", "Search Apps")}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useCallback, useLayoutEffect, useRef, useState } from "react";
|
||||
import { Search, X } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SearchInput } from "@/components/ui/input";
|
||||
import { SegmentedControl } from "@/components/ui/segmented-control";
|
||||
import { SETTINGS_SEARCH_INPUT_CLASS } from "@/components/settings/shared/SettingsControls";
|
||||
import { CatalogSkeleton } from "@/components/settings/shared/CatalogSkeleton";
|
||||
@@ -102,7 +102,7 @@ export function ChannelsSettings({
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-center">
|
||||
<div className="relative min-w-0 flex-1">
|
||||
<Search className="pointer-events-none absolute start-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden />
|
||||
<Input type="search" value={query} onChange={(event) => setQuery(event.target.value)}
|
||||
<SearchInput type="search" value={query} onChange={(event) => setQuery(event.target.value)}
|
||||
aria-label={t("settings.channels.search")}
|
||||
placeholder={t("settings.channels.search")}
|
||||
className={`h-12 ps-11 text-[15px] ${SETTINGS_SEARCH_INPUT_CLASS}`} />
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
DialogDescription,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Input, SearchInput } from "@/components/ui/input";
|
||||
import { SegmentedControl } from "@/components/ui/segmented-control";
|
||||
import type { McpPresetInfo } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
@@ -432,7 +432,7 @@ function ToolsPanel({
|
||||
<label className="relative min-w-0 flex-1">
|
||||
<span className="sr-only">{tx("settings.mcp.searchTools", "Search tools")}</span>
|
||||
<Search className="pointer-events-none absolute left-3.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" aria-hidden />
|
||||
<Input
|
||||
<SearchInput
|
||||
value={query}
|
||||
onChange={(event) => onQueryChange(event.target.value)}
|
||||
placeholder={tx("settings.mcp.searchToolsPlaceholder", "Search tools")}
|
||||
|
||||
@@ -98,12 +98,12 @@ export function useSettingsController({
|
||||
const [localPrefs, setLocalPrefs] = useState<LocalPreferences>(() => readLocalPreferences());
|
||||
const modelState = useModelSettingsState(initialSettings);
|
||||
const {
|
||||
editingProviderKeys, expandedProvider, form, modelCallOrder, modelCallOrderSaving,
|
||||
editingProviderKeys, form, modelCallOrder, modelCallOrderSaving,
|
||||
modelConfigurationSaving, modelMigrationSaving, modelPresetBeforeCreateRef,
|
||||
modelPresetCreating, modelPresetEditingName, modelPresetNameError, modelPresetPendingDelete,
|
||||
providerForms, providerOAuthCompleting,
|
||||
providerOAuthDialogError, providerOAuthFlow, providerOAuthFlowRef, providerOAuthResponse,
|
||||
providerSaving, saving, setForm,
|
||||
providerSaving, providerOperation, saving, setForm,
|
||||
setModelCallOrder, setModelPresetCreating, setModelPresetEditingName, setModelPresetNameError,
|
||||
setModelPresetPendingDelete,
|
||||
setProviderForms, setProviderOAuthCompleting, setProviderOAuthDialogError,
|
||||
@@ -450,7 +450,7 @@ export function useSettingsController({
|
||||
createCustomProvider,
|
||||
handleDeleteModelConfiguration,
|
||||
handleMigrateModelConfigurations,
|
||||
handleToggleProvider,
|
||||
resetProviderDraft,
|
||||
runProviderOAuth,
|
||||
saveModelSettings,
|
||||
saveProvider,
|
||||
@@ -523,7 +523,6 @@ export function useSettingsController({
|
||||
customMcpForm,
|
||||
editingProviderKeys,
|
||||
error,
|
||||
expandedProvider,
|
||||
featureCatalog,
|
||||
form,
|
||||
handleApiServiceAction,
|
||||
@@ -542,7 +541,7 @@ export function useSettingsController({
|
||||
handleMigrateModelConfigurations,
|
||||
handleNanobotFeatureAction,
|
||||
handleSaveCustomMcp,
|
||||
handleToggleProvider,
|
||||
resetProviderDraft,
|
||||
handleWebSearchProviderChange,
|
||||
hostEngineApplying,
|
||||
imageGenerationDirty,
|
||||
@@ -588,6 +587,7 @@ export function useSettingsController({
|
||||
providerOAuthFlow,
|
||||
providerOAuthResponse,
|
||||
providerSaving,
|
||||
providerOperation,
|
||||
remoteBrowserAccess,
|
||||
resetWebSearchDraft,
|
||||
restartViaSettingsSurface,
|
||||
|
||||
Reference in new issue
Block a user