feat(ui): design-council polish overhaul
CI / ci (push) Canceled after 0s
CI / ci (pull_request) Canceled after 0s
CI / ci (push) Canceled after 0s
CI / ci (pull_request) Canceled after 0s
Eight arbitrated rounds over the workspace surface: piece-scoped Mentor hosting, conversation-voice system messages, glyph-measured roster truncation, bounded learnings/archive columns, symmetric trends grid, top-aligned settings forms, serif editor titles, outline rail rhythm, launch auto-focus root fix. New seams pinned by SessionScopeTests + WordBoundaryTruncationTests; full suite green.
This commit is contained in:
1 parent
b2db859887
commit
3a7d495b4b
21 files changed
+2287
-516
No files matched your search
@@ -11,11 +11,13 @@
|
||||
// remapped onto the two-color palette per the locked contract
|
||||
// (ref/prototypes/wf154-mentor-pane-prototype.html). Speaker-act rows
|
||||
// render as speech (right-aligned terracotta capsule / full-width serif
|
||||
// prose, markdown parsed at flush, verbatim while streaming — the Vivarium
|
||||
// #97 pattern); every other text row is the system's quiet mono voice on
|
||||
// the fg-wash 6% card. Composer: surface input, accent Send flipping to a
|
||||
// terracotta-outlined Stop, floating liveness chip (streaming only), the
|
||||
// debug toggle at the trailing edge.
|
||||
// markdown parsed at flush, verbatim while streaming — the Vivarium
|
||||
// #97 pattern); every other text row is the system's quiet mono voice on
|
||||
// the fg-wash 6% card. Round-2 polish: interruption/error status rows
|
||||
// carry a restrained terracotta accent. Composer: surface input, accent
|
||||
// Send flipping to a terracotta-outlined Stop, floating liveness chip
|
||||
// (streaming only), the debug toggle hover-revealed at the trailing
|
||||
// edge — zero visible footprint at rest.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
@@ -44,12 +46,25 @@ struct SessionTranscriptView: View {
|
||||
@State private var pendingKeep: PendingKeep?
|
||||
/// The freeform draft (#30: shared input rail).
|
||||
@State private var draft = ""
|
||||
/// Round-2 polish (argon#21/sol#43/mercury#58): the debug toggle is
|
||||
/// hover-revealed — true while the pointer is over the composer row.
|
||||
@State private var composerHover = false
|
||||
/// #155: the pane's live width — the user capsule caps at 85% of the
|
||||
/// CONTENT column (width − 2×16 transcript pads). Seeded to the mentor
|
||||
/// MEASURE column (width − 2×16 transcript pads). Seeded to the mentor
|
||||
/// column so the first frame is right there; the Sessions pane's wider
|
||||
/// column corrects it on the first geometry pass.
|
||||
@State private var paneWidth: CGFloat = 356
|
||||
|
||||
/// Round-1 polish (argon#4/mercury#43): the reading measure —
|
||||
/// conversational content caps at a comfortable ~720pt, centered in the
|
||||
/// (possibly ~830pt+) Sessions column. The mentor column (356) caps
|
||||
/// naturally. Scroll anchoring untouched (#24 bottom-anchor contract).
|
||||
private static let measureCap: CGFloat = 720
|
||||
|
||||
private var measureWidth: CGFloat {
|
||||
min(paneWidth, Self.measureCap)
|
||||
}
|
||||
|
||||
private struct PendingKeep: Identifiable {
|
||||
let rowID: UUID
|
||||
let candidate: ResearchCandidate
|
||||
@@ -58,9 +73,10 @@ struct SessionTranscriptView: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// The user capsule's cap — 85% of the visible column (contract ruling).
|
||||
/// The user capsule's cap — 85% of the visible MEASURE column
|
||||
/// (contract ruling, pads included).
|
||||
private var capsuleCap: CGFloat {
|
||||
max(0, (paneWidth - 32) * 0.85)
|
||||
max(0, (measureWidth - 32) * 0.85)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -107,11 +123,15 @@ struct SessionTranscriptView: View {
|
||||
}
|
||||
|
||||
private var transcript: some View {
|
||||
ScrollView {
|
||||
let visible = model.rows.filter { showsDebugRows || Self.isWritingRow($0) }
|
||||
return ScrollView {
|
||||
// Contract turn rhythm: 18px between turns; pads 18/16/12.
|
||||
// Round-7 (mercury#21/argon#39): rows render with their
|
||||
// PREDECESSOR in reach — the warning-styling and gap rules
|
||||
// below are pairwise, not per-row.
|
||||
LazyVStack(alignment: .leading, spacing: 18) {
|
||||
ForEach(model.rows.filter { showsDebugRows || Self.isWritingRow($0) }) { row in
|
||||
rowView(row)
|
||||
ForEach(visible.indices, id: \.self) { index in
|
||||
rowView(visible[index], previous: index > 0 ? visible[index - 1] : nil)
|
||||
}
|
||||
if showsDebugRows, !model.streamingThought.isEmpty {
|
||||
// Live thinking: open while it runs (spinner toggle),
|
||||
@@ -124,12 +144,19 @@ struct SessionTranscriptView: View {
|
||||
agentProse(Text(verbatim: model.streamingText))
|
||||
}
|
||||
}
|
||||
.padding(EdgeInsets(top: 18, leading: 16, bottom: 12, trailing: 16))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(EdgeInsets(top: 18, leading: 16, bottom: 16, trailing: 16))
|
||||
// Round-1 polish: the reading measure — content centers in a
|
||||
// ≤720pt column (argon#4/mercury#43); anchor untouched (#24).
|
||||
.frame(maxWidth: measureWidth)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
}
|
||||
// #24 fix: programmatic scrollTo raced the growing lazy rows and
|
||||
// mislanded at the TOP; the native bottom anchor needs no scroll code.
|
||||
.defaultScrollAnchor(.bottom)
|
||||
// Round-1 polish (argon#27/mercury#61): viewport clearance — a row
|
||||
// sliced mid-scroll never rides the header divider (the content pad
|
||||
// above only shows at full scroll-up).
|
||||
.padding(.top, 14)
|
||||
}
|
||||
|
||||
/// The writing-session filter: prose + card events stay; raw rows and
|
||||
@@ -147,16 +174,56 @@ struct SessionTranscriptView: View {
|
||||
/// onto the contract's three voices. Everything else (refusals, pass
|
||||
/// kick-off labels, reveals) is the system's mono voice. Static,
|
||||
/// nonisolated — pure, testable from any context.
|
||||
/// Round-1 polish: engine-emitted operational notices (interruptions)
|
||||
/// and replayed pass kick-offs are STATUS, not conversation — they map
|
||||
/// to the system voice too (never serif prose, never a user capsule).
|
||||
nonisolated static func speaker(of text: String) -> Speaker {
|
||||
if text.hasPrefix("Mentor: ") {
|
||||
return .agent
|
||||
let body = String(text.dropFirst("Mentor: ".count))
|
||||
return body.hasPrefix("Operation interrupted:") ? .system : .agent
|
||||
}
|
||||
if text.hasPrefix("You: ") {
|
||||
return .user
|
||||
return isPassKickoff(String(text.dropFirst("You: ".count))) ? .system : .user
|
||||
}
|
||||
return .system
|
||||
}
|
||||
|
||||
/// Round-1 polish: a replayed pass kick-off — the engine replays the
|
||||
/// pass prompt as a user turn whose body opens with PassContext's fixed
|
||||
/// "Pass Pass N — <level>." line. Static, nonisolated — pure.
|
||||
nonisolated static func isPassKickoff(_ body: String) -> Bool {
|
||||
body.hasPrefix("Pass Pass ")
|
||||
}
|
||||
|
||||
/// Round-1 polish: the system row's display text — a replayed pass
|
||||
/// kick-off shows its FIRST LINE only (the full engine prompt stays out
|
||||
/// of the UI); every other status row renders verbatim. Static,
|
||||
/// nonisolated — pure, testable from any context.
|
||||
///
|
||||
/// Round-2 polish (r1 regression): PassContext's first line already
|
||||
/// carries "Pass " + the pass name, so the raw line reads "Pass Pass
|
||||
/// 2 — …" — collapse the doubled leading "Pass Pass N" to "Pass N".
|
||||
nonisolated static func statusDisplayText(_ text: String) -> String {
|
||||
guard text.hasPrefix("You: ") else { return text }
|
||||
let body = text.dropFirst("You: ".count)
|
||||
guard isPassKickoff(String(body)) else { return text }
|
||||
let line = String(body.prefix(while: { $0 != "\n" }))
|
||||
guard line.hasPrefix("Pass Pass ") else { return line }
|
||||
return "Pass " + line.dropFirst("Pass Pass ".count)
|
||||
}
|
||||
|
||||
/// Round-2 polish (argon#24/mercury#60/sol#9): operational warnings —
|
||||
/// engine-emitted interruptions, connection losses, and the model's
|
||||
/// failure rows — get the restrained terracotta accent in the status
|
||||
/// voice. Refusals and cancellations stay neutral (they are outcomes,
|
||||
/// not failures). Static, nonisolated — pure, test-pinnable.
|
||||
nonisolated static func isWarningStatus(_ text: String) -> Bool {
|
||||
let body = text.hasPrefix("Mentor: ") ? String(text.dropFirst("Mentor: ".count)) : text
|
||||
return body.hasPrefix("Operation interrupted")
|
||||
|| body.hasPrefix("connection lost")
|
||||
|| body.contains(" failed — ")
|
||||
}
|
||||
|
||||
/// The three contract voices for a text row.
|
||||
nonisolated enum Speaker {
|
||||
case agent
|
||||
@@ -186,7 +253,7 @@ struct SessionTranscriptView: View {
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func rowView(_ row: SessionRow) -> some View {
|
||||
private func rowView(_ row: SessionRow, previous: SessionRow?) -> some View {
|
||||
switch row.content {
|
||||
case let .text(text):
|
||||
switch Self.speaker(of: text) {
|
||||
@@ -195,7 +262,20 @@ struct SessionTranscriptView: View {
|
||||
case .user:
|
||||
userCapsule(String(text.dropFirst("You: ".count)))
|
||||
case .system:
|
||||
statusBox(text)
|
||||
// Round-7 (mercury#21): the full warning treatment (tinted
|
||||
// fill + border) renders ONLY while this row is the
|
||||
// transcript's last meaningful row — an older interruption
|
||||
// above a completed reply is history.
|
||||
// Round-8 (argon#8): a historical warning keeps the
|
||||
// terracotta ink + glyph (see `statusBox`) — distinct,
|
||||
// just not shouting.
|
||||
let current = Self.isWarningStatus(text) && isLastMeaningfulRow(row)
|
||||
statusBox(Self.statusDisplayText(text), current: current)
|
||||
// Round-7 (argon#39): 8pt of air when the warning
|
||||
// banner directly follows the pass kick-off pill —
|
||||
// at the stack's uniform 18pt the pair read as one
|
||||
// fused block.
|
||||
.padding(.top, current && Self.isKickoffPill(previous) ? 8 : 0)
|
||||
}
|
||||
case let .thought(text):
|
||||
// #24 dogfood fix: collapsed — a pass's thought stream runs to
|
||||
@@ -230,13 +310,15 @@ struct SessionTranscriptView: View {
|
||||
}
|
||||
|
||||
/// User turns: the right-aligned capsule — terracotta wash 14% fill,
|
||||
/// fg ink, sans 13/1.5, pads 16/12, radius 12/12/2/12 (the 2pt tail
|
||||
/// bottom-trailing), capped at 85% of the visible column.
|
||||
/// fg ink, sans 14/1.5 (Round-2, mercury#62 partial: one point up;
|
||||
/// lineSpacing re-derived from the same CSS 1.5 math — pads 16/12
|
||||
/// untouched), radius 12/12/2/12 (the 2pt tail bottom-trailing),
|
||||
/// capped at 85% of the visible column.
|
||||
private func userCapsule(_ text: String) -> some View {
|
||||
Text(text)
|
||||
.font(DesignTokens.concourse(13))
|
||||
.font(DesignTokens.concourse(14))
|
||||
.foregroundStyle(DesignTokens.foreground)
|
||||
.lineSpacing(3.7) // CSS 1.5 (19.5 − Concourse's natural 15.8)
|
||||
.lineSpacing(4) // CSS 1.5 (21 − Concourse's scaled natural ≈ 17)
|
||||
.textSelection(.enabled)
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 12)
|
||||
@@ -257,16 +339,36 @@ struct SessionTranscriptView: View {
|
||||
}
|
||||
|
||||
/// The quiet system voice: mono 11/1.5 muted on the fg-wash card —
|
||||
/// refusals, pass kick-off labels, reveals. Fit-content width.
|
||||
private func statusBox(_ text: String) -> some View {
|
||||
Text(text)
|
||||
.font(DesignTokens.ubuntuMono(11))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
.lineSpacing(5.5) // CSS 1.5
|
||||
.textSelection(.enabled)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 10)
|
||||
.background(washCard)
|
||||
/// refusals, pass kick-off labels, reveals.
|
||||
/// Round-6 (mercury#5/sol#10/argon#15): warning rows are their own
|
||||
/// component — warning glyph, structured headline + muted detail.
|
||||
/// Round-7 (mercury#21): the full treatment (fill + border) renders
|
||||
/// only when the caller passes `current` (last meaningful row).
|
||||
/// Round-8 (argon#8/mercury#16): a warning row ALWAYS carries the
|
||||
/// terracotta ink + glyph — historical ones on the plain wash pill —
|
||||
/// and ALL status rows share one width treatment: the transcript
|
||||
/// column's full width, leading edge aligned (fit-content pills and
|
||||
/// full-width banners read as two glued regions).
|
||||
@ViewBuilder
|
||||
private func statusBox(_ text: String, current: Bool = false) -> some View {
|
||||
if Self.isWarningStatus(text) {
|
||||
let parts = Self.warningParts(text)
|
||||
WarningStatusRow(
|
||||
headline: parts.headline,
|
||||
detail: parts.detail.map(Self.calmDetail),
|
||||
emphasized: current,
|
||||
)
|
||||
} else {
|
||||
Text(text)
|
||||
.font(DesignTokens.ubuntuMono(11))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
.lineSpacing(5.5) // CSS 1.5
|
||||
.textSelection(.enabled)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 10)
|
||||
.background(washCard)
|
||||
}
|
||||
}
|
||||
|
||||
/// The card-fill ruling (owner, 2026-11-03): thinking cards, status
|
||||
@@ -356,7 +458,9 @@ struct SessionTranscriptView: View {
|
||||
}
|
||||
|
||||
private var dimmed: Double {
|
||||
candidate.disposition == .pending ? 1 : 0.45
|
||||
// Round-2 sweep: 0.45 broke the 0.75 informational floor —
|
||||
// 0.75 still reads closed against the 1.0 pending card.
|
||||
candidate.disposition == .pending ? 1 : 0.75
|
||||
}
|
||||
|
||||
private var washCard: some View {
|
||||
@@ -443,13 +547,133 @@ struct SessionTranscriptView: View {
|
||||
} label: {
|
||||
Text(kind)
|
||||
.font(DesignTokens.ubuntuMono(11))
|
||||
.foregroundStyle(.secondary)
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Warning status row (round-6 — file-scope, type_body_length
|
||||
|
||||
// posture; MonoButton/ResearchNoteContent precedent)
|
||||
|
||||
/// Round-6 (mercury#5/sol#10/argon#15 — all seats): the operational
|
||||
/// warning row as a real component — the 11pt warning glyph, mono 12,
|
||||
/// structured headline over a muted detail line; wrapping allowed. No
|
||||
/// new hues — the accent over its own wash.
|
||||
/// Round-8 (argon#8/mercury#16): `emphasized` (the transcript's last
|
||||
/// meaningful row) carries the full treatment — accent wash fill (~9%)
|
||||
/// + 1pt accent border; a historical warning keeps the terracotta glyph
|
||||
/// + headline on the same plain wash pill the neutral status rows use —
|
||||
/// distinct, never shouting.
|
||||
private struct WarningStatusRow: View {
|
||||
let headline: String
|
||||
let detail: String?
|
||||
var emphasized = true
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .top, spacing: 8) {
|
||||
Image(systemName: "exclamationmark.triangle")
|
||||
.font(.system(size: 11))
|
||||
.foregroundStyle(DesignTokens.accent)
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
Text(headline)
|
||||
.font(DesignTokens.ubuntuMono(12).weight(.semibold))
|
||||
.foregroundStyle(DesignTokens.accent)
|
||||
if let detail {
|
||||
Text(detail)
|
||||
.font(DesignTokens.ubuntuMono(12))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 10)
|
||||
.background(washFill)
|
||||
.overlay(emphasized ? borderOverlay : nil)
|
||||
.textSelection(.enabled)
|
||||
.accessibilityElement(children: .combine)
|
||||
}
|
||||
|
||||
private var washFill: some View {
|
||||
RoundedRectangle(cornerRadius: DesignTokens.radius)
|
||||
.fill(emphasized ? DesignTokens.accent.opacity(0.09) : DesignTokens.foreground.opacity(0.06))
|
||||
}
|
||||
|
||||
private var borderOverlay: some View {
|
||||
RoundedRectangle(cornerRadius: DesignTokens.radius)
|
||||
.strokeBorder(DesignTokens.accent, lineWidth: 1)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Warning display seams (round-6 split + round-8 calm copy —
|
||||
|
||||
// file-scope extension, type_body_length posture; pure + test-pinned.
|
||||
// NOT private: ACPClientTests pins both seams via @testable.)
|
||||
|
||||
extension SessionTranscriptView {
|
||||
/// Round-6 (all seats): the warning row's headline/detail split — drop
|
||||
/// the speaker prefix, then cut at the first ": " ("Operation
|
||||
/// interrupted: waiting for model response (61.6s elapsed)." → headline
|
||||
/// "Operation interrupted", detail the rest). No ": " → the whole line
|
||||
/// is the headline ("connection lost"). Static, nonisolated — pure.
|
||||
nonisolated static func warningParts(_ text: String) -> (headline: String, detail: String?) {
|
||||
var body = text
|
||||
if body.hasPrefix("Mentor: ") {
|
||||
body = String(body.dropFirst("Mentor: ".count))
|
||||
}
|
||||
if body.hasPrefix("You: ") {
|
||||
body = String(body.dropFirst("You: ".count))
|
||||
}
|
||||
guard let separator = body.range(of: ": ") else { return (body, nil) }
|
||||
return (String(body[..<separator.lowerBound]), String(body[separator.upperBound...]))
|
||||
}
|
||||
|
||||
/// Round-8 (argon#8 — calm copy): the engine's own interruption detail,
|
||||
/// rephrased without inventing states — "waiting for model response
|
||||
/// (61.6s elapsed)" renders as "waiting on the model — 61.6s". Only
|
||||
/// the engine's known phrasing is rewritten (plain prefix/suffix
|
||||
/// match, trailing period tolerated); anything else passes through
|
||||
/// verbatim. Static, nonisolated — pure.
|
||||
nonisolated static func calmDetail(_ detail: String) -> String {
|
||||
let trimmed = detail.hasSuffix(".") ? String(detail.dropLast()) : detail
|
||||
let prefix = "waiting for model response ("
|
||||
let suffix = " elapsed)"
|
||||
guard trimmed.hasPrefix(prefix), trimmed.hasSuffix(suffix),
|
||||
trimmed.count > prefix.count + suffix.count
|
||||
else { return detail }
|
||||
let elapsed = trimmed.dropFirst(prefix.count).dropLast(suffix.count)
|
||||
return "waiting on the model — \(elapsed)"
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Round-7 row rules (file-scope extension — type_body_length
|
||||
|
||||
// posture, the composer extension's precedent)
|
||||
|
||||
private extension SessionTranscriptView {
|
||||
/// Round-7 (mercury#21): this row is the transcript's last MEANINGFUL
|
||||
/// row — nothing rendered or streaming sits below it. A warning row
|
||||
/// keeps its warning styling only in this position; once a reply (or a
|
||||
/// live stream) follows, it is history. Pure display — the model keeps
|
||||
/// every row either way.
|
||||
func isLastMeaningfulRow(_ row: SessionRow) -> Bool {
|
||||
guard !model.isStreaming else { return false }
|
||||
return model.rows.last(where: { showsDebugRows || Self.isWritingRow($0) })?.id == row.id
|
||||
}
|
||||
|
||||
/// Round-7 (argon#39): a replayed pass kick-off row — the status pill
|
||||
/// a warning banner must not hug (the 8pt-air rule). Static,
|
||||
/// nonisolated — pure.
|
||||
nonisolated static func isKickoffPill(_ row: SessionRow?) -> Bool {
|
||||
guard let row, case let .text(text) = row.content, text.hasPrefix("You: ") else { return false }
|
||||
return isPassKickoff(String(text.dropFirst("You: ".count)))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Composer (#155 contract restyle; file-scope extension —
|
||||
|
||||
// type_body_length posture, MentorPaneView precedent)
|
||||
@@ -457,56 +681,83 @@ struct SessionTranscriptView: View {
|
||||
private extension SessionTranscriptView {
|
||||
/// The composer: surface-fill input (radius 10, border), the ONE action
|
||||
/// button — accent Send idle, terracotta-outlined Stop mid-stream — and
|
||||
/// the debug toggle at the trailing edge. The liveness chip floats
|
||||
/// ABOVE the composer while streaming (contract ruling: the composer
|
||||
/// row stays flat).
|
||||
/// the hover-revealed debug toggle at the row's trailing edge. The
|
||||
/// liveness chip floats ABOVE the composer while streaming (contract
|
||||
/// ruling: the composer row stays flat).
|
||||
/// Round-1 polish: field and Send match heights (36 — both edges align,
|
||||
/// argon#33/mercury#38); the debug toggle rides IN the row after Send,
|
||||
/// not on a strip below it (mercury#64/sol#50).
|
||||
/// Round-2 polish: the row centers inside the SAME ≤720pt measure the
|
||||
/// transcript reads in (argon#22/sol#48) with the transcript's 16pt
|
||||
/// edge — input and conversation share one column; the toggle renders
|
||||
/// only while the pointer is over the composer (argon#21/sol#43/
|
||||
/// mercury#58) — its slot stays reserved so nothing shifts on hover.
|
||||
private var inputBar: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
HStack(alignment: .bottom, spacing: 8) {
|
||||
TextField("Ask the mentor…", text: $draft, axis: .vertical)
|
||||
.textFieldStyle(.plain)
|
||||
.font(DesignTokens.concourse(13))
|
||||
.lineLimit(1 ... 4)
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 8)
|
||||
.frame(minHeight: 36)
|
||||
.background(RoundedRectangle(cornerRadius: DesignTokens.radius).fill(DesignTokens.surface))
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: DesignTokens.radius)
|
||||
.strokeBorder(DesignTokens.border, lineWidth: 1),
|
||||
)
|
||||
.onSubmit { send() } // ⌅/fallback submit — send() no-ops on the double fire
|
||||
.onKeyPress(phases: .down) { press in
|
||||
guard press.key == .return else { return .ignored }
|
||||
// Plain Return sends, Shift+Return breaks the line,
|
||||
// every other chord keeps its native newline (⌥↩ above
|
||||
// all). macOS routes Return — ANY modifiers — to the
|
||||
// field's submit action otherwise (Vivarium owner
|
||||
// report 2026-10-26). Caps Lock is masked inside
|
||||
// returnIntent — an exact `==` sent the draft under it.
|
||||
// ponytail: the newline appends at the END, not the
|
||||
// caret — caret-aware insertion needs NSTextView
|
||||
// access; revisit if mid-draft edits ever matter.
|
||||
switch Self.returnIntent(for: press.modifiers) {
|
||||
case .send:
|
||||
send()
|
||||
return .handled
|
||||
case .lineBreak:
|
||||
draft += "\n"
|
||||
return .handled
|
||||
case .passthrough:
|
||||
return .ignored
|
||||
}
|
||||
}
|
||||
sendButton
|
||||
HStack(alignment: .bottom, spacing: 8) {
|
||||
TextField(
|
||||
"Ask the mentor…",
|
||||
text: $draft,
|
||||
// Round-1 polish (mercury#70/sol#51): placeholder at muted
|
||||
// ink — legible at a glance, not tertiary-faint.
|
||||
prompt: Text("Ask the mentor…").foregroundStyle(DesignTokens.muted),
|
||||
axis: .vertical,
|
||||
)
|
||||
.textFieldStyle(.plain)
|
||||
.font(DesignTokens.concourse(13))
|
||||
.lineLimit(1 ... 4)
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 8)
|
||||
.frame(minHeight: 36)
|
||||
.background(RoundedRectangle(cornerRadius: DesignTokens.radius).fill(DesignTokens.surface))
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: DesignTokens.radius)
|
||||
.strokeBorder(DesignTokens.border, lineWidth: 1),
|
||||
)
|
||||
.onSubmit { send() } // ⌅/fallback submit — send() no-ops on the double fire
|
||||
.onKeyPress(phases: .down) { press in
|
||||
guard press.key == .return else { return .ignored }
|
||||
// Plain Return sends, Shift+Return breaks the line,
|
||||
// every other chord keeps its native newline (⌥↩ above
|
||||
// all). macOS routes Return — ANY modifiers — to the
|
||||
// field's submit action otherwise (Vivarium owner
|
||||
// report 2026-10-26). Caps Lock is masked inside
|
||||
// returnIntent — an exact `==` sent the draft under it.
|
||||
// ponytail: the newline appends at the END, not the
|
||||
// caret — caret-aware insertion needs NSTextView
|
||||
// access; revisit if mid-draft edits ever matter.
|
||||
switch Self.returnIntent(for: press.modifiers) {
|
||||
case .send:
|
||||
send()
|
||||
return .handled
|
||||
case .lineBreak:
|
||||
draft += "\n"
|
||||
return .handled
|
||||
case .passthrough:
|
||||
return .ignored
|
||||
}
|
||||
}
|
||||
sendButton
|
||||
if let debugBinding {
|
||||
debugToggle(debugBinding)
|
||||
// Hover reveal: the view is ABSENT at rest (no hit target,
|
||||
// no focus stop, no a11y node) — the fixed slot keeps Send
|
||||
// from shifting when the pointer enters the row.
|
||||
ZStack {
|
||||
if composerHover {
|
||||
debugToggle(debugBinding)
|
||||
}
|
||||
}
|
||||
.frame(width: 40)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 14)
|
||||
.padding(.top, 12)
|
||||
.padding(.bottom, 10)
|
||||
.padding(.horizontal, 16)
|
||||
// Round-5 (argon#47 tail): symmetric vertical padding — top ==
|
||||
// bottom at 14 (r4's 12/10 read heavier above the divider's
|
||||
// edge than below the input).
|
||||
.padding(.vertical, 14)
|
||||
// One column with the transcript: cap at the measure, center.
|
||||
.frame(maxWidth: measureWidth)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.onHover { composerHover = $0 }
|
||||
.overlay(alignment: .top) {
|
||||
// #23 dogfood: a pass legitimately runs minutes of silent tool
|
||||
// work — without the chip the pane reads as dead. Contract
|
||||
@@ -516,12 +767,40 @@ private extension SessionTranscriptView {
|
||||
.offset(y: -40)
|
||||
}
|
||||
}
|
||||
.disabled(model.phase.isReady == false)
|
||||
// Owner ruling (2026-11-07): the scoped Mentor pane can be ready
|
||||
// with NO hosted session (empty presentation) — the Sessions pane
|
||||
// then shows this surface with nothing active, and the composer
|
||||
// must refuse honestly (disabled), never eat a typed prompt into
|
||||
// a silently-failed sendPrompt.
|
||||
.disabled(!model.phase.isReady || model.activeEntry == nil)
|
||||
}
|
||||
|
||||
/// ONE action button (Vivarium): Send idle / Stop mid-stream. The
|
||||
/// default-action shortcut rides the Send state ONLY — Stop must never
|
||||
/// catch a plain Return.
|
||||
/// Round-1 polish: 36pt to match the input (both edges align,
|
||||
/// argon#33). Round-4 contrast (sol#39/argon#11/mercury#52/56): the
|
||||
/// disabled Send is no longer a 0.75-dimmed accent pill (near-invisible)
|
||||
/// — #6B6964 ink on the #E8E5DF-hinted fill at full opacity, the
|
||||
/// council's disabled language.
|
||||
private var canSend: Bool {
|
||||
model.isStreaming || !draft.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
||||
}
|
||||
|
||||
private var sendFill: Color {
|
||||
if model.isStreaming {
|
||||
return .clear
|
||||
}
|
||||
return canSend ? DesignTokens.accent : DesignTokens.border
|
||||
}
|
||||
|
||||
private var sendInk: Color {
|
||||
if model.isStreaming {
|
||||
return DesignTokens.accent
|
||||
}
|
||||
return canSend ? DesignTokens.surface : DesignTokens.muted
|
||||
}
|
||||
|
||||
private var sendButton: some View {
|
||||
Button {
|
||||
if model.isStreaming {
|
||||
@@ -532,20 +811,20 @@ private extension SessionTranscriptView {
|
||||
} label: {
|
||||
Text(model.isStreaming ? "Stop" : "Send")
|
||||
.font(DesignTokens.ubuntuMono(11))
|
||||
.foregroundStyle(model.isStreaming ? DesignTokens.accent : DesignTokens.surface)
|
||||
.foregroundStyle(sendInk)
|
||||
.padding(.horizontal, 14)
|
||||
.frame(minHeight: 30)
|
||||
.frame(minHeight: 36)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 6)
|
||||
.fill(model.isStreaming ? Color.clear : DesignTokens.accent),
|
||||
.fill(sendFill),
|
||||
)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 6)
|
||||
.strokeBorder(model.isStreaming ? DesignTokens.accent : Color.clear, lineWidth: 1),
|
||||
.strokeBorder(sendStroke, lineWidth: 1),
|
||||
)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.disabled(!model.isStreaming && draft.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
|
||||
.disabled(!canSend)
|
||||
.keyboardShortcut(model.isStreaming ? nil : .defaultAction)
|
||||
.help(
|
||||
model.isStreaming
|
||||
@@ -554,6 +833,18 @@ private extension SessionTranscriptView {
|
||||
)
|
||||
}
|
||||
|
||||
/// Round-5 (sol#36/argon#45): the disabled Send keeps its r4 ink
|
||||
/// treatment and gains the one-step-stronger border — the #D8D4CC-
|
||||
/// equivalent darkening of border #E8E5DF via foreground opacity
|
||||
/// (no new hex), same as the disabled Blind Read. Enabled states
|
||||
/// untouched (Send's fill carries it; Stop keeps its accent outline).
|
||||
private var sendStroke: Color {
|
||||
if model.isStreaming {
|
||||
return DesignTokens.accent
|
||||
}
|
||||
return canSend ? .clear : DesignTokens.foreground.opacity(0.17)
|
||||
}
|
||||
|
||||
/// The liveness chip — a hint, not a control (Stop lives in the Send
|
||||
/// slot). thinMaterial is the contract's translucent-surface+blur
|
||||
/// approximation (#154 deviation note).
|
||||
@@ -561,8 +852,12 @@ private extension SessionTranscriptView {
|
||||
HStack(spacing: 8) {
|
||||
ProgressView().controlSize(.small)
|
||||
Text("Mentor is working — Stop to interrupt.")
|
||||
.font(DesignTokens.ubuntuMono(10))
|
||||
.foregroundStyle(.secondary)
|
||||
// Round-4: 11 — informational micro-labels ride the 11pt
|
||||
// legibility floor (mercury#52).
|
||||
.font(DesignTokens.ubuntuMono(11))
|
||||
// Round-2 sweep: muted at full ink — .secondary broke the
|
||||
// 0.75 contrast floor for informational micro-labels.
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
}
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 5)
|
||||
@@ -570,8 +865,11 @@ private extension SessionTranscriptView {
|
||||
.allowsHitTesting(false)
|
||||
}
|
||||
|
||||
/// Settled #5: the Debug toggle's new seat — mono-10 lowercase text
|
||||
/// toggle at the composer's trailing edge (muted off, accent on).
|
||||
/// Settled #5: the Debug toggle's seat — the composer row's trailing
|
||||
/// edge (Round-1: mono-10 lowercase, muted, riding IN the row after
|
||||
/// Send). Round-2 polish: hover-revealed — the toggle mounts only
|
||||
/// while the pointer is over the composer (see inputBar); muted at
|
||||
/// FULL opacity when off (the 0.65 dim broke the 0.75 floor).
|
||||
private func debugToggle(_ binding: Binding<Bool>) -> some View {
|
||||
Button {
|
||||
binding.wrappedValue.toggle()
|
||||
@@ -579,10 +877,10 @@ private extension SessionTranscriptView {
|
||||
Text("debug")
|
||||
.font(DesignTokens.ubuntuMono(10))
|
||||
.foregroundStyle(binding.wrappedValue ? DesignTokens.accent : DesignTokens.muted)
|
||||
.opacity(binding.wrappedValue ? 1 : 0.65)
|
||||
// Optically centers against the 36pt input at rest.
|
||||
.padding(.bottom, 11)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
.help("Show session updates, tool calls, and engine thinking.")
|
||||
// Audit #155: the checkbox this replaced announced switch state —
|
||||
// a plain Button must say it itself.
|
||||
|
||||
Reference in new issue
Block a user