mirror of
https://github.com/awizemann/scarf.git
synced 2026-05-10 18:44:45 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e8fcd699f2 | |||
| d82b28258d | |||
| 323a1e55f4 | |||
| 959a68b707 |
@@ -82,6 +82,11 @@ final class ServerRegistry {
|
|||||||
/// Flip the default server to `id`. Passing `ServerContext.local.id`
|
/// Flip the default server to `id`. Passing `ServerContext.local.id`
|
||||||
/// clears the flag on every remote entry, making Local the implicit
|
/// clears the flag on every remote entry, making Local the implicit
|
||||||
/// default. Passing an unknown ID is a no-op. Persisted on return.
|
/// default. Passing an unknown ID is a no-op. Persisted on return.
|
||||||
|
///
|
||||||
|
/// Intentionally doesn't fire `onEntriesChanged` — that hook means "the
|
||||||
|
/// set of servers changed" and drives the menu-bar fanout rebuild. A
|
||||||
|
/// default-flag flip doesn't change the set; SwiftUI views reading
|
||||||
|
/// `defaultServerID` redraw via `@Observable`'s tracking of `entries`.
|
||||||
func setDefaultServer(_ id: ServerID) {
|
func setDefaultServer(_ id: ServerID) {
|
||||||
var changed = false
|
var changed = false
|
||||||
for idx in entries.indices {
|
for idx in entries.indices {
|
||||||
@@ -93,7 +98,6 @@ final class ServerRegistry {
|
|||||||
}
|
}
|
||||||
if changed {
|
if changed {
|
||||||
save()
|
save()
|
||||||
onEntriesChanged?()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,19 +143,20 @@ struct ManageServersView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A star button that marks the open-on-launch default. Filled + yellow
|
/// A star button that marks the open-on-launch default. Filled + yellow
|
||||||
/// on the current default row (and non-interactive — clicking it is a
|
/// on the current default row (disabled, since clicking would be a
|
||||||
/// no-op since the flag is already set); outline + secondary elsewhere,
|
/// no-op); outline + secondary elsewhere, clicking promotes that row
|
||||||
/// clicking promotes that row to default.
|
/// to default.
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private func defaultStar(for id: ServerID, currentDefault: ServerID) -> some View {
|
private func defaultStar(for id: ServerID, currentDefault: ServerID) -> some View {
|
||||||
let isDefault = id == currentDefault
|
let isDefault = id == currentDefault
|
||||||
Button {
|
Button {
|
||||||
if !isDefault { registry.setDefaultServer(id) }
|
registry.setDefaultServer(id)
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemName: isDefault ? "star.fill" : "star")
|
Image(systemName: isDefault ? "star.fill" : "star")
|
||||||
.foregroundStyle(isDefault ? .yellow : .secondary)
|
.foregroundStyle(isDefault ? .yellow : .secondary)
|
||||||
}
|
}
|
||||||
.buttonStyle(.borderless)
|
.buttonStyle(.borderless)
|
||||||
|
.disabled(isDefault)
|
||||||
.help(isDefault ? "Opens on launch" : "Set as default — open this server when Scarf launches.")
|
.help(isDefault ? "Opens on launch" : "Set as default — open this server when Scarf launches.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ final class SettingsViewModel {
|
|||||||
var hermesRunning = false
|
var hermesRunning = false
|
||||||
var rawConfigYAML = ""
|
var rawConfigYAML = ""
|
||||||
var personalities: [String] = []
|
var personalities: [String] = []
|
||||||
var providers = ["anthropic", "openrouter", "nous", "openai-codex", "google-ai-studio", "xai", "ollama-cloud", "zai", "kimi-coding", "minimax"]
|
|
||||||
var terminalBackends = ["local", "docker", "singularity", "modal", "daytona", "ssh"]
|
var terminalBackends = ["local", "docker", "singularity", "modal", "daytona", "ssh"]
|
||||||
var browserBackends = ["browseruse", "firecrawl", "local"]
|
var browserBackends = ["browseruse", "firecrawl", "local"]
|
||||||
var ttsProviders = ["edge", "elevenlabs", "openai", "minimax", "mistral", "neutts"]
|
var ttsProviders = ["edge", "elevenlabs", "openai", "minimax", "mistral", "neutts"]
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import SwiftUI
|
|||||||
|
|
||||||
struct SidebarView: View {
|
struct SidebarView: View {
|
||||||
@Environment(AppCoordinator.self) private var coordinator
|
@Environment(AppCoordinator.self) private var coordinator
|
||||||
|
@Environment(\.serverContext) private var serverContext
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@Bindable var coordinator = coordinator
|
@Bindable var coordinator = coordinator
|
||||||
@@ -59,6 +60,6 @@ struct SidebarView: View {
|
|||||||
}
|
}
|
||||||
.listStyle(.sidebar)
|
.listStyle(.sidebar)
|
||||||
.navigationTitle("Scarf")
|
.navigationTitle("Scarf")
|
||||||
.splitViewAutosaveName("ScarfMainSidebar")
|
.splitViewAutosaveName("ScarfMainSidebar.\(serverContext.id)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user