feat(settings): sidebar + detail Settings page (#135)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
Profiles S2 over the variant C verdict (#130): Settings becomes a sidebar + detail shell — Content (the #17 Home control, unchanged) · Pass 1 · Pass 2 · Chat ('· Sessions' rides it) · Provider Keys. Each surface page edits its model block in memory: provider menu, an NSComboBox sourcing hermes' registry cache with first-class free text (the #132 seed claude-sonnet-5-5 is NOT in the cache — custom is the default state, pinned), per-provider effort menus led by 'unset · provider default' (zai low/high/max; OpenAI + Anthropic the five-rung ladder), variant B's current-model headline, and a user-requested Restore Defaults back to the seed. Provider Keys carries endpoint, the z.ai key-type toggle swapping the endpoint family (paas/v4 ↔ coding/paas/v4 — a custom endpoint survives), and masked keys with reveal; no Keychain (#131). Persistence is S3's job: every change routes through an injectable SettingsWriting seam whose implementer contract is frozen now (MUST debounce — the key field fires per keystroke; secrets via stdin/env, never argv; error text redacted before it renders). Write failures surface in an orange strip, cleared by the next success. Dogfood fix, log-observed via os_log probes on the live app: comboBoxSelectionDidChange fires BEFORE stringValue updates — the pick is read from objectValueOfSelectedItem and the box re-synced by hand, or the model never learns a dropdown pick. Two blind fixes failed before the probe round settled it; pinned against the stale-string fixture and filed to the swift wiki. Finish-audit fanout (ponytail/security/general): Ship/SHIP/APPROVE — applied the SettingsWriting contract, an inlined one-caller wrapper, a corrected registry-leniency comment, and a seed-provider pin; declined deleting the hydration clamp (trust-boundary validation for S3's config.yaml reads); deferred endpoint scheme validation to S3's write boundary. Suite: 432 passed / 432 (xcresult-verified). DOX: Museion/AGENTS.md, MuseionTests/AGENTS.md, CHANGELOG, session log. Closes #135
This commit is contained in:
1 parent
610f8789bd
commit
42a27cc8a3
12 files changed
+1315
-32
No files matched your search
+181
-27
@@ -3,50 +3,204 @@
|
||||
// Museion
|
||||
//
|
||||
// #17 (S1.1): Settings — the Museion Home path, repoint-only (ADR-0004).
|
||||
// #72 rework: the Typography + Text Flow sections are gone — single-user
|
||||
// app, prose typography is hardcoded (editing: ProseTypography constants;
|
||||
// reading: Museion/Resources/reading.css, editable while the app runs).
|
||||
// #135 (Profiles S2): reworked to the #130 prototype's variant C verdict —
|
||||
// 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).
|
||||
//
|
||||
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
/// Settings pane. Home control per #17.
|
||||
/// Settings pane — sidebar + detail per prototype variant C.
|
||||
struct SettingsPaneView: View {
|
||||
@Binding var home: URL
|
||||
@State private var page: SettingsPage = .content
|
||||
/// #135: in-memory model, pane-local until S3 lifts persistence in.
|
||||
@State private var model = SettingsModel()
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 24) {
|
||||
contentSection
|
||||
VStack(spacing: 0) {
|
||||
PaneHeader(title: "Settings")
|
||||
if let error = model.lastWriteError {
|
||||
Text(error)
|
||||
.font(.system(size: 11, design: DesignTokens.mono))
|
||||
.foregroundStyle(.orange)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.horizontal, 14)
|
||||
.padding(.vertical, 4)
|
||||
}
|
||||
HStack(spacing: 0) {
|
||||
sidebar
|
||||
Rectangle()
|
||||
.fill(DesignTokens.border)
|
||||
.frame(width: 1)
|
||||
detail
|
||||
}
|
||||
.padding(24)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
}
|
||||
.background(DesignTokens.background)
|
||||
}
|
||||
|
||||
// MARK: Home (#17)
|
||||
// MARK: Sidebar (prototype `.vC .side`)
|
||||
|
||||
private var contentSection: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
Text("Content")
|
||||
.font(.system(size: 13, weight: .semibold))
|
||||
HStack(spacing: 8) {
|
||||
Text(home.path(percentEncoded: false))
|
||||
.font(.system(size: 12, design: DesignTokens.mono))
|
||||
.lineLimit(1)
|
||||
.truncationMode(.middle)
|
||||
.textSelection(.enabled)
|
||||
Spacer(minLength: 12)
|
||||
Button("Choose…") { chooseHome() }
|
||||
private var sidebar: some View {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
ForEach(SettingsPage.allCases) { candidate in
|
||||
SettingsSidebarButton(
|
||||
page: candidate,
|
||||
selection: $page,
|
||||
)
|
||||
}
|
||||
Text(
|
||||
"Repoint-only: Museion never moves content. The Posts list reads this folder's projects/ and archive/ directories.",
|
||||
)
|
||||
.font(.callout)
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
.padding(.horizontal, 8)
|
||||
.padding(.vertical, 14)
|
||||
.frame(width: DesignTokens.settingsSidebarWidth)
|
||||
}
|
||||
|
||||
// MARK: Detail (prototype `.vC .detail`)
|
||||
|
||||
private var detail: some View {
|
||||
ScrollView {
|
||||
switch page {
|
||||
case .content:
|
||||
ContentSettingsPage(home: $home)
|
||||
case .pass1:
|
||||
SurfaceSettingsPage(model: model, surface: .pass1)
|
||||
case .pass2:
|
||||
SurfaceSettingsPage(model: model, surface: .pass2)
|
||||
case .chat:
|
||||
SurfaceSettingsPage(model: model, surface: .chat)
|
||||
case .keys:
|
||||
ProviderKeysPage(model: model)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
|
||||
/// The sidebar's destinations (#135): the #17 Content control, one page per
|
||||
/// LLM surface (Sessions rides Chat — #126), and the provider keys.
|
||||
enum SettingsPage: String, CaseIterable, Identifiable, Hashable {
|
||||
case content
|
||||
case pass1
|
||||
case pass2
|
||||
case chat
|
||||
case keys
|
||||
|
||||
var id: String {
|
||||
rawValue
|
||||
}
|
||||
|
||||
var label: String {
|
||||
switch self {
|
||||
case .content: "Content"
|
||||
case .pass1: "Pass 1"
|
||||
case .pass2: "Pass 2"
|
||||
case .chat: "Chat"
|
||||
case .keys: "Provider Keys"
|
||||
}
|
||||
}
|
||||
|
||||
/// The prototype's trailing mono annotation: pass chips + the Sessions
|
||||
/// note on Chat (the chat row notes "Sessions rides this engine").
|
||||
var annotation: String? {
|
||||
switch self {
|
||||
case .pass1: "P1"
|
||||
case .pass2: "P2"
|
||||
case .chat: "· Sessions"
|
||||
default: nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One sidebar row (prototype `.vC .side-button`): quiet label, trailing
|
||||
/// mono annotation, surface card + inset accent bar when current.
|
||||
private struct SettingsSidebarButton: View {
|
||||
let page: SettingsPage
|
||||
@Binding var selection: SettingsPage
|
||||
@State private var hover = false
|
||||
|
||||
var body: some View {
|
||||
let selected = selection == page
|
||||
Button {
|
||||
selection = page
|
||||
} label: {
|
||||
HStack(spacing: 8) {
|
||||
Text(page.label)
|
||||
.foregroundStyle(DesignTokens.foreground)
|
||||
Spacer(minLength: 0)
|
||||
if let annotation = page.annotation {
|
||||
Text(annotation)
|
||||
.font(.system(size: 10, design: DesignTokens.mono))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 7)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.background {
|
||||
if selected || hover {
|
||||
RoundedRectangle(cornerRadius: 8)
|
||||
.fill(selected ? DesignTokens.surface : DesignTokens.foreground.opacity(0.06))
|
||||
}
|
||||
}
|
||||
.overlay(alignment: .leading) {
|
||||
// `.side-button.current` inset accent bar.
|
||||
if selected {
|
||||
RoundedRectangle(cornerRadius: 1)
|
||||
.fill(DesignTokens.accent)
|
||||
.frame(width: 2)
|
||||
.padding(.vertical, 4)
|
||||
}
|
||||
}
|
||||
.onHover { hover = $0 }
|
||||
.accessibilityLabel(page.label)
|
||||
.accessibilityAddTraits(selected ? [.isSelected] : [])
|
||||
}
|
||||
}
|
||||
|
||||
/// The Content page: the existing #17 Home control, repoint-only, in the
|
||||
/// variant C form (quiet label, mono path, Choose…).
|
||||
private struct ContentSettingsPage: View {
|
||||
@Binding var home: URL
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text("Content")
|
||||
.font(.system(size: 16, weight: .semibold, design: DesignTokens.serif))
|
||||
Text("Where the corpus lives.")
|
||||
.font(.system(size: 12))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
VStack(alignment: .leading, spacing: 14) {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
SettingsFieldLabel("Museion Home")
|
||||
HStack(spacing: 8) {
|
||||
Text(home.path(percentEncoded: false))
|
||||
.font(.system(size: 12, design: DesignTokens.mono))
|
||||
.lineLimit(1)
|
||||
.truncationMode(.middle)
|
||||
.textSelection(.enabled)
|
||||
Spacer(minLength: 12)
|
||||
Button("Choose…") { chooseHome() }
|
||||
.buttonStyle(.bordered)
|
||||
}
|
||||
}
|
||||
Text("Repoint-only: Museion never moves content.")
|
||||
.font(.system(size: 11.5))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
}
|
||||
.padding(.top, 12)
|
||||
}
|
||||
.frame(maxWidth: DesignTokens.settingsFormWidth, alignment: .leading)
|
||||
.padding(.horizontal, 26)
|
||||
.padding(.top, 18)
|
||||
.padding(.bottom, 48)
|
||||
}
|
||||
|
||||
private func chooseHome() {
|
||||
|
||||
Reference in new issue
Block a user