Skip to content

Commit ce4fd6e

Browse files
fix(settings): wire up version dialog button in ServerHealthStatus (#253)
* fix(settings): wire up version dialog button in ServerHealthStatus * fix(settings): render VersionSelectDialog outside outer Dialog to prevent nesting issues * fix(settings): use portal + guarded close for version dialog to prevent Radix nesting issue * fix(settings): replace portal workaround with direct VersionSelectDialog render Remove the createPortal + useRef guarded-close pattern for the version dialog (introduced to work around Radix nesting issues). Instead render VersionSelectDialog directly inside the Dialog and prevent outside interactions via onInteractOutside/onFocusOutside/onPointerDownOutside preventDefault. Delete the obsolete VersionSelectContent component.
1 parent 0d6419a commit ce4fd6e

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

frontend/src/components/settings/SettingsDialog.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ProviderSettings } from '@/components/settings/ProviderSettings'
1111
import { AccountSettings } from '@/components/settings/AccountSettings'
1212
import { VoiceSettings } from '@/components/settings/VoiceSettings'
1313
import { NotificationSettings } from '@/components/settings/NotificationSettings'
14+
import { VersionSelectDialog } from '@/components/settings/VersionSelectDialog'
1415
import { Dialog, DialogContent } from '@/components/ui/dialog'
1516
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
1617
import { Settings2, Keyboard, Code, ChevronLeft, Key, GitBranch, User, Volume2, Bell, X } from 'lucide-react'
@@ -22,6 +23,7 @@ type SettingsView = 'menu' | 'general' | 'git' | 'shortcuts' | 'opencode' | 'pro
2223
export function SettingsDialog() {
2324
const { isOpen, close, activeTab, setActiveTab } = useSettingsDialog()
2425
const [mobileView, setMobileView] = useState<SettingsView>('menu')
26+
const [isVersionDialogOpen, setIsVersionDialogOpen] = useState(false)
2527
const [sectionHistory, setSectionHistory] = useState<SettingsView[]>([])
2628
const [authSectionsOpen, setAuthSectionsOpen] = useState(true)
2729
const toggleAuthSections = useCallback(() => setAuthSectionsOpen((open) => !open), [])
@@ -64,14 +66,13 @@ export function SettingsDialog() {
6466
return
6567
}
6668
const handleKeyDown = (e: KeyboardEvent) => {
67-
if (e.key === 'Escape') {
68-
e.stopPropagation()
69+
if (e.key === 'Escape' && !isVersionDialogOpen) {
6970
close()
7071
}
7172
}
72-
document.addEventListener('keydown', handleKeyDown)
73-
return () => document.removeEventListener('keydown', handleKeyDown)
74-
}, [isOpen, close])
73+
document.addEventListener('keydown', handleKeyDown, { capture: true })
74+
return () => document.removeEventListener('keydown', handleKeyDown, { capture: true })
75+
}, [isOpen, close, isVersionDialogOpen])
7576

7677
const menuItems = [
7778
{ id: 'account', icon: User, label: 'Account', description: 'Profile, passkeys, and sign out' },
@@ -104,6 +105,9 @@ export function SettingsDialog() {
104105
fullscreen
105106
canSwipeBack={() => mobileView !== 'menu'}
106107
onSwipeBack={handleSettingsBack}
108+
onInteractOutside={(e) => e.preventDefault()}
109+
onFocusOutside={(e) => e.preventDefault()}
110+
onPointerDownOutside={(e) => e.preventDefault()}
107111
>
108112
<div className="hidden sm:flex sm:flex-col sm:h-full sm:min-h-0">
109113
<div className="sticky top-0 z-10 bg-gradient-to-b from-background via-background to-transparent border-b border-border backdrop-blur-sm px-6 py-4 flex-shrink-0 flex items-center justify-between">
@@ -159,7 +163,7 @@ export function SettingsDialog() {
159163
<TabsContent key="shortcuts" value="shortcuts" className="mt-0"><KeyboardShortcuts /></TabsContent>
160164
<TabsContent key="opencode" value="opencode" className="mt-0">
161165
<div className="space-y-6">
162-
<ServerHealthStatus />
166+
<ServerHealthStatus onOpenVersionDialog={() => setIsVersionDialogOpen(true)} />
163167
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
164168
<OpenCodeServerAuthSettings isOpen={authSectionsOpen} onToggle={toggleAuthSections} />
165169
<ManagerTokenSettings isOpen={authSectionsOpen} onToggle={toggleAuthSections} />
@@ -232,7 +236,7 @@ export function SettingsDialog() {
232236
{mobileView === 'shortcuts' && <div key="shortcuts"><KeyboardShortcuts /></div>}
233237
{mobileView === 'opencode' && (
234238
<div key="opencode" className="space-y-6">
235-
<ServerHealthStatus />
239+
<ServerHealthStatus onOpenVersionDialog={() => setIsVersionDialogOpen(true)} />
236240
<OpenCodeServerAuthSettings />
237241
<ManagerTokenSettings />
238242
<ServerEnvVarsSettings />
@@ -242,7 +246,12 @@ export function SettingsDialog() {
242246
{mobileView === 'providers' && <div key="providers"><ProviderSettings /></div>}
243247
</div>
244248
</div>
249+
245250
</DialogContent>
251+
<VersionSelectDialog
252+
open={isVersionDialogOpen}
253+
onOpenChange={setIsVersionDialogOpen}
254+
/>
246255
</Dialog>
247256
)
248257
}

0 commit comments

Comments
 (0)