Files
museion/docs/devlog/20261027-issue135-profiles-s2-settings-page-ui_log.md
T
AlexKucera 42a27cc8a3
CI / ci (push) Canceled after 0s
feat(settings): sidebar + detail Settings page (#135)
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
2026-10-27 11:52:39 +01:00

11 KiB

#135 Profiles S2 — Settings page UI (sidebar + detail)

Date: 2026-10-27 Type: issue Reference: #135

Goal

Implement ticket #135 (Profiles S2, part of the #125 wayfinder map): rework SettingsPaneView to the #130 prototype's variant C verdict — a sidebar + detail shape with destinations Content · Pass 1 · Pass 2 · Chat · Provider Keys — over an in-memory model with an injectable write-path protocol (persistence is S3's job). Acceptance: variant C reproduced natively with working interactions (provider switch swaps the effort menu, z.ai key-type toggle swaps the endpoint family, reveal toggles) + unit tests for provider → effort options, custom-model state, key-type → endpoint family.

Verification

  • Full suite: 432 passed / 432 total (xcresult executed-count verified, never the banner), xcodebuild build SUCCEEDED, swiftformat + swiftlint clean on every touched file.
  • The one first-run failure (second pass while one runs refuses and cancel ends it) was the documented fake-ACP load flake (#30/#134 class) — it ran while the app was launching; 432/432 on the isolation rerun.
  • The combobox dogfood fix was verified from the LIVE app via temporary os_log probes (log show --info): a real click logged selectionDidChange stringValue=claude-sonnet-5-5 idx=7 → commit: raw=claude-opus-4-6 -> COMMIT, then the user confirmed working. Probes stripped afterwards.
  • Visual capture from the agent shell was impossible all session (no Screen Recording/AX permission, cua-driver down, testmanagerd flake per #134) — the pixel-level pass was the user's one-glance checklist instead.

What Was Done

  • Museion/SettingsModel.swift (new) — ModelProvider (rawValues are hermes slugs; OpenAI = openai-api, label "OpenAI"), per-provider effort ladders (zai low/high/max; OpenAI + Anthropic low/medium/high/xhigh/max), pinned provider-switch default models (prototype #130's flagships), ZaiKeyType endpoint families (/api/paas/v4 ↔ /api/coding/paas/v4, factsheet §1), ModelRegistry (lenient decode of ~/.hermes/provider_models_cache.json, memoized via static let loadedDefault), SurfaceModelConfig (seed = the #132 sonnet posture), SettingsModel (@MainActor @Observable, pane-local until S3): config(for:) clamps a hydrated out-of-ladder effort to nil, resetToDefault (the user-requested Restore Defaults), fire-and-forget writes tracked in pendingWrites (capped; awaitPendingWrites() is the tests' deterministic sync), lastWriteError failure strip cleared by the next SUCCESSFUL write, and the SettingsWriting write-path seam — the docstring carries the implementer contract (MUST debounce — the key field fires per keystroke; secrets via stdin/env never argv; error text redacted). S2 ships NoopSettingsWriter.
  • Museion/SettingsPaneView.swift (reworked) — variant C shell: SettingsPage sidebar (quiet labels + trailing mono annotations — Chat carries "· Sessions"; surface card + inset 2px accent bar when current) + detail column; Content page = the #17 Home control unchanged (repoint-only); orange lastWriteError strip under the header.
  • Museion/SettingsPagesView.swift (new) — per-surface page (provider menu, model combobox + "custom (not in registry)" note, per-provider effort menu led by "unset · provider default", variant B's current-model accent headline stolen into C, 24k budget stated as a non-control, Restore Defaults in the page header) + Provider Keys page (per-provider block: endpoint, z.ai key-type segment swapping the family, masked key + reveal, coding-plan distribution note).
  • Museion/ModelComboBox.swift (new) — NSComboBox representable: registry list + first-class free text (claude-sonnet-5-5 is NOT in the cache — custom is the default state), echo-guard update (OutlineRowTextView pattern), commits on three rails (action/Enter, controlTextDidEndEditing/blur, comboBoxSelectionDidChange/list-pick).
  • Museion/DesignTokens.swift — settingsSidebarWidth 190 / settingsFormWidth 480.
  • MuseionTests/SettingsModelTests.swift (new, 18 tests + the combobox pin) — effort ladders + unset default + provider-switch reset; custom-model state (seed custom, registry known, switch defaults, empty registry = all free text, blanks never commit); z.ai family mapping, toggle swap, custom-endpoint survival, cleared-endpoint adoption; the write-path seam via a RecordingWriter double (struct record, #134 ConfigWrite precedent; failSurfaceWrites knob pins the failure path); reset-to-seed; hydration clamp; registry lenient decode; the combobox commit rails incl. the stale-stringValue fixture.
  • DOX — Museion/AGENTS.md (Settings section rewritten for the #135 world) + MuseionTests/AGENTS.md (test-file entry).

Decisions & Rationale

Decision Rationale
Model combobox = NSComboBox representable The issue's fold-in demands "a proper combobox" — the native control gives dropdown + free text + completion in one; the prototype's Custom… ↩ two-state dance collapsed into it
Provider switch resets model to a pinned flagship + effort to unset Prototype #130's pinned behavior (the visual contract); registry order is capability-sorted, not default-sorted
Single z.ai endpoint value; toggle swaps family only when at a family default The real write path persists ONE base_url; a custom endpoint is user data and survives the toggle (2-line guard, prevents loss)
@MainActor protocol SettingsWriting The NonisolatedNonsendingByDefault upcoming feature rejects nonisolated-async conformances touching MainActor state (measured on this toolchain); S3 writers hop off-main internally
Write failures land in lastWriteError, cleared on SUCCESS not commit LearningsPane strip posture; clearing at commit was optimistic and documented wrong (mid-session review catch)
Registry memoized (loadedDefault), per-launch SwiftUI runs @State default args on every construction of the pane — the disk read must happen once (mid-session review catch; ponytail: no live refresh)
Read-boundary effort clamp in config(for:) S3 hydrates from hand-edited config.yaml; an out-of-ladder effort would render a blank menu selection — the exact silent-UI-break class the combobox bug demonstrated. Ponytail reviewer asked to delete it as S3-for-later; declined — trust-boundary validation for data a planned slice certainly delivers, pinned + documented
awaitPendingWrites() instead of test sleeps Repo learning #30/#134: timing-based waits are the fake-ACP flake class; deterministic main-actor sync instead
Endpoint scheme validation deferred No network call exists in S2; the key only attaches to the URL at S3's write boundary — validate there (finish-audit deferral, recorded)
SettingsWriting docstring contract (debounce-MUST, secrets never argv, redact errors) Finish-audit security finding (medium): per-keystroke commits would make S3's .env fan-out persist every partial prefix of a typed key; the cheapest right-seam fix is freezing the contract at the seam, not UI plumbing now
One-caller ModelRegistry.contains inlined Finish-audit ponytail finding; 4 lines out, no loss

Gotchas & Fixes

Problem Root Cause Fix
Model dropdown picks didn't change the model (user-reported twice) Guess #1 (missing delegate method) was half right; the REAL cause, proven by os_log probes on the live app: comboBoxSelectionDidChange fires BEFORE stringValue updates — the handler read the STALE old value, the echo guard SKIPped, and the pick never reached the model (the box followed visually, the state was stuck) Read the pick from objectValueOfSelectedItem, re-sync box.stringValue by hand (the no-field-editor path produces no follow-up event); pinned against the stale-string fixture
Two blind fixes shipped before the probe round AppKit event-ordering questions aren't answerable by reading docs — macOS 27's actual delivery differs Temporary os_log probes + one human click settled it in a single round; probes stripped after. Recorded in the swift wiki (gotchas/swiftui-appkit-layout.md #17) + agent memory
Probe log came back empty log stream/log show filter out Logger.info lines unless --info/--level info is passed Re-query with --info; captured the decisive trace
First delegate fix round failed to compile (os import, probe access level, self. capture in the log closure) Iterated in the small; swiftformat also re-joins guard lines the linter then flags (148/154-char lines) Fixed per error; split guards so the formatter can't re-join them into line-length violations
Task.isFinished doesn't exist on this toolchain pendingWrites.removeAll { $0.isFinished } failed to build Cap-64 array trim instead (ponytail-commented)
First finish-audit fanout died (3/3 interrupted, no findings drafted) Provider-side interruption mid-model-response User cancelled that round; re-ran cleanly after the dogfood fix — all three completed
Root AGENTS.md lost its SwiftFairy paragraph mid-session User's own edit, not ours Left untouched; the MCP was unavailable all session anyway — consulted the swift agent-wiki + live probes instead

Files Changed

File Change Summary
Museion/SettingsModel.swift NEW — providers/efforts/key-types/registry + SettingsModel + SettingsWriting seam
Museion/SettingsPaneView.swift Reworked to variant C sidebar + detail shell; Content page unchanged behavior
Museion/SettingsPagesView.swift NEW — surface pages + Provider Keys page + field-label/segment controls
Museion/ModelComboBox.swift NEW — NSComboBox representable, three commit rails
Museion/DesignTokens.swift +settingsSidebarWidth/settingsFormWidth
MuseionTests/SettingsModelTests.swift NEW — 19 tests over the model + combobox wiring
Museion/AGENTS.md, MuseionTests/AGENTS.md DOX pass for the Settings slice

Open Items & Next Steps

  • Profiles S3 — persistence over the SettingsWriting seam (hermes -p <profile> config set + .env fan-out per the docstring contract); lift SettingsModel to AppGateState; endpoint scheme validation at the write boundary (finish-audit deferral).
  • Profiles S4 (#137) — per-surface engine lifecycle; consumes ProfileSurface(passKind:).
  • Visual pixel-diff of variant C against the prototype remains human-verified only (capture permissions blocked all session) — if it recurs, granting the terminal Screen Recording + AX would unlock automated visual checks.
  • testmanagerd UI-runner flake persists machine-wide (pre-dates this slice, #134).

Log written by write-log skill