From c661b997c516a5a05eaae2c32b76b12ab3a9fb64 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Sun, 8 Sep 2024 16:09:17 +0800 Subject: [PATCH] feat: Edit assistant settings with real-time sync. - Added support for editing an assistant's settings with real-time synchronization to the agent. --- src/renderer/src/pages/home/Navbar.tsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/renderer/src/pages/home/Navbar.tsx b/src/renderer/src/pages/home/Navbar.tsx index 70705698ce..a68c850204 100644 --- a/src/renderer/src/pages/home/Navbar.tsx +++ b/src/renderer/src/pages/home/Navbar.tsx @@ -7,9 +7,10 @@ import { useTheme } from '@renderer/context/ThemeProvider' import { useAssistant } from '@renderer/hooks/useAssistant' import { useSettings } from '@renderer/hooks/useSettings' import { useShowAssistants, useShowTopics } from '@renderer/hooks/useStore' +import { syncAsistantToAgent } from '@renderer/services/assistant' import { Assistant, Topic } from '@renderer/types' import { Switch } from 'antd' -import { FC } from 'react' +import { FC, useCallback } from 'react' import styled from 'styled-components' import SelectModelButton from './components/SelectModelButton' @@ -21,7 +22,7 @@ interface Props { } const HeaderNavbar: FC = ({ activeAssistant, setActiveAssistant }) => { - const { assistant } = useAssistant(activeAssistant.id) + const { assistant, updateAssistant } = useAssistant(activeAssistant.id) const { showAssistants, toggleShowAssistants } = useShowAssistants() const { theme, toggleTheme } = useTheme() const { topicPosition } = useSettings() @@ -32,6 +33,15 @@ const HeaderNavbar: FC = ({ activeAssistant, setActiveAssistant }) => { assistant && setActiveAssistant(assistant) } + const onEditAssistant = useCallback( + async (assistant: Assistant) => { + const _assistant = await AssistantSettingPopup.show({ assistant }) + updateAssistant(_assistant) + syncAsistantToAgent(_assistant) + }, + [updateAssistant] + ) + return ( {showAssistants && ( @@ -59,10 +69,7 @@ const HeaderNavbar: FC = ({ activeAssistant, setActiveAssistant }) => { )} - AssistantSettingPopup.show({ assistant })}> + {assistant.name}