feat(mentor): editorial chat voice for the transcript (#155)
CI / ci (push) Canceled after 0s

Wayfinder map #153, build slice 1 of the #154 contract: the shared
SessionTranscriptView speaks the two-color editorial voice — speaker
prefixes map onto serif agent prose (markdown at flush, verbatim
streaming), right-aligned terracotta user capsules, and the mono status
box on the fg-wash card; ThinkingBlock port; composer restyle with one
Send/Stop button, floating liveness chip, and the Debug toggle moved to
its trailing edge (Sessions pane inherits the same surface).

Finish-audit fanout hardened it: interpreted markdown opens http(s) only
(openURL gate at the sink — engine prose echoes imported content; pinned
via the pure linkVerdict seam), Caps Lock no longer turns Shift+Return
into a send (pinned), the plain-Button toggles speak state to VoiceOver,
and the dead GeometryReader wrapper is gone.

Suite 584/584 (xcresult count), flip-verified pins, swiftformat +
swiftlint clean at the error tier.
This commit is contained in:
AlexKucera committed 2026-11-04 09:46:21 +01:00
1 parent ef246e3f27
commit 2aa8bdabd8
8 files changed
+542 -101

No files matched your search

+39
View File
@@ -16,6 +16,7 @@
// files build rigs on it) + the client/model suites that pin its contract.
import Foundation
import SwiftUI
@testable import Museion
import Testing
@@ -430,6 +431,44 @@ struct ACPClientTests {
#expect(!SessionTranscriptView.isWritingRow(SessionRow(content: .raw(kind: "tool_call_update", json: "{}"))))
}
/// #155 (map #153): the editorial-voice classifier — the model's speaker
/// prefixes map onto the contract's three voices (agent prose / user
/// capsule / system status box); everything else is the system's mono
/// voice (refusals, pass kick-off labels, reveals).
@Test func `speaker classifier maps prefixes onto the contract voices`() {
#expect(SessionTranscriptView.speaker(of: "Mentor: The opening earns its place.") == .agent)
#expect(SessionTranscriptView.speaker(of: "Mentor: (refused the prompt)") == .agent)
#expect(SessionTranscriptView.speaker(of: "You: What would you cut first?") == .user)
#expect(SessionTranscriptView.speaker(of: "Pass 1 · The piece") == .system)
#expect(SessionTranscriptView.speaker(of: "Session refused — the mentor is mid-turn.") == .system)
#expect(SessionTranscriptView.speaker(of: "A = Pass 1 start snapshot · B = current document") == .system)
}
/// #155 audit (security): the link-open gate — interpreted markdown
/// opens http(s) only; every other scheme (file:, mailto:, custom app
/// schemes) is discarded. Engine prose echoes imported content, so a
/// lying `[label](scheme:…)` link must never reach a handler.
@Test func `linkVerdict discards non-http schemes from interpreted markdown`() throws {
#expect(try SessionTranscriptView.linkVerdict(for: #require(URL(string: "https://mentor.dev/critique"))) == .open)
#expect(try SessionTranscriptView.linkVerdict(for: #require(URL(string: "http://mentor.dev/critique"))) == .open)
// Scheme matching is case-insensitive on the wire.
#expect(try SessionTranscriptView.linkVerdict(for: #require(URL(string: "HTTPS://MENTOR.DEV/x"))) == .open)
for scheme in ["file:///etc/passwd", "mailto:x@y.dev", "notesapp://open", "javascript:alert(1)"] {
#expect(try SessionTranscriptView.linkVerdict(for: #require(URL(string: scheme))) == .discard, "\(scheme) should be discarded")
}
}
/// #155 audit: the Return split — Caps Lock must not turn Shift+Return
/// into a send (an exact `==` did).
@Test func `returnIntent masks caps lock and splits plain vs shift return`() {
#expect(SessionTranscriptView.returnIntent(for: []) == .send)
#expect(SessionTranscriptView.returnIntent(for: .shift) == .lineBreak)
#expect(SessionTranscriptView.returnIntent(for: [.shift, .capsLock]) == .lineBreak)
#expect(SessionTranscriptView.returnIntent(for: .capsLock) == .send)
#expect(SessionTranscriptView.returnIntent(for: .option) == .passthrough)
#expect(SessionTranscriptView.returnIntent(for: [.command]) == .passthrough)
}
@MainActor
@Test func `refusal maps to ended refusal and still renders the refusal row`() async {
let fake = makeFakeACP(at: acpTempDir("outcome-refusal"), mode: "refuseOnPrompt")