Merge branch 'feat/mcp-frontend' into deploy/dev

This commit is contained in:
Joel 2025-06-03 10:46:52 +08:00
commit c27af0dd7d
3 changed files with 11 additions and 5 deletions

View File

@ -143,9 +143,9 @@ const ReasoningConfigForm: React.FC<Props> = ({
}] = useBoolean(false) }] = useBoolean(false)
const [schema, setSchema] = useState<SchemaRoot | null>(null) const [schema, setSchema] = useState<SchemaRoot | null>(null)
console.log(schema) const [schemaRootName, setSchemaRootName] = useState<string>('')
const renderField = (schema: any, showSchema: (schema: SchemaRoot) => void) => { const renderField = (schema: any, showSchema: (schema: SchemaRoot, rootName: string) => void) => {
const { const {
variable, variable,
label, label,
@ -205,7 +205,7 @@ const ReasoningConfigForm: React.FC<Props> = ({
asChild={false}> asChild={false}>
<div <div
className='ml-0.5 cursor-pointer rounded-[4px] p-px text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary' className='ml-0.5 cursor-pointer rounded-[4px] p-px text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary'
onClick={() => showSchema(input_schema as SchemaRoot)} onClick={() => showSchema(input_schema as SchemaRoot, label[language] || label.en_US)}
> >
<RiBracesLine className='size-3.5'/> <RiBracesLine className='size-3.5'/>
</div> </div>
@ -318,14 +318,16 @@ const ReasoningConfigForm: React.FC<Props> = ({
} }
return ( return (
<div className='space-y-3 px-4 py-2'> <div className='space-y-3 px-4 py-2'>
{!isShowSchema && schemas.map(schema => renderField(schema, (s: SchemaRoot) => { {!isShowSchema && schemas.map(schema => renderField(schema, (s: SchemaRoot, rootName: string) => {
setSchema(s) setSchema(s)
setSchemaRootName(rootName)
showSchema() showSchema()
}))} }))}
{isShowSchema && ( {isShowSchema && (
<SchemaModal <SchemaModal
isShow={isShowSchema} isShow={isShowSchema}
schema={schema!} schema={schema!}
rootName={schemaRootName}
onClose={hideSchema} onClose={hideSchema}
/> />
)} )}

View File

@ -11,12 +11,14 @@ import { RiCloseLine } from '@remixicon/react'
type Props = { type Props = {
isShow: boolean isShow: boolean
schema: SchemaRoot schema: SchemaRoot
rootName: string
onClose: () => void onClose: () => void
} }
const SchemaModal: FC<Props> = ({ const SchemaModal: FC<Props> = ({
isShow, isShow,
schema, schema,
rootName,
onClose, onClose,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
@ -43,6 +45,7 @@ const SchemaModal: FC<Props> = ({
<VisualEditorContextProvider> <VisualEditorContextProvider>
<VisualEditor <VisualEditor
schema={schema} schema={schema}
rootName={rootName}
readOnly readOnly
></VisualEditor> ></VisualEditor>
</VisualEditorContextProvider> </VisualEditorContextProvider>

View File

@ -5,6 +5,7 @@ import { useSchemaNodeOperations } from './hooks'
export type VisualEditorProps = { export type VisualEditorProps = {
schema: SchemaRoot schema: SchemaRoot
rootName?: string
readOnly?: boolean readOnly?: boolean
onChange?: (schema: SchemaRoot) => void onChange?: (schema: SchemaRoot) => void
} }
@ -16,7 +17,7 @@ const VisualEditor: FC<VisualEditorProps> = (props) => {
return ( return (
<div className='h-full overflow-auto rounded-xl bg-background-section-burn p-1 pl-2'> <div className='h-full overflow-auto rounded-xl bg-background-section-burn p-1 pl-2'>
<SchemaNode <SchemaNode
name='structured_output' name={props.rootName || 'structured_output'}
schema={schema} schema={schema}
required={false} required={false}
path={[]} path={[]}