Merge pull request #6493 from menloresearch/fix/edit-dialog
chore: prevent click outside for edit dialog
This commit is contained in:
commit
b4fd7c300a
@ -236,7 +236,11 @@ export default function AddEditAssistant({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogContent>
|
<DialogContent
|
||||||
|
onInteractOutside={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
}}
|
||||||
|
>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>
|
<DialogTitle>
|
||||||
{editingKey
|
{editingKey
|
||||||
|
|||||||
@ -303,11 +303,16 @@ export default function AddEditMCPServer({
|
|||||||
const serverConfig = config as MCPServerConfig
|
const serverConfig = config as MCPServerConfig
|
||||||
|
|
||||||
// Validate type field if present
|
// Validate type field if present
|
||||||
if (serverConfig.type && !['stdio', 'http', 'sse'].includes(serverConfig.type)) {
|
if (
|
||||||
setError(t('mcp-servers:editJson.errorInvalidType', {
|
serverConfig.type &&
|
||||||
|
!['stdio', 'http', 'sse'].includes(serverConfig.type)
|
||||||
|
) {
|
||||||
|
setError(
|
||||||
|
t('mcp-servers:editJson.errorInvalidType', {
|
||||||
serverName: trimmedServerName,
|
serverName: trimmedServerName,
|
||||||
type: serverConfig.type
|
type: serverConfig.type,
|
||||||
}))
|
})
|
||||||
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +371,12 @@ export default function AddEditMCPServer({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogContent showCloseButton={false}>
|
<DialogContent
|
||||||
|
showCloseButton={false}
|
||||||
|
onInteractOutside={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
}}
|
||||||
|
>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle className="flex items-center justify-between">
|
<DialogTitle className="flex items-center justify-between">
|
||||||
<span>
|
<span>
|
||||||
|
|||||||
@ -61,7 +61,11 @@ export default function EditJsonMCPserver({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogContent>
|
<DialogContent
|
||||||
|
onInteractOutside={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
}}
|
||||||
|
>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>
|
<DialogTitle>
|
||||||
{serverName
|
{serverName
|
||||||
|
|||||||
@ -44,10 +44,8 @@ export const ImportVisionModelDialog = ({
|
|||||||
>(null)
|
>(null)
|
||||||
const [isValidatingMmproj, setIsValidatingMmproj] = useState(false)
|
const [isValidatingMmproj, setIsValidatingMmproj] = useState(false)
|
||||||
|
|
||||||
const validateGgufFile = useCallback(async (
|
const validateGgufFile = useCallback(
|
||||||
filePath: string,
|
async (filePath: string, fileType: 'model' | 'mmproj'): Promise<void> => {
|
||||||
fileType: 'model' | 'mmproj'
|
|
||||||
): Promise<void> => {
|
|
||||||
if (fileType === 'model') {
|
if (fileType === 'model') {
|
||||||
setIsValidating(true)
|
setIsValidating(true)
|
||||||
setValidationError(null)
|
setValidationError(null)
|
||||||
@ -98,10 +96,12 @@ export const ImportVisionModelDialog = ({
|
|||||||
// Import the readGgufMetadata function directly from Tauri
|
// Import the readGgufMetadata function directly from Tauri
|
||||||
const { invoke } = await import('@tauri-apps/api/core')
|
const { invoke } = await import('@tauri-apps/api/core')
|
||||||
|
|
||||||
const metadata = await invoke('plugin:llamacpp|read_gguf_metadata', {
|
const metadata = await invoke(
|
||||||
|
'plugin:llamacpp|read_gguf_metadata',
|
||||||
|
{
|
||||||
path: filePath,
|
path: filePath,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
// Check if architecture matches expected type
|
// Check if architecture matches expected type
|
||||||
const architecture = (
|
const architecture = (
|
||||||
@ -135,9 +135,14 @@ export const ImportVisionModelDialog = ({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (directError) {
|
} catch (directError) {
|
||||||
console.error('Failed to validate mmproj file directly:', directError)
|
console.error(
|
||||||
|
'Failed to validate mmproj file directly:',
|
||||||
|
directError
|
||||||
|
)
|
||||||
const errorMessage = `Failed to read MMProj metadata: ${
|
const errorMessage = `Failed to read MMProj metadata: ${
|
||||||
directError instanceof Error ? directError.message : 'Unknown error'
|
directError instanceof Error
|
||||||
|
? directError.message
|
||||||
|
: 'Unknown error'
|
||||||
}`
|
}`
|
||||||
setMmprojValidationError(errorMessage)
|
setMmprojValidationError(errorMessage)
|
||||||
}
|
}
|
||||||
@ -158,15 +163,23 @@ export const ImportVisionModelDialog = ({
|
|||||||
setIsValidatingMmproj(false)
|
setIsValidatingMmproj(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [modelName, serviceHub])
|
},
|
||||||
|
[modelName, serviceHub]
|
||||||
|
)
|
||||||
|
|
||||||
const validateModelFile = useCallback(async (filePath: string): Promise<void> => {
|
const validateModelFile = useCallback(
|
||||||
|
async (filePath: string): Promise<void> => {
|
||||||
await validateGgufFile(filePath, 'model')
|
await validateGgufFile(filePath, 'model')
|
||||||
}, [validateGgufFile])
|
},
|
||||||
|
[validateGgufFile]
|
||||||
|
)
|
||||||
|
|
||||||
const validateMmprojFile = useCallback(async (filePath: string): Promise<void> => {
|
const validateMmprojFile = useCallback(
|
||||||
|
async (filePath: string): Promise<void> => {
|
||||||
await validateGgufFile(filePath, 'mmproj')
|
await validateGgufFile(filePath, 'mmproj')
|
||||||
}, [validateGgufFile])
|
},
|
||||||
|
[validateGgufFile]
|
||||||
|
)
|
||||||
|
|
||||||
const handleFileSelect = async (type: 'model' | 'mmproj') => {
|
const handleFileSelect = async (type: 'model' | 'mmproj') => {
|
||||||
const selectedFile = await serviceHub.dialog().open({
|
const selectedFile = await serviceHub.dialog().open({
|
||||||
@ -291,7 +304,11 @@ export const ImportVisionModelDialog = ({
|
|||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||||
<DialogTrigger asChild>{trigger}</DialogTrigger>
|
<DialogTrigger asChild>{trigger}</DialogTrigger>
|
||||||
<DialogContent>
|
<DialogContent
|
||||||
|
onInteractOutside={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
}}
|
||||||
|
>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle className="flex items-center gap-2">
|
<DialogTitle className="flex items-center gap-2">
|
||||||
Import Model
|
Import Model
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user