From 848a91313dc27afccc6e96f32b70b09c0e1d6763 Mon Sep 17 00:00:00 2001 From: sabaimran Date: Wed, 12 Feb 2025 19:24:02 -0800 Subject: [PATCH] Move the create agent button to the bottom of the sidebar and fix experience when resetting settings --- .../web/app/common/modelSelector.tsx | 9 + .../components/chatSidebar/chatSidebar.tsx | 277 +++++++++--------- 2 files changed, 151 insertions(+), 135 deletions(-) diff --git a/src/interface/web/app/common/modelSelector.tsx b/src/interface/web/app/common/modelSelector.tsx index 0ea573c6..beacdbdc 100644 --- a/src/interface/web/app/common/modelSelector.tsx +++ b/src/interface/web/app/common/modelSelector.tsx @@ -67,6 +67,15 @@ export function ModelSelector({ ...props }: ModelSelectorProps) { const model = models.find(model => model.name === props.selectedModel); setSelectedModel(model); } + else if (props.selectedModel === null && userConfig) { + const selectedChatModelOption = userConfig.chat_model_options.find(model => model.id === userConfig.selected_chat_model_config); + if (!selectedChatModelOption) { + props.onSelect(userConfig.chat_model_options[0], false); + return; + } else { + props.onSelect(selectedChatModelOption, false); + } + } }, [props.selectedModel, models]); useEffect(() => { diff --git a/src/interface/web/app/components/chatSidebar/chatSidebar.tsx b/src/interface/web/app/components/chatSidebar/chatSidebar.tsx index 0775abba..69479f89 100644 --- a/src/interface/web/app/components/chatSidebar/chatSidebar.tsx +++ b/src/interface/web/app/components/chatSidebar/chatSidebar.tsx @@ -145,8 +145,8 @@ function AgentCreationForm(props: IAgentCreationProps) { @@ -166,131 +166,131 @@ function AgentCreationForm(props: IAgentCreationProps) { } -
- { - doneCreating && createdSlug ? ( -
- - - - - Created successfully! - - - - - - -
- ) : -
-
- - setCustomAgentName(e.target.value)} - /> +
+ { + doneCreating && createdSlug ? ( +
+ + + + + Created successfully! + + + + + +
-
-
- + ) : +
+
+ + setCustomAgentName(e.target.value)} + />
-
- +
+
+ +
+
+ +
-
- } -
- - { - error && ( -
- {error} -
- ) - } - { - !doneCreating && ( - - ) - } - -
- + } +
+ + { + error && ( +
+ {error} +
+ ) + } + { + !doneCreating && ( + + ) + } + +
+
) @@ -317,6 +317,8 @@ function ChatSidebarInternal({ ...props }: ChatSideBarProps) { const [isSaving, setIsSaving] = useState(false); + const isSubscribed = authenticatedData?.is_active ?? false; + function setupAgentData() { if (agentData) { setInputTools(agentData.input_tools); @@ -456,16 +458,6 @@ function ChatSidebarInternal({ ...props }: ChatSideBarProps) {

Chat Options

- { - isEditable && customPrompt && !isDefaultAgent && selectedModel && ( - - ) - } ) } @@ -508,7 +500,7 @@ function ChatSidebarInternal({ ...props }: ChatSideBarProps) { Model { - !authenticatedData?.is_active && ( + !isSubscribed && ( Upgrade @@ -518,7 +510,7 @@ function ChatSidebarInternal({ ...props }: ChatSideBarProps) { handleModelSelect(model.name, userModification)} initialModel={isDefaultAgent ? undefined : agentData?.chat_model} selectedModel={selectedModel} @@ -647,6 +639,20 @@ function ChatSidebarInternal({ ...props }: ChatSideBarProps) { ) : <> + { + !hasModified && isEditable && customPrompt && !isDefaultAgent && selectedModel && ( + + + + + + ) + }