mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
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:
1 parent
72bb20a4fa
commit
cd9a552bf8
34 files changed
+1627
-986
No files matched your search
@@ -6,7 +6,8 @@
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
"preview": "vite preview",
|
||||
"test": "vitest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hookform/resolvers": "^5.2.2",
|
||||
@@ -48,6 +49,9 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.36.0",
|
||||
"@testing-library/jest-dom": "^6.9.1",
|
||||
"@testing-library/react": "^16.3.1",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
"@types/node": "^24.8.1",
|
||||
"@types/react": "^19.2.2",
|
||||
"@types/react-dom": "^19.2.2",
|
||||
@@ -57,6 +61,7 @@
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.22",
|
||||
"globals": "^16.4.0",
|
||||
"jsdom": "^27.4.0",
|
||||
"openapi-typescript": "^7.10.1",
|
||||
"postcss": "^8.5.6",
|
||||
"tailwindcss": "^4.1.14",
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
#root {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 6em;
|
||||
padding: 1.5em;
|
||||
will-change: filter;
|
||||
transition: filter 300ms;
|
||||
}
|
||||
.logo:hover {
|
||||
filter: drop-shadow(0 0 2em #646cffaa);
|
||||
}
|
||||
.logo.react:hover {
|
||||
filter: drop-shadow(0 0 2em #61dafbaa);
|
||||
}
|
||||
|
||||
@keyframes logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
a:nth-of-type(2) .logo {
|
||||
animation: logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
})
|
||||
@@ -1,53 +0,0 @@
|
||||
import { Settings } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { BackButton } from "@/components/ui/back-button";
|
||||
import { useSettingsDialog } from "@/hooks/useSettingsDialog";
|
||||
import { useTheme } from "@/hooks/useTheme";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
interface HeaderProps {
|
||||
title: string;
|
||||
backTo?: string;
|
||||
action?: ReactNode;
|
||||
}
|
||||
|
||||
export function Header({ title, backTo, action }: HeaderProps) {
|
||||
const { open: openSettings } = useSettingsDialog();
|
||||
const theme = useTheme();
|
||||
|
||||
return (
|
||||
<header className="sticky top-0 z-10 bg-gradient-to-b from-background via-background to-background border-b border-border backdrop-blur-sm">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="flex items-center justify-between h-16">
|
||||
<div className="flex items-center gap-4">
|
||||
{backTo && <BackButton to={backTo} />}
|
||||
<div className="flex items-center gap-2">
|
||||
{title === "OpenCode" ? (
|
||||
<img
|
||||
src={theme === 'light' ? "/opencode-wordmark-light.svg" : "/opencode-wordmark-dark.svg"}
|
||||
alt="OpenCode"
|
||||
className="h-6 w-auto sm:h-8"
|
||||
/>
|
||||
) : (
|
||||
<h1 className="text-xl font-semibold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent truncate">
|
||||
{title}
|
||||
</h1>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{action && <div>{action}</div>}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={openSettings}
|
||||
className="text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200"
|
||||
>
|
||||
<Settings className="w-10 h-10" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { BranchSwitcher } from "@/components/repo/BranchSwitcher";
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
|
||||
import { BackButton } from "@/components/ui/back-button";
|
||||
import { Plus, FolderOpen, GitBranch, Plug, MoreVertical } from "lucide-react";
|
||||
|
||||
interface RepoDetailHeaderProps {
|
||||
repoName: string;
|
||||
repoId: number;
|
||||
currentBranch: string | null;
|
||||
isWorktree: boolean;
|
||||
repoUrl: string | null;
|
||||
onMcpClick: () => void;
|
||||
onFilesClick: () => void;
|
||||
onNewSession: () => void;
|
||||
disabledNewSession?: boolean;
|
||||
}
|
||||
|
||||
export function RepoDetailHeader({
|
||||
repoName,
|
||||
repoId,
|
||||
currentBranch,
|
||||
isWorktree,
|
||||
repoUrl,
|
||||
onMcpClick,
|
||||
onFilesClick,
|
||||
onNewSession,
|
||||
disabledNewSession,
|
||||
}: RepoDetailHeaderProps) {
|
||||
const branchToDisplay = isWorktree ? (currentBranch ? `WT: ${currentBranch}` : "Worktree") : currentBranch
|
||||
const isNotMainBranch = currentBranch && currentBranch !== "main" && currentBranch !== "master"
|
||||
|
||||
return (
|
||||
<div className="flex-shrink-0 z-10 bg-gradient-to-b from-background via-background to-background backdrop-blur-sm px-4 py-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3 min-w-0">
|
||||
<BackButton />
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<h1 className="text-base truncate max-w-[200px] sm:max-w-none font-semibold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent">
|
||||
{repoName}
|
||||
</h1>
|
||||
{!isWorktree && currentBranch && branchToDisplay ? (
|
||||
<BranchSwitcher
|
||||
repoId={repoId}
|
||||
currentBranch={currentBranch}
|
||||
isWorktree={isWorktree}
|
||||
repoUrl={repoUrl}
|
||||
className="hidden sm:flex w-[140px] max-w-[140px]"
|
||||
/>
|
||||
) : branchToDisplay ? (
|
||||
<Badge
|
||||
className={`text-xs px-1.5 sm:px-2.5 py-0.5 ${
|
||||
isWorktree
|
||||
? "bg-purple-600/20 text-purple-400 border-purple-600/40"
|
||||
: isNotMainBranch
|
||||
? "bg-blue-600/20 text-blue-400 border-blue-600/40"
|
||||
: "bg-zinc-600/20 text-zinc-400 border-zinc-600/40"
|
||||
}`}
|
||||
title={isWorktree ? "Worktree" : branchToDisplay}
|
||||
>
|
||||
{isWorktree && <GitBranch className="h-3 w-3 sm:mr-1" />}
|
||||
<span className="hidden sm:inline">{branchToDisplay}</span>
|
||||
</Badge>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={onMcpClick}
|
||||
size="sm"
|
||||
className="hidden sm:flex text-foreground border-border hover:bg-accent transition-all duration-200 hover:scale-105"
|
||||
>
|
||||
<Plug className="w-4 h-4 sm:mr-2" />
|
||||
<span className="hidden sm:inline">MCP</span>
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={onFilesClick}
|
||||
size="sm"
|
||||
className="hidden sm:flex text-foreground border-border hover:bg-accent transition-all duration-200 hover:scale-105"
|
||||
>
|
||||
<FolderOpen className="w-4 h-4 sm:mr-2" />
|
||||
<span className="hidden sm:inline">Files</span>
|
||||
</Button>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="sm:hidden text-foreground border-border hover:bg-accent transition-all duration-200 hover:scale-105"
|
||||
>
|
||||
<MoreVertical className="w-5 h-5" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
{!isWorktree && currentBranch && (
|
||||
<>
|
||||
<div className="px-2 py-1.5">
|
||||
<BranchSwitcher
|
||||
repoId={repoId}
|
||||
currentBranch={currentBranch}
|
||||
isWorktree={isWorktree}
|
||||
repoUrl={repoUrl}
|
||||
iconOnly={false}
|
||||
className="w-full"
|
||||
/>
|
||||
</div>
|
||||
<div className="h-px bg-border my-1" />
|
||||
</>
|
||||
)}
|
||||
<DropdownMenuItem onClick={onMcpClick}>
|
||||
<Plug className="w-4 h-4 mr-2" /> MCP
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={onFilesClick}>
|
||||
<FolderOpen className="w-4 h-4 mr-2" /> Files
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
<Button
|
||||
onClick={onNewSession}
|
||||
disabled={disabledNewSession}
|
||||
size="sm"
|
||||
className="bg-blue-600 hover:bg-blue-700 text-white transition-all duration-200 hover:scale-105"
|
||||
>
|
||||
<Plus className="w-4 h-4 sm:mr-2" />
|
||||
<span className="hidden sm:inline">New Session</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -458,7 +458,7 @@ export function ModelSelectDialog({
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-7xl w-[95vw] h-[90vh] max-h-[90vh] bg-background border-border text-foreground p-0 flex flex-col gap-0">
|
||||
<DialogContent mobileFullscreen className="sm:w-[95vw] sm:max-w-7xl sm:h-[90vh] sm:max-h-[90vh] bg-background border-border text-foreground flex flex-col gap-0">
|
||||
<DialogHeader className="p-4 sm:p-6 pb-2 border-b border-border flex-shrink-0">
|
||||
<DialogTitle className="text-lg sm:text-xl font-semibold">
|
||||
{selectedProvider && selectedProviderData ? `Select Model - ${selectedProviderData.name}` : 'Select Model'}
|
||||
|
||||
@@ -2,10 +2,8 @@ import { useState } from "react";
|
||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { listRepos, deleteRepo } from "@/api/repos";
|
||||
import { DeleteDialog } from "@/components/ui/delete-dialog";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
|
||||
import { Loader2, GitBranch, Search, Trash2, MoreVertical } from "lucide-react";
|
||||
import { ListToolbar } from "@/components/ui/list-toolbar";
|
||||
import { Loader2, GitBranch, Search } from "lucide-react";
|
||||
import { RepoCard } from "./RepoCard";
|
||||
|
||||
export function RepoList() {
|
||||
@@ -127,73 +125,34 @@ export function RepoList() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteAll = () => {
|
||||
if (filteredRepos.length === 0) return;
|
||||
setSelectedRepos(new Set(filteredRepos.map((r) => r.id)));
|
||||
setDeleteDialogOpen(true);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="px-0 py-2 md:p-4">
|
||||
<div className="flex items-center gap-3 mb-4 md:mb-6 px-2 md:px-0">
|
||||
<div className="relative flex-1">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400" />
|
||||
<Input
|
||||
placeholder="Search"
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="pl-10"
|
||||
/>
|
||||
</div>
|
||||
{filteredRepos.length > 0 && (
|
||||
<Button
|
||||
onClick={handleSelectAll}
|
||||
variant={selectedRepos.size > 0 ? "default" : "outline"}
|
||||
className="whitespace-nowrap hidden md:flex"
|
||||
>
|
||||
{filteredRepos.every((repo) => selectedRepos.has(repo.id))
|
||||
? "Deselect All"
|
||||
: "Select All"}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
onClick={handleBatchDelete}
|
||||
variant="destructive"
|
||||
disabled={selectedRepos.size === 0}
|
||||
className="hidden md:flex whitespace-nowrap"
|
||||
>
|
||||
<Trash2 className="w-4 h-4 mr-2" />
|
||||
Delete ({selectedRepos.size})
|
||||
</Button>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="md:hidden"
|
||||
disabled={filteredRepos.length === 0}
|
||||
>
|
||||
<MoreVertical className="w-4 h-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
{filteredRepos.length > 0 && (
|
||||
<DropdownMenuItem onClick={handleSelectAll}>
|
||||
{filteredRepos.every((repo) => selectedRepos.has(repo.id))
|
||||
? "Deselect All"
|
||||
: "Select All"}
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuItem
|
||||
onClick={handleBatchDelete}
|
||||
disabled={selectedRepos.size === 0}
|
||||
className="text-destructive focus:text-destructive"
|
||||
>
|
||||
<Trash2 className="w-4 h-4 mr-2" />
|
||||
Delete ({selectedRepos.size})
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
<div className="px-0 md:p-4 h-full flex flex-col">
|
||||
<div className="mb-4 md:mb-6 px-2 md:px-0">
|
||||
<ListToolbar
|
||||
searchQuery={searchQuery}
|
||||
onSearchChange={setSearchQuery}
|
||||
selectedCount={selectedRepos.size}
|
||||
totalCount={filteredRepos.length}
|
||||
allSelected={
|
||||
filteredRepos.length > 0 &&
|
||||
filteredRepos.every((repo) => selectedRepos.has(repo.id))
|
||||
}
|
||||
onToggleSelectAll={handleSelectAll}
|
||||
onDelete={handleBatchDelete}
|
||||
onDeleteAll={handleDeleteAll}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="mx-2 md:mx-0">
|
||||
<div className="h-[calc(100dvh-140px)] md:h-[calc(100vh-160px)] overflow-y-auto py-2 md:py-0">
|
||||
<div className="mx-2 md:mx-0 flex-1 min-h-0">
|
||||
<div className="h-full overflow-y-auto py-2 md:py-0">
|
||||
{filteredRepos.length === 0 ? (
|
||||
<div className="text-center p-12">
|
||||
<Search className="w-12 h-12 mx-auto mb-4 text-zinc-600" />
|
||||
@@ -237,6 +196,7 @@ export function RepoList() {
|
||||
onCancel={() => {
|
||||
setDeleteDialogOpen(false);
|
||||
setRepoToDelete(null);
|
||||
setSelectedRepos(new Set());
|
||||
}}
|
||||
title={
|
||||
selectedRepos.size > 0
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { useState, useEffect, useCallback, useRef } from 'react'
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '@/components/ui/dialog'
|
||||
import { Switch } from '@/components/ui/switch'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Loader2, Plug, XCircle, AlertCircle, Search } from 'lucide-react'
|
||||
import { Loader2, XCircle, AlertCircle, Plug } from 'lucide-react'
|
||||
import { mcpApi, type McpStatus } from '@/api/mcp'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { showToast } from '@/lib/toast'
|
||||
@@ -26,71 +25,12 @@ interface RepoMcpDialogProps {
|
||||
directory: string | undefined
|
||||
}
|
||||
|
||||
function getServerDisplayName(serverId: string): string {
|
||||
const name = serverId.replace(/[-_]/g, ' ')
|
||||
return name.charAt(0).toUpperCase() + name.slice(1)
|
||||
}
|
||||
|
||||
function getServerDescription(serverConfig: McpServerConfig): string {
|
||||
if (serverConfig.type === 'local' && serverConfig.command) {
|
||||
const command = serverConfig.command.join(' ')
|
||||
if (command.includes('filesystem')) return 'File system access'
|
||||
if (command.includes('git')) return 'Git repository operations'
|
||||
if (command.includes('sqlite')) return 'SQLite database access'
|
||||
if (command.includes('postgres')) return 'PostgreSQL database access'
|
||||
if (command.includes('brave-search')) return 'Web search via Brave'
|
||||
if (command.includes('github')) return 'GitHub repository access'
|
||||
if (command.includes('slack')) return 'Slack integration'
|
||||
if (command.includes('puppeteer')) return 'Web automation'
|
||||
if (command.includes('fetch')) return 'HTTP requests'
|
||||
if (command.includes('memory')) return 'Persistent memory'
|
||||
return `Local: ${command}`
|
||||
} else if (serverConfig.type === 'remote' && serverConfig.url) {
|
||||
return `${serverConfig.url}`
|
||||
}
|
||||
return 'MCP server'
|
||||
}
|
||||
|
||||
function getStatusBadge(status?: McpStatus) {
|
||||
if (!status) return null
|
||||
|
||||
switch (status.status) {
|
||||
case 'connected':
|
||||
return <Badge variant="default" className="text-xs bg-green-600">Connected</Badge>
|
||||
case 'disabled':
|
||||
return <Badge className="text-xs bg-gray-700 text-gray-300 border-gray-600 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-600">Disabled</Badge>
|
||||
case 'failed':
|
||||
return (
|
||||
<Badge variant="destructive" className="text-xs flex items-center gap-1">
|
||||
<AlertCircle className="h-3 w-3" />
|
||||
Failed
|
||||
</Badge>
|
||||
)
|
||||
case 'needs_auth':
|
||||
return (
|
||||
<Badge variant="outline" className="text-xs border-yellow-500 text-yellow-600">
|
||||
Needs Auth
|
||||
</Badge>
|
||||
)
|
||||
default:
|
||||
return <Badge variant="outline" className="text-xs">Unknown</Badge>
|
||||
}
|
||||
}
|
||||
|
||||
export function RepoMcpDialog({ open, onOpenChange, config, directory }: RepoMcpDialogProps) {
|
||||
const [localStatus, setLocalStatus] = useState<Record<string, McpStatus>>({})
|
||||
const [isLoadingStatus, setIsLoadingStatus] = useState(false)
|
||||
const [searchQuery, setSearchQuery] = useState('')
|
||||
const searchInputRef = useRef<HTMLInputElement>(null)
|
||||
|
||||
const mcpServers = config?.content?.mcp as Record<string, McpServerConfig> | undefined || {}
|
||||
const serverIds = Object.keys(mcpServers)
|
||||
const filteredServerIds = serverIds.filter((serverId) => {
|
||||
const displayName = getServerDisplayName(serverId).toLowerCase()
|
||||
const description = getServerDescription(mcpServers[serverId]).toLowerCase()
|
||||
const query = searchQuery.toLowerCase()
|
||||
return displayName.includes(query) || description.includes(query)
|
||||
})
|
||||
|
||||
const fetchStatus = useCallback(async () => {
|
||||
if (!directory || serverIds.length === 0) return
|
||||
@@ -99,8 +39,6 @@ export function RepoMcpDialog({ open, onOpenChange, config, directory }: RepoMcp
|
||||
try {
|
||||
const status = await mcpApi.getStatusFor(directory)
|
||||
setLocalStatus(status)
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch MCP status:', error)
|
||||
} finally {
|
||||
setIsLoadingStatus(false)
|
||||
}
|
||||
@@ -134,66 +72,87 @@ export function RepoMcpDialog({ open, onOpenChange, config, directory }: RepoMcp
|
||||
useEffect(() => {
|
||||
if (open && directory) {
|
||||
fetchStatus()
|
||||
searchInputRef.current?.focus()
|
||||
}
|
||||
if (!open) {
|
||||
setSearchQuery('')
|
||||
}, [open, directory, fetchStatus])
|
||||
|
||||
const getDisplayName = (serverId: string): string => {
|
||||
const name = serverId.replace(/[-_]/g, ' ')
|
||||
return name.charAt(0).toUpperCase() + name.slice(1)
|
||||
}
|
||||
|
||||
const getDescription = (serverConfig: McpServerConfig): string => {
|
||||
if (serverConfig.type === 'local' && serverConfig.command) {
|
||||
const command = serverConfig.command.join(' ')
|
||||
if (command.includes('filesystem')) return 'File system access'
|
||||
if (command.includes('git')) return 'Git repository operations'
|
||||
if (command.includes('sqlite')) return 'SQLite database access'
|
||||
if (command.includes('postgres')) return 'PostgreSQL database access'
|
||||
if (command.includes('brave-search')) return 'Web search via Brave'
|
||||
if (command.includes('github')) return 'GitHub repository access'
|
||||
if (command.includes('slack')) return 'Slack integration'
|
||||
if (command.includes('puppeteer')) return 'Web automation'
|
||||
if (command.includes('fetch')) return 'HTTP requests'
|
||||
if (command.includes('memory')) return 'Persistent memory'
|
||||
return `Local: ${command}`
|
||||
} else if (serverConfig.type === 'remote' && serverConfig.url) {
|
||||
return serverConfig.url
|
||||
}
|
||||
}, [open, directory, serverIds.length, fetchStatus])
|
||||
return 'MCP server'
|
||||
}
|
||||
|
||||
const getStatusBadge = (status?: McpStatus) => {
|
||||
if (!status) return null
|
||||
|
||||
switch (status.status) {
|
||||
case 'connected':
|
||||
return <Badge variant="default" className="text-xs bg-green-600">Connected</Badge>
|
||||
case 'disabled':
|
||||
return <Badge className="text-xs bg-gray-700 text-gray-300 border-gray-600 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-600">Disabled</Badge>
|
||||
case 'failed':
|
||||
return (
|
||||
<Badge variant="destructive" className="text-xs flex items-center gap-1">
|
||||
<AlertCircle className="h-3 w-3" />
|
||||
Failed
|
||||
</Badge>
|
||||
)
|
||||
case 'needs_auth':
|
||||
return (
|
||||
<Badge variant="outline" className="text-xs border-yellow-500 text-yellow-600">
|
||||
Needs Auth
|
||||
</Badge>
|
||||
)
|
||||
default:
|
||||
return <Badge variant="outline" className="text-xs">Unknown</Badge>
|
||||
}
|
||||
}
|
||||
|
||||
if (!directory) return null
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-[95%] sm:max-w-[500px] p-0 gap-0 h-[90vh] sm:h-[80vh] flex flex-col">
|
||||
<DialogHeader className="px-4 sm:px-6 pt-4 sm:pt-6 pb-2 sm:pb-3 shrink-0 border-b border-border">
|
||||
<div className="flex items-center gap-2">
|
||||
<Plug className="w-4 h-4 text-muted-foreground" />
|
||||
<DialogTitle className="text-base sm:text-lg">MCP for This Location</DialogTitle>
|
||||
</div>
|
||||
<p className="text-xs sm:text-sm text-muted-foreground mt-1">
|
||||
<DialogContent mobileFullscreen className="sm:max-w-[400px] sm:max-h-[80vh] flex flex-col gap-0 pb-safe">
|
||||
<DialogHeader className="px-4 sm:px-6 pt-4 sm:pt-6 pb-2 sm:pb-3 shrink-0 ">
|
||||
<DialogTitle>MCP for This Location</DialogTitle>
|
||||
<DialogDescription>
|
||||
Toggle MCP servers for this repository
|
||||
</p>
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="px-4 sm:px-6 py-3 border-b border-border shrink-0">
|
||||
<div className="relative">
|
||||
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground" />
|
||||
<Input
|
||||
ref={searchInputRef}
|
||||
placeholder="Search MCP servers..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="pl-9"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="px-4 sm:px-6 py-3 sm:py-4 flex-1 overflow-y-auto min-h-0">
|
||||
{serverIds.length === 0 ? (
|
||||
<div className="text-center py-6 sm:py-8">
|
||||
<Plug className="w-10 h-10 mx-auto text-muted-foreground mb-3 opacity-50" />
|
||||
<p className="text-sm text-muted-foreground">
|
||||
No MCP servers configured globally
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground mt-1">
|
||||
Add them in Settings first
|
||||
</p>
|
||||
<div className="text-center py-6 text-muted-foreground">
|
||||
<Plug className="w-10 h-10 mx-auto mb-3 opacity-50" />
|
||||
<p className="text-sm">No MCP servers configured globally</p>
|
||||
<p className="text-xs mt-1">Add them in Settings first</p>
|
||||
</div>
|
||||
) : filteredServerIds.length === 0 ? (
|
||||
<div className="text-center py-6 sm:py-8">
|
||||
<Search className="w-10 h-10 mx-auto text-muted-foreground mb-3 opacity-50" />
|
||||
<p className="text-sm text-muted-foreground">
|
||||
No MCP servers match "{searchQuery}"
|
||||
</p>
|
||||
</div>
|
||||
) : isLoadingStatus ? (
|
||||
) : isLoadingStatus ? (
|
||||
<div className="flex items-center justify-center py-8">
|
||||
<Loader2 className="w-6 h-6 animate-spin text-muted-foreground" />
|
||||
<Loader2 className="w-4 h-4 animate-spin text-blue-600 dark:text-blue-400" />
|
||||
<span className="ml-2 text-sm text-muted-foreground">Loading...</span>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
{filteredServerIds.map((serverId) => {
|
||||
{serverIds.map((serverId) => {
|
||||
const serverConfig = mcpServers[serverId]
|
||||
const status = localStatus[serverId]
|
||||
const isConnected = status?.status === 'connected'
|
||||
@@ -202,20 +161,20 @@ export function RepoMcpDialog({ open, onOpenChange, config, directory }: RepoMcp
|
||||
return (
|
||||
<div
|
||||
key={serverId}
|
||||
className="flex items-center justify-between gap-3 p-2 sm:p-3 rounded-lg border border-border bg-card"
|
||||
className="flex items-center justify-between gap-3 p-3 rounded-lg border border-border bg-card"
|
||||
>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<p className="text-xs sm:text-sm font-medium truncate">
|
||||
{getServerDisplayName(serverId)}
|
||||
<p className="text-sm font-medium truncate">
|
||||
{getDisplayName(serverId)}
|
||||
</p>
|
||||
{getStatusBadge(status)}
|
||||
</div>
|
||||
<p className="text-[10px] sm:text-xs text-muted-foreground truncate">
|
||||
{getServerDescription(serverConfig)}
|
||||
<p className="text-xs text-muted-foreground truncate">
|
||||
{getDescription(serverConfig)}
|
||||
</p>
|
||||
{failed && status.status === 'failed' && (
|
||||
<div className="flex items-center gap-1 mt-1 text-[10px] text-red-500">
|
||||
<div className="flex items-center gap-1 mt-1 text-xs text-red-500">
|
||||
<XCircle className="w-3 h-3 flex-shrink-0" />
|
||||
<span className="truncate">{status.error}</span>
|
||||
</div>
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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">
|
||||
|
||||
@@ -117,34 +117,30 @@ export function ProviderSettings() {
|
||||
|
||||
return (
|
||||
<Card key={provider.id} className="bg-card border-border">
|
||||
<CardHeader>
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex-1">
|
||||
<CardTitle className="text-base flex items-center gap-2">
|
||||
<CardHeader className="p-4">
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex items-start justify-between gap-2">
|
||||
<CardTitle className="text-base">
|
||||
{provider.name || provider.id}
|
||||
{hasKey ? (
|
||||
<Badge variant="default" className="bg-green-600 hover:bg-green-700">
|
||||
<Check className="h-3 w-3 mr-1" />
|
||||
Connected
|
||||
</Badge>
|
||||
) : (
|
||||
<Badge variant="secondary">
|
||||
<X className="h-3 w-3 mr-1" />
|
||||
Not Connected
|
||||
</Badge>
|
||||
)}
|
||||
</CardTitle>
|
||||
<CardDescription className="mt-1">
|
||||
{provider.npm ? <span className="text-xs">Package: {provider.npm}</span> : null}
|
||||
{typeof provider.options?.baseURL === 'string' && (
|
||||
<span className="text-xs block">{provider.options.baseURL}</span>
|
||||
)}
|
||||
{modelCount > 0 && (
|
||||
<span className="text-xs block">{modelCount} model{modelCount !== 1 ? 's' : ''}</span>
|
||||
)}
|
||||
</CardDescription>
|
||||
{hasKey ? (
|
||||
<Badge variant="default" className="bg-green-600 hover:bg-green-700 shrink-0">
|
||||
<Check className="h-3 w-3 mr-1" />
|
||||
Connected
|
||||
</Badge>
|
||||
) : (
|
||||
<Badge variant="secondary" className="shrink-0">
|
||||
<X className="h-3 w-3 mr-1" />
|
||||
Not Connected
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<CardDescription>
|
||||
{modelCount > 0 && (
|
||||
<span className="text-xs">{modelCount} model{modelCount !== 1 ? 's' : ''}</span>
|
||||
)}
|
||||
</CardDescription>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
variant={hasKey ? 'outline' : 'default'}
|
||||
|
||||
@@ -98,7 +98,7 @@ export function SettingsDialog({ open, onOpenChange }: SettingsDialogProps) {
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
<div className="sm:hidden flex flex-col h-full min-h-0">
|
||||
<div className="sm:hidden flex flex-col h-full min-h-0 pt-safe">
|
||||
<div className="flex-shrink-0 bg-gradient-to-b from-background via-background to-transparent border-b border-border backdrop-blur-sm px-4 py-4 flex items-center justify-between">
|
||||
<div className="flex items-center gap-2 flex-1">
|
||||
{mobileView !== 'menu' && (
|
||||
|
||||
@@ -9,7 +9,7 @@ interface DeleteDialogProps {
|
||||
onConfirm: () => void
|
||||
onCancel: () => void
|
||||
title: string
|
||||
description: string
|
||||
description: React.ReactNode
|
||||
itemName?: string
|
||||
isDeleting?: boolean
|
||||
}
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "./dialog";
|
||||
|
||||
describe("DialogContent", () => {
|
||||
it("applies safe-area padding when fullscreen prop is true", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent fullscreen data-testid="dialog-content">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Test Dialog</DialogTitle>
|
||||
</DialogHeader>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
const content = screen.getByTestId("dialog-content");
|
||||
expect(content).toHaveStyle({ paddingTop: "env(safe-area-inset-top, 0px)" });
|
||||
});
|
||||
|
||||
it("applies safe-area padding when mobileFullscreen prop is true", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent mobileFullscreen data-testid="dialog-content">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Test Dialog</DialogTitle>
|
||||
</DialogHeader>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
const content = screen.getByTestId("dialog-content");
|
||||
expect(content).toHaveStyle({ paddingTop: "env(safe-area-inset-top, 0px)" });
|
||||
});
|
||||
|
||||
it("applies inset-0 for fullscreen dialogs", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent fullscreen data-testid="dialog-content">
|
||||
Content
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
const content = screen.getByTestId("dialog-content");
|
||||
expect(content).toHaveClass("inset-0");
|
||||
});
|
||||
|
||||
it("applies inset-0 for mobileFullscreen dialogs", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent mobileFullscreen data-testid="dialog-content">
|
||||
Content
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
const content = screen.getByTestId("dialog-content");
|
||||
expect(content).toHaveClass("inset-0");
|
||||
});
|
||||
|
||||
it("does not apply safe-area padding when neither fullscreen nor mobileFullscreen", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent data-testid="dialog-content">
|
||||
Content
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
const content = screen.getByTestId("dialog-content");
|
||||
const style = content.getAttribute("style") || "";
|
||||
expect(style).not.toContain("safe-area");
|
||||
expect(content).not.toHaveClass("inset-0");
|
||||
});
|
||||
|
||||
it("hides close button when fullscreen is true", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent fullscreen data-testid="dialog-content">
|
||||
Content
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
expect(screen.queryByRole("button", { name: /close/i })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows close button when mobileFullscreen is true", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent mobileFullscreen data-testid="dialog-content">
|
||||
Content
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
expect(screen.getByRole("button", { name: /close/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("hides close button when hideCloseButton is true", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent hideCloseButton data-testid="dialog-content">
|
||||
Content
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
expect(screen.queryByRole("button", { name: /close/i })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("merges custom className with default classes", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent className="custom-class" data-testid="dialog-content">
|
||||
Content
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
const content = screen.getByTestId("dialog-content");
|
||||
expect(content).toHaveClass("custom-class");
|
||||
expect(content).toHaveClass("fixed");
|
||||
expect(content).toHaveClass("z-50");
|
||||
});
|
||||
|
||||
it("renders children correctly", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent>
|
||||
<span>Test Child Content</span>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
expect(screen.getByText("Test Child Content")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -30,33 +30,52 @@ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
|
||||
interface DialogContentProps
|
||||
extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {
|
||||
hideCloseButton?: boolean
|
||||
fullscreen?: boolean
|
||||
mobileFullscreen?: boolean
|
||||
}
|
||||
|
||||
const DialogContent = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Content>,
|
||||
DialogContentProps
|
||||
>(({ className, children, hideCloseButton, ...props }, ref) => (
|
||||
<DialogPortal>
|
||||
<DialogOverlay />
|
||||
<DialogPrimitive.Content
|
||||
ref={ref}
|
||||
aria-describedby={undefined}
|
||||
className={cn(
|
||||
"fixed left-[50%] top-[50%] z-50 grid w-[90%] max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg [&.w-screen]:left-0 [&.w-screen]:top-0 [&.w-screen]:translate-x-0 [&.w-screen]:translate-y-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
{!hideCloseButton && (
|
||||
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
</DialogPrimitive.Close>
|
||||
)}
|
||||
</DialogPrimitive.Content>
|
||||
</DialogPortal>
|
||||
))
|
||||
>(({ className, children, hideCloseButton, fullscreen, mobileFullscreen, ...props }, ref) => {
|
||||
const isMobileFullscreenMode = fullscreen || mobileFullscreen
|
||||
|
||||
return (
|
||||
<DialogPortal>
|
||||
<DialogOverlay />
|
||||
<DialogPrimitive.Content
|
||||
ref={ref}
|
||||
aria-describedby={undefined}
|
||||
className={cn(
|
||||
"fixed z-50 grid gap-4 border bg-background shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||
fullscreen
|
||||
? "inset-0 w-full h-full max-w-none max-h-none p-0 rounded-none"
|
||||
: mobileFullscreen
|
||||
? "inset-0 w-full h-full max-w-none max-h-none p-0 rounded-none sm:inset-auto sm:left-[50%] sm:top-[50%] sm:w-[90%] sm:max-w-lg sm:max-h-none sm:translate-x-[-50%] sm:translate-y-[-50%] sm:p-6 sm:rounded-lg"
|
||||
: "left-[50%] top-[50%] w-[90%] max-w-lg translate-x-[-50%] translate-y-[-50%] p-6 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
||||
className
|
||||
)}
|
||||
style={isMobileFullscreenMode ? {
|
||||
paddingTop: 'env(safe-area-inset-top, 0px)',
|
||||
} : undefined}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
{!hideCloseButton && !fullscreen && (
|
||||
<DialogPrimitive.Close
|
||||
className="absolute right-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
|
||||
style={mobileFullscreen ? {
|
||||
top: 'calc(env(safe-area-inset-top, 0px) + 1rem)',
|
||||
} : { top: '1rem' }}
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
</DialogPrimitive.Close>
|
||||
)}
|
||||
</DialogPrimitive.Content>
|
||||
</DialogPortal>
|
||||
)
|
||||
})
|
||||
DialogContent.displayName = DialogPrimitive.Content.displayName
|
||||
|
||||
const DialogHeader = ({
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import * as React from "react"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
interface FullscreenSheetProps {
|
||||
children: React.ReactNode
|
||||
className?: string
|
||||
style?: React.CSSProperties
|
||||
}
|
||||
|
||||
interface FullscreenSheetHeaderProps {
|
||||
children: React.ReactNode
|
||||
className?: string
|
||||
}
|
||||
|
||||
interface FullscreenSheetContentProps {
|
||||
children: React.ReactNode
|
||||
className?: string
|
||||
}
|
||||
|
||||
const FullscreenSheet = React.forwardRef<HTMLDivElement, FullscreenSheetProps>(
|
||||
({ children, className, style, ...props }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn("fixed inset-0 z-50 bg-background flex flex-col", className)}
|
||||
style={style}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
)
|
||||
FullscreenSheet.displayName = "FullscreenSheet"
|
||||
|
||||
const FullscreenSheetHeader = React.forwardRef<HTMLDivElement, FullscreenSheetHeaderProps>(
|
||||
({ children, className, ...props }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex-shrink-0 border-b border-border bg-background backdrop-blur-sm pt-safe",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
)
|
||||
FullscreenSheetHeader.displayName = "FullscreenSheetHeader"
|
||||
|
||||
const FullscreenSheetContent = React.forwardRef<HTMLDivElement, FullscreenSheetContentProps>(
|
||||
({ children, className, ...props }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn("flex-1 overflow-hidden min-h-0", className)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
)
|
||||
FullscreenSheetContent.displayName = "FullscreenSheetContent"
|
||||
|
||||
export { FullscreenSheet, FullscreenSheetHeader, FullscreenSheetContent }
|
||||
@@ -0,0 +1,227 @@
|
||||
import { Settings } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { BackButton } from "@/components/ui/back-button";
|
||||
import { PageHeader } from "@/components/ui/page-header";
|
||||
import { useSettingsDialog } from "@/hooks/useSettingsDialog";
|
||||
import { useTheme } from "@/hooks/useTheme";
|
||||
import { EditSessionTitleDialog } from "@/components/session/EditSessionTitleDialog";
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
|
||||
import { MoreVertical } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { ReactNode } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useMobile } from "@/hooks/useMobile";
|
||||
import { Loader2, X } from "lucide-react";
|
||||
|
||||
interface HeaderProps {
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
function HeaderBase({ children, className, ...props }: HeaderProps) {
|
||||
return (
|
||||
<PageHeader className={cn("flex-shrink-0", className)} {...props}>
|
||||
<div className="flex items-center justify-between px-2 sm:px-4 py-1.5 sm:py-2">
|
||||
{children}
|
||||
</div>
|
||||
</PageHeader>
|
||||
);
|
||||
}
|
||||
|
||||
function HeaderBackButton({ to, className }: { to?: string; className?: string }) {
|
||||
return to ? <BackButton to={to} className={className} /> : null;
|
||||
}
|
||||
|
||||
interface HeaderTitleProps {
|
||||
children: ReactNode;
|
||||
logo?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
function HeaderTitle({ children, logo, className }: HeaderTitleProps) {
|
||||
const theme = useTheme();
|
||||
|
||||
return (
|
||||
<div className={cn("flex items-center gap-2", className)}>
|
||||
{logo && typeof children === "string" && children === "OpenCode" ? (
|
||||
<img
|
||||
src={theme === 'light' ? "/opencode-wordmark-light.svg" : "/opencode-wordmark-dark.svg"}
|
||||
alt="OpenCode"
|
||||
className="h-6 w-auto sm:h-8"
|
||||
/>
|
||||
) : (
|
||||
<h1 className="text-xl font-semibold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent truncate">
|
||||
{children}
|
||||
</h1>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
interface HeaderEditableTitleProps {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
subtitle?: string;
|
||||
generating?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
function HeaderEditableTitle({ value, onChange, subtitle, generating, className }: HeaderEditableTitleProps) {
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const [editTitle, setEditTitle] = useState(value);
|
||||
const isMobile = useMobile();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isEditing) {
|
||||
setEditTitle(value);
|
||||
}
|
||||
}, [value, isEditing]);
|
||||
|
||||
const handleTitleClick = () => {
|
||||
setIsEditing(true);
|
||||
setEditTitle(value);
|
||||
};
|
||||
|
||||
const handleTitleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (editTitle.trim() && editTitle !== value) {
|
||||
onChange(editTitle.trim());
|
||||
}
|
||||
setIsEditing(false);
|
||||
};
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Escape') {
|
||||
setEditTitle(value);
|
||||
setIsEditing(false);
|
||||
} else if (e.key === 'Enter') {
|
||||
handleTitleSubmit(e);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = (newTitle: string) => {
|
||||
if (newTitle.trim() && newTitle !== value) {
|
||||
onChange(newTitle.trim());
|
||||
}
|
||||
setIsEditing(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={cn("min-w-0 flex-1", className)}>
|
||||
{isMobile && (
|
||||
<EditSessionTitleDialog
|
||||
isOpen={isEditing}
|
||||
currentTitle={value}
|
||||
onClose={() => setIsEditing(false)}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
)}
|
||||
{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>
|
||||
) : (
|
||||
<div className="min-w-0">
|
||||
{generating ? (
|
||||
<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 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}
|
||||
>
|
||||
{value}
|
||||
</h1>
|
||||
)}
|
||||
{subtitle && (
|
||||
<p className="text-[10px] sm:text-xs text-muted-foreground truncate">
|
||||
{subtitle}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function HeaderActions({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return <div className={cn("flex items-center gap-2", className)}>{children}</div>;
|
||||
}
|
||||
|
||||
function HeaderMobileDropdown({ children, className }: { children: ReactNode; className?: string }) {
|
||||
const isMobile = useMobile();
|
||||
|
||||
if (!isMobile) return null;
|
||||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className={cn("text-foreground border-border hover:bg-accent transition-all duration-200 h-8 w-8", className)}
|
||||
title="Options"
|
||||
>
|
||||
<MoreVertical className="w-4 h-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
{children}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
);
|
||||
}
|
||||
|
||||
function HeaderSettingsButton() {
|
||||
const { open: openSettings } = useSettingsDialog();
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={openSettings}
|
||||
className="text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
|
||||
>
|
||||
<Settings className="w-4 h-4" />
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
export const Header = Object.assign(HeaderBase, {
|
||||
BackButton: HeaderBackButton,
|
||||
Title: HeaderTitle,
|
||||
EditableTitle: HeaderEditableTitle,
|
||||
Actions: HeaderActions,
|
||||
MobileDropdown: HeaderMobileDropdown,
|
||||
Settings: HeaderSettingsButton,
|
||||
}) as typeof HeaderBase & {
|
||||
BackButton: typeof HeaderBackButton;
|
||||
Title: typeof HeaderTitle;
|
||||
EditableTitle: typeof HeaderEditableTitle;
|
||||
Actions: typeof HeaderActions;
|
||||
MobileDropdown: typeof HeaderMobileDropdown;
|
||||
Settings: typeof HeaderSettingsButton;
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Trash2, Search } from "lucide-react";
|
||||
|
||||
interface ListToolbarProps {
|
||||
searchQuery: string;
|
||||
onSearchChange: (query: string) => void;
|
||||
searchPlaceholder?: string;
|
||||
selectedCount: number;
|
||||
totalCount: number;
|
||||
allSelected: boolean;
|
||||
onToggleSelectAll: () => void;
|
||||
onDelete: () => void;
|
||||
onDeleteAll: () => void;
|
||||
}
|
||||
|
||||
export function ListToolbar({
|
||||
searchQuery,
|
||||
onSearchChange,
|
||||
searchPlaceholder = "Search",
|
||||
selectedCount,
|
||||
totalCount,
|
||||
allSelected,
|
||||
onToggleSelectAll,
|
||||
onDelete,
|
||||
onDeleteAll,
|
||||
}: ListToolbarProps) {
|
||||
const hasItems = totalCount > 0;
|
||||
const hasSelection = selectedCount > 0;
|
||||
|
||||
const handleMobileDelete = () => {
|
||||
if (hasSelection) {
|
||||
onDelete();
|
||||
} else {
|
||||
onDeleteAll();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<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={searchPlaceholder}
|
||||
value={searchQuery}
|
||||
onChange={(e) => onSearchChange(e.target.value)}
|
||||
className="pl-10"
|
||||
/>
|
||||
</div>
|
||||
{hasItems && (
|
||||
<Button
|
||||
onClick={onToggleSelectAll}
|
||||
variant={hasSelection ? "default" : "outline"}
|
||||
className="whitespace-nowrap hidden md:flex"
|
||||
>
|
||||
{allSelected ? "Deselect All" : "Select All"}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
onClick={onDelete}
|
||||
variant="destructive"
|
||||
disabled={!hasSelection}
|
||||
className="hidden md:flex whitespace-nowrap"
|
||||
>
|
||||
<Trash2 className="w-4 h-4 mr-2" />
|
||||
Delete ({selectedCount})
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleMobileDelete}
|
||||
variant="destructive"
|
||||
size="icon"
|
||||
className="md:hidden"
|
||||
disabled={!hasItems}
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { PageHeader } from "./page-header";
|
||||
|
||||
describe("PageHeader", () => {
|
||||
it("applies pt-safe class for iOS safe area", () => {
|
||||
render(<PageHeader data-testid="header">Content</PageHeader>);
|
||||
const header = screen.getByTestId("header");
|
||||
expect(header).toHaveClass("pt-safe");
|
||||
});
|
||||
|
||||
it("applies sticky top-0 positioning", () => {
|
||||
render(<PageHeader data-testid="header">Content</PageHeader>);
|
||||
const header = screen.getByTestId("header");
|
||||
expect(header).toHaveClass("sticky");
|
||||
expect(header).toHaveClass("top-0");
|
||||
});
|
||||
|
||||
it("renders children correctly", () => {
|
||||
render(
|
||||
<PageHeader>
|
||||
<span>Test Child</span>
|
||||
</PageHeader>
|
||||
);
|
||||
expect(screen.getByText("Test Child")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("merges custom className", () => {
|
||||
render(
|
||||
<PageHeader data-testid="header" className="custom-class">
|
||||
Content
|
||||
</PageHeader>
|
||||
);
|
||||
const header = screen.getByTestId("header");
|
||||
expect(header).toHaveClass("custom-class");
|
||||
expect(header).toHaveClass("pt-safe");
|
||||
});
|
||||
|
||||
it("forwards additional props", () => {
|
||||
render(
|
||||
<PageHeader data-testid="header" aria-label="Page header">
|
||||
Content
|
||||
</PageHeader>
|
||||
);
|
||||
const header = screen.getByTestId("header");
|
||||
expect(header).toHaveAttribute("aria-label", "Page header");
|
||||
});
|
||||
|
||||
it("applies z-10 for proper stacking", () => {
|
||||
render(<PageHeader data-testid="header">Content</PageHeader>);
|
||||
const header = screen.getByTestId("header");
|
||||
expect(header).toHaveClass("z-10");
|
||||
});
|
||||
|
||||
it("applies background and border styling", () => {
|
||||
render(<PageHeader data-testid="header">Content</PageHeader>);
|
||||
const header = screen.getByTestId("header");
|
||||
expect(header).toHaveClass("border-b");
|
||||
expect(header).toHaveClass("border-border");
|
||||
expect(header).toHaveClass("bg-gradient-to-b");
|
||||
});
|
||||
|
||||
it("applies backdrop-blur-sm for frosted glass effect", () => {
|
||||
render(<PageHeader data-testid="header">Content</PageHeader>);
|
||||
const header = screen.getByTestId("header");
|
||||
expect(header).toHaveClass("backdrop-blur-sm");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import * as React from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export interface PageHeaderProps extends React.HTMLAttributes<HTMLElement> {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export const PageHeader = React.forwardRef<HTMLElement, PageHeaderProps>(
|
||||
({ className, children, ...props }, ref) => {
|
||||
return (
|
||||
<header
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"sticky top-0 z-10 border-b border-border bg-gradient-to-b from-background via-background to-background backdrop-blur-sm pt-safe",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</header>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
PageHeader.displayName = "PageHeader";
|
||||
@@ -279,8 +279,14 @@ body {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.pb-safe {
|
||||
padding-bottom: env(safe-area-inset-bottom, 0px);
|
||||
@utility pt-safe {
|
||||
padding-top: constant(safe-area-inset-top);
|
||||
padding-top: env(safe-area-inset-top);
|
||||
}
|
||||
|
||||
@utility pb-safe {
|
||||
padding-bottom: constant(safe-area-inset-bottom);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
|
||||
/* Prevent iOS zoom on all input elements */
|
||||
|
||||
@@ -4,12 +4,17 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { getRepo } from "@/api/repos";
|
||||
import { SessionList } from "@/components/session/SessionList";
|
||||
import { FileBrowserSheet } from "@/components/file-browser/FileBrowserSheet";
|
||||
import { RepoDetailHeader } from "@/components/layout/RepoDetailHeader";
|
||||
import { Header } from "@/components/ui/header";
|
||||
import { SwitchConfigDialog } from "@/components/repo/SwitchConfigDialog";
|
||||
import { RepoMcpDialog } from "@/components/repo/RepoMcpDialog";
|
||||
import { useCreateSession } from "@/hooks/useOpenCode";
|
||||
import { OPENCODE_API_ENDPOINT, API_BASE_URL } from "@/config";
|
||||
import { useSwipeBack } from "@/hooks/useMobile";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { BranchSwitcher } from "@/components/repo/BranchSwitcher";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Plug, FolderOpen, Plus, GitBranch } from "lucide-react";
|
||||
|
||||
import { Loader2 } from "lucide-react";
|
||||
|
||||
@@ -107,24 +112,86 @@ export function RepoDetail() {
|
||||
const branchToDisplay = repo.currentBranch || repo.branch;
|
||||
const displayName = branchToDisplay ? `${repoName} (${branchToDisplay})` : repoName;
|
||||
const currentBranch = repo.currentBranch || repo.branch || "main";
|
||||
const isWorktree = repo.isWorktree || false;
|
||||
|
||||
return (
|
||||
<div
|
||||
<div
|
||||
ref={pageRef}
|
||||
className="h-dvh max-h-dvh overflow-hidden bg-gradient-to-br from-background via-background to-background flex flex-col"
|
||||
style={swipeStyles}
|
||||
>
|
||||
<RepoDetailHeader
|
||||
repoName={repoName}
|
||||
repoId={repoId}
|
||||
currentBranch={currentBranch}
|
||||
isWorktree={repo.isWorktree || false}
|
||||
repoUrl={repo.repoUrl}
|
||||
onMcpClick={() => setMcpDialogOpen(true)}
|
||||
onFilesClick={() => setFileBrowserOpen(true)}
|
||||
onNewSession={handleCreateSession}
|
||||
disabledNewSession={!opcodeUrl || createSessionMutation.isPending}
|
||||
/>
|
||||
<Header>
|
||||
<Header.BackButton to="/" />
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<Header.Title>{repoName}</Header.Title>
|
||||
{isWorktree ? (
|
||||
<Badge className="text-xs px-1.5 sm:px-2.5 py-0.5 bg-purple-600/20 text-purple-400 border-purple-600/40" title="Worktree">
|
||||
<GitBranch className="h-3 w-3 sm:mr-1" />
|
||||
<span className="hidden sm:inline">WT: {currentBranch}</span>
|
||||
</Badge>
|
||||
) : !isWorktree && currentBranch ? (
|
||||
<BranchSwitcher
|
||||
repoId={repoId}
|
||||
currentBranch={currentBranch}
|
||||
isWorktree={false}
|
||||
repoUrl={repo.repoUrl}
|
||||
className="hidden sm:flex w-[140px] max-w-[140px]"
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
<Header.Actions>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => setMcpDialogOpen(true)}
|
||||
size="sm"
|
||||
className="hidden sm:flex text-foreground border-border hover:bg-accent transition-all duration-200 hover:scale-105"
|
||||
>
|
||||
<Plug className="w-4 h-4 sm:mr-2" />
|
||||
<span className="hidden sm:inline">MCP</span>
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => setFileBrowserOpen(true)}
|
||||
size="sm"
|
||||
className="hidden sm:flex text-foreground border-border hover:bg-accent transition-all duration-200 hover:scale-105"
|
||||
>
|
||||
<FolderOpen className="w-4 h-4 sm:mr-2" />
|
||||
<span className="hidden sm:inline">Files</span>
|
||||
</Button>
|
||||
<Header.MobileDropdown>
|
||||
{!isWorktree && currentBranch && (
|
||||
<>
|
||||
<div className="px-2 py-1.5">
|
||||
<BranchSwitcher
|
||||
repoId={repoId}
|
||||
currentBranch={currentBranch}
|
||||
isWorktree={false}
|
||||
repoUrl={repo.repoUrl}
|
||||
iconOnly={false}
|
||||
className="w-full"
|
||||
/>
|
||||
</div>
|
||||
<div className="h-px bg-border my-1" />
|
||||
</>
|
||||
)}
|
||||
<DropdownMenuItem onClick={() => setMcpDialogOpen(true)}>
|
||||
<Plug className="w-4 h-4 mr-2" /> MCP
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setFileBrowserOpen(true)}>
|
||||
<FolderOpen className="w-4 h-4 mr-2" /> Files
|
||||
</DropdownMenuItem>
|
||||
</Header.MobileDropdown>
|
||||
<Button
|
||||
onClick={() => handleCreateSession()}
|
||||
disabled={!opcodeUrl || createSessionMutation.isPending}
|
||||
size="sm"
|
||||
className="bg-blue-600 hover:bg-blue-700 text-white transition-all duration-200 hover:scale-105"
|
||||
>
|
||||
<Plus className="w-4 h-4 sm:mr-2" />
|
||||
<span className="hidden sm:inline">New Session</span>
|
||||
</Button>
|
||||
</Header.Actions>
|
||||
</Header>
|
||||
|
||||
<div className="flex-1 flex flex-col min-h-0">
|
||||
{opcodeUrl && repoDirectory && (
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState } from "react";
|
||||
import { RepoList } from "@/components/repo/RepoList";
|
||||
import { AddRepoDialog } from "@/components/repo/AddRepoDialog";
|
||||
import { FileBrowserSheet } from "@/components/file-browser/FileBrowserSheet";
|
||||
import { Header } from "@/components/layout/Header";
|
||||
import { Header } from "@/components/ui/header";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Plus, FolderOpen } from "lucide-react";
|
||||
|
||||
@@ -15,29 +15,28 @@ export function Repos() {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-background via-background to-background">
|
||||
<Header
|
||||
title="OpenCode"
|
||||
action={
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => setFileBrowserOpen(true)}
|
||||
>
|
||||
<FolderOpen className="w-4 h-4 sm:mr-2" />
|
||||
<span className="hidden sm:inline">Workspace</span>
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => setAddRepoOpen(true)}
|
||||
>
|
||||
<Plus className="w-4 h-4 mr-1" />
|
||||
<span className="hidden sm:inline">Repository</span>
|
||||
<span className="sm:hidden">Repo</span>
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
<div className="container mx-auto sm:p-2 p-4">
|
||||
<div className="h-dvh max-h-dvh overflow-hidden bg-gradient-to-br from-background via-background to-background flex flex-col">
|
||||
<Header>
|
||||
<div className="flex items-center gap-3">
|
||||
<Header.Title logo>OpenCode</Header.Title>
|
||||
</div>
|
||||
<Header.Actions>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => setFileBrowserOpen(true)}
|
||||
className="text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
|
||||
>
|
||||
<FolderOpen className="w-4 h-4" />
|
||||
</Button>
|
||||
<Button onClick={() => setAddRepoOpen(true)} size="sm">
|
||||
<Plus className="w-4 h-4 mr-1" />
|
||||
Repo
|
||||
</Button>
|
||||
<Header.Settings />
|
||||
</Header.Actions>
|
||||
</Header>
|
||||
<div className="container mx-auto sm:p-2 flex-1 pt-2 px-2 min-h-0 overflow-auto">
|
||||
<RepoList />
|
||||
</div>
|
||||
<AddRepoDialog open={addRepoOpen} onOpenChange={setAddRepoOpen} />
|
||||
|
||||
@@ -4,13 +4,17 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import { getRepo } from "@/api/repos";
|
||||
import { MessageThread } from "@/components/message/MessageThread";
|
||||
import { PromptInput, type PromptInputHandle } from "@/components/message/PromptInput";
|
||||
import { X, VolumeX } from "lucide-react";
|
||||
import { X, VolumeX, FolderOpen, Plug, Settings, Upload, CornerUpLeft } from "lucide-react";
|
||||
import { ModelSelectDialog } from "@/components/model/ModelSelectDialog";
|
||||
import { SessionDetailHeader } from "@/components/session/SessionDetailHeader";
|
||||
import { Header } from "@/components/ui/header";
|
||||
import { SessionList } from "@/components/session/SessionList";
|
||||
|
||||
import { FileBrowserSheet } from "@/components/file-browser/FileBrowserSheet";
|
||||
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { BranchSwitcher } from "@/components/repo/BranchSwitcher";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { ContextUsageIndicator } from "@/components/session/ContextUsageIndicator";
|
||||
import { useSession, useAbortSession, useUpdateSession, useMessages, useTitleGenerating, useCreateSession } from "@/hooks/useOpenCode";
|
||||
import { OPENCODE_API_ENDPOINT, API_BASE_URL } from "@/config";
|
||||
import { useSSE } from "@/hooks/useSSE";
|
||||
@@ -294,29 +298,110 @@ export function SessionDetail() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
<div
|
||||
ref={pageRef}
|
||||
className="h-dvh max-h-dvh overflow-hidden bg-gradient-to-br from-background via-background to-background flex flex-col"
|
||||
style={swipeStyles}
|
||||
>
|
||||
<SessionDetailHeader
|
||||
repo={repo}
|
||||
sessionId={sessionId}
|
||||
sessionTitle={session?.title || "Untitled Session"}
|
||||
repoId={repoId}
|
||||
isConnected={isConnected}
|
||||
isReconnecting={isReconnecting}
|
||||
opcodeUrl={opcodeUrl}
|
||||
repoDirectory={repoDirectory}
|
||||
parentSessionId={session?.parentID}
|
||||
isTitleGenerating={isTitleGenerating}
|
||||
onFileBrowserOpen={() => setFileBrowserOpen(true)}
|
||||
onSettingsOpen={openSettings}
|
||||
onMcpDialogOpen={() => setMcpDialogOpen(true)}
|
||||
onSessionTitleUpdate={handleSessionTitleUpdate}
|
||||
onParentSessionClick={handleParentSessionClick}
|
||||
onAttachFile={handleAttachFile}
|
||||
/>
|
||||
<Header>
|
||||
<div className="flex items-center gap-1.5 sm:gap-3 min-w-0 flex-1">
|
||||
{session?.parentID ? (
|
||||
<>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={handleParentSessionClick}
|
||||
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">
|
||||
<Header.BackButton to={`/repos/${repoId}`} className="text-xs sm:text-sm" />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<Header.BackButton to={`/repos/${repoId}`} className="text-xs sm:text-sm" />
|
||||
)}
|
||||
<Header.EditableTitle
|
||||
value={session?.title || "Untitled Session"}
|
||||
onChange={handleSessionTitleUpdate}
|
||||
subtitle={repo.repoUrl?.split("/").pop()?.replace(".git", "") || repo.localPath || "Repository"}
|
||||
generating={isTitleGenerating}
|
||||
/>
|
||||
</div>
|
||||
<Header.Actions className="gap-2 sm:gap-4">
|
||||
<ContextUsageIndicator
|
||||
opcodeUrl={opcodeUrl}
|
||||
sessionID={sessionId}
|
||||
directory={repoDirectory}
|
||||
isConnected={isConnected}
|
||||
isReconnecting={isReconnecting}
|
||||
/>
|
||||
<BranchSwitcher
|
||||
repoId={repoId}
|
||||
currentBranch={repo.currentBranch || "main"}
|
||||
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={() => setFileBrowserOpen(true)}
|
||||
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={() => setMcpDialogOpen(true)}
|
||||
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={openSettings}
|
||||
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>
|
||||
<Header.MobileDropdown>
|
||||
<div className="px-2 py-1.5">
|
||||
<BranchSwitcher
|
||||
repoId={repoId}
|
||||
currentBranch={repo.currentBranch || "main"}
|
||||
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={() => setFileBrowserOpen(true)}>
|
||||
<FolderOpen className="w-4 h-4 mr-2" /> Files
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={handleAttachFile}>
|
||||
<Upload className="w-4 h-4 mr-2" /> Upload
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setMcpDialogOpen(true)}>
|
||||
<Plug className="w-4 h-4 mr-2" /> MCP
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={openSettings}>
|
||||
<Settings className="w-4 h-4 mr-2" /> Settings
|
||||
</DropdownMenuItem>
|
||||
</Header.MobileDropdown>
|
||||
</Header.Actions>
|
||||
</Header>
|
||||
|
||||
<div className="flex-1 overflow-hidden flex flex-col relative">
|
||||
<div key={sessionId} ref={messageContainerRef} className="flex-1 overflow-y-auto overflow-x-hidden pb-28 overscroll-contain">
|
||||
|
||||
@@ -1,35 +1,24 @@
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
||||
import { Header } from '@/components/layout/Header'
|
||||
import { Header } from '@/components/ui/header'
|
||||
import { GeneralSettings } from '@/components/settings/GeneralSettings'
|
||||
import { KeyboardShortcuts } from '@/components/settings/KeyboardShortcuts'
|
||||
import { OpenCodeConfigManager } from '@/components/settings/OpenCodeConfigManager'
|
||||
|
||||
export function Settings() {
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-[#0a0a0a] via-[#0d0d0d] to-[#0a0a0a]">
|
||||
<Header title="Settings" backTo="/" />
|
||||
<div className="min-h-screen bg-gradient-to-br from-background via-background to-background">
|
||||
<Header>
|
||||
<Header.BackButton to="/" />
|
||||
<Header.Title>Settings</Header.Title>
|
||||
<Header.Settings />
|
||||
</Header>
|
||||
|
||||
<div className="max-w-4xl mx-auto p-6">
|
||||
<Tabs defaultValue="general" className="w-full">
|
||||
<TabsList className="grid w-full grid-cols-3 mb-8 bg-[#141414] border border-[#262626] p-1">
|
||||
<TabsTrigger
|
||||
value="general"
|
||||
className="data-[state=active]:bg-blue-800 data-[state=active]:text-white text-zinc-400"
|
||||
>
|
||||
General
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="shortcuts"
|
||||
className="data-[state=active]:bg-blue-800 data-[state=active]:text-white text-zinc-400"
|
||||
>
|
||||
Shortcuts
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="opencode"
|
||||
className="data-[state=active]:bg-blue-800 data-[state=active]:text-white text-zinc-400"
|
||||
>
|
||||
OpenCode
|
||||
</TabsTrigger>
|
||||
<TabsList className="grid w-full grid-cols-3 mb-8">
|
||||
<TabsTrigger value="general">General</TabsTrigger>
|
||||
<TabsTrigger value="shortcuts">Shortcuts</TabsTrigger>
|
||||
<TabsTrigger value="opencode">OpenCode</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="general">
|
||||
@@ -40,19 +29,19 @@ export function Settings() {
|
||||
<KeyboardShortcuts />
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="opencode">
|
||||
<TabsContent value="opencode">
|
||||
<OpenCodeConfigManager />
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="commands">
|
||||
<div className="bg-[#141414] border border-[#262626] rounded-lg p-8 text-center">
|
||||
<p className="text-zinc-500">Commands manager coming soon</p>
|
||||
<div className="border border-border rounded-lg p-8 text-center">
|
||||
<p className="text-muted-foreground">Commands manager coming soon</p>
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="agents">
|
||||
<div className="bg-[#141414] border border-[#262626] rounded-lg p-8 text-center">
|
||||
<p className="text-zinc-500">Agents manager coming soon</p>
|
||||
<div className="border border-border rounded-lg p-8 text-center">
|
||||
<p className="text-muted-foreground">Agents manager coming soon</p>
|
||||
</div>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
|
||||
@@ -1,30 +1,13 @@
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { FileBrowser } from '@/components/file-browser/FileBrowser'
|
||||
import { ArrowLeft } from 'lucide-react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { Header } from '@/components/ui/header'
|
||||
|
||||
export function Workspace() {
|
||||
const navigate = useNavigate()
|
||||
|
||||
return (
|
||||
<div className="h-screen bg-gradient-to-br from-background via-background to-background flex flex-col">
|
||||
<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-4 py-2">
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => navigate('/repos')}
|
||||
className="text-muted-foreground hover:text-foreground transition-all duration-200 hover:scale-105"
|
||||
>
|
||||
<ArrowLeft className="w-4 h-4" />
|
||||
</Button>
|
||||
<h1 className="text-lg font-semibold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent">
|
||||
Workspace
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Header>
|
||||
<Header.BackButton to="/repos" />
|
||||
<Header.Title>Workspace</Header.Title>
|
||||
</Header>
|
||||
|
||||
<div className="flex-1 overflow-hidden p-4">
|
||||
<FileBrowser />
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
@@ -0,0 +1,18 @@
|
||||
import path from "path";
|
||||
import { defineConfig } from "vitest/config";
|
||||
import react from "@vitejs/plugin-react";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
test: {
|
||||
environment: "jsdom",
|
||||
globals: true,
|
||||
setupFiles: ["./src/test/setup.ts"],
|
||||
include: ["src/**/*.test.{ts,tsx}"],
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user