8c7328f3a(remote quotas: a Remote set to Select none still tells its cards) was committed from a stale tree. Beside its own three files (docs/subsystems/providers-accounts.md, remote_quotas_scope.go, remote_quotas_test.go) it wrote 21 files back to their state before35aaaa4b9, which took out: -35aaaa4b9, the Codex client setting (codex_request.go, codex_tier.go, settings.go, settingsapi.go, api.go, app.js, i18n.js, index.html, codex-client.test.cjs and the rest); -2fa79aef3, a save of the bytes a file already holds changes nothing (#6289: logins.go, logins_unchanged_test.go); -797a23cad, the tray's words (traywords.go, traytip_words_test.go). The 21 files are checked out from 8c7328f3a^. After this commit `git diff 8c7328f3a^ --stat` names only the three remote-quota files, so main is the three lost commits plus 8c7328f3a's own change. Run (mica, at this tree): gofmt -l clean; go test -count=1 -tags nogui ./internal/provider ./internal/settings ./internal/settingsapi ok. ./internal/cli and . are red on main already, not from this: the codex-client and codex-open routes have no notYet entry, and catalog.go's mmddSnapshot is compiled at launch (1ca2c62c4). Both are fixed in the next two commits.
77 lines
2.2 KiB
Go
77 lines
2.2 KiB
Go
package provider
|
|
|
|
import (
|
|
"fmt"
|
|
"slices"
|
|
"strings"
|
|
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// CodexServiceTier is the service tier set for every request Codex sends
|
|
// (settings.CodexServiceTier): "" as Codex asks it, settings.CodexTierStandard
|
|
// for none, "priority" or "ultrafast". A value this magpie doesn't know
|
|
// (a newer one's, a file edited by hand) is read as "" and changes nothing.
|
|
func CodexServiceTier() string {
|
|
v := strings.TrimSpace(heldSettings().CodexServiceTier)
|
|
if !slices.Contains(settings.CodexServiceTiers, v) {
|
|
return ""
|
|
}
|
|
return v
|
|
}
|
|
|
|
// SetCodexServiceTier sets settings.CodexServiceTier.
|
|
func SetCodexServiceTier(tier string) error {
|
|
tier = strings.TrimSpace(tier)
|
|
if !slices.Contains(settings.CodexServiceTiers, tier) {
|
|
return fmt.Errorf("Codex's service tier must be one of %q, not %q", settings.CodexServiceTiers[1:], tier)
|
|
}
|
|
s := settings.Load()
|
|
if s.CodexServiceTier == tier {
|
|
return nil
|
|
}
|
|
s.CodexServiceTier = tier
|
|
return settings.Save(s)
|
|
}
|
|
|
|
// SetCodexOpen sets what the Open button of Codex's Agents row opens: "",
|
|
// "app" or "terminal" (Yink88564391 on X).
|
|
func SetCodexOpen(v string) error {
|
|
v = strings.TrimSpace(v)
|
|
if !slices.Contains(settings.CodexOpens, v) {
|
|
return fmt.Errorf("Codex's Open button must open one of %q, not %q", settings.CodexOpens[1:], v)
|
|
}
|
|
s := settings.Load()
|
|
if s.CodexOpen == v {
|
|
return nil
|
|
}
|
|
s.CodexOpen = v
|
|
return settings.Save(s)
|
|
}
|
|
|
|
// CodexClient is the Codex client magpie presents to the ChatGPT backend
|
|
// (settings.CodexClient): "" for Codex CLI, "desktop" for the Codex app. A
|
|
// value this magpie doesn't know (a newer one's, a file edited by hand) is
|
|
// read as "" and changes nothing.
|
|
func CodexClient() string {
|
|
v := strings.TrimSpace(heldSettings().CodexClient)
|
|
if !slices.Contains(settings.CodexClients, v) {
|
|
return ""
|
|
}
|
|
return v
|
|
}
|
|
|
|
// SetCodexClient sets settings.CodexClient.
|
|
func SetCodexClient(v string) error {
|
|
v = strings.TrimSpace(v)
|
|
if !slices.Contains(settings.CodexClients, v) {
|
|
return fmt.Errorf("the Codex client must be one of %q, not %q", settings.CodexClients[1:], v)
|
|
}
|
|
s := settings.Load()
|
|
if s.CodexClient == v {
|
|
return nil
|
|
}
|
|
s.CodexClient = v
|
|
return settings.Save(s)
|
|
}
|