Added a lot of functionality. Bugfixes and changes

This commit is contained in:
2026-02-15 16:46:06 +01:00
parent 2434e554f8
commit 04c9b8da1e
31 changed files with 6653 additions and 239 deletions

View File

@@ -18,6 +18,7 @@ struct HeaderView: View {
let onProviderChange: (Settings.Provider) -> Void
private let settings = SettingsService.shared
private let registry = ProviderRegistry.shared
private let gitSync = GitSyncService.shared
var body: some View {
HStack(spacing: 12) {
@@ -120,10 +121,13 @@ struct HeaderView: View {
if mcpEnabled {
StatusPill(icon: "folder", label: "MCP", color: .blue)
}
if settings.syncEnabled && settings.syncAutoSave {
SyncStatusPill()
}
}
// Divider between status and stats
if onlineMode || mcpEnabled || model?.capabilities.imageGeneration == true {
if onlineMode || mcpEnabled || model?.capabilities.imageGeneration == true || (settings.syncEnabled && settings.syncAutoSave) {
Divider()
.frame(height: 16)
.opacity(0.5)
@@ -186,6 +190,81 @@ struct StatusPill: View {
}
}
struct SyncStatusPill: View {
private let gitSync = GitSyncService.shared
@State private var syncColor: Color = .secondary
@State private var syncLabel: String = "Sync"
@State private var tooltipText: String = ""
var body: some View {
HStack(spacing: 3) {
Circle()
.fill(syncColor)
.frame(width: 6, height: 6)
Text(syncLabel)
.font(.system(size: 10, weight: .medium))
.foregroundColor(.oaiSecondary)
}
.padding(.horizontal, 6)
.padding(.vertical, 2)
.background(syncColor.opacity(0.1), in: Capsule())
.help(tooltipText)
.onAppear {
updateState()
}
.onChange(of: gitSync.syncStatus) {
updateState()
}
.onChange(of: gitSync.isSyncing) {
updateState()
}
.onChange(of: gitSync.lastSyncError) {
updateState()
}
}
private func updateState() {
// Determine sync state
if let error = gitSync.lastSyncError {
syncColor = .red
syncLabel = "Error"
tooltipText = "Sync failed: \(error)"
} else if gitSync.isSyncing {
syncColor = .orange
syncLabel = "Syncing"
tooltipText = "Syncing..."
} else if gitSync.syncStatus.isCloned {
syncColor = .green
syncLabel = "Synced"
if let lastSync = gitSync.syncStatus.lastSyncTime {
tooltipText = "Last synced: \(timeAgo(lastSync))"
} else {
tooltipText = "Synced"
}
} else {
syncColor = .secondary
syncLabel = "Sync"
tooltipText = "Sync not configured"
}
}
private func timeAgo(_ date: Date) -> String {
let seconds = Int(Date().timeIntervalSince(date))
if seconds < 60 {
return "just now"
} else if seconds < 3600 {
let minutes = seconds / 60
return "\(minutes)m ago"
} else if seconds < 86400 {
let hours = seconds / 3600
return "\(hours)h ago"
} else {
let days = seconds / 86400
return "\(days)d ago"
}
}
}
#Preview {
VStack {
HeaderView(