Fix CreateConfigDialog event propagation and mobile scrolling

This commit is contained in:
Chris Scott committed 2025-11-29 18:32:56 -05:00
1 parent c0c18a5bde
commit d650287211
4 files changed
+47 -41

No files matched your search

+11
View File
@@ -71,6 +71,17 @@ A full-stack web application for running [OpenCode](https://github.com/sst/openc
### File Context
![File Context](https://github.com/chriswritescode-dev/opencode-web/releases/download/0.2.5/file-context.gif)
## Mobile Screenshots
### Repository List
<img width="300" alt="Mobile Repository List" src="https://github.com/user-attachments/assets/4a854373-9e4d-41ac-9a6c-c0eb37b0ac42" />
### Chat Interface
<img width="300" alt="Mobile Chat Interface" src="https://github.com/user-attachments/assets/57fe81c1-b169-43eb-b95f-6e027d7bea10" />
### OpenCode Configuration
<img width="300" alt="Mobile OpenCode Configuration" src="https://github.com/user-attachments/assets/fcb16958-3134-434f-8c78-fb07259f5ce1" />
## Coming Soon
- **Authentication** - User authentication and session management
@@ -12,10 +12,9 @@ interface CreateConfigDialogProps {
onOpenChange: (open: boolean) => void
onCreate: (name: string, content: string, isDefault: boolean) => Promise<void>
isUpdating: boolean
children?: React.ReactNode
}
export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating, children }: CreateConfigDialogProps) {
export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating }: CreateConfigDialogProps) {
const [name, setName] = useState('')
const [content, setContent] = useState('')
const [isDefault, setIsDefault] = useState(false)
@@ -23,7 +22,10 @@ export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating,
const [errorLine, setErrorLine] = useState<number | null>(null)
const textareaRef = useRef<HTMLTextAreaElement>(null)
const handleSubmit = async () => {
const handleSubmit = async (event?: React.MouseEvent) => {
event?.preventDefault()
event?.stopPropagation()
if (!name.trim() || !content.trim()) return
try {
@@ -90,16 +92,14 @@ export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating,
}
return (
<>
{children}
<Dialog open={isOpen} onOpenChange={onOpenChange}>
<DialogContent className="max-w-2xl">
<DialogHeader>
<Dialog open={isOpen} onOpenChange={onOpenChange}>
<DialogContent className="max-w-2xl max-h-[90vh] sm:max-h-[85vh] flex flex-col">
<DialogHeader className="flex-shrink-0">
<DialogTitle>Create OpenCode Config</DialogTitle>
</DialogHeader>
<div className="space-y-4">
<div className="space-y-4 overflow-y-auto flex-1 pr-2">
<div>
<Label htmlFor="config-name">Config Name</Label>
<Label htmlFor="config-name" className="pb-1">Config Name</Label>
<Input
id="config-name"
value={name}
@@ -109,7 +109,7 @@ export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating,
</div>
<div>
<Label htmlFor="config-upload">Upload JSON File</Label>
<Label htmlFor="config-upload" className="pb-1">Upload JSON File</Label>
<Input
id="config-upload"
type="file"
@@ -119,14 +119,14 @@ export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating,
</div>
<div>
<Label htmlFor="config-content">Config Content (JSON)</Label>
<Label htmlFor="config-content" className="pb-1">Config Content (JSON)</Label>
<Textarea
id="config-content"
ref={textareaRef}
value={content}
onChange={(e) => handleContentChange(e.target.value)}
placeholder='{"$schema": "https://opencode.ai/config.json", "theme": "dark"}'
rows={20}
rows={12}
className="font-mono text-sm"
/>
{error && (
@@ -147,22 +147,22 @@ export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating,
/>
<Label htmlFor="config-default">Set as default configuration</Label>
</div>
</div>
<div className="flex justify-end gap-2">
<Button variant="outline" onClick={() => onOpenChange(false)}>
Cancel
</Button>
<Button
onClick={handleSubmit}
disabled={isUpdating || !name.trim() || !content.trim()}
>
{isUpdating && <Loader2 className="h-4 w-4 mr-2 animate-spin" />}
Create
</Button>
</div>
<div className="flex justify-end gap-2 flex-shrink-0 pt-4 border-t">
<Button variant="outline" onClick={() => onOpenChange(false)}>
Cancel
</Button>
<Button
type="button"
onClick={(e) => handleSubmit(e)}
disabled={isUpdating || !name.trim() || !content.trim()}
>
{isUpdating && <Loader2 className="h-4 w-4 mr-2 animate-spin" />}
Create
</Button>
</div>
</DialogContent>
</Dialog>
</>
)
}
@@ -2,7 +2,6 @@ import { useState, useEffect } from 'react'
import { Loader2, Plus, Trash2, Edit, Star, StarOff, Download, RotateCcw } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { DialogTrigger } from '@/components/ui/dialog'
import { Label } from '@/components/ui/label'
import { Badge } from '@/components/ui/badge'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
@@ -194,19 +193,16 @@ export function OpenCodeConfigManager() {
)}
Restart Server
</Button>
<CreateConfigDialog
<Button type="button" onClick={() => setIsCreateDialogOpen(true)}>
<Plus className="h-4 w-4 mr-2" />
New Config
</Button>
<CreateConfigDialog
isOpen={isCreateDialogOpen}
onOpenChange={setIsCreateDialogOpen}
onCreate={createConfig}
isUpdating={isUpdating}
>
<DialogTrigger asChild>
<Button>
<Plus className="h-4 w-4 mr-2" />
New Config
</Button>
</DialogTrigger>
</CreateConfigDialog>
/>
</div>
</div>
@@ -222,12 +218,11 @@ export function OpenCodeConfigManager() {
<Card key={config.id}>
<CardHeader className="pb-3">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<div className="flex items-center gap-2 flex-wrap">
<CardTitle className="text-base">{config.name}</CardTitle>
{config.isDefault && (
<Badge variant="default" className="text-xs">
<Star className="h-3 w-3 mr-1" />
Default
<Badge variant="default" className="">
<Star className="h-4 w-4" />
</Badge>
)}
</div>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "opencode-webui",
"version": "0.3.1",
"version": "0.3.2",
"private": true,
"type": "module",
"packageManager": "pnpm@9.15.0",