feat(settings): profiles write path + Test Connection (#136)
Profiles S3 over the S2 shell: every Settings change now persists. Model/effort writes ride the engine's own CLI — `hermes -p <profile> config set/unset` for model.provider / model.default / model.reasoning_effort / model.base_url (zai endpoint family written LAST: setting model.provider clears a stale base_url, live-probed; unset-when-absent is idempotent success). Provider keys upsert VAR=value into ALL THREE profiles' .env — a key entered before any surface is on its provider still persists and pre-lands for any later switch (maintainer ruling 2026-10-28; no switch re-fire). 0600, foreign lines preserved byte-for-byte, line-broken values refused at the shared sink (env-file injection guard), NSLock serializes the read-upsert-write across concurrent provider writes. Hydration reads model blocks and keys back at pane open — a restart neither blanks the key fields nor refuses Test Connection; an edit made mid-read owns the truth (no stomp), and a custom z.ai base_url seeds the endpoint field instead of being clobbered to a family default. Per-target writes coalesce AND chain past the debounce guard: cancellation can't stop a past-the-guard CLI write, so the newer write queues — the last edit is always the last write to land (finish-audit race fix, pinned). Test Connection = two-step probe (GET /models, then a minimal streaming chat) with honest decode per the factsheet: zai 1113 → wrong key type, 401s → auth failed (Anthropic request_id), finish=length → starved, empty 200 → request failed, errors riding a 2xx decoded as the provider error. Live-probed wire corrections (dogfood, 2026-10-28): Content-Type application/json on every request — URLSession defaults to form-urlencoded and providers diverge (zai 200+envelope, OpenAI 400, Anthropic tolerates); OpenAI speaks the Responses API (/responses, input + max_output_tokens, flagship gpt-6.1-sol); probe token cap 512 (64 starved reasoning models into "no content"); OpenAI's "error": null event snapshots don't decode as failures. Finish-audit (ponytail + security + general reviewers): write-ordering race + .env lost update + hydrate stomp + custom-endpoint clobber fixed and pinned (one-shot hold / latched read knobs in the test double); ~30 lines of dead flexibility cut (keyType protocol param, works(reply:) payload, unused timeout knob, double JSON round trips). Suite 468/468 xcresult-verified; swiftlint clean; factsheet §6 correction logged. Closes #136
This commit is contained in:
1 parent
42a27cc8a3
commit
5ad605eb3c
20 files changed
+1983
-161
No files matched your search
@@ -7,8 +7,9 @@
|
||||
// a Settings sidebar + detail column (System Settings shape): destinations
|
||||
// Content · Pass 1 · Pass 2 · Chat · Provider Keys. Content keeps the #17
|
||||
// Home control unchanged; the surface and keys pages live in
|
||||
// SettingsPagesView.swift over the in-memory SettingsModel (persistence is
|
||||
// S3's job — the write-path protocol is the seam).
|
||||
// SettingsPagesView.swift.
|
||||
// #136 (Profiles S3): the model runs over HermesSettingsWriter (the real
|
||||
// CLI/.env rail) and hydrates from the profiles at pane open.
|
||||
//
|
||||
|
||||
import AppKit
|
||||
@@ -17,9 +18,20 @@ import SwiftUI
|
||||
/// Settings pane — sidebar + detail per prototype variant C.
|
||||
struct SettingsPaneView: View {
|
||||
@Binding var home: URL
|
||||
/// #136: the gate's binary winner — HermesSettingsWriter's CLI rail and
|
||||
/// the hydration reads both need it (nil before a gate pass: writes
|
||||
/// surface their failure, reads leave the seed).
|
||||
let binaryPath: String?
|
||||
@State private var page: SettingsPage = .content
|
||||
/// #135: in-memory model, pane-local until S3 lifts persistence in.
|
||||
@State private var model = SettingsModel()
|
||||
/// #135/#136: the model over the REAL write path; hydrated from the
|
||||
/// profiles at pane open.
|
||||
@State private var model: SettingsModel
|
||||
|
||||
init(home: Binding<URL>, binaryPath: String?) {
|
||||
_home = home
|
||||
self.binaryPath = binaryPath
|
||||
_model = State(initialValue: SettingsModel(writer: HermesSettingsWriter(hermesBinary: binaryPath)))
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
@@ -41,6 +53,7 @@ struct SettingsPaneView: View {
|
||||
}
|
||||
}
|
||||
.background(DesignTokens.background)
|
||||
.task { await model.hydrate() }
|
||||
}
|
||||
|
||||
// MARK: Sidebar (prototype `.vC .side`)
|
||||
|
||||
Reference in new issue
Block a user