'use client' import { useState, useEffect } from 'react' import { useData } from '@/components/data-provider' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { Badge } from '@/components/ui/badge' import { RefreshCw, RotateCcw, AlertTriangle, Database, HardDrive, FolderSync, } from 'lucide-react' import { BackupCard } from '@/components/backup-section' export default function SettingsPage() { const { syncing, resetting, lastSyncResult, lastSyncTime, handleSync, handleReset } = useData() const [resetOpen, setResetOpen] = useState(false) const [paths, setPaths] = useState<{ database: string; images: string; claudeLogs: string; codexLogs: string } | null>(null) useEffect(() => { fetch('/api/check') .then((r) => r.json()) .then((d) => { if (d.paths) setPaths(d.paths) }) .catch(() => {}) }, []) return (
{/* Local Data */}
Local Data Manage your synced session data
{/* Sync */}
Sync Logs

Import new sessions from ~/.claude and ~/.codex into the local database.

{lastSyncTime && (

Last synced: {lastSyncTime.toLocaleString()} {lastSyncResult && ( — {lastSyncResult.sessionsAdded} added, {lastSyncResult.sessionsSkipped} skipped )}

)}
{/* Reset */}
Reset Database

Delete all synced data and re-import from log files on disk. Use if data seems corrupted.

{/* Database Info */}
Storage Where your data lives
Database {paths?.database ?? 'agentfit.db'}
Claude Code logs {paths?.claudeLogs ?? '~/.claude/projects/'}
Codex logs {paths?.codexLogs ?? '~/.codex/sessions/'}
Extracted images {paths?.images ?? 'data/images/'}
{/* GitHub Backup */} {/* Reset confirmation dialog */} Destructive Action
This will permanently delete all synced data from the database and re-import from log files currently on disk.
Warning: If your coding agent (Claude Code, Codex, etc.) has purged old log files, that data will be permanently lost. The database may contain sessions that no longer exist on disk.
This cannot be undone. Consider backing up agentfit.db first.
) }