diff --git a/frontend/src/components/settings/AgentDialog.tsx b/frontend/src/components/settings/AgentDialog.tsx
index 5acfcaee..df47e09e 100644
--- a/frontend/src/components/settings/AgentDialog.tsx
+++ b/frontend/src/components/settings/AgentDialog.tsx
@@ -1,7 +1,7 @@
import { useForm } from 'react-hook-form'
import { zodResolver } from '@hookform/resolvers/zod'
import { z } from 'zod'
-import { useMemo } from 'react'
+import { useMemo, useEffect } from 'react'
import { useQuery } from '@tanstack/react-query'
import { Button } from '@/components/ui/button'
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'
@@ -66,8 +66,6 @@ interface AgentDialogProps {
}
export function AgentDialog({ open, onOpenChange, onSubmit, editingAgent }: AgentDialogProps) {
- const parsedModel = parseModelString(editingAgent?.agent.model)
-
const { data: providers = [] } = useQuery({
queryKey: ['providers-with-models'],
queryFn: () => getProvidersWithModels(),
@@ -89,28 +87,39 @@ export function AgentDialog({ open, onOpenChange, onSubmit, editingAgent }: Agen
}))
}, [providers])
+ const getDefaultValues = (agent?: { name: string; agent: Agent } | null): AgentFormValues => {
+ const parsed = parseModelString(agent?.agent.model)
+ return {
+ name: agent?.name || '',
+ description: agent?.agent.description || '',
+ prompt: agent?.agent.prompt || '',
+ mode: agent?.agent.mode || 'subagent',
+ temperature: agent?.agent.temperature ?? 0.7,
+ topP: agent?.agent.topP ?? agent?.agent.top_p ?? 1,
+ modelId: parsed.modelId,
+ providerId: parsed.providerId,
+ write: agent?.agent.tools?.write ?? true,
+ edit: agent?.agent.tools?.edit ?? true,
+ bash: agent?.agent.tools?.bash ?? true,
+ webfetch: agent?.agent.tools?.webfetch ?? true,
+ editPermission: agent?.agent.permission?.edit ?? 'allow',
+ bashPermission: typeof agent?.agent.permission?.bash === 'string' ? agent.agent.permission.bash : 'allow',
+ webfetchPermission: agent?.agent.permission?.webfetch ?? 'allow',
+ disable: agent?.agent.disable ?? false
+ }
+ }
+
const form = useForm
({
resolver: zodResolver(agentFormSchema),
- defaultValues: {
- name: editingAgent?.name || '',
- description: editingAgent?.agent.description || '',
- prompt: editingAgent?.agent.prompt || '',
- mode: editingAgent?.agent.mode || 'subagent',
- temperature: editingAgent?.agent.temperature ?? 0.7,
- topP: editingAgent?.agent.topP ?? editingAgent?.agent.top_p ?? 1,
- modelId: parsedModel.modelId,
- providerId: parsedModel.providerId,
- write: editingAgent?.agent.tools?.write ?? true,
- edit: editingAgent?.agent.tools?.edit ?? true,
- bash: editingAgent?.agent.tools?.bash ?? true,
- webfetch: editingAgent?.agent.tools?.webfetch ?? true,
- editPermission: editingAgent?.agent.permission?.edit ?? 'allow',
- bashPermission: typeof editingAgent?.agent.permission?.bash === 'string' ? editingAgent.agent.permission.bash : 'allow',
- webfetchPermission: editingAgent?.agent.permission?.webfetch ?? 'allow',
- disable: editingAgent?.agent.disable ?? false
- }
+ defaultValues: getDefaultValues(editingAgent)
})
+ useEffect(() => {
+ if (open) {
+ form.reset(getDefaultValues(editingAgent))
+ }
+ }, [open, editingAgent, form])
+
const selectedProviderId = form.watch('providerId')
const modelOptions: ComboboxOption[] = useMemo(() => {
diff --git a/frontend/src/components/settings/AgentsMdEditor.tsx b/frontend/src/components/settings/AgentsMdEditor.tsx
index 32a10eb8..461e2e15 100644
--- a/frontend/src/components/settings/AgentsMdEditor.tsx
+++ b/frontend/src/components/settings/AgentsMdEditor.tsx
@@ -27,6 +27,7 @@ export function AgentsMdEditor() {
mutationFn: (newContent: string) => settingsApi.updateAgentsMd(newContent),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['agents-md'] })
+ queryClient.invalidateQueries({ queryKey: ['opencode', 'agents'] })
setHasChanges(false)
showToast.success('AGENTS.md saved and server restarted')
},
diff --git a/frontend/src/components/settings/OpenCodeConfigManager.tsx b/frontend/src/components/settings/OpenCodeConfigManager.tsx
index 989e602a..eaf9e4c1 100644
--- a/frontend/src/components/settings/OpenCodeConfigManager.tsx
+++ b/frontend/src/components/settings/OpenCodeConfigManager.tsx
@@ -1,5 +1,5 @@
import { useState, useEffect, useRef } from 'react'
-import { Loader2, Plus, Trash2, Edit, Star, StarOff, Download, RotateCcw, FileText, ArrowUpCircle } from 'lucide-react'
+import { Loader2, Plus, Trash2, Edit, Star, StarOff, Download, RotateCcw, FileText, ArrowUpCircle, History } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { Label } from '@/components/ui/label'
@@ -12,6 +12,7 @@ import { CommandsEditor } from './CommandsEditor'
import { AgentsEditor } from './AgentsEditor'
import { AgentsMdEditor } from './AgentsMdEditor'
import { McpManager } from './McpManager'
+import { VersionSelectDialog } from './VersionSelectDialog'
import { settingsApi } from '@/api/settings'
import { useMutation, useQueryClient } from '@tanstack/react-query'
import { useServerHealth } from '@/hooks/useServerHealth'
@@ -62,6 +63,7 @@ export function OpenCodeConfigManager() {
})
const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false)
const [isEditDialogOpen, setIsEditDialogOpen] = useState(false)
+ const [isVersionDialogOpen, setIsVersionDialogOpen] = useState(false)
const [deleteConfirmConfig, setDeleteConfirmConfig] = useState(null)
const agentsMdRef = useRef(null)
@@ -127,21 +129,6 @@ export function OpenCodeConfigManager() {
return getApiErrorMessage(error, 'Failed to restart OpenCode server')
}
- const rollbackMutation = useMutation({
- mutationFn: async () => {
- return await settingsApi.rollbackOpenCodeConfig()
- },
- onSuccess: (data) => {
- queryClient.invalidateQueries({ queryKey: ['opencode', 'agents'] })
- queryClient.invalidateQueries({ queryKey: ['settings'] })
- showToast.success(data.message, { id: 'rollback-config' })
- fetchConfigs()
- },
- onError: () => {
- showToast.error('Failed to rollback to previous config', { id: 'rollback-config' })
- },
- })
-
const fetchConfigs = async () => {
try {
setIsLoading(true)
@@ -385,18 +372,10 @@ export function OpenCodeConfigManager() {
+
+
{configs.length === 0 ? (
diff --git a/frontend/src/components/settings/VersionSelectDialog.tsx b/frontend/src/components/settings/VersionSelectDialog.tsx
new file mode 100644
index 00000000..b9349b89
--- /dev/null
+++ b/frontend/src/components/settings/VersionSelectDialog.tsx
@@ -0,0 +1,147 @@
+import { useState } from 'react'
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
+import { Loader2, Check, Download } from 'lucide-react'
+import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '@/components/ui/dialog'
+import { Button } from '@/components/ui/button'
+import { settingsApi } from '@/api/settings'
+import { showToast } from '@/lib/toast'
+
+interface VersionSelectDialogProps {
+ open: boolean
+ onOpenChange: (open: boolean) => void
+}
+
+export function VersionSelectDialog({ open, onOpenChange }: VersionSelectDialogProps) {
+ const queryClient = useQueryClient()
+ const [selectedVersion, setSelectedVersion] = useState(null)
+
+ const { data, isLoading, error } = useQuery({
+ queryKey: ['opencode-versions'],
+ queryFn: () => settingsApi.getOpenCodeVersions(),
+ enabled: open,
+ staleTime: 60000,
+ })
+
+ const installMutation = useMutation({
+ mutationFn: (version: string) => settingsApi.installOpenCodeVersion(version),
+ onSuccess: (result) => {
+ queryClient.invalidateQueries({ queryKey: ['opencode-versions'] })
+ queryClient.invalidateQueries({ queryKey: ['server-health'] })
+ showToast.success(result.message)
+ onOpenChange(false)
+ },
+ onError: () => {
+ showToast.error('Failed to install version')
+ },
+ })
+
+ const handleInstall = () => {
+ if (!selectedVersion) return
+ showToast.loading(`Installing OpenCode v${selectedVersion}...`, { id: 'install-version' })
+ installMutation.mutate(selectedVersion, {
+ onSettled: () => {
+ showToast.dismiss('install-version')
+ }
+ })
+ }
+
+ const formatDate = (dateString: string) => {
+ return new Date(dateString).toLocaleDateString(undefined, {
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric'
+ })
+ }
+
+ return (
+
+ )
+}
diff --git a/package.json b/package.json
index 35cf6699..a74f1f5e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "opencode-manager",
- "version": "0.7.3",
+ "version": "0.7.4",
"private": false,
"type": "module",
"packageManager": "pnpm@9.15.0",