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

@@ -13,7 +13,7 @@ export function DeleteSessionDialog({ open, onOpenChange, onConfirm, onCancel, i
const isMultiple = sessionCount > 1
const title = isMultiple ? "Delete Sessions" : "Delete Session"
const description = isMultiple
? `Are you sure you want to delete ${sessionCount} sessions? This action cannot be undone.`
? <>Are you sure you want to delete <span className="text-destructive font-bold text-lg">{sessionCount}</span> sessions? This action cannot be undone.</>
: "Are you sure you want to delete this session? This action cannot be undone."
return (
@@ -52,7 +52,7 @@ export function EditSessionTitleDialog({ isOpen, currentTitle, onClose, onSave }
<DialogContent
hideCloseButton
className={isMobile
? "w-screen max-w-none left-0 top-0 translate-x-0 translate-y-0 rounded-none border-0 border-b bg-background p-4 gap-0"
? "w-screen max-w-none left-0 top-0 translate-x-0 translate-y-0 rounded-none border-0 border-b bg-background p-4 gap-0 pt-safe"
: "p-6 gap-0"
}
>
@@ -1,284 +0,0 @@
import { BackButton } from "@/components/ui/back-button";
import { ContextUsageIndicator } from "@/components/session/ContextUsageIndicator";
import { BranchSwitcher } from "@/components/repo/BranchSwitcher";
import { Button } from "@/components/ui/button";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import { EditSessionTitleDialog } from "@/components/session/EditSessionTitleDialog";
import { Loader2, Settings, CornerUpLeft, Plug, FolderOpen, MoreVertical, Upload, X } from "lucide-react";
import { useState, useEffect } from "react";
import { useMobile } from "@/hooks/useMobile";
interface Repo {
id: number;
repoUrl?: string | null;
fullPath: string;
localPath: string;
currentBranch?: string;
isWorktree?: boolean;
isLocal?: boolean;
cloneStatus: 'ready' | 'cloning' | 'error';
}
interface SessionDetailHeaderProps {
repo: Repo;
sessionId: string;
sessionTitle: string;
repoId: number;
isConnected: boolean;
isReconnecting?: boolean;
opcodeUrl: string | null;
repoDirectory: string | undefined;
parentSessionId?: string;
isTitleGenerating?: boolean;
onFileBrowserOpen: () => void;
onSettingsOpen: () => void;
onMcpDialogOpen: () => void;
onSessionTitleUpdate: (newTitle: string) => void;
onParentSessionClick?: () => void;
onAttachFile?: () => void;
}
export function SessionDetailHeader({
repo,
sessionId,
sessionTitle,
repoId,
isConnected,
isReconnecting,
opcodeUrl,
repoDirectory,
parentSessionId,
isTitleGenerating,
onFileBrowserOpen,
onSettingsOpen,
onMcpDialogOpen,
onSessionTitleUpdate,
onParentSessionClick,
onAttachFile,
}: SessionDetailHeaderProps) {
const [isEditing, setIsEditing] = useState(false);
const isMobile = useMobile();
const [editTitle, setEditTitle] = useState(sessionTitle);
useEffect(() => {
if (!isEditing) {
setEditTitle(sessionTitle);
}
}, [sessionTitle, isEditing]);
if (repo.cloneStatus !== 'ready') {
return (
<div className="sticky top-0 z-10 border-b border-border bg-gradient-to-b from-background via-background to-background backdrop-blur-sm px-2 sm:px-4 py-1.5 sm:py-2">
<div className="flex items-center justify-center">
<Loader2 className="w-4 h-4 animate-spin text-muted-foreground mr-2" />
<span className="text-sm text-muted-foreground">
{repo.cloneStatus === 'cloning' ? 'Cloning repository...' : 'Repository not ready'}
</span>
</div>
</div>
);
}
const repoName = repo.repoUrl?.split("/").pop()?.replace(".git", "") || repo.localPath || "Repository";
const currentBranch = repo.currentBranch || "main";
const handleTitleClick = () => {
setIsEditing(true);
setEditTitle(sessionTitle);
};
const handleTitleSubmit = (e: React.FormEvent) => {
e.preventDefault();
if (editTitle.trim() && editTitle !== sessionTitle) {
onSessionTitleUpdate(editTitle.trim());
}
setIsEditing(false);
};
const handleKeyDown = (e: React.KeyboardEvent) => {
if (e.key === 'Escape') {
setEditTitle(sessionTitle);
setIsEditing(false);
} else if (e.key === 'Enter') {
handleTitleSubmit(e);
}
};
return (
<div className="sticky top-0 z-10 border-b border-border bg-gradient-to-b from-background via-background to-background backdrop-blur-sm px-2 sm:px-4 py-1.5 sm:py-2">
<div className="flex items-center justify-between gap-2">
<div className="flex items-center gap-1.5 sm:gap-3 min-w-0 flex-1">
{parentSessionId ? (
<>
<Button
variant="ghost"
size="sm"
onClick={onParentSessionClick}
className="text-purple-600 dark:text-purple-400 hover:text-purple-700 dark:hover:text-purple-300 hover:bg-purple-100 dark:hover:bg-purple-900/20 h-7 px-2 gap-1"
title="Back to parent session"
>
<CornerUpLeft className="w-3.5 h-3.5" />
<span className="hidden sm:inline text-xs">Parent</span>
</Button>
<div className="hidden sm:block">
<BackButton to={`/repos/${repoId}`} className="text-xs sm:text-sm" />
</div>
</>
) : (
<BackButton to={`/repos/${repoId}`} className="text-xs sm:text-sm" />
)}
<div className="min-w-0 flex-1">
{isMobile && (
<EditSessionTitleDialog
isOpen={isEditing}
currentTitle={sessionTitle}
onClose={() => setIsEditing(false)}
onSave={(newTitle) => {
onSessionTitleUpdate(newTitle);
setIsEditing(false);
}}
/>
)}
{isEditing && !isMobile ? (
<form onSubmit={handleTitleSubmit} className="flex items-center gap-1 min-w-0">
<input
type="text"
value={editTitle}
onChange={(e) => setEditTitle(e.target.value)}
onBlur={(e) => {
if (!e.relatedTarget?.closest('button')) {
handleTitleSubmit(e);
}
}}
onKeyDown={handleKeyDown}
className="text-[16px] sm:text-base font-semibold bg-background border border-border rounded-l px-2 py-1 outline-none w-full truncate focus:border-primary sm:max-w-[250px] h-7"
autoFocus
/>
<Button
type="button"
variant="ghost"
size="icon"
className="h-7 w-7 rounded-l-none border border-l-0 border-border hover:bg-accent flex-shrink-0 mt-0"
onClick={() => setEditTitle("")}
>
<X className="w-3.5 h-3.5" />
</Button>
</form>
) : (
<>
{isTitleGenerating ? (
<div className="flex items-center gap-2">
<Loader2 className="w-3 h-3 animate-spin text-muted-foreground" />
<span className="text-xs sm:text-base text-muted-foreground italic">Generating title...</span>
</div>
) : (
<h1
className="text-xs text-green-500 sm:text-base font-semibold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent truncate cursor-pointer hover:opacity-80 transition-opacity"
onClick={handleTitleClick}
>
{sessionTitle}
</h1>
)}
<p className="text-[10px] sm:text-xs text-green-600 dark:text-green-400 truncate">
{repoName}
</p>
</>
)}
</div>
</div>
<div className="flex items-center gap-2 sm:gap-4 flex-shrink-0">
<div>
<ContextUsageIndicator
opcodeUrl={opcodeUrl}
sessionID={sessionId}
directory={repoDirectory}
isConnected={isConnected}
isReconnecting={isReconnecting}
/>
</div>
<BranchSwitcher
repoId={repoId}
currentBranch={currentBranch}
isWorktree={repo.isWorktree}
repoUrl={repo.repoUrl}
repoLocalPath={repo.localPath}
className="hidden sm:flex max-w-[80px] sm:w-[140px] sm:max-w-[140px]"
/>
<Button
variant="ghost"
size="icon"
onClick={onFileBrowserOpen}
className="hidden sm:flex text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
title="Files"
>
<FolderOpen className="w-4 h-4" />
</Button>
<Button
variant="ghost"
size="icon"
onClick={onMcpDialogOpen}
className="hidden sm:flex text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
title="MCP Servers"
>
<Plug className="w-4 h-4" />
</Button>
<Button
variant="ghost"
size="icon"
onClick={onSettingsOpen}
className="hidden sm:flex text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
title="Settings"
>
<Settings className="w-4 h-4" />
</Button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="ghost"
size="icon"
className="sm:hidden text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
title="Options"
>
<MoreVertical className="w-4 h-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<div className="px-2 py-1.5">
<BranchSwitcher
repoId={repoId}
currentBranch={currentBranch}
isWorktree={repo.isWorktree}
repoUrl={repo.repoUrl}
repoLocalPath={repo.localPath}
iconOnly={false}
className="w-full"
/>
</div>
<div className="h-px bg-border my-1" />
<DropdownMenuItem onClick={onFileBrowserOpen}>
<FolderOpen className="w-4 h-4 mr-2" /> Files
</DropdownMenuItem>
{onAttachFile && (
<DropdownMenuItem onClick={onAttachFile}>
<Upload className="w-4 h-4 mr-2" /> Upload
</DropdownMenuItem>
)}
<DropdownMenuItem onClick={onMcpDialogOpen}>
<Plug className="w-4 h-4 mr-2" /> MCP
</DropdownMenuItem>
<DropdownMenuItem onClick={onSettingsOpen}>
<Settings className="w-4 h-4 mr-2" /> Settings
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
</div>
);
}
+21 -69
View File
@@ -1,11 +1,8 @@
import { useState, useMemo } from "react";
import { useSessions, useDeleteSession } from "@/hooks/useOpenCode";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import { ListToolbar } from "@/components/ui/list-toolbar";
import { DeleteSessionDialog } from "./DeleteSessionDialog";
import { SessionCard } from "./SessionCard";
import { Trash2, Search, MoreVertical } from "lucide-react";
interface SessionListProps {
opcodeUrl: string;
@@ -97,6 +94,7 @@ export const SessionList = ({
const cancelDelete = () => {
setDeleteDialogOpen(false);
setSessionToDelete(null);
setSelectedSessions(new Set());
};
const toggleSessionSelection = (sessionId: string, selected: boolean) => {
@@ -131,74 +129,28 @@ export const SessionList = ({
}
};
const handleDeleteAll = () => {
if (!filteredSessions || filteredSessions.length === 0) return;
setSessionToDelete(filteredSessions.map((s) => s.id));
setDeleteDialogOpen(true);
};
return (
<div className="flex flex-col h-full min-h-0">
<div className="px-4 pt-2 pb-3 flex-shrink-0 border-b border-border">
<div className="flex items-center gap-3">
<div className="relative flex-1">
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground" />
<Input
type="text"
placeholder="Search"
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
className="pl-10"
/>
</div>
{filteredSessions && filteredSessions.length > 0 && (
<Button
onClick={toggleSelectAll}
variant={selectedSessions.size > 0 ? "default" : "outline"}
className="whitespace-nowrap hidden md:flex"
>
{filteredSessions.every((session) =>
selectedSessions.has(session.id),
)
? "Deselect All"
: "Select All"}
</Button>
)}
<Button
onClick={handleBulkDelete}
variant="destructive"
disabled={selectedSessions.size === 0}
className="hidden md:flex whitespace-nowrap"
>
<Trash2 className="w-4 h-4 mr-2" />
Delete ({selectedSessions.size})
</Button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="outline"
size="icon"
className="md:hidden"
disabled={filteredSessions.length === 0}
>
<MoreVertical className="w-4 h-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
{filteredSessions.length > 0 && (
<DropdownMenuItem onClick={toggleSelectAll}>
{filteredSessions.every((session) =>
selectedSessions.has(session.id),
)
? "Deselect All"
: "Select All"}
</DropdownMenuItem>
)}
<DropdownMenuItem
onClick={handleBulkDelete}
disabled={selectedSessions.size === 0}
className="text-destructive focus:text-destructive"
>
<Trash2 className="w-4 h-4 mr-2" />
Delete ({selectedSessions.size})
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
<ListToolbar
searchQuery={searchQuery}
onSearchChange={setSearchQuery}
selectedCount={selectedSessions.size}
totalCount={filteredSessions.length}
allSelected={
filteredSessions.length > 0 &&
filteredSessions.every((session) => selectedSessions.has(session.id))
}
onToggleSelectAll={toggleSelectAll}
onDelete={handleBulkDelete}
onDeleteAll={handleDeleteAll}
/>
</div>
<div className="flex-1 overflow-y-auto px-4 pt-3 pb-4 min-h-0">