mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 00:54:23 +00:00
Add auto restart configuration fields to InstanceModal and zodFormUtils
This commit is contained in:
@@ -109,6 +109,9 @@ const InstanceModal: React.FC<InstanceModalProps> = ({
|
|||||||
setShowAdvanced(!showAdvanced)
|
setShowAdvanced(!showAdvanced)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if auto_restart is enabled
|
||||||
|
const isAutoRestartEnabled = formData.auto_restart === true
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogContent className="sm:max-w-[600px] max-h-[80vh] overflow-hidden flex flex-col">
|
<DialogContent className="sm:max-w-[600px] max-h-[80vh] overflow-hidden flex flex-col">
|
||||||
@@ -146,10 +149,40 @@ const InstanceModal: React.FC<InstanceModalProps> = ({
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Basic Fields - Automatically generated from type */}
|
{/* Auto Restart Configuration Section */}
|
||||||
|
<div className="space-y-4">
|
||||||
|
<h3 className="text-lg font-medium">Auto Restart Configuration</h3>
|
||||||
|
|
||||||
|
{/* Auto Restart Toggle */}
|
||||||
|
<ZodFormField
|
||||||
|
fieldKey="auto_restart"
|
||||||
|
value={formData.auto_restart}
|
||||||
|
onChange={handleFieldChange}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Show restart options only when auto restart is enabled */}
|
||||||
|
{isAutoRestartEnabled && (
|
||||||
|
<div className="ml-6 space-y-4 border-l-2 border-muted pl-4">
|
||||||
|
<ZodFormField
|
||||||
|
fieldKey="max_restarts"
|
||||||
|
value={formData.max_restarts}
|
||||||
|
onChange={handleFieldChange}
|
||||||
|
/>
|
||||||
|
<ZodFormField
|
||||||
|
fieldKey="restart_delay"
|
||||||
|
value={formData.restart_delay}
|
||||||
|
onChange={handleFieldChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Basic Fields - Automatically generated from type (excluding auto restart options) */}
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<h3 className="text-lg font-medium">Basic Configuration</h3>
|
<h3 className="text-lg font-medium">Basic Configuration</h3>
|
||||||
{basicFields.map((fieldKey) => (
|
{basicFields
|
||||||
|
.filter(fieldKey => fieldKey !== 'auto_restart') // Exclude auto_restart as it's handled above
|
||||||
|
.map((fieldKey) => (
|
||||||
<ZodFormField
|
<ZodFormField
|
||||||
key={fieldKey}
|
key={fieldKey}
|
||||||
fieldKey={fieldKey}
|
fieldKey={fieldKey}
|
||||||
@@ -173,16 +206,19 @@ const InstanceModal: React.FC<InstanceModalProps> = ({
|
|||||||
)}
|
)}
|
||||||
Advanced Configuration
|
Advanced Configuration
|
||||||
<span className="text-muted-foreground text-sm font-normal">
|
<span className="text-muted-foreground text-sm font-normal">
|
||||||
({advancedFields.length} options)
|
({advancedFields.filter(f => !['max_restarts', 'restart_delay'].includes(f as string)).length} options)
|
||||||
</span>
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Advanced Fields - Automatically generated from type */}
|
{/* Advanced Fields - Automatically generated from type (excluding restart options) */}
|
||||||
{showAdvanced && (
|
{showAdvanced && (
|
||||||
<div className="space-y-4 pl-6 border-l-2 border-muted">
|
<div className="space-y-4 pl-6 border-l-2 border-muted">
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{advancedFields.sort().map((fieldKey) => (
|
{advancedFields
|
||||||
|
.filter(fieldKey => !['max_restarts', 'restart_delay'].includes(fieldKey as string)) // Exclude restart options as they're handled above
|
||||||
|
.sort()
|
||||||
|
.map((fieldKey) => (
|
||||||
<ZodFormField
|
<ZodFormField
|
||||||
key={fieldKey}
|
key={fieldKey}
|
||||||
fieldKey={fieldKey}
|
fieldKey={fieldKey}
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ export const basicFieldsConfig: Record<string, {
|
|||||||
label: 'Auto Restart',
|
label: 'Auto Restart',
|
||||||
description: 'Automatically restart the instance on failure'
|
description: 'Automatically restart the instance on failure'
|
||||||
},
|
},
|
||||||
|
max_restarts: {
|
||||||
|
label: 'Max Restarts',
|
||||||
|
placeholder: '3',
|
||||||
|
description: 'Maximum number of restart attempts (0 = unlimited)'
|
||||||
|
},
|
||||||
|
restart_delay: {
|
||||||
|
label: 'Restart Delay (seconds)',
|
||||||
|
placeholder: '5',
|
||||||
|
description: 'Delay in seconds before attempting restart'
|
||||||
|
},
|
||||||
model: {
|
model: {
|
||||||
label: 'Model Path',
|
label: 'Model Path',
|
||||||
placeholder: '/path/to/model.gguf',
|
placeholder: '/path/to/model.gguf',
|
||||||
|
|||||||
Reference in New Issue
Block a user