You can close this tab
-
+ )
+ return GitHubIcon
+ })()
+ : FolderOpen,
+ description: `Worktree setup for ${project.name}`,
+ projectId: project.id,
+ }))
+ }, [projects])
+
+ // All tabs combined for lookups
+ const ALL_TABS = useMemo(
+ () => [...MAIN_TABS, ...ADVANCED_TABS, ...projectTabs],
+ [projectTabs]
+ )
+
+ // Helper to get tab label from tab id
+ const getTabLabel = (tabId: SettingsTab): string => {
+ return ALL_TABS.find((t) => t.id === tabId)?.label ?? "Settings"
+ }
+
+ // Narrow screen: track whether we're showing tab list or content
+ const [showContent, setShowContent] = useState(false)
+
+ // Reset content view when dialog closes
+ useEffect(() => {
+ if (!isOpen) {
+ setShowContent(false)
+ }
+ }, [isOpen])
+
+ // Handle keyboard navigation
+ useEffect(() => {
+ if (!isOpen) return
+
+ const handleKeyDown = (event: KeyboardEvent) => {
+ if (event.key === "Escape") {
+ event.preventDefault()
+ if (isNarrowScreen && showContent) {
+ setShowContent(false)
+ } else {
+ onClose()
+ }
+ }
+ }
+
+ document.addEventListener("keydown", handleKeyDown)
+ return () => document.removeEventListener("keydown", handleKeyDown)
+ }, [isOpen, onClose, isNarrowScreen, showContent])
+
+ // Ensure portal target only accessed on client
+ useEffect(() => {
+ setMounted(true)
+ if (typeof document !== "undefined") {
+ setPortalTarget(document.body)
+ }
+ }, [])
+
+ const handleTabClick = (tabId: SettingsTab) => {
+ setActiveTab(tabId)
+ if (isNarrowScreen) {
+ setShowContent(true)
+ }
+ }
+
+ const renderTabContent = () => {
+ // Handle dynamic project tabs
+ if (activeTab.startsWith('project-')) {
+ const projectId = activeTab.replace('project-', '')
+ return