Add app loader and skeleton states

This commit is contained in:
Chris Scott committed 2026-01-15 19:03:25 -05:00
1 parent 7ba2cf2328
commit 2ba959ac0b
5 files changed
+78 -15

No files matched your search

+29
View File
@@ -14,6 +14,35 @@
</head>
<body>
<div id="root"></div>
<div id="app-loader" style="
position: absolute;
top: 0;
left: 0;
width: 100%;
min-height: calc(100% + env(safe-area-inset-top));
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 24px;
background: #000;
z-index: 9999;
">
<img src="/opencode-wordmark-dark.svg" alt="OpenCode" style="height: 42px; width: auto;" />
<div style="
width: 24px;
height: 24px;
border: 2px solid rgba(255,255,255,0.1);
border-top-color: rgba(255,255,255,0.8);
border-radius: 50%;
animation: app-loader-spin 0.8s linear infinite;
"></div>
</div>
<style>
@keyframes app-loader-spin {
to { transform: rotate(360deg); }
}
</style>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
+10
View File
@@ -1,3 +1,4 @@
import { useEffect } from 'react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { BrowserRouter, Routes, Route } from 'react-router-dom'
import { Toaster } from 'sonner'
@@ -24,6 +25,15 @@ function RouterContent() {
const { isOpen, close } = useSettingsDialog()
useTheme()
useEffect(() => {
const loader = document.getElementById('app-loader')
if (loader) {
loader.style.transition = 'opacity 0.2s ease-out'
loader.style.opacity = '0'
setTimeout(() => loader.remove(), 200)
}
}, [])
return (
<>
<Routes>
@@ -10,7 +10,6 @@ import {
import { GitBranch, Check, Plus, GitCommit, Loader2 } from "lucide-react";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { listBranches, switchBranch, GitAuthError } from "@/api/repos";
import { useGitStatus } from "@/api/git";
import { AddBranchWorkspaceDialog } from "@/components/repo/AddBranchWorkspaceDialog";
import { GitChangesSheet } from "@/components/file-browser/GitChangesSheet";
import { showToast } from "@/lib/toast";
@@ -29,7 +28,6 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep
const [addBranchOpen, setAddBranchOpen] = useState(false);
const [gitChangesOpen, setGitChangesOpen] = useState(false);
const queryClient = useQueryClient();
const { data: gitStatus } = useGitStatus(repoId);
const { data: branches, isLoading: branchesLoading, refetch: refetchBranches } = useQuery({
queryKey: ["branches", repoId],
@@ -100,11 +98,6 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep
<div className="flex items-center gap-2 w-full">
<GitCommit className="w-3 h-3" />
<span className="flex-1">View Changes</span>
{gitStatus?.hasChanges && (
<span className="text-xs text-yellow-500">
{gitStatus.files.length}
</span>
)}
</div>
</DropdownMenuItem>
</>
@@ -117,11 +110,6 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep
<div className="flex items-center gap-2 w-full">
<GitCommit className="w-3 h-3" />
<span className="flex-1">View Changes</span>
{gitStatus?.hasChanges && (
<span className="text-xs text-yellow-500">
{gitStatus.files.length}
</span>
)}
</div>
</DropdownMenuItem>
{repoUrl && (
@@ -0,0 +1,22 @@
export function RepoCardSkeleton() {
return (
<div className="relative border rounded-xl overflow-hidden border-border bg-card w-full">
<div className="p-2">
<div className="flex items-start gap-3 mb-1">
<div className="w-5 h-5 bg-muted animate-pulse rounded" />
<div className="h-5 bg-muted animate-pulse rounded w-32" />
</div>
<div className="flex items-center gap-2 text-sm">
<div className="flex flex-1 items-center gap-3">
<div className="h-4 bg-muted animate-pulse rounded w-20" />
</div>
<div className="flex items-center gap-1 shrink-0">
<div className="h-8 w-8 bg-muted animate-pulse rounded" />
<div className="h-8 w-8 bg-muted animate-pulse rounded" />
<div className="h-8 w-8 bg-muted animate-pulse rounded" />
</div>
</div>
</div>
</div>
)
}
+17 -3
View File
@@ -6,9 +6,10 @@ import { CSS } from "@dnd-kit/utilities"
import { listRepos, deleteRepo, updateRepoOrder } from "@/api/repos"
import { DeleteDialog } from "@/components/ui/delete-dialog"
import { ListToolbar } from "@/components/ui/list-toolbar"
import { Loader2, GitBranch, Search, GripVertical } from "lucide-react"
import { GitBranch, Search, GripVertical } from "lucide-react"
import type { Repo } from "@/api/types"
import { RepoCard } from "./RepoCard"
import { RepoCardSkeleton } from "./RepoCardSkeleton"
function SortableRepoCard({
repo,
@@ -147,8 +148,21 @@ export function RepoList() {
if (isLoading && !repos) {
return (
<div className="flex items-center justify-center p-8">
<Loader2 className="w-6 h-6 animate-spin" />
<div className="px-0 md:p-4 h-full flex flex-col">
<div className="px-2 md:px-0">
<div className="h-10 bg-muted/50 animate-pulse rounded w-full" />
</div>
<div className="mx-2 md:mx-0 flex-1 min-h-0">
<div className="h-full overflow-y-auto pt-4 pb-2 md:pb-0">
<div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-2 gap-3 md:gap-4 w-full">
{Array.from({ length: 6 }).map((_, i) => (
<div key={i} className="pl-8">
<RepoCardSkeleton />
</div>
))}
</div>
</div>
</div>
</div>
)
}