fix: centralize iOS safe area and refactor list components (#47)

* fix: add iOS safe-area-inset-top support for fullscreen overlays

- Add pt-safe CSS utility class for safe-area-inset-top
- Create FullscreenSheet component with built-in safe-area support
- Add fullscreen prop to DialogContent for fullscreen dialogs
- Update FileBrowserSheet to use FullscreenSheet
- Update MobileFilePreviewModal to use FullscreenSheet
- Add pt-safe to SettingsDialog mobile view

Fixes status bar overlap on iOS devices with notch/Dynamic Island

* fix: add pt-safe to main page headers

- Header.tsx (main repos page)
- SessionDetailHeader.tsx (session page)

* docs: add TDD refactoring plan for iOS safe area

* remove plan file from repo

* refactor: centralize iOS safe area handling with PageHeader component

- Add PageHeader component with pt-safe, sticky, z-10, border-b styling
- Add TDD test infrastructure (vitest config, testing-library, jsdom)
- Refactor Header, SessionDetailHeader, RepoDetailHeader, Workspace to use PageHeader
- Fix missing pt-safe on RepoDetailHeader and Workspace pages
- All header safe area styling now has single fix point

* fix: add pt-safe to remaining fullscreen dialogs and sheets

- GitChangesSheet, FilePreviewDialog: add fullscreen prop
- ModelSelectDialog, RepoMcpDialog: add pt-safe class
- EditSessionTitleDialog: add pt-safe on mobile

* fix: use mobile-first positioning for large dialogs

Dialogs need top-0 positioning on mobile for pt-safe to work.
Centered dialogs don't benefit from safe area padding.

* fix: add mobileFullscreen prop to DialogContent

- Fullscreen on mobile with pt-safe, centered on desktop
- Simplifies large dialog styling

* fix: use inline styles for iOS safe area to fix CSS cascade issues

- Convert pt-safe/pb-safe to @utility directives with iOS 11 fallback
- Use inline styles on DialogContent for reliable safe-area padding
- Position close button with calc(env(safe-area-inset-top) + 1rem)
- Add 10 tests for DialogContent safe-area behavior

* refactor: extract ListToolbar and Header components for reuse

- Add ListToolbar component for search/select all/delete UI
- Add Header compound component (Header.Root, Header.Title, etc.)
- Update SessionList and RepoList to use ListToolbar
- Mobile delete: deletes selected or all if none selected
- Cancel delete now clears selection
- Remove unused layout components

---------

Co-authored-by: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com>
This commit is contained in:
Justin CarlsonandChris Scott authored and GitHub committed 2026-01-04 14:05:59 -05:00
1 parent 72bb20a4fa
commit cd9a552bf8
34 files changed
+1627 -986

No files matched your search

@@ -2,6 +2,7 @@ import { useEffect, useState, memo, useCallback, useRef } from 'react'
import { FileBrowser } from './FileBrowser'
import { Button } from '@/components/ui/button'
import { PathDisplay } from '@/components/ui/path-display'
import { FullscreenSheet, FullscreenSheetHeader, FullscreenSheetContent } from '@/components/ui/fullscreen-sheet'
import { X } from 'lucide-react'
import { GPU_ACCELERATED_STYLE, MODAL_TRANSITION_MS } from '@/lib/utils'
import { useSwipeBack } from '@/hooks/useMobile'
@@ -37,6 +38,7 @@ export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose
return () => clearTimeout(timer)
}
}, [isOpen])
const handleDirectoryLoad = useCallback((info: { workspaceRoot?: string; currentPath: string }) => {
if (!info.currentPath || info.currentPath === '.' || info.currentPath === '') {
setDisplayPath('/')
@@ -94,11 +96,8 @@ export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose
transition: 'opacity 150ms ease-out',
}}
>
<div
className="absolute inset-0 bg-background flex flex-col"
style={{ ...GPU_ACCELERATED_STYLE, ...swipeStyles }}
>
<div className="flex-shrink-0 border-b border-border bg-background backdrop-blur-sm px-4 py-1">
<FullscreenSheet style={{ ...GPU_ACCELERATED_STYLE, ...swipeStyles }}>
<FullscreenSheetHeader className="px-4 py-1">
<div className="flex items-center justify-between">
<div className="flex items-center gap-3">
{(displayPath === '/' || !repoName) && (
@@ -119,17 +118,17 @@ export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose
</Button>
)}
</div>
</div>
</FullscreenSheetHeader>
<div className="flex-1 overflow-hidden min-h-0">
<FullscreenSheetContent>
<FileBrowser
basePath={normalizedBasePath}
embedded={true}
initialSelectedFile={initialSelectedFile}
onDirectoryLoad={handleDirectoryLoad}
/>
</div>
</div>
</FullscreenSheetContent>
</FullscreenSheet>
</div>
)
})
@@ -61,6 +61,7 @@ export function FilePreviewDialog({ isOpen, onClose, filePath, repoBasePath, onF
<DialogContent
className="w-screen h-screen max-w-none max-h-none p-0 bg-background border-0 flex flex-col"
hideCloseButton
fullscreen
>
<div className="flex-1 overflow-hidden min-h-0">
{isLoading ? (
@@ -1,12 +1,14 @@
import { useState, useEffect, useRef } from 'react'
import { Dialog, DialogContent } from '@/components/ui/dialog'
import { createPortal } from 'react-dom'
import { GitChangesPanel } from './GitChangesPanel'
import { FileDiffView } from './FileDiffView'
import { FilePreviewDialog } from './FilePreviewDialog'
import { FullscreenSheet, FullscreenSheetHeader, FullscreenSheetContent } from '@/components/ui/fullscreen-sheet'
import { Button } from '@/components/ui/button'
import { X, GitBranch } from 'lucide-react'
import { useMobile, useSwipeBack } from '@/hooks/useMobile'
import { useQueryClient } from '@tanstack/react-query'
import { GPU_ACCELERATED_STYLE, MODAL_TRANSITION_MS } from '@/lib/utils'
interface GitChangesSheetProps {
isOpen: boolean
@@ -63,39 +65,66 @@ export function GitChangesSheet({ isOpen, onClose, repoId, currentBranch, repoLo
queryClient.invalidateQueries({ queryKey: ['fileDiff'] })
}
const handleOpenChange = (open: boolean) => {
if (!open) {
onClose()
const [shouldRender, setShouldRender] = useState(false)
useEffect(() => {
if (isOpen) {
setShouldRender(true)
document.body.style.overflow = 'hidden'
} else {
const timer = setTimeout(() => setShouldRender(false), MODAL_TRANSITION_MS)
document.body.style.overflow = 'unset'
return () => clearTimeout(timer)
}
}
return () => {
document.body.style.overflow = 'unset'
}
}, [isOpen])
return (
<Dialog open={isOpen} onOpenChange={handleOpenChange}>
<DialogContent
ref={contentRef}
className="w-screen h-screen max-w-none max-h-none p-0 gap-0 bg-background border-0 flex flex-col"
hideCloseButton
style={swipeStyles}
>
<div className="flex items-center justify-between px-4 sm:py-3 border-b border-border flex-shrink-0">
<div className="flex items-center gap-2">
<GitBranch className="w-4 h-4 text-foreground" />
<h2 className="text-sm font-semibold text-foreground">
{selectedFile ? 'File Changes' : 'Git Changes'}
</h2>
<span className="text-xs text-muted-foreground">({currentBranch})</span>
useEffect(() => {
const handleEscape = (e: KeyboardEvent) => {
if (e.key === 'Escape' && isOpen) {
onClose()
}
}
document.addEventListener('keydown', handleEscape)
return () => document.removeEventListener('keydown', handleEscape)
}, [isOpen, onClose])
if (!isOpen && !shouldRender) return null
return createPortal(
<div
ref={contentRef}
className="fixed inset-0 z-50"
style={{
opacity: isOpen ? 1 : 0,
pointerEvents: isOpen ? 'auto' : 'none',
transition: 'opacity 150ms ease-out',
}}
>
<FullscreenSheet style={{ ...GPU_ACCELERATED_STYLE, ...swipeStyles }}>
<FullscreenSheetHeader className="px-4 py-1">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<GitBranch className="w-4 h-4 text-foreground" />
<h2 className="text-sm font-semibold text-foreground">
{selectedFile ? 'File Changes' : 'Git Changes'}
</h2>
<span className="text-xs text-muted-foreground">({currentBranch})</span>
</div>
<Button
variant="ghost"
size="icon"
onClick={onClose}
className="text-muted-foreground hover:text-foreground hover:bg-muted transition-all duration-200 h-8 w-8"
>
<X className="w-4 h-4" />
</Button>
</div>
<Button
variant="ghost"
size="icon"
onClick={onClose}
className="text-muted-foreground hover:text-foreground hover:bg-muted transition-all duration-200 h-8 w-8"
>
<X className="w-4 h-4" />
</Button>
</div>
</FullscreenSheetHeader>
<div className="flex-1 overflow-hidden min-h-0">
<FullscreenSheetContent>
{isMobile ? (
selectedFile ? (
<FileDiffView
@@ -137,7 +166,7 @@ export function GitChangesSheet({ isOpen, onClose, repoId, currentBranch, repoLo
</div>
</div>
)}
</div>
</FullscreenSheetContent>
<FilePreviewDialog
isOpen={!!previewFilePath}
@@ -147,7 +176,8 @@ export function GitChangesSheet({ isOpen, onClose, repoId, currentBranch, repoLo
onFileSaved={handleFileSaved}
initialLineNumber={previewLineNumber}
/>
</DialogContent>
</Dialog>
</FullscreenSheet>
</div>,
document.body
)
}
@@ -1,5 +1,6 @@
import { memo, useCallback, useState, useEffect, useRef } from "react";
import { FilePreview } from "./FilePreview";
import { FullscreenSheet } from "@/components/ui/fullscreen-sheet";
import type { FileInfo } from "@/types/files";
import { GPU_ACCELERATED_STYLE, MODAL_TRANSITION_MS } from "@/lib/utils";
import { useSwipeBack } from "@/hooks/useMobile";
@@ -51,21 +52,17 @@ export const MobileFilePreviewModal = memo(function MobileFilePreviewModal({
}
return (
<div
ref={containerRef}
className="fixed inset-0 z-50 bg-background"
style={{ isolation: 'isolate', ...GPU_ACCELERATED_STYLE, ...swipeStyles }}
>
<div
className={`h-full overflow-hidden bg-background ${showFilePreviewHeader ? "" : "pb-8"}`}
>
<FilePreview
file={localFile}
hideHeader={!showFilePreviewHeader}
isMobileModal={showFilePreviewHeader}
onCloseModal={handleClose}
/>
</div>
<div ref={containerRef} style={{ isolation: 'isolate' }}>
<FullscreenSheet style={{ ...GPU_ACCELERATED_STYLE, ...swipeStyles }}>
<div className={`h-full overflow-hidden bg-background pt-safe ${showFilePreviewHeader ? "" : "pb-8"}`}>
<FilePreview
file={localFile}
hideHeader={!showFilePreviewHeader}
isMobileModal={showFilePreviewHeader}
onCloseModal={handleClose}
/>
</div>
</FullscreenSheet>
</div>
);
})