diff --git a/src/renderer/src/pages/settings/AgentSettings/AgentEssentialSettings.tsx b/src/renderer/src/pages/settings/AgentSettings/AgentEssentialSettings.tsx index e06b5a5ac8..ba18763d7c 100644 --- a/src/renderer/src/pages/settings/AgentSettings/AgentEssentialSettings.tsx +++ b/src/renderer/src/pages/settings/AgentSettings/AgentEssentialSettings.tsx @@ -5,8 +5,7 @@ import { Input } from 'antd' import { FC, useState } from 'react' import { useTranslation } from 'react-i18next' -import { SettingDivider } from '..' -import { AgentLabel, SettingsInline, SettingsTitle } from './shared' +import { AgentLabel, SettingsContainer, SettingsItem, SettingsTitle } from './shared' interface AgentEssentialSettingsProps { agent: AgentEntity | undefined | null @@ -26,27 +25,28 @@ const AgentEssentialSettings: FC = ({ agent, update if (!agent) return null return ( -
- + + {t('agent.type.label')} - - - {t('common.name')} - - setName(e.target.value)} - onBlur={() => { - if (name !== agent.name) { - onUpdate() - } - }} - style={{ flex: 1 }} - /> - -
+ + + {t('common.name')} + + setName(e.target.value)} + onBlur={() => { + if (name !== agent.name) { + onUpdate() + } + }} + style={{ flex: 1 }} + /> + + + ) } diff --git a/src/renderer/src/pages/settings/AgentSettings/AgentPromptSettings.tsx b/src/renderer/src/pages/settings/AgentSettings/AgentPromptSettings.tsx index db58e6ba6c..9cf6478f0d 100644 --- a/src/renderer/src/pages/settings/AgentSettings/AgentPromptSettings.tsx +++ b/src/renderer/src/pages/settings/AgentSettings/AgentPromptSettings.tsx @@ -12,7 +12,7 @@ import { useTranslation } from 'react-i18next' import ReactMarkdown from 'react-markdown' import styled from 'styled-components' -import { SettingsTitle } from './shared' +import { SettingsContainer, SettingsItem, SettingsTitle } from './shared' interface AgentPromptSettingsProps { agent: AgentEntity | undefined | null @@ -51,70 +51,65 @@ const AgentPromptSettings: FC = ({ agent, update }) => if (!agent) return null return ( - - - {t('common.prompt')} - - - - - - - {showPreview ? ( - { - const currentScrollTop = editorRef.current?.getScrollTop?.() || 0 + + + + {t('common.prompt')} + + + + + + + {showPreview ? ( + { + const currentScrollTop = editorRef.current?.getScrollTop?.() || 0 + setShowPreview(false) + requestAnimationFrame(() => editorRef.current?.setScrollTop?.(currentScrollTop)) + }}> + {processedPrompt || instructions} + + ) : ( + + )} + + + + Tokens: {tokenCount} + - - + } else { + onUpdate() + requestAnimationFrame(() => { + setShowPreview(true) + requestAnimationFrame(() => editorRef.current?.setScrollTop?.(currentScrollTop)) + }) + } + }}> + {showPreview ? t('common.edit') : t('common.save')} + + + + ) } -const Container = styled.div` - display: flex; - flex: 1; - flex-direction: column; - overflow: hidden; -` - const TextAreaContainer = styled.div` position: relative; width: 100%; diff --git a/src/renderer/src/pages/settings/AgentSettings/shared.tsx b/src/renderer/src/pages/settings/AgentSettings/shared.tsx index 6ca583db65..a570c82036 100644 --- a/src/renderer/src/pages/settings/AgentSettings/shared.tsx +++ b/src/renderer/src/pages/settings/AgentSettings/shared.tsx @@ -4,14 +4,12 @@ import { getAgentTypeLabel } from '@renderer/i18n/label' import { AgentType } from '@renderer/types' import React from 'react' +import { SettingDivider } from '..' + export const SettingsTitle: React.FC = ({ children }) => { return
{children}
} -export const SettingsInline: React.FC = ({ children }) => { - return
{children}
-} - export type AgentLabelProps = { type: AgentType name?: string @@ -31,3 +29,37 @@ export const AgentLabel: React.FC = ({ type, name, classNames, ) } + +export interface SettingsItemProps extends React.ComponentPropsWithRef<'div'> { + /** Add a divider beneath the item if true, defaults to true. */ + divider?: boolean + /** Apply row direction flex or not, defaults to false. */ + inline?: boolean +} + +export const SettingsItem: React.FC = ({ + children, + divider = true, + inline = false, + className, + ...props +}) => { + return ( + <> +
+ {children} +
+ {divider && } + + ) +} + +export const SettingsContainer: React.FC> = ({ children, className, ...props }) => { + return ( +
+ {children} +
+ ) +}