feat(mentor): editorial pane chrome (#156)
CI / ci (push) Canceled after 0s

Wayfinder map #153, build slice 2 of the #154 contract: the pane's
chrome joins the transcript's editorial voice (#155).

Header per .pane-head — serif-15/600 "Mentor", engine status, mono-10
session chip; ready is the semantic green dot (DesignTokens.readyGreen,
the palette's sole exception) + lowercase mono "ready", base version in
the tooltip, the drift note kept visible. The segmented Pass 1 | Pass 2
| Chat picker is dead (settled #4): PassBarView always carries and owns
the compact text-tab selector (2pt accent underline) over a PASS N ·
STATE status line, the cost line, and the actions as MonoButton —
accent solid / surface+border / accent outline, the danger voice.
Fix-cards row is the ruled plain mono link; crash, missing-engine, and
starting states render as the quiet state-cards.

Finish-audit fanout: security clean; orphaned MARK, stale doc comment,
and a phantom-border comment fixed; pass-selector remount reset and
solid-button contrast parked in the devlog (swift-wiki gotcha #28).

Suite 592/592 (xcresult count), swiftformat + swiftlint clean at the
error tier.

Closes #153
This commit is contained in:
AlexKucera committed 2026-11-04 10:37:13 +01:00
1 parent 2aa8bdabd8
commit d6c4712aaa
8 files changed
+317 -140

No files matched your search

+2 -1
View File
@@ -130,7 +130,7 @@ Single-context: `GLOSSARY.md` + `docs/adr/` at the repo root. See `docs/agents/d
<!-- gitnexus:start -->
# GitNexus — Code Intelligence
This project is indexed by GitNexus as **museion** (6075 symbols, 25600 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
This project is indexed by GitNexus as **museion** (6119 symbols, 26141 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
> Index stale? Run `node .gitnexus/run.cjs analyze` from the project root — it auto-selects an available runner. No `.gitnexus/run.cjs` yet? `npx gitnexus analyze` (npm 11 crash → `npm i -g gitnexus`; #1939).
@@ -200,6 +200,7 @@ Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Fu
<!-- write-log: window-start -->
| Date | Log |
|------|-----|
| 2026-11-04 | [20261104-issue156-mentor-pane-chrome-editorial-voice_log.md](docs/devlog/20261104-issue156-mentor-pane-chrome-editorial-voice_log.md) |
| 2026-11-04 | [20261104-issue155-shared-conversation-surface-editorial-voice_log.md](docs/devlog/20261104-issue155-shared-conversation-surface-editorial-voice_log.md) |
| 2026-11-03 | [20261103-issue151-gateless-launch-async-engine-check-rail-pill-auto-fire_log.md](docs/devlog/20261103-issue151-gateless-launch-async-engine-check-rail-pill-auto-fire_log.md) |
| 2026-11-03 | [20261103-issue58-voice-payload-landed_log.md](docs/devlog/20261103-issue58-voice-payload-landed_log.md) |
+2
View File
@@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file. The format
### Changed
- **mentor:** Editorial pane chrome (#156, wayfinder map #153 — the #154 contract's build slice 2; the map closes here) — MentorPaneView's chrome now speaks the same two-color editorial voice the transcript gained in #155. The header drops the icon and "Mentor Session" headline for a serif-15/600 "Mentor", and the ready state becomes the semantic green dot (`DesignTokens.readyGreen` — the palette's single sanctioned exception) + lowercase mono `ready`; the base engine version moves to the tooltip (the rare gate/handshake drift note stays visible in orange). The segmented Pass 1 | Pass 2 | Chat picker is gone — the pass bar always carries and owns a compact text-tab selector (mono-10 uppercase tracked, 2pt accent underline on the active tab) above a `PASS N · STATE` status line, the cost line, and the actions as the contract's `MonoButton` (accent solid Run/Restart, surface+border Blind Read, accent-outline Cancel — danger is terracotta, no second hue). The fix-cards row is the ruled plain mono link (no card, no hairline of its own), and the crash / missing-engine / starting states render as quiet state-cards (terracotta tri, serif head, sans-muted body, mini-spinner mono interim). Finish-audit pass: security clean; the orphaned pass-surface MARK, the stale `hermes <base>` doc comment, and a phantom-border comment are fixed; two advisories parked in the devlog (pass-selector state resets on a phase dip — filed as swift-wiki gotcha #28; solid-button contrast ≈ 3.85:1, inherited from #155, to fix pane-wide if flagged). Suite 592 (issue #156)
- **mentor:** Editorial chat voice on the shared transcript (#155, wayfinder map #153 — the #154 contract's build slice 1) — the Mentor and Sessions panes' shared conversation surface now speaks the two-color editorial voice. The model's speaker prefixes map onto three render voices (`speaker(of:)`, pinned): "Mentor:" turns render as full-width serif 15/1.6 prose (markdown parsed at flush, verbatim while streaming — the Vivarium #97 pattern), "You:" turns as right-aligned terracotta-wash capsules (radius 12/12/2/12, capped at 85% of the live column width), and everything else (refusals, pass kick-off labels, Blind Read reveals) as the quiet mono status box on the fg-wash card. ThinkingBlock port: mono-11 toggle over serif-13 muted on the recessed card, open with a spinner while live, collapsed when flushed; research-note cards inherit the wash family. The composer restyles per contract — surface-fill input, ONE accent Send flipping to a terracotta-outlined Stop (plain Return sends, Shift+Return breaks the line — the composer previously sent the draft on Return with no way to type a newline at all), a floating thinMaterial liveness chip above the composer while streaming, and the Debug toggle seated at its trailing edge (the header checkbox is gone; the header keeps title + engine status + session chip). Finish-audit (3 reviewers) hardened it: interpreted markdown opens http(s) ONLY — an `openURL` gate at the sink (engine prose echoes imported content, so a lying label-over-scheme link can never reach a registered handler; pinned via the pure `linkVerdict` seam), Caps Lock no longer turns Shift+Return into a send (pinned), and the two plain-Button toggles speak their state to VoiceOver. Suite 584, flip-verified pins (issue #155)
- **launch:** Gateless launch (#151, wayfinder map #148) — every launch opened a blocking EngineGate sheet over a placeholder logo, ran `hermes acp --check` behind it, and only handed over the workspace on pass + Start Writing; a provisioning failure then raised a second modal sheet (`ProvisioningFailureCard`). Now the workspace IS the first frame: the posts scan starts immediately, the engine check runs async beside it (`AppGateState.startLaunchCheck` from `ContentView.task` — the gate era's exact auto-fire chain moved verbatim: provisioning ×3 then the daily backup on pass, once per app-launch, first window only, no-op under hosted tests), and engine state never interrupts — a 44×44 rail pill above Archive (pulsing accent dot while checking, warning glyph on an accent wash when failed, nothing at all once healthy — the slot collapses and the rail spacing closes) plus mono-10 mentor-pane header states ("checking the engine…" / "engine missing" / "setup failed" / `hermes <base>` once ready — the BASE version, not the gate's derived string; session chip renders only once ready). Failure auto-expands an anchored floating card at the rail's bottom-left (340pt, accent border — floats, never blocks): engine-missing carries #40's install steps with the gateless correction ("Passes and Sessions need it — the editor keeps working"), Copy, Installation guide, Re-check (disabled-while-checking, "Checking…"), and Technical details (stderr + probed path); provisioning failure rides the same card (failing profile named, Retry inline — a successful retry dismisses it). Panes spawn the engine the moment the check lands (`.task(id: binaryPath)` on the nil→value arrival). `state.json` semantics unchanged (About still reads it). The gate sheet, placeholder screen, `EngineGateView`, and `ProvisioningFailureCard` are deleted; #38's no-silent-degradation AC survives, carried by the pill. New pins in `GatelessLaunchTests` (hosted-test no-op, chain armed, pill + mentor-header visibility mappings); `EngineGateTests` untouched and green. Finish-audit pass: the Sessions pane gains the same honest missing-engine notice (never an eternal "Starting…" spinner), focus mode recesses the fail card with the rail (deep work uninterrupted; exiting focus restores it), and the dead `deferFailure` (#48's Not-Now) is deleted with its test. Suite 582 (issues #148–#151)
+3 -3
View File
@@ -20,7 +20,7 @@ Owned by the root AGENTS.md contract. The `.xcodeproj` uses **filesystem-synchro
## Workspace shell (M1, #17 + #18 / S1.1)
- `DesignTokens.swift` — palette/geometry from the design contract (`ref/Web-Prototype/museion-workspace.html` `:root` + grid): background/surface/foreground/muted/border/accent colors, radius 10, column widths (rail 56, library 232, mentor 356; the export's editor min 420 lands with #19's editor column), serif/mono font designs. **#89 (2026-10-09):** two-color world, calibrated live — `background` #FAF9F3 (chrome + focus ground), `surface` #FFFEFB (one page color for edit AND read); deliberate departure from the export palette, values live-calibrated not contract-fixed. Light-only — one palette.
- `DesignTokens.swift` — palette/geometry from the design contract (`ref/Web-Prototype/museion-workspace.html` `:root` + grid): background/surface/foreground/muted/border/accent colors, radius 10, column widths (rail 56, library 232, mentor 356; the export's editor min 420 lands with #19's editor column), serif/mono font designs. **#89 (2026-10-09):** two-color world, calibrated live — `background` #FAF9F3 (chrome + focus ground), `surface` #FFFEFB (one page color for edit AND read); deliberate departure from the export palette, values live-calibrated not contract-fixed. Light-only — one palette, with the single semantic exception `readyGreen` (#153/#156: the mentor header's ready dot; a meaning, never a style color).
- `WorkspaceView.swift` — the first-frame main surface (#151: gateless — rendered unconditionally by ContentView; the engine check runs async beside it): nav rail (Posts/Sessions/Learnings/Trends + the #151 engine-status pill + Settings at bottom) + active pane. `RailButton` per the export (44×44, muted icon, hover wash, surface card + 2px edge bar when current). **#32 (S5.2):** the rail's fourth destination — Trends (`chart.xyaxis.line`, after Learnings — measurement beside memory) → `TrendsPaneView` (own file). **#28 (S2.3):** Sessions is real — `SessionsPaneView` (own file) over the engine-owned session model: `PaneHeader("Sessions")` carries the New Session control (**#30: always a Menu** — "New Session" / "New Session on \<title\>" when Posts has an open piece / "New Brainstorm" → `beginBrainstormSession`; the plain-button branch died with the second action; association stays by name/convention, `pieceTitle` on the roster entry; disabled on `!canStartSession`), two-column body — roster list at `libraryWidth` (rows in `LibraryPostRow`'s exact 2px-strip language: serif-13 name + mono-11 meta `pieceTitle · yyyy-MM-dd HH:mm`; row click = `resumeSession`, the engine replays the transcript, an engine-unknown id lands the model's honest refusal row and the entry stays) | transcript via the shared `SessionTranscriptView` (home passed through — #29 research candidates curate in either pane; **#30: the shared surface carries the freeform composer + liveness + Stop too — the pane is a conversation, not a read-only transcript**; the pane-local liveness row died with the move). Detail column: idle/starting → "Starting the mentor engine…" progress; crashed → a plain "Restart it in the Mentor pane" pointer (never a second restart flow); ready → actions row (active session name serif + engine version mono, **#30: New Post · Fork · Compact** bordered mono-11 — Fork · Compact disabled on `!canStartSession`, New Post never engine-gated (it reads in-memory transcript rows; a crashed engine must not strand the draft); New Post stages the pane-local ask — `sessionDraft` @State seeded from `draftCandidateText()`, the private `NewPostFromSessionSheet` prefills the editable candidate (origin: ai stated in-UI, Create disabled on blank), Create → `PostsModel.newPostFromSession`, dismissal is the cancel; a FAILED write keeps the sheet up with the reason inline (ApplyAskSheet posture — the edited draft is never destroyed); empty transcript = empty prefill, the sheet still works) + transcript. The pane's `.task` runs the same idempotent `openSession()` (XCTest-guarded) and seeds `model.binaryPath` from the gate when nil, so the pane can be the first to spawn the engine. Empty state names how sessions arrive (a pass, or New Session). The transcript renderer + freeform input rail live in `SessionTranscriptView` (own file) — MentorPaneView's transcript views moved there verbatim (#24's `defaultScrollAnchor(.bottom)` preserved); `isWritingRow` moved with it and MentorPaneView delegates; **#30: the composer (input 1…4 lines + send + liveness + Stop) moved there too — one conversation surface, two panes** (the Mentor pane keeps the crash card). **#155 (map #153, contract `ref/prototypes/wf154-mentor-pane-prototype.html`):** the surface wears the editorial chat voice — `speaker(of:)` (static, test-pinned) maps the model's `"Mentor: "`/`"You: "` prefixes onto agent serif-15/1.6 prose (markdown at flush, verbatim while streaming — Vivarium #97; **interpreted markdown opens http(s) ONLY — `linkVerdict` gates the surface's `openURL` environment, every other scheme discards: engine prose echoes imported content, #34 gate-at-sink doctrine**) / right-aligned terracotta-wash-14% capsule (radius 12/12/2/12, 85% of live column width — `onGeometryChange`, both panes' columns) / mono-11 status box on the fg-wash-6% card (refusals, pass kick-off labels, reveals — the system voice); ThinkingBlock port (mono-11 toggle, serif-13 muted on the wash card, open while live, collapsed when flushed, per-instance expansion state); research-note cards inherit the wash family; the composer restyles per contract — surface-fill input, ONE accent Send flipping to terracotta-outlined Stop (default-action shortcut rides Send only), floating `.thinMaterial` liveness chip above the composer (streaming only, hit-through), plain Return sends / Shift+Return breaks the line (Vivarium owner-report fix; `send()` gained the empty-trim guard), and the debug toggle seats at the composer's trailing edge via `debugBinding: Binding<Bool>?` (nil = no toggle). **#26:** Learnings is real — `LearningsPaneView` (own file), a list-only pane (Archive posture) over `<home>/learnings/`: `LearningsIndex` (nonisolated) scans type dirs → groups (dir name lowercased, library section-head voice) → entries newest-first (`YYYYMMDD-` filename prefix desc, undated last), pattern/problem/promoted read leniently via `Post.frontmatter` Line truncated
- `PostsPaneView.swift` — Posts destination: library column (Pass State groups in mono-11 uppercase labels, post rows with title + passState/origin meta), empty state, editor column (`PostEditorView`), mentor column (`MentorPaneView`, fixed 356). Selecting a post opens an editing session; `PaneHeader` carries the New Post button (export `.pane-head .icon-btn`). **#92:** the editor column renders the external guest (`model.externalSession`) ahead of the post session — one guest at a time, mentor column stays. **#108 (variant B, `ref/prototypes/wf104-library-ui-prototype.html`):** `PostsLibraryColumn` regroups — serif-15 semibold project section heads (lowercased in display — #108 live verdict; small caps rejected as a UI treatment for project names) + mono-11 `· N` count, Pass-State groups inside (10px mono, 0.8 opacity, leading-22 indent), collapse restored per the prototype's toggle (click the head — chevron rotates; per-view state, not persisted); `LibraryPostRow` (extracted, internal — Archive reuses it): always-2px leading strip (accent when selected — no layout shift; `UnevenRoundedRectangle` 0/8/8/0 per `.vB .post-row`), ✳ suffix on outline pieces (row-level help — a Text span isn't individually hoverable); row menu = Rename… · Convert to Post… (outline pieces only, #114 — stages the ask) · Move to Project… (`MoveToProjectSheet`, radio list of non-archived projects, Move disabled when unchanged) · Move to Archive · Move to Trash; `RenamePostSheet` internal for the Archive pane's reuse. **#144:** the library search — a plain-text field under the Posts header (debounced 250 ms, title+body filter over non-archived pieces; body scan runs off-main through `PostStore.readBody`, so frontmatter is never searched), flat results with title matches first (Finder order preserved in both halves, count line above, same `LibraryPostRow`); state is view-local (`query`/`matches`, nil = sections render), so both render sites (unfocused layout + focus-mode reveal) get the field; clearing returns the project sections. **#33 (S6.1):** the editor column's session branch passes `publish:` to PostEditorView (a mono-11 Publish toolbar button, nil = hidden — drafts/guests/previews carry none); the pane hosts the `MicropubPublishSheet` (`.sheet(isPresented:)` beside `.task(id: home)`).
- `PostLibrary.swift` — `Post` (nonisolated: id/title/passState/origin + #107 type/project/isArchived + #32 `firstDraftStats: FirstDraftStats?`; `ContentType` post|outline) + `Post.scan(home:) -> [Post]`: **#107/ADR-0012 two-level scan** — enumerates `projects/<name>/<id>/post.md` AND `archive/<name>/<id>/post.md` (archive → isArchived), same skip guards at both levels (no post.md = lazy folder, loose files, hidden dirs, symlinked dirs), `type` read leniently (absent/unknown → post), title-sorted; Title = first non-empty line after frontmatter (`untitled` on blank, marker-only, or unterminated-frontmatter bodies); `pass_state`/`origin` frontmatter keys read leniently (First Draft/writer defaults, quoted YAML values unquoted, leading blank line before `---` tolerated). Scan runs off-main (bind/rescan in PostsModel). **#32 (S5.2):** scan also reads the five `stats_*` keys into `firstDraftStats` — `Post.FirstDraftStats` (captured Date parsed from the `yyyy-MM-dd'T'HH:mm:ss` stamp, per-access POSIX formatter — the repo's no-static convention; + `DraftStats`), nil unless EVERY key parses to a FINITE Double (`Double("nan")`/`"inf"` parse — a non-finite peak would trap the chart's y-domain; finish-audit #32). The read-back re-gates on the capture gate's immutable pair (origin writer, type post — NOT pass_state, which legitimately advances): app-internal edit paths never grow the keys, and `stats_*` arriving by import (external YAML rides verbatim) on an ai or outline piece still never renders — a migrated writer piece keeps its real arc. **#143 (OPT-F3):** `scan(home:cache:)` takes an optional `PostScanCache` (path+mtime+size-keyed parse memo — an unchanged post.md is never re-read, a moved piece re-parses at its new path, project/isArchived re-derive from the walk; nil default = the old read-everything behavior, so every other caller is unchanged). The stamp is taken BEFORE the read and keys the store — a mid-scan rewrite can never be pinned as fresh (a late overlapping store keys its own pre-read stamp; the next scan mismatches and re-reads). **#33 (S6.1):** `Post` gains `micropubURL: String?` (frontmatter `micropub_url`, read leniently but gated on `Micropub.trustworthyURL` — imported frontmatter rides verbatim, so a hostile value scans nil and never pre-arms the publish sheet; defaulted so every hand-constructed `Post(id:…)` site keeps compiling).
@@ -50,7 +50,7 @@ Owned by the root AGENTS.md contract. The `.xcodeproj` uses **filesystem-synchro
- **#151 — the gateless flip:** `AppGateState.startLaunchCheck()` (called from `ContentView.task`) arms the auto-fire chain (`wireAutoFire` — provisioning `runPass(hermesBinary:)` then `backup.runPass()`, the gate era's exact `onEnginePass` body) and awaits `beginAutomaticCheck()`; `hasStarted` preserves #41's once-per-app-launch, first-window-only rule (⌘N no-ops). No-ops under hosted tests (`XCTestConfigurationFilePath` — the panes' guard pattern; never probe or auto-provision there). ContentView renders `WorkspaceView` unconditionally — the posts scan starts at first frame, concurrent with the check; nothing library-side waits on the gate. The blocking sheet, placeholder logo screen, `gateRaised`/`gateDismissed`, and `EngineGateView`/`ProvisioningFailureCard` are deleted.
- `EngineStatusView.swift` — the status surfaces (#149 variant A, prototype `prototypes/GatelessStatusPrototype.swift`): `EngineStatusSurface.visibility(phase:provisioningFailed:)` (pure, test-pinned — the mapping: idle/pass+healthy → hidden, checking → pulse, fail/pass+provisioning-failed → failed), `EngineStatusPill` (44×44 rail slot above Archive: 8pt pulsing accent dot while checking, `exclamationmark.triangle.fill` on an accent-12% wash when failed, nothing when healthy — the slot collapses and rail spacing closes), `EngineStatusCard` (the anchored fail card: 340pt, bottom-leading at railWidth+12/bottom 14, surface bg, accent-0.5 border, radius 12, shadow — floats, never blocks, never pushes layout; auto-expands on each failure arrival via WorkspaceView's `.onChange(of: visibility)`, chevron collapses, slot click re-opens; WorkspaceView hosts slot + card overlay — focus mode recesses the CARD with the rail, the expanded state surviving for exit-focus). Engine-fail content = #40 copy with the gateless subtitle ("Passes and Sessions need it — the editor keeps working"), the two install steps + Copy + Installation guide link, Re-check (accent, disabled-while-checking, label "Checking…"), Technical details (stderr excerpt + "Probed: <path>"; bare Probed line when stderr is empty). Provisioning failure rides the same card: title "Setup failed", phase rawValue + failing profile mono (#134), the safe-to-retry body, Retry inline (re-runs provisioning; success nils `lastFailure` and the surface disappears — live-read, no snapshot).
- `state.json` lives at `~/Library/Application Support/Museion/` — schemaVersion 1, wholesale-replaced after every completed check (Re-check included); fail records carry no `engineVersion`. About (`AboutEngineView` in `MuseionApp.swift`) reads the file and never triggers a check.
- Panes spawn the engine the moment the check lands: `MentorPaneView`/`SessionsPaneView` seed `.task(id: binaryPath)` (nil→value arrival re-fires; a nil binary never calls `openSession` — that path lands the crash card, so the gate's fail state owns the interim). The mentor pane header carries mono-10 engine states beside "Mentor Session" (checking… muted + mini spinner / engine missing accent / setup failed accent / `hermes <base>` once ready — the BASE version, handshake answer first, gate's derived string `+`-stripped meanwhile; drift note keeps its orange help). The session chip renders only once ready; status text wins layout priority. Both panes' idle branches show the honest missing-engine notice when the gate failed (never an eternal "Starting…" spinner — SessionsPaneView takes `gate` for it). The header's state derivation is `MentorEngineStatus.state(phase:provisioningFailed:)` — pure, test-pinned (the outrank rule: engine failure wins over a lingering provisioning failure).
- Panes spawn the engine the moment the check lands: `MentorPaneView`/`SessionsPaneView` seed `.task(id: binaryPath)` (nil→value arrival re-fires; a nil binary never calls `openSession` — that path lands the crash card, so the gate's fail state owns the interim). The mentor pane header carries mono-10 engine states beside the serif "Mentor" title (checking… muted + mini spinner / engine missing accent / setup failed accent / #156: ready = the semantic green dot + lowercase `ready` — the BASE version rides the tooltip, handshake answer first, gate's derived string `+`-stripped meanwhile; drift note keeps its orange text + help). The session chip renders only once ready; status text wins layout priority. Both panes' idle branches show the honest missing-engine notice when the gate failed (never an eternal "Starting…" spinner — SessionsPaneView takes `gate` for it). The header's state derivation is `MentorEngineStatus.state(phase:provisioningFailed:)` — pure, test-pinned (the outrank rule: engine failure wins over a lingering provisioning failure).
- Tests: `MuseionTests/EngineGateTests.swift` (untouched — probe order, first-stderr reporting, timeout kill, state records, onPass-fires-per-passing-check, once-per-model) + `MuseionTests/GatelessLaunchTests.swift` (#151: startLaunchCheck hosted-test no-op, wireAutoFire arms the chain, the pill visibility mapping incl. provisioning-failure-under-passed-gate, the mentor header mapping).
## Profile provisioning (S2.1 #43–#48; #134 Profiles S1)
@@ -80,7 +80,7 @@ Owned by the root AGENTS.md contract. The `.xcodeproj` uses **filesystem-synchro
- `MentorSessionModel.swift` — `MentorSessionModel` (@MainActor @Observable): engine state machine (idle/starting/ready/crashed; `isStreaming` Bool; **#28: `.ready` carries NO sessionId — session ids live in the roster**). Lazy lifecycle: spawns on first `openSession()` (skipped under hosted tests via `XCTestConfigurationFilePath`; **#28: openSession = spawn + ensure ONE session — the default freeform "Mentor" on first launch, the newest roster entry on relaunch, RESUMED (session/load replays its history — the review fix; a fresh transcript over an engine that knows the session would prompt/fork/compact against unloaded state)**), handshake `initialize` → advisory version compare vs state.json (`recordedVersionProvider` injectable; **compares base versions** — the gate records the derived version (`acp --version` → `0.21.5+2177.g735e426`) while the handshake answers the base (`agentInfo.version` → `0.21.5`), so raw string equality fabricates drift on every dev install; `baseVersion(of:)` strips `+`-build metadata; one os_log line + both versions in the pane, never blocks). **#28: the handshake is initialize ONLY — sessions are created separately (`newSession`/`ensureDefaultSession`), the bridge is session-agnostic.** `sendPrompt` (#24 seam: `@discardableResult`, returns `TurnOutcome` — `.ended(stopReason:)` for any completion stopReason incl. `refusal`, `.cancelled` for `cancelled`, `.failed` on a thrown transport error or the not-ready/streaming guard refusal; the model appends NO extra row on cancel — the orchestrator owns pass wording) streams `agent_message_chunk` into a buffer flushed on turn end; **thought lane (#24 dogfood fix): `agent_thought_chunk` streams into its own `streamingThought` buffer** — a pass's thinking runs to hundreds of lines and conflating it with the critique made one giant blob; it flushes to a collapsed `.thought` row FIRST (it preceded the message), and `restart()` clears both buffers; an optional `label:` renders verbatim as the user row INSTEAD of the raw prompt (pass wire stubs never hit the transcript); **#23 dogfood fix: `sendPrompt` sends session/prompt with `promptTimeout` (nonisolated, 1800 s), NOT the client's 15 s request default** — the prompt response arrives when the TURN ends, minutes into a pass; the default abandoned live turns ("connection lost" while the engine kept working, Stop vanished with `isStreaming`; test-pinned `promptTimeout >= 600`); tool calls with fix-card-shaped `rawInput` (pattern+problem minimum) render as `FixCard` (ADR-0006 fields; **audit: the parser takes the nested `submit_fix_cards` argument shape first — `{piece_path, cards:[…]}`, snake_case, anchor as `{quote,occurrence}` object — the LIVE rail; the flat #14-era shape stays as fallback; the old flat-only parser never matched the real tool**); every other update type a collapsible raw-JSON row. **Audit hardening: a prompt response missing `stopReason` maps to `.failed` (a turn without stopReason never advances a pass), and `sendPrompt` guards the client instead of force-unwrapping.** Cancel = `session/cancel` notification, Stop button. Crash keeps transcript + last prompt; Restart re-spawns. `clientRef` mirror exists solely so nonisolated deinit can close the child.
**#28 (S2.3) session lifecycle:** the model hosts MULTIPLE engine-owned sessions on the ONE bridge. Transcripts are per-session structs keyed by wire sessionId; `rows`/`streamingText`/`streamingThought` are same-named computed proxies over the ACTIVE session (every existing caller compiles unchanged). `SessionEntry` (nonisolated, Codable: `sessionId`/`name`/`pieceTitle`/`createdAt`) + `SessionRoster` (nonisolated; JSON array at `~/Library/Application Support/Museion/sessions.json`, `rosterDirectory` injectable — `init(binaryPath:rosterDirectory:)`; an injected-nil dir under hosted tests redirects to a unique temp dir so suites never touch the real roster; EngineGate's silent-fail write posture). **The roster persists NAMES ONLY — id/name/pieceTitle/createdAt (the "name/convention" of PRD S2.7); transcripts are engine-owned (ADR-0007: swap the engine, transcripts stay behind), replayed on demand.** API: `newSession(name:pieceTitle:)` (wire session/new, rostered newest-first, activated), `resumeSession(_)` (wire session/load — the adapter replays full history as `session/update` BEFORE responding; user turns arrive as `user_message_chunk` and RENDER on replay, live-turn echoes stay ignored; **#30 dogfood: the REAL 0.21.5 load response carries NO top-level `sessionId` — the id rides `_meta.hermes.sessionProvenance.acpSessionId`, so extraction accepts both shapes and empty-everywhere alone means the engine doesn't know it → `false` + an honest row, entry stays rostered — never a fabricated empty session; the top-level-only read made every real-engine resume fail as "unknown"**), `forkActiveSession()` (wire session/fork → "<name> (fork)", pieceTitle carried, fresh transcript; the adapter's empty-string sessionId = refusal), `compactActiveSession()` (the `/compress` slash prompt over the existing sendPrompt rail, label "Compact…" — the raw command never renders; refused while streaming), `beginBrainstormSession(pieceTitle:)` (#30: the brainstorm flavor — a "Brainstorm" rostered session whose first turn is `brainstormPrompt`, the normal prompt rail, no new machinery; pinned: roster head + labeled opener + raw prompt absent + reply streams into ITS transcript), `draftCandidateText()` / `draftCandidateText(in:)` (#30: the New-Post-from-Session candidate — the LAST "Mentor: " text row, prefix stripped; user/thought/card/research/raw rows never prefill, blank bodies skipped, and the refusal/connection-shaped rows sharing the display prefix are excluded — ponytail-marked until SessionRow carries speaker identity), `canStartSession` (ready && !isStreaming — the pane's enable-flag), `transcriptRows(of:)` (internal — read any transcript without activating). Notification routing files updates under the PARAMS' sessionId (multi-session safe), not the active one; notification→MainActor hops ride `DispatchQueue.main.async`, NOT `Task { @MainActor }` — the unstructured-Task hops starved behind parallel test work (replay updates landed seconds late or never) and only the main queue gives FIFO ordering with the continuation resume, making the adapter's replay-before-response contract guaranteed rather than probabilistic. **#29 (S8.1–S8.3) research candidates:** `ResearchCandidate` (nonisolated: piecePath/title/url/quote/note + `Disposition` pending|kept(fileName)|rejected) rides `SessionRow.Content.researchNote` — `appendToolCall` routes on PAYLOAD SHAPE (a top-level `notes` array) BEFORE the fix-card parse — titles are display text, never a routing key, and a research payload with stray pattern/problem keys must not vanish into a card row — then parses via `ResearchCandidate.batch` (one candidate PER note; missing piece_path/empty notes/note missing title-url or whitespace-only title/url — the wire's trim rule, both boundaries agree — → [] → the raw row owns it, all-or-nothing per batch), so candidates live in the transcript = engine-owned cargo: resume replays the tool calls and re-materializes them (dispositions reset — honest, they were never persisted). `setResearchDisposition(rowID:_:)` flips the ACTIVE session's row in place (unknown id = no-op). `isWritingRow` keeps `.researchNote` visible in the writing voice.
**#137 (S4, ADR-0014) per-surface engine lifecycle:** passes run on their OWN one-shot engines — `runPass(kind:stub:pieceTitle:)` spawns `ACPEngineClient(binaryPath:, profile: ProfileSurface(passKind:))` (museion-passN), streams the verdict into a TRANSIENT unrostered transcript under `passTranscriptKey` ("pass", the active entry lives only for the run — #129: passes are never rostered; `handleNotification` maps the pass wire sid onto the key), and tears the engine down at the verdict (`teardownPassEngine`; onCrash deliberately nil — a pass-engine crash lands the honest failure row, never the crash card; KNOWN EDGE, accepted v1: a chat-engine crash mid-pass flips the pane while the pass completes underneath). **#122: the spawn/session/new/teardown block is ONE private rail — `runOneShot(profile:name:prompt:pieceTitle:)` — shared by `runPass` and `runBlindRead(prompt:pieceTitle:reveal:)` (the Blind Read rides the CHAT profile `museion`: context-free = a fresh session, not a different judge — decision #120; the reveal row appends only on `.ended` with stopReason ≠ "refusal" — a refusal still ends .ended, and a 2×-document prompt makes length refusals realistic — after the turn-end flush, so the mapping can never leak to the judge). `name` ("Pass 1"/"Blind Read") composes the label; the rail's failure rows speak `\(label) failed` so a Blind Read spawn failure never reads "Pass failed".** The turn pipeline is ONE `turnCore(client:wireSid:key:prompt:label:)` shared by sendPrompt and the pass run (label row, session/prompt, stopReason mapping, buffer flush); `sendPrompt` refuses the pass surface with a visible row (read-only transcript). Restart posture: `restart()` (crash button) and `requestRestart()` (model-change, Settings fires it) share `respawn()` — teardown, fresh spawn, resume the PRE-restart active rostered session (not blindly the newest); `requestRestart` defers to turn end while `isStreaming` (`pendingRestart`, fired from both turn-end defers — a reply is never cut mid-stream) and ignores .idle/.starting (a future spawn reads fresh config). `stopStreaming` routes `session/cancel` to the PASS engine while a pass runs. Internal test observables: `passEngineChildPid`, `isPassEngineRunning`. **Run Pass readiness (#137 acceptance 3, slice B):** `PassReadiness` (ready | missingKey(providerLabel) | unknown) per kind, stored in the class body (`passReadiness`; `passReadinessWriter` = injectable read seam, nil → ad-hoc `HermesSettingsWriter` over the gate's binary, no binaryPath → stays empty); `refreshPassReadiness()` reads both pass profiles' providers in ONE task group, then each DISTINCT provider's key — an unreadable surface maps `.unknown` (never block on our own read failure). `PostsModel.runPass` guards `.missingKey` BEFORE the open-piece guard: `lastError` names the provider and nothing touches disk, not even the pre-pass snapshot.
- `MentorPaneView.swift` — the debug pane (post #28 no longer the only session surface — Sessions pane shares the transcript renderer): header (**#151: mono-10 engine states beside the title — checking… / engine missing / setup failed / `hermes <base>` once ready, gate's phase machine the source, session chip only once ready, status text wins layout priority; the running version + orange drift note render inside the ready state** — **#28: the version shows `activeEntry`'s id alongside, `.ready` no longer carries it**; **#155: the Debug toggle moved to the shared composer's trailing edge** (`debugBinding` — mono-10 lowercase text toggle; the header keeps title + engine status + session chip) — `@AppStorage("mentorDebugRows")`, off by default: the writing-session transcript filters to prose + card events via `isWritingRow` (static, test-pinned); raw session/tool rows, collapsed thinking, and live thinking render only when checked — the model keeps every row either way, so the toggle flips with history intact), transcript — **#28: rendered by the shared `SessionTranscriptView(model:showsDebugRows:)` (own file); MentorPaneView passes the debug binding** (text rows, fix-card tool calls as one-line `FixCardEventRow`s — pattern title only, the detail lives in the palette; RawUpdateRow disclosure; **#24 dogfood fix:** `defaultScrollAnchor(.bottom)` — programmatic `scrollTo` raced the growing lazy rows and mislanded at the TOP; `.thought` rows render as collapsed `ThinkingBlock`s (the engine's thinking — kept out of the critique text; live thinking mounts the block open, spinner toggle, #155)), composer — **#155: restyled per contract inside the shared surface** (the pane's own freeform-input/liveness row died with the #30 move; liveness is the floating chip, Stop is the Send slot), crash card (Restart, last prompt, stderr tail behind Technical details; input + crash card live in a file-scope `private extension MentorPaneView` — type_body_length posture). **#24 (S3.1):** below the header a segmented **Pass 1 | Pass 2 | Chat** picker (the design contract's `.mentor-tabs`) — pass modes carry the pass bar (`PassBarView`, private): what the pass critiques + `PassContext.estimateTokens` cost line ("· ~N tokens") or "Open a post to run a pass.", the open piece's Pass State chip (library's post-meta voice), and the actions — Cancel (bordered, only while `posts.runningPass` streams or (#122) `posts.runningBlindRead` — one Cancel rail ends either run) ↔ **#122: Blind Read** (bordered, beside Run — disabled with the reason in help: no open post, `!posts.openPieceHasSnapshot` ("run a Pass first"), or the engine can't take the turn; one click fires `posts.blindRead`; help otherwise names it advisory-only, records nothing) ↔ Run Pass N (borderedProminent; disabled with no open piece, engine not ready, mid-turn, or (#137) the pass profile's provider is unkeyed — a mono-11 `Missing <provider> key —` line under the state row carries a borderless accent **Open Settings** button (`onOpenSettings`, threaded MentorPaneView→PostsPaneView→WorkspaceView's `selection = .settings`, ArchivePaneView closure precedent), the disabled Run's help names the reason, and `.unknown` never disables (the spawn's honest failure owns that path). Chat hides the bar; transcript + input stay shared (the pass's streamed critique renders in the same transcript). The header's session chip hides while the transient pass transcript (`passTranscriptKey`) owns the active surface, and the pane's `.task(id: binaryPath)` runs `refreshPassReadiness()` before the hosted-test guard — #151: keyed on the nil→value arrival so the engine spawns the moment the gateless check lands (a nil binary never calls openSession); re-fires re-run it, so a key added in Settings re-enables Run Pass. `gate: AppGateState?` (#151 header states) + `posts: PostsModel?` + `home: URL?` params (nil = previews); PostsPaneView's mentor column passes all three. **#23 follow-up (dogfood):** card detail lives in the **Fix Cards palette** — a floating `Window` scene (id `fix-cards`, `FixCardsPalette` in `FixCardsWindow.swift`, `defaultSize` 340×540) beside About, opened via `openWindow` from a mono "Fix Cards · N" row below the pass bar (shown only when cards exist). The palette shows the open piece's title + `posts.openPieceCards` — **#25 (S3.2/S3.3): the card WORK surface, open cards first (scan order preserved: newest pass first, rank ascending), closed cards dimmed at 0.45 with their status in the meta and no actions**; row actions per lane: mechanical + valid → Apply + Skip, demonstration → Done + Skip (never Apply, ADR-0006), stale anchor → Skip only; Apply = ask-before, a BLOCKING sheet showing the exact edit (anchored quote → replacement, "(cut)" when the fix is empty) with Apply/Cancel — .stale swaps the sheet to the stale alert (no retry), .refused shows the reason inline; no apply-all, no batch, the sheet is the only pathLine truncated
- `MentorPaneView.swift` — the debug pane (post #28 no longer the only session surface — Sessions pane shares the transcript renderer): header (**#156 contract `.pane-head`: serif-15/600 "Mentor" title (icon + "Session" died, settled #5) + engine status + mono-10 muted-0.75 session chip — checking… / engine missing / setup failed unchanged (#151); ready = the semantic green dot (`DesignTokens.readyGreen`, the sole palette exception) + lowercase mono `ready`, base version in the tooltip, orange drift note still visible when gate and handshake disagree; gate's phase machine the source, chip only once ready, status text wins layout priority**; **#155: the Debug toggle moved to the shared composer's trailing edge** (`debugBinding` — mono-10 lowercase text toggle; the header keeps title + engine status + session chip) — `@AppStorage("mentorDebugRows")`, off by default: the writing-session transcript filters to prose + card events via `isWritingRow` (static, test-pinned); raw session/tool rows, collapsed thinking, and live thinking render only when checked — the model keeps every row either way, so the toggle flips with history intact), transcript — **#28: rendered by the shared `SessionTranscriptView(model:showsDebugRows:)` (own file); MentorPaneView passes the debug binding** (text rows, fix-card tool calls as one-line `FixCardEventRow`s — pattern title only, the detail lives in the palette; RawUpdateRow disclosure; **#24 dogfood fix:** `defaultScrollAnchor(.bottom)` — programmatic `scrollTo` raced the growing lazy rows and mislanded at the TOP; `.thought` rows render as collapsed `ThinkingBlock`s (the engine's thinking — kept out of the critique text; live thinking mounts the block open, spinner toggle, #155)), composer — **#155: restyled per contract inside the shared surface** (the pane's own freeform-input/liveness row died with the #30 move; liveness is the floating chip, Stop is the Send slot), crash card (**#156 `.state-card`: accent tri — danger = terracotta, no second hue — serif-14/600 head, sans-12 muted body, Restart as the solid-accent `MonoButton`; last prompt mono-11 muted, stderr tail behind Technical details; crash card lives in the file-scope `private extension MentorPaneView` — type_body_length posture; the idle/starting interim is the same quiet mono voice, and the missing-engine card already spoke it**). **#24 (S3.1) → #156:** the segmented **Pass 1 | Pass 2 | Chat** picker is DEAD (settled #4 — chat is not a mode; the bar always carries, transcript + composer always present, the pass's streamed critique renders in the same transcript). `PassBarView` (private, owns `@State kind: PassKind`) per the #154 contract: the compact selector — Pass 1 / Pass 2 text tabs, mono-10 uppercase tracked, active = fg ink + 2pt accent underline — then the `PASS N · STATE` status line (mono-10 uppercase tracked, the open piece's Pass State, library's post-meta voice), the sans-11 muted cost line (`PassContext.estimateTokens` "· ~N tokens" or "Open a post to run a pass."), then the actions as `MonoButton` (private, #156 `.btn`: mono-11, h 28, radius 6, three looks — accent solid / surface+border / accent outline; #155 sendButton precedent, hand-drawn fills — borderedProminent carries the system tint): Cancel (outline, only while `posts.runningPass` streams or (#122) `posts.runningBlindRead` — one Cancel rail ends either run) ↔ **#122: Blind Read** (secondary, beside Run — disabled with the reason in help: no open post, `!posts.openPieceHasSnapshot` ("run a Pass first"), or the engine can't take the turn; one click fires `posts.blindRead`; help otherwise names it advisory-only, records nothing) ↔ Run Pass N (solid accent; disabled with no open piece, engine not ready, mid-turn, or (#137) the pass profile's provider is unkeyed — a mono-11 `Missing <provider> key —` line under the actions carries a borderless accent **Open Settings** button (`onOpenSettings`, threaded MentorPaneView→PostsPaneView→WorkspaceView's `selection = .settings`, ArchivePaneView closure precedent), the disabled Run's help names the reason, and `.unknown` never disables (the spawn's honest failure owns that path). The header's session chip hides while the transient pass transcript (`passTranscriptKey`) owns the active surface, and the pane's `.task(id: binaryPath)` runs `refreshPassReadiness()` before the hosted-test guard — #151: keyed on the nil→value arrival so the engine spawns the moment the gateless check lands (a nil binary never calls openSession); re-fires re-run it, so a key added in Settings re-enables Run Pass. `gate: AppGateState?` (#151 header states) + `posts: PostsModel?` + `home: URL?` params (nil = previews); PostsPaneView's mentor column passes all three. **#23 follow-up (dogfood):** card detail lives in the **Fix Cards palette** — a floating `Window` scene (id `fix-cards`, `FixCardsPalette` in `FixCardsWindow.swift`, `defaultSize` 340×540) beside About, oLine truncated
- Wiring: `AppGateState.mentor` is the app-scoped model ( #151: PostsPaneView's mentor column passes `gate.gateModel.currentBinaryPath` as `binaryPath`; the pane re-seeds `mentor.binaryPath` on the nil→value arrival — no re-probe); quit teardown on `NSApplication.willTerminateNotification` → `mentor.shutdown()` (idempotent; scenePhase `.inactive` would fire on plain focus loss).
- Tests: `MuseionTests/ACPClientTests.swift` — fake ACP server (zsh speaking real NDJSON over the real Process path; mode file + base64 card payload beside the binary, self-locating per ProfileProvisionerTests convention). Covers handshake version, streamed updates + fix-card parse (model over the real client+fake path), advisory drift note, crash → onCrash exactly once, cancel fire-and-forget, teardown kills hung child.
+4
View File
@@ -19,6 +19,10 @@ enum DesignTokens {
static let muted = Color(red: 0x6B / 255, green: 0x69 / 255, blue: 0x64 / 255)
static let border = Color(red: 0xE8 / 255, green: 0xE5 / 255, blue: 0xDF / 255)
static let accent = Color(red: 0xC9 / 255, green: 0x64 / 255, blue: 0x42 / 255)
/// #153 map settle / #154 contract: the SOLE palette exception — the
/// semantic ready-green of the mentor header's ready dot. Never a style
/// color; it means "engine healthy".
static let readyGreen = Color(red: 0x36 / 255, green: 0x66 / 255, blue: 0x4F / 255)
static let radius: CGFloat = 10
+20 -16
View File
@@ -283,7 +283,8 @@ struct EngineStatusCard: View {
/// The mentor pane header's mono-10 engine states, one per gate verdict:
/// "checking the engine…" muted + mini spinner / "engine missing" accent
/// with help / "setup failed" accent / `hermes <base>` once ready. The
/// with help / "setup failed" accent / #156: the green ready-dot +
/// lowercase `ready` once ready (the base version rides the tooltip). The
/// gate's phase machine is the source; nil gate (previews) derives from
/// the mentor model alone.
struct MentorEngineStatus: View {
@@ -340,24 +341,27 @@ struct MentorEngineStatus: View {
.foregroundStyle(DesignTokens.accent)
.help("Profile setup didn't finish — retry from the rail's status card")
case .ready:
// The BASE version (handshake answer first, the gate's derived
// string `+`-stripped meanwhile — the drift-note contract),
// plus the advisory drift note when they diverge.
if !readyVersion.isEmpty {
HStack(spacing: 8) {
Text("hermes \(readyVersion)")
// #156 (contract `.pane-head`): the ready signal is the semantic
// green dot + lowercase mono "ready" (#153 settle #6). The base
// version rides the tooltip; the advisory drift note stays visible
// (orange, pre-existing advisory) the rare time gate and handshake
// disagree.
HStack(spacing: 5) {
Circle()
.fill(DesignTokens.readyGreen)
.frame(width: 6, height: 6)
Text("ready")
if let note = model.versionNote {
Text(note)
.foregroundStyle(.orange)
.lineLimit(1)
.truncationMode(.middle)
if let note = model.versionNote {
Text(note)
.help(note)
.foregroundStyle(.orange)
}
.help(note)
}
.font(.system(size: 10, design: DesignTokens.mono))
.foregroundStyle(.tertiary)
.layoutPriority(1)
}
.font(.system(size: 10, design: DesignTokens.mono))
.foregroundStyle(DesignTokens.muted)
.help(readyVersion.isEmpty ? "Engine ready" : "hermes \(readyVersion)")
.layoutPriority(1)
}
}
+217 -120
View File
@@ -2,14 +2,19 @@
// MentorPaneView.swift
// Museion
//
// M0 ACP bridge (#14): the debug pane — the M0 demo surface. Post-gate main
// surface replacing the content placeholder (map decision: pane placement).
// The mentor pane (#14 map → #153/#156): the editorial chrome per the
// locked contract (ref/prototypes/wf154-mentor-pane-prototype.html) —
// serif pane head with the green ready dot and session chip, the compact
// Pass 1 / Pass 2 selector + status line in the pass bar (the segmented
// mode picker died, settled #4), a plain mono fix-cards row, and the
// crash / missing-engine / starting states in the same voice.
//
import SwiftUI
/// The mentor debug pane: transcript, freeform input, Stop while streaming,
/// restart prompt on crash. Post-gate main surface (map decision).
/// The mentor pane: the pass bar + shared transcript around it (the
/// conversation surface itself lives in SessionTranscriptView) and the
/// crash restart prompt.
struct MentorPaneView: View {
@State private var model: MentorSessionModel
/// #23 follow-up: opens the Fix Cards palette window (scene "fix-cards").
@@ -28,10 +33,6 @@ struct MentorPaneView: View {
/// #137 (S4): opens Settings — the missing-key line's way out (nil =
/// previews; PostsPaneView threads WorkspaceView's pane hop).
var onOpenSettings: (() -> Void)?
/// #24 (S3.1): the segmented surface — Pass 1 | Pass 2 | Chat. Pass
/// modes carry the pass bar; Chat is the freeform surface alone.
private enum Mode: Hashable { case pass1, pass2, chat }
@State private var mode: Mode = .pass1
/// Writing-session filter (#23 dogfood): session/tool/debug rows render
/// only when on — off by default, persisted. The model keeps every row
/// either way (debug history intact; the toggle flips instantly).
@@ -77,33 +78,40 @@ struct MentorPaneView: View {
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
} else {
ProgressView("Starting the mentor engine…")
.frame(maxWidth: .infinity, maxHeight: .infinity)
// #156: the interim in the editorial voice — mono, quiet.
VStack(spacing: 8) {
ProgressView().controlSize(.small)
Text("Starting the mentor engine…")
.font(.system(size: 11, design: DesignTokens.mono))
.foregroundStyle(DesignTokens.muted)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
case .ready:
modePicker
if let kind = passKind {
PassBarView(kind: kind, posts: posts, home: home, model: model, onOpenSettings: onOpenSettings)
Divider()
}
// #156 (settled #4): the pass bar always carries — its Pass 1 /
// Pass 2 selector replaced the mode picker; the transcript +
// composer below are the conversation surface, chat is not a
// mode.
PassBarView(posts: posts, home: home, model: model, onOpenSettings: onOpenSettings)
Divider()
if let posts, !posts.openPieceCards.isEmpty {
// #23 follow-up: the detail moved to the palette window —
// this row just names it and opens it.
// #23 follow-up + #156 ruling: a plain mono row — a link,
// not content (no card, no hairline of its own; the
// Divider above already separates it from the bar).
Button {
openWindow(id: "fix-cards")
} label: {
Label(
"Fix Cards · \(posts.openPieceCards.count)",
systemImage: "rectangle.and.pencil.and.ellipsis",
)
HStack(spacing: 6) {
Image(systemName: "rectangle.and.pencil.and.ellipsis")
Text("Fix Cards · \(posts.openPieceCards.count)")
}
.font(.system(size: 11, design: DesignTokens.mono))
.foregroundStyle(DesignTokens.muted)
}
.buttonStyle(.borderless)
.buttonStyle(.plain)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.horizontal, 12)
.padding(.vertical, 6)
Divider()
.padding(.horizontal, 14)
.padding(.top, 10)
}
// #28: the transcript rendering is shared — the Sessions pane
// reads the same surface in the writing voice. #30: the
@@ -144,11 +152,11 @@ struct MentorPaneView: View {
// MARK: Header
private var header: some View {
HStack(spacing: 8) {
Image(systemName: "bubble.left.and.text.bubble.right")
.foregroundStyle(.secondary)
Text("Mentor Session")
.font(.headline)
HStack(spacing: 10) {
// #156 (contract `.pane-head`): serif 15/600 title + engine
// status + session chip — nothing else (settled #5).
Text("Mentor")
.font(.system(size: 15, weight: .semibold, design: DesignTokens.serif))
.fixedSize()
MentorEngineStatus(gate: gate, model: model)
Spacer()
@@ -159,39 +167,18 @@ struct MentorPaneView: View {
// layout priority.
if case .ready = model.phase, let sessionId = model.activeEntry?.sessionId, sessionId != MentorSessionModel.passTranscriptKey {
Text("session \(sessionId.prefix(8))")
.font(.caption2)
.foregroundStyle(.tertiary)
.font(.system(size: 10, design: DesignTokens.mono))
.foregroundStyle(DesignTokens.muted)
.opacity(0.75)
.textSelection(.enabled)
}
}
.padding(.horizontal, 12)
.padding(.horizontal, 14)
// #90: pane heads align at the export's 52px — same height as the
// Posts header and the editor toolbar, so the three hairlines read
// as one line.
.frame(minHeight: 52)
}
// MARK: Pass surface (#24, S3.1)
private var passKind: PassKind? {
switch mode {
case .pass1: .pass1
case .pass2: .pass2
case .chat: nil
}
}
private var modePicker: some View {
Picker("Mentor surface", selection: $mode) {
Text("Pass 1").tag(Mode.pass1)
Text("Pass 2").tag(Mode.pass2)
Text("Chat").tag(Mode.chat)
}
.pickerStyle(.segmented)
.padding(.horizontal, 12)
.padding(.top, 10)
.padding(.bottom, 8)
}
}
// MARK: Crash card (file-scope extension — type_body_length posture; the
@@ -204,26 +191,28 @@ private extension MentorPaneView {
// in-pane Restart prompt; the transcript replays from the engine, ADR-0007)
private func crashCard(lastPrompt: String?) -> some View {
VStack(spacing: 14) {
// #156 (contract `.state-card`): accent tri (danger = terracotta —
// no second hue), serif 14/600 head, sans-12 muted body, Restart
// in the solid-accent button voice.
VStack(spacing: 10) {
Image(systemName: "exclamationmark.triangle.fill")
.font(.system(size: 30))
.foregroundStyle(.orange)
.font(.system(size: 24))
.foregroundStyle(DesignTokens.accent)
Text("The mentor engine stopped")
.font(.title3)
.font(.system(size: 14, weight: .semibold, design: DesignTokens.serif))
Text("Nothing is lost — the transcript stays, and the engine can be restarted.")
.font(.callout)
.foregroundStyle(.secondary)
.font(.system(size: 12))
.foregroundStyle(DesignTokens.muted)
.multilineTextAlignment(.center)
if let lastPrompt, !lastPrompt.isEmpty {
Text("Last prompt: \(lastPrompt)")
.font(.caption)
.foregroundStyle(.tertiary)
.font(.system(size: 11, design: DesignTokens.mono))
.foregroundStyle(DesignTokens.muted)
.lineLimit(2)
}
Button("Restart") {
MonoButton(title: "Restart") {
Task { await model.restart() }
}
.buttonStyle(.borderedProminent)
if !model.stderrTail.isEmpty {
DisclosureGroup("Technical details") {
Text(model.stderrTail.joined(separator: "\n"))
@@ -241,11 +230,70 @@ private extension MentorPaneView {
}
}
/// #24 (S3.1): the pass bar — what the pass critiques + the honest cost
/// estimate (PassContext), the open piece's Pass State, and the Run/Cancel
/// action. Additive chrome above the mentor pane's shared transcript.
/// #156 (contract `.btn`): the pane's action button — mono 11, 28pt,
/// radius 6 — in the contract's three looks: accent solid (primary),
/// surface + border (secondary), accent outline (the danger/Stop voice).
/// #155 sendButton precedent: a plain button with the fills drawn by hand
/// (borderedProminent carries the system tint, not the palette).
private struct MonoButton: View {
enum Style { case solid, secondary, outline }
let title: String
var style: Style = .solid
var disabled = false
let action: () -> Void
var body: some View {
Button(action: action) {
Text(title)
.font(.system(size: 11, design: DesignTokens.mono))
.foregroundStyle(ink)
.padding(.horizontal, 13)
.frame(minHeight: 28)
.background(RoundedRectangle(cornerRadius: 6).fill(fill))
.overlay(
RoundedRectangle(cornerRadius: 6)
.strokeBorder(stroke, lineWidth: 1),
)
}
.buttonStyle(.plain)
.disabled(disabled)
.opacity(disabled ? 0.45 : 1)
}
private var ink: Color {
switch style {
case .solid: DesignTokens.surface
case .secondary: DesignTokens.foreground
case .outline: DesignTokens.accent
}
}
private var fill: Color {
switch style {
case .solid: DesignTokens.accent
case .secondary: DesignTokens.surface
case .outline: .clear
}
}
private var stroke: Color {
switch style {
case .solid: .clear
case .secondary: DesignTokens.border
case .outline: DesignTokens.accent
}
}
}
/// #24 (S3.1) → #156: the pass bar — the compact Pass 1 / Pass 2 selector
/// + `PASS N · STATE` status line (settled #4: the selector replaced the
/// segmented mode picker), what the pass critiques + the honest cost
/// estimate (PassContext), and the Run / Blind Read / Cancel actions.
/// Additive chrome above the mentor pane's shared transcript.
private struct PassBarView: View {
let kind: PassKind
/// The selected pass — the bar's own state (nothing outside reads it).
@State private var kind: PassKind = .pass1
let posts: PostsModel?
let home: URL?
let model: MentorSessionModel
@@ -253,35 +301,83 @@ private struct PassBarView: View {
let onOpenSettings: (() -> Void)?
var body: some View {
VStack(alignment: .leading, spacing: 8) {
VStack(alignment: .leading, spacing: 0) {
selector
.padding(.bottom, 9)
statusLine
.padding(.bottom, 5)
Text(description)
.font(.callout)
.font(.system(size: 11))
.foregroundStyle(DesignTokens.muted)
.frame(maxWidth: .infinity, alignment: .leading)
HStack {
Text(stateLabel)
.font(.system(size: 11, design: DesignTokens.mono))
.foregroundStyle(DesignTokens.muted)
Spacer()
actions
}
.fixedSize(horizontal: false, vertical: true)
.padding(.bottom, 10)
actions
// #137: the pass profile's provider has no key — name it and
// offer the way out. A readable-but-keyed profile shows nothing.
if let label = missingKeyLabel {
HStack(spacing: 4) {
Text("Missing \(label) key —")
Button("Open Settings") {
onOpenSettings?()
}
.buttonStyle(.borderless)
.foregroundStyle(DesignTokens.accent)
}
.font(.system(size: 11, design: DesignTokens.mono))
.foregroundStyle(DesignTokens.muted)
missingKeyLine(label: label)
.padding(.top, 8)
}
}
.padding(.horizontal, 12)
.padding(.bottom, 10)
.padding(.horizontal, 14)
.padding(.vertical, 12)
}
/// Contract `.selector`: text tabs — mono 10, uppercase, tracked; the
/// active tab carries fg ink + a 2pt accent underline.
private var selector: some View {
HStack(spacing: 14) {
passTab(.pass1)
passTab(.pass2)
}
}
private func passTab(_ pass: PassKind) -> some View {
Button {
kind = pass
} label: {
Text(pass.rawValue)
.font(.system(size: 10, design: DesignTokens.mono))
.tracking(0.8) // CSS .08em @ 10px
.textCase(.uppercase)
.foregroundStyle(kind == pass ? DesignTokens.foreground : DesignTokens.muted)
.padding(.top, 3)
.padding(.bottom, 5)
.overlay(alignment: .bottom) {
if kind == pass {
Rectangle()
.fill(DesignTokens.accent)
.frame(height: 2)
}
}
}
.buttonStyle(.plain)
.accessibilityLabel(pass.rawValue)
.accessibilityAddTraits(kind == pass ? [.isSelected] : [])
}
/// Contract `.status-line`: `PASS N · STATE` — the open piece's Pass
/// State in the library's post-meta voice.
private var statusLine: some View {
Text("\(kind.rawValue) · \(stateLabel)")
.font(.system(size: 10, design: DesignTokens.mono))
.tracking(0.8)
.textCase(.uppercase)
.foregroundStyle(DesignTokens.muted)
}
/// #137: the missing-key ask — mono 11, the Open Settings way out.
private func missingKeyLine(label: String) -> some View {
HStack(spacing: 4) {
Text("Missing \(label) key —")
Button("Open Settings") {
onOpenSettings?()
}
.buttonStyle(.borderless)
.foregroundStyle(DesignTokens.accent)
}
.font(.system(size: 11, design: DesignTokens.mono))
.foregroundStyle(DesignTokens.muted)
}
/// #137: nil unless the pass profile's provider is readable AND unkeyed
@@ -311,40 +407,50 @@ private struct PassBarView: View {
return posts.posts.first(where: { $0.id == posts.selectedPostID })?.passState.rawValue ?? "—"
}
/// Cancel while a pass or Blind Read runs; Run otherwise — disabled
/// with no open piece, while the engine can't take the turn, or (#137)
/// while the pass profile's provider has no key (the help names it).
/// Cancel while a pass or Blind Read runs (the accent-outline danger
/// voice); Run + Blind Read otherwise — Run disabled with no open
/// piece, while the engine can't take the turn, or (#137) while the
/// pass profile's provider has no key (the help names it).
/// #122: the Blind Read trigger sits beside Run — advisory-only.
@ViewBuilder
private var actions: some View {
if posts?.runningPass != nil || posts?.runningBlindRead == true {
Button("Cancel") {
posts?.cancelPass(mentor: model)
}
.buttonStyle(.bordered)
} else {
blindReadButton
if let label = missingKeyLabel {
runPassButton
.disabled(true)
.help("\(kind.rawValue) needs a \(label) API key — add it in Settings → Provider Keys.")
HStack(spacing: 7) {
if posts?.runningPass != nil || posts?.runningBlindRead == true {
MonoButton(title: "Cancel", style: .outline) {
posts?.cancelPass(mentor: model)
}
} else {
runPassButton
.disabled(posts?.session?.postID == nil || !model.phase.isReady || model.isStreaming)
blindReadButton
if let label = missingKeyLabel {
MonoButton(title: "Run \(kind.rawValue)", disabled: true, action: runPass)
.help("\(kind.rawValue) needs a \(label) API key — add it in Settings → Provider Keys.")
} else {
MonoButton(
title: "Run \(kind.rawValue)",
disabled: posts?.session?.postID == nil || !model.phase.isReady || model.isStreaming,
action: runPass,
)
}
}
}
}
private func runPass() {
guard let posts, let home else { return }
Task { await posts.runPass(kind, home: home, mentor: model) }
}
/// #122: the Blind Read — one purposeful click judges the current
/// document against the Pass-start snapshot, blind. Disabled with the
/// blocking reason in help (no snapshot yet is the fresh-piece norm).
private var blindReadButton: some View {
Button("Blind Read") {
MonoButton(
title: "Blind Read",
style: .secondary,
disabled: blindReadBlocked != nil,
) {
guard let posts, let home else { return }
Task { await posts.blindRead(home: home, mentor: model) }
}
.buttonStyle(.bordered)
.disabled(blindReadBlocked != nil)
.help(
blindReadBlocked
?? "Judge the current document against the Pass-start snapshot — advisory only, nothing is recorded.",
@@ -358,15 +464,6 @@ private struct PassBarView: View {
guard model.phase.isReady, !model.isStreaming else { return "The mentor engine can't take the turn right now." }
return nil
}
/// The Run button core — shared by the ready and missing-key branches.
private var runPassButton: some View {
Button("Run \(kind.rawValue)") {
guard let posts, let home else { return }
Task { await posts.runPass(kind, home: home, mentor: model) }
}
.buttonStyle(.borderedProminent)
}
}
#Preview {
@@ -0,0 +1,68 @@
# Restyle the mentor pane chrome (MentorPaneView) — build slice 2 of map #153
> **Date:** 2026-11-04
> **Type:** issue
> **Reference:** [#156](https://git.babylondreams.de/AlexKucera/museion/issues/156) (map [#153](https://git.babylondreams.de/AlexKucera/museion/issues/153), contract [#154](https://git.babylondreams.de/AlexKucera/museion/issues/154))
## Goal
Build slice 2 of the mentor-pane editorial-voice map: MentorPaneView's chrome per the locked contract (`ref/prototypes/wf154-mentor-pane-prototype.html` @ 9b1fa75) — header (serif title, green ready dot, session chip), the segmented mode picker dead (pass bar gains the Pass 1 / Pass 2 selector + status line), pass bar + fix-cards row in the mono voice, crash / missing-engine / starting states in the editorial voice. Close with build + test green, swiftformat + swiftlint clean, and this log.
## What Was Done
- `Museion/DesignTokens.swift` — `readyGreen` (#36664F) added: the map's sole palette exception, a semantic meaning ("engine healthy"), never a style color.
- `Museion/EngineStatusView.swift` — `MentorEngineStatus`'s ready branch remapped per contract: 6pt green dot + lowercase mono-10 `ready`; the base `hermes` version demoted to the tooltip; the advisory drift note stays visible (orange) when gate and handshake disagree. Checking / engine-missing / setup-failed branches untouched — they already spoke the mono-10 chrome voice.
- `Museion/MentorPaneView.swift`:
- **Header**: icon + "Mentor Session" headline died → serif-15/600 "Mentor"; session chip → mono-10 muted @ 0.75; pads 12→14.
- **Mode picker dead** (settled #4): `Mode` enum + `modePicker` + `passKind` computed deleted. `PassBarView` always renders in `.ready` — chat is not a mode; transcript + composer are always present (pass critiques already render in the shared transcript).
- **Pass bar rebuilt per contract**: compact selector (Pass 1 / Pass 2 text tabs, mono-10 uppercase tracked, active = fg ink + 2pt accent underline) → `PASS N · STATE` status line (mono-10 uppercase tracked) → sans-11 muted cost line → actions. `@State kind: PassKind` now lives in PassBarView (nothing outside reads it).
- **`MonoButton`** (private, new): the contract's `.btn` — mono-11, h 28, radius 6, three looks: accent solid (Run, Restart), surface + border (Blind Read), accent outline (Cancel — the danger voice). Hand-drawn fills per #155's sendButton precedent (borderedProminent carries the system tint, not the palette). Disabled = 0.45 opacity + `.disabled`.
- **Fix-cards row**: plain mono row ruling — no card chrome, no hairline of its own (the Divider above separates it from the bar), leading-aligned below the bar.
- **Crash card**: terracotta tri (danger = terracotta, no second hue — was orange), serif-14/600 head, sans-12 muted body, last prompt mono-11 muted, Restart as solid-accent MonoButton. Technical-details disclosure unchanged.
- **Starting interim**: `ProgressView("…")` → mini spinner + mono-11 muted line (the quiet system voice).
- DOX pass: `Museion/AGENTS.md` — MentorPaneView bullet (header/pass-bar/crash clauses rewritten for #156, stale #28 version-display note removed), engine-check section's header-states line, DesignTokens palette line (readyGreen exception).
## Decisions & Rationale
| Decision | Rationale |
|----------|-----------|
| Version demoted to tooltip, drift note stays visible orange | The contract's header is dot + `ready` + chip — chrome silence. The version is lookup info (tooltip suffices; state.json + rail card keep it), but the drift note is a rare advisory that must not disappear — visibility beats chrome purity for a warning that exists. |
| `MonoButton` shared by pass bar + crash card | Three button looks × four call sites — one 50-line private struct beats four hand-rolled copies; the #155 sendButton already proved the hand-drawn-fill pattern. |
| Selector state lives in PassBarView | Nothing outside the bar reads the selection — no binding threading through MentorPaneView for a private concern. |
| "Blind Read" casing kept over the mock's "Blind read" | The GLOSSARY term is binding project vocabulary; the mock's incidental casing is not a ruled value. |
| No new tests | Pure visual restyle; no new pure seams. `MentorEngineStatus.state` mapping (the pinned logic) untouched. |
## Gotchas & Fixes
| Problem | Root Cause | Fix |
|---------|------------|-----|
| First body patch over-indented `case .ready:` one level | Patch string authored one tab deep | Immediate follow-up patch; swiftformat then found nothing further to move |
| AGENTS.md DesignTokens patch failed to match | I paraphrased the file's wording from memory of the first read | Read the exact line tail (`awk NR==23`), retried verbatim — matched |
| `tea api` open-issues jq one-liner died on quoting/null labels | Some issues carry null `labels`/`assignees` | Defensive `(x // [])` coalescing in jq |
## Files Changed
| File | Change Summary |
|------|---------------|
| `Museion/DesignTokens.swift` | + `readyGreen` (sole palette exception) |
| `Museion/EngineStatusView.swift` | Ready branch → green dot + mono `ready`, version → tooltip |
| `Museion/MentorPaneView.swift` | Header restyle, mode picker dead, pass bar + MonoButton, fix row, crash/starting cards |
| `Museion/AGENTS.md` | DOX pass for #156 |
| `docs/devlog/20261104-issue156-mentor-pane-chrome-editorial-voice_log.md` | This log |
## Verification
- `xcodebuild … build` → **BUILD SUCCEEDED**
- `xcodebuild … test` → xcresult: **592/592 passed, 0 failed, 0 skipped** (582 at #155 + 10 from the #157 library-search coverage merge)
- swiftformat (changed files only) clean; swiftlint: no errors — one tolerated file-length warning (MentorPaneView 475/1000-error, #155's 573-line precedent)
## Open Items & Next Steps
- [ ] Code is **uncommitted on `main`** (working tree) — commit awaits explicit authorization (#155 precedent).
- [ ] Map #153 closes when the pane lands (merged); both build slices (#155 merged, #156 this log) then done.
- [ ] Audit-deferred (finish-audit 2026-11-04): pass-selector `@State kind` resets to Pass 1 when the `.ready` branch unmounts/remounts (crash → Restart, mentor-column collapse < 920px). Deliberate local state, one click to restore — move to `@AppStorage` if it ever annoys.
- [ ] Audit-deferred (finish-audit 2026-11-04): MonoButton solid look is surface-on-accent ≈ 3.85:1, under AA 4.5:1 for small text — inherited from #155's sendButton; fix both together in a pane-wide a11y pass (darker accent fill or bump label size) if flagged.
---
*Log written by write-log skill*
+1
View File
@@ -5,6 +5,7 @@ Complete history of session logs in this directory, newest first. One-line summa
<!-- write-log: full-index -->
| Date | Type | File | Summary |
|------|------|------|---------|
| 2026-11-04 | issue | [20261104-issue156-mentor-pane-chrome-editorial-voice_log.md](20261104-issue156-mentor-pane-chrome-editorial-voice_log.md) | #156: pane chrome — serif header + green ready dot, mode picker dead (selector + status line), MonoButton actions, crash/starting cards editorial |
| 2026-11-04 | issue | [20261104-issue155-shared-conversation-surface-editorial-voice_log.md](20261104-issue155-shared-conversation-surface-editorial-voice_log.md) | #155: shared transcript restyle — three voices (capsule/serif prose/status box), ThinkingBlock port, composer + floating liveness chip, debug toggle moved to composer edge |
| 2026-11-03 | issue | [20261103-issue151-gateless-launch-async-engine-check-rail-pill-auto-fire_log.md](20261103-issue151-gateless-launch-async-engine-check-rail-pill-auto-fire_log.md) | Gateless launch: workspace is the first frame, async check, rail pill + fail card, auto-fired provisioning/backup. |
| 2026-11-03 | issue | [20261103-issue58-voice-payload-landed_log.md](20261103-issue58-voice-payload-landed_log.md) | #58: Swadia VOICE payload — new owned-insight skill, retelling/next-line cards, interview-first stance, allocation row P1 10 · P2 9 · Chat 11 |