Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(llm): edit a provider's models from the chat picker
Elian Doran8e4fbd5f6dd1
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 8ceeeca8d6..cc3200c706 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2157,7 +2157,8 @@"extended_thinking": "Extended thinking","legacy_models": "Legacy models","model_cost_included": "Subscription",- "no_models_selected": "No models selected, edit this provider in settings",+ "no_models_selected": "No models selected — click the pencil to choose",+ "edit_models": "Edit models","thinking": "Thinking...","thought_process": "Thought process","tool_calls": "{{count}} tool call(s)",diff --git a/apps/client/src/widgets/react/FormList.css b/apps/client/src/widgets/react/FormList.cssindex 176912f3c9..bb49f43bb7 100644--- a/apps/client/src/widgets/react/FormList.css+++ b/apps/client/src/widgets/react/FormList.css@@ -37,3 +37,15 @@flex-grow: 1;}}++.dropdown-header.dropdown-header-with-action {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 0.5em;++ /* Shrink the whole icon-action box (not just the glyph) to the 26px used by+ the right-panel card-header-buttons — .icon-action derives its width,+ height and font-size from this variable. */+ --icon-button-size: 26px;+}diff --git a/apps/client/src/widgets/react/FormList.tsx b/apps/client/src/widgets/react/FormList.tsxindex f1fca5586c..022aeae965 100644--- a/apps/client/src/widgets/react/FormList.tsx+++ b/apps/client/src/widgets/react/FormList.tsx@@ -223,12 +223,17 @@ function FormListContent({ children, badges, description, disabled, disabledToolinterface FormListHeaderOpts {text: string;+ /** Optional element rendered right-aligned in the header (e.g. an edit action). */+ action?: ComponentChildren;}-export function FormListHeader({ text }: FormListHeaderOpts) {+export function FormListHeader({ text, action }: FormListHeaderOpts) {return (<li>- <h6 className="dropdown-header">{text}</h6>+ <h6 className={`dropdown-header ${action ? "dropdown-header-with-action" : ""}`}>+ <span>{text}</span>+ {action}+ </h6></li>);}diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsxindex 4131666d2a..73fa945eee 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx@@ -86,7 +86,12 @@ export default function ChatInputBar({onModelChange,inSidebar}: ChatInputBarProps) {- const [showAddProviderModal, setShowAddProviderModal] = useState(false);+ // Provider add/edit modal. `modalProvider` undefined = adding; a config = editing.+ // The bumping token re-keys the modal so it re-initializes its wizard on each open.+ const [modalProvider, setModalProvider] = useState<LlmProviderConfig | undefined>();+ const [modalStep, setModalStep] = useState<1 | 2>(1);+ const [modalOpen, setModalOpen] = useState(false);+ const [openToken, setOpenToken] = useState(0);const editorApiRef = useRef<CKEditorApi>();const editorInstanceRef = useRef<CKTextEditor>();// Always-fresh submit handler for the editor's enter listener.@@ -167,12 +172,29 @@ export default function ChatInputBar({}};- const handleAddProvider = useCallback(async (provider: LlmProviderConfig) => {- // Get current providers and add the new one- const currentProviders = options.getJson("llmProviders") || [];- const newProviders = [...currentProviders, provider];- await options.save("llmProviders", JSON.stringify(newProviders));- // Refresh models to pick up the new provider+ const openModal = useCallback((provider?: LlmProviderConfig, step: 1 | 2 = 1) => {+ setModalProvider(provider);+ setModalStep(step);+ setOpenToken(token => token + 1);+ setModalOpen(true);+ }, []);++ // Open the model-selection step for an existing provider (the dropdown pencil).+ const openEditModels = useCallback((providerId: string) => {+ const configs = (options.getJson("llmProviders") as LlmProviderConfig[] | null) ?? [];+ const config = configs.find(c => c.id === providerId);+ if (config) {+ openModal(config, 2);+ }+ }, [openModal]);++ // Upsert the saved provider (editing replaces by id, adding appends) and refresh the picker.+ const handleSaveProvider = useCallback(async (provider: LlmProviderConfig) => {+ const configs = (options.getJson("llmProviders") as LlmProviderConfig[] | null) ?? [];+ const next = configs.some(c => c.id === provider.id)+ ? configs.map(c => (c.id === provider.id ? provider : c))+ : [...configs, provider];+ await options.save("llmProviders", JSON.stringify(next));chat.refreshModels();}, [chat]);@@ -209,240 +231,262 @@ export default function ChatInputBar({<Buttontext={t("llm_chat.add_provider")}icon="bx bx-plus"- onClick={() => setShowAddProviderModal(true)}+ onClick={() => openModal()}/></div><AddProviderModal- show={showAddProviderModal}- onHidden={() => setShowAddProviderModal(false)}- onSave={handleAddProvider}+ key={openToken}+ show={modalOpen}+ existingProvider={modalProvider}+ initialStep={modalStep}+ onHidden={() => setModalOpen(false)}+ onSave={handleSaveProvider}/></div>);}return (- <form- className="llm-chat-input-form"- onSubmit={handleSubmit}- onDrop={attachments.handleDrop}- onDragOver={attachments.handleDragOver}- >- {chat.pendingAttachments.length > 0 && (- <div className="llm-chat-attachments">- {chat.pendingAttachments.map((att) => (- <div- key={att.attachmentId}- className={`llm-chat-attachment-chip llm-chat-attachment-chip-${att.type}`}- title={att.title}- >- {att.type === "image" ? (- <SafeImage src={att.url} alt={att.title} />- ) : (- <div className="llm-chat-attachment-file">- <span className={`bx ${att.type === "file" ? "bxs-file-pdf" : "bxs-file-blank"} llm-chat-attachment-file-icon`} />- <span className="llm-chat-attachment-file-name">{att.title}</span>- </div>- )}- <button- type="button"- className="llm-chat-attachment-remove"- title={t("llm_chat.remove_attachment")}- onClick={() => chat.removePendingAttachment(att.attachmentId)}- disabled={chat.isStreaming}+ <>+ <form+ className="llm-chat-input-form"+ onSubmit={handleSubmit}+ onDrop={attachments.handleDrop}+ onDragOver={attachments.handleDragOver}+ >+ {chat.pendingAttachments.length > 0 && (+ <div className="llm-chat-attachments">+ {chat.pendingAttachments.map((att) => (+ <div+ key={att.attachmentId}+ className={`llm-chat-attachment-chip llm-chat-attachment-chip-${att.type}`}+ title={att.title}>- <span className="bx bx-x" />- </button>- </div>- ))}- </div>- )}- <CKEditor- apiRef={editorApiRef}- className="llm-chat-input"- editor={CKEditorAttributeEditor}- config={{+ {att.type === "image" ? (+ <SafeImage src={att.url} alt={att.title} />+ ) : (+ <div className="llm-chat-attachment-file">+ <span className={`bx ${att.type === "file" ? "bxs-file-pdf" : "bxs-file-blank"} llm-chat-attachment-file-icon`} />+ <span className="llm-chat-attachment-file-name">{att.title}</span>+ </div>+ )}+ <button+ type="button"+ className="llm-chat-attachment-remove"+ title={t("llm_chat.remove_attachment")}+ onClick={() => chat.removePendingAttachment(att.attachmentId)}+ disabled={chat.isStreaming}+ >+ <span className="bx bx-x" />+ </button>+ </div>+ ))}+ </div>+ )}+ <CKEditor+ apiRef={editorApiRef}+ className="llm-chat-input"+ editor={CKEditorAttributeEditor}+ config={{// Markdown autoformatting (block quotes, code fences, lists, links) without a toolbar.- extraPlugins: CHAT_INPUT_PLUGINS,- toolbar: { items: [] },- placeholder: t("llm_chat.placeholder"),- mention: { feeds: mentionFeeds },- licenseKey: "GPL",- language: "en"- }}- onChange={(html) => {- chat.setInput(editorHtmlToMarkdown(html ?? ""));- }}- onInitialized={(editor) => {- editorInstanceRef.current = editor;- const insertNewBlock = () => {- insertNewBlockCommand(editor);- editor.editing.view.scrollToTheSelection();- };- editor.editing.view.document.on(- "enter",- (event, data) => {+ extraPlugins: CHAT_INPUT_PLUGINS,+ toolbar: { items: [] },+ placeholder: t("llm_chat.placeholder"),+ mention: { feeds: mentionFeeds },+ licenseKey: "GPL",+ language: "en"+ }}+ onChange={(html) => {+ chat.setInput(editorHtmlToMarkdown(html ?? ""));+ }}+ onInitialized={(editor) => {+ editorInstanceRef.current = editor;+ const insertNewBlock = () => {+ insertNewBlockCommand(editor);+ editor.editing.view.scrollToTheSelection();+ };+ editor.editing.view.document.on(+ "enter",+ (event, data) => {// Inside a code block, don't submit — let CodeBlock turn Enter/Shift+Enter// into newlines, so multi-line snippets can be typed.- if (isSelectionInCodeBlock(editor)) return;- // Shift+Enter builds blocks — a new list item / paragraph, or exiting an empty- // list item / code-block line — so lists and blocks can be built while plain- // Enter submits. Normally handled by the keydown keystroke below; this is a- // fallback for the rare case where the keystroke doesn't cancel the event.- if (data.isSoft) {+ if (isSelectionInCodeBlock(editor)) return;+ // Shift+Enter builds blocks — a new list item / paragraph, or exiting an empty+ // list item / code-block line — so lists and blocks can be built while plain+ // Enter submits. Normally handled by the keydown keystroke below; this is a+ // fallback for the rare case where the keystroke doesn't cancel the event.+ if (data.isSoft) {+ event.stop();+ data.preventDefault();+ insertNewBlock();+ return;+ }+ // Plain Enter submits.event.stop();data.preventDefault();- insertNewBlock();- return;- }- // Plain Enter submits.- event.stop();- data.preventDefault();- submitRef.current(new Event("submit"));- },- { priority: "high" }- );- // Shift/Ctrl/Alt+Enter all insert a new block. Bind them on keydown via keystrokes- // rather than the `enter` view event: modified Enter combos don't fire that event, and- // — crucially for Shift+Enter — CodeBlock consumes the `enter` event in its own context- // (and stops it) before our handler runs, so intercepting on keydown is the only way to- // let Shift+Enter leave a code block from its empty last line.- editor.keystrokes.set("Shift+Enter", (_keyEvtData, cancel) => { cancel(); insertNewBlock(); });- editor.keystrokes.set("Ctrl+Enter", (_keyEvtData, cancel) => { cancel(); insertNewBlock(); });- editor.keystrokes.set("Alt+Enter", (_keyEvtData, cancel) => { cancel(); insertNewBlock(); });- // Backspace at the very start of a list item leaves the list (outdent → paragraph)- // instead of CKEditor's default, which merges the item into the previous one as a- // bullet-less continuation block — confusing in a simple chat input. The list handles- // this on the `delete` view event (fired from `beforeinput`), so intercepting on the- // earlier `keydown` and cancelling suppresses that event before the list can merge.- editor.keystrokes.set("Backspace", (_keyEvtData, cancel) => {- if (outdentListItemAtStart(editor)) cancel();- });- // Capture pasted images at the DOM layer so CKEditor doesn't- // try to embed them as base64 data URLs inside the editor.- // Go through `pasteHandlerRef` so this one-time registration- // always sees the latest closure (chatNoteId arrives via a- // useEffect in the parent, after first render).- const editable = editor.editing.view.getDomRoot();- editable?.addEventListener(- "paste",- (e) => attachments.pasteHandlerRef.current(e as ClipboardEvent),- { capture: true }- );- }}- />- <input- ref={attachments.fileInputRef}- type="file"- accept={attachments.acceptAttr}- multiple- onChange={attachments.handleFilePickerChange}- style={{ display: "none" }}- />- <div className="llm-chat-options">- <div className="llm-chat-model-selector">- <span className="bx bx-chip" />- <Dropdown- text={<>{currentModel?.name}</>}- disabled={chat.isStreaming}- buttonClassName="llm-chat-model-select"- className="llm-chat-model-dropdown"- // In the sidebar the menu lives inside `.sidebar-chat-container`'s- // `overflow: hidden`, which clips the leftward-opening legacy submenu.- // Portal it to the body (with a fixed popper) so it can extend past the- // sidebar edge, matching the sidebar's other dropdowns.- portalToBody={inSidebar}- dropdownOptions={inSidebar ? { popperConfig: { strategy: "fixed" } } : undefined}- >- {chat.modelGroups.map(group => (- <Fragment key={group.id}>- <FormListHeader text={group.name} />- {group.models.length > 0 ? group.models.map(model => (- <FormListItem- key={`${model.providerId ?? model.provider}:${model.id}`}- onClick={() => handleModelSelect(model)}- checked={isSelectedModel(model)}- >- {model.name}{model.costDescription && <> <small>({model.costDescription})</small></>}- </FormListItem>- )) : (- // Provider configured before model selection existed (or with- // everything deselected): keep the group visible with a hint.- <FormListItem disabled onClick={() => {}}>- <small>{t("llm_chat.no_models_selected")}</small>- </FormListItem>- )}- </Fragment>- ))}- <FormDropdownDivider />- <FormListToggleableItem- icon="bx bx-globe"- title={t("llm_chat.web_search")}- currentValue={chat.enableWebSearch && !webSearchUnavailable}- onChange={handleWebSearchToggle}- disabled={chat.isStreaming || webSearchUnavailable}- disabledTooltip={webSearchUnavailable ? t("llm_chat.web_search_unavailable_gemini") : undefined}- />- <FormListToggleableItem- icon="bx bx-note"- title={t("llm_chat.note_tools")}- currentValue={chat.enableNoteTools}- onChange={handleNoteToolsToggle}- disabled={chat.isStreaming}- />- <FormListToggleableItem- icon="bx bx-brain"- title={t("llm_chat.extended_thinking")}- currentValue={chat.enableExtendedThinking}- onChange={handleExtendedThinkingToggle}- disabled={chat.isStreaming}- />- </Dropdown>- {activeNoteId && activeNoteTitle && (- <Button- text={activeNoteTitle}- icon={isNoteContextEnabled ? "bx-file" : "bx-hide"}- kind="lowProfile"- size="micro"- className={`llm-chat-note-context ${isNoteContextEnabled ? "active" : ""}`}- onClick={handleNoteContextToggle}+ submitRef.current(new Event("submit"));+ },+ { priority: "high" }+ );+ // Shift/Ctrl/Alt+Enter all insert a new block. Bind them on keydown via keystrokes+ // rather than the `enter` view event: modified Enter combos don't fire that event, and+ // — crucially for Shift+Enter — CodeBlock consumes the `enter` event in its own context+ // (and stops it) before our handler runs, so intercepting on keydown is the only way to+ // let Shift+Enter leave a code block from its empty last line.+ editor.keystrokes.set("Shift+Enter", (_keyEvtData, cancel) => { cancel(); insertNewBlock(); });+ editor.keystrokes.set("Ctrl+Enter", (_keyEvtData, cancel) => { cancel(); insertNewBlock(); });+ editor.keystrokes.set("Alt+Enter", (_keyEvtData, cancel) => { cancel(); insertNewBlock(); });+ // Backspace at the very start of a list item leaves the list (outdent → paragraph)+ // instead of CKEditor's default, which merges the item into the previous one as a+ // bullet-less continuation block — confusing in a simple chat input. The list handles+ // this on the `delete` view event (fired from `beforeinput`), so intercepting on the+ // earlier `keydown` and cancelling suppresses that event before the list can merge.+ editor.keystrokes.set("Backspace", (_keyEvtData, cancel) => {+ if (outdentListItemAtStart(editor)) cancel();+ });+ // Capture pasted images at the DOM layer so CKEditor doesn't+ // try to embed them as base64 data URLs inside the editor.+ // Go through `pasteHandlerRef` so this one-time registration+ // always sees the latest closure (chatNoteId arrives via a+ // useEffect in the parent, after first render).+ const editable = editor.editing.view.getDomRoot();+ editable?.addEventListener(+ "paste",+ (e) => attachments.pasteHandlerRef.current(e as ClipboardEvent),+ { capture: true }+ );+ }}+ />+ <input+ ref={attachments.fileInputRef}+ type="file"+ accept={attachments.acceptAttr}+ multiple+ onChange={attachments.handleFilePickerChange}+ style={{ display: "none" }}+ />+ <div className="llm-chat-options">+ <div className="llm-chat-model-selector">+ <span className="bx bx-chip" />+ <Dropdown+ text={<>{currentModel?.name}</>}disabled={chat.isStreaming}- title={isNoteContextEnabled- ? t("llm_chat.note_context_enabled", { title: activeNoteTitle })- : t("llm_chat.note_context_disabled")}- />- )}- {chat.lastPromptTokens > 0 && (- <div- className="llm-chat-context-indicator"- title={`${formatTokenCount(chat.lastPromptTokens)} / ${formatTokenCount(contextWindow)} ${t("llm_chat.tokens")}`}+ buttonClassName="llm-chat-model-select"+ className="llm-chat-model-dropdown"+ // In the sidebar the menu lives inside `.sidebar-chat-container`'s+ // `overflow: hidden`, which clips the leftward-opening legacy submenu.+ // Portal it to the body (with a fixed popper) so it can extend past the+ // sidebar edge, matching the sidebar's other dropdowns.+ portalToBody={inSidebar}+ dropdownOptions={inSidebar ? { popperConfig: { strategy: "fixed" } } : undefined}>- <div- className="llm-chat-context-pie"- style={{- background: `conic-gradient(${pieColor} ${percentage}%, var(--accented-background-color) ${percentage}%)`- }}+ {chat.modelGroups.map(group => (+ <Fragment key={group.id}>+ <FormListHeader+ text={group.name}+ action={+ <ActionButton+ icon="bx bx-edit"+ text={t("llm_chat.edit_models")}+ onClick={() => openEditModels(group.id)}+ />+ }+ />+ {group.models.length > 0 ? group.models.map(model => (+ <FormListItem+ key={`${model.providerId ?? model.provider}:${model.id}`}+ onClick={() => handleModelSelect(model)}+ checked={isSelectedModel(model)}+ >+ {model.name}{model.costDescription && <> <small>({model.costDescription})</small></>}+ </FormListItem>+ )) : (+ // Provider configured before model selection existed (or with+ // everything deselected): keep the group visible with a hint.+ <FormListItem disabled onClick={() => {}}>+ <small>{t("llm_chat.no_models_selected")}</small>+ </FormListItem>+ )}+ </Fragment>+ ))}+ <FormDropdownDivider />+ <FormListToggleableItem+ icon="bx bx-globe"+ title={t("llm_chat.web_search")}+ currentValue={chat.enableWebSearch && !webSearchUnavailable}+ onChange={handleWebSearchToggle}+ disabled={chat.isStreaming || webSearchUnavailable}+ disabledTooltip={webSearchUnavailable ? t("llm_chat.web_search_unavailable_gemini") : undefined}+ />+ <FormListToggleableItem+ icon="bx bx-note"+ title={t("llm_chat.note_tools")}+ currentValue={chat.enableNoteTools}+ onChange={handleNoteToolsToggle}+ disabled={chat.isStreaming}+ />+ <FormListToggleableItem+ icon="bx bx-brain"+ title={t("llm_chat.extended_thinking")}+ currentValue={chat.enableExtendedThinking}+ onChange={handleExtendedThinkingToggle}+ disabled={chat.isStreaming}+ />+ </Dropdown>+ {activeNoteId && activeNoteTitle && (+ <Button+ text={activeNoteTitle}+ icon={isNoteContextEnabled ? "bx-file" : "bx-hide"}+ kind="lowProfile"+ size="micro"+ className={`llm-chat-note-context ${isNoteContextEnabled ? "active" : ""}`}+ onClick={handleNoteContextToggle}+ disabled={chat.isStreaming}+ title={isNoteContextEnabled+ ? t("llm_chat.note_context_enabled", { title: activeNoteTitle })+ : t("llm_chat.note_context_disabled")}/>- <span className="llm-chat-context-text">{t("llm_chat.context_used", { percentage: percentage.toFixed(0) })}</span>- </div>- )}+ )}+ {chat.lastPromptTokens > 0 && (+ <div+ className="llm-chat-context-indicator"+ title={`${formatTokenCount(chat.lastPromptTokens)} / ${formatTokenCount(contextWindow)} ${t("llm_chat.tokens")}`}+ >+ <div+ className="llm-chat-context-pie"+ style={{+ background: `conic-gradient(${pieColor} ${percentage}%, var(--accented-background-color) ${percentage}%)`+ }}+ />+ <span className="llm-chat-context-text">{t("llm_chat.context_used", { percentage: percentage.toFixed(0) })}</span>+ </div>+ )}+ </div>+ <ActionButton+ icon="bx bx-paperclip"+ text={t("llm_chat.attach_file")}+ onClick={attachments.openFilePicker}+ disabled={chat.isStreaming || !chat.chatNoteId}+ className="llm-chat-attach-btn"+ />+ <ActionButton+ icon={chat.isStreaming ? "bx bx-stop" : "bx bx-send"}+ text={chat.isStreaming ? t("llm_chat.stop") : t("llm_chat.send")}+ onClick={chat.isStreaming ? chat.stopStreaming : handleSubmit}+ disabled={!chat.isStreaming && !chat.hasInputText && chat.pendingAttachments.length === 0}+ className={`llm-chat-send-btn ${chat.isStreaming ? "llm-chat-stop-btn" : ""}`}+ /></div>- <ActionButton- icon="bx bx-paperclip"- text={t("llm_chat.attach_file")}- onClick={attachments.openFilePicker}- disabled={chat.isStreaming || !chat.chatNoteId}- className="llm-chat-attach-btn"- />- <ActionButton- icon={chat.isStreaming ? "bx bx-stop" : "bx bx-send"}- text={chat.isStreaming ? t("llm_chat.stop") : t("llm_chat.send")}- onClick={chat.isStreaming ? chat.stopStreaming : handleSubmit}- disabled={!chat.isStreaming && !chat.hasInputText && chat.pendingAttachments.length === 0}- className={`llm-chat-send-btn ${chat.isStreaming ? "llm-chat-stop-btn" : ""}`}- />- </div>- </form>+ </form>+ <AddProviderModal+ key={openToken}+ show={modalOpen}+ existingProvider={modalProvider}+ initialStep={modalStep}+ onHidden={() => setModalOpen(false)}+ onSave={handleSaveProvider}+ />+ </>);}diff --git a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsxindex ec87aa5e25..4529951cd8 100644--- a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx+++ b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx@@ -69,12 +69,14 @@ interface AddProviderModalProps {onSave: (provider: LlmProviderConfig) => void;/** When provided, the modal edits this provider in place instead of adding a new one. */existingProvider?: LlmProviderConfig;+ /** Step to open on. Pass 2 to jump straight to model selection (e.g. editing from the chat picker). */+ initialStep?: 1 | 2;}-export default function AddProviderModal({ show, onHidden, onSave, existingProvider }: AddProviderModalProps) {+export default function AddProviderModal({ show, onHidden, onSave, existingProvider, initialStep = 1 }: AddProviderModalProps) {const isEdit = !!existingProvider;// Connection details first, then model selection. Editing keeps the same two steps.- const [step, setStep] = useState<1 | 2>(1);+ const [step, setStep] = useState<1 | 2>(initialStep);const [selectedProvider, setSelectedProvider] = useState(existingProvider?.provider ?? PROVIDER_TYPES[0].id);const [apiKey, setApiKey] = useState(existingProvider?.apiKey ?? "");const [baseUrl, setBaseUrl] = useState(existingProvider?.baseURL ?? "");@@ -97,7 +99,7 @@ export default function AddProviderModal({ show, onHidden, onSave, existingProvi);function reset() {- setStep(1);+ setStep(initialStep);setSelectedProvider(existingProvider?.provider ?? PROVIDER_TYPES[0].id);setApiKey(existingProvider?.apiKey ?? "");setBaseUrl(existingProvider?.baseURL ?? "");