feat(ui): design-council polish overhaul
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:
AlexKucera committed 2026-11-07 20:41:34 +01:00
1 parent b2db859887
commit 3a7d495b4b
21 files changed
+2287 -516

No files matched your search

+53 -7
View File
@@ -239,9 +239,20 @@ struct PostEditorView: View {
// MARK: Toolbar
private var toolbar: some View {
HStack {
// #ui-r6 (mercury#51): one 10pt rhythm across the fixed pairs —
// Read→crumb read ~7 (default stack spacing) against Publish→
// Saved's ~18 (spacing + the old trailing padding); the spacer
// stays the only flexible gap.
HStack(spacing: 10) {
// #68: labeled toggle, far left, before the crumb.
// #ui-r5 (mercury#22): same geometry family as Publish —
// BorderedSecondaryButtonStyle(28): one height (28) and one
// corner radius (8) across the editor toolbar; content is the
// only difference. (Run Pass lives in MentorPaneView —
// cross-file, intentionally untouched; its 28pt height now
// matches, its accent fill marks the primary action.)
Button(reading ? "Edit" : "Read") { toggleReading() }
.buttonStyle(BorderedSecondaryButtonStyle(minHeight: 28))
.help(reading ? "Return to editing (⌘R)" : "Render this post (⌘R)")
Text(crumb)
.font(.system(size: 11, design: DesignTokens.mono))
@@ -251,12 +262,13 @@ struct PostEditorView: View {
Spacer()
// #33 (S6.1): the publish entry — draft first, then publish.
if let publish {
// #ui-r4 (argon#46): the bordered mono-11 pill — the action
// reads distinct from the passive "Saved" status beside it.
// #ui-r6: no trailing padding — the stack's 10pt spacing is
// the whole Publish→Saved gap (was 10+8 ≈ 18).
Button("Publish") { publish() }
.buttonStyle(.plain)
.font(.system(size: 11, design: DesignTokens.mono))
.foregroundStyle(DesignTokens.muted)
.buttonStyle(BorderedSecondaryButtonStyle(minHeight: 28))
.help("Send to Micro.blog — draft first, then publish")
.padding(.trailing, 10)
}
if let session {
SaveStateDot(state: session.saveState)
@@ -404,6 +416,27 @@ struct ProseTextView: NSViewRepresentable {
return state
}
/// #ui-r1 (sol#14/argon#28): a document may open with leading blank
/// lines (Post.scan's title rule skips them) — a programmatic caret at
/// location 0 then rests inside the invisible 9pt blank fragment ABOVE
/// the title, rendering as a detached terracotta stroke at the canvas
/// top. Programmatic landings (cursor restore, reading flip-back) hop
/// over leading blanks to the first content line; interactive
/// placements (click, drag, typing) never route through here.
static func caretPastLeadingBlanks(_ location: Int, in text: String) -> Int {
let buffer = text as NSString
var lineStart = 0
while lineStart < buffer.length {
let line = buffer.lineRange(for: NSRange(location: lineStart, length: 0))
let lineText = buffer.substring(with: line)
if !lineText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
return location < line.location ? line.location : location
}
lineStart = NSMaxRange(line)
}
return location
}
func makeNSView(context: Context) -> NSScrollView {
let tv = ProseListTextView() // #115: list shortcuts + folds on the plain surface
tv.ingestFolder = ingestFolder // #141: image-drop ingest (nil on drafts/guests)
@@ -435,7 +468,13 @@ struct ProseTextView: NSViewRepresentable {
tv.textContainer?.containerSize = NSSize(width: 0, height: CGFloat.greatestFiniteMagnitude)
tv.textContainer?.widthTracksTextView = true
tv.textContainer?.lineFragmentPadding = 24
tv.textContainerInset = NSSize(width: 0, height: 20)
// #ui-r2 (sol#10/argon#19): top padding so the title anchors the
// page instead of floating against the chrome (r1: 20, r2: 40;
// #ui-r4 mercury#24: 46 — ~6pt more clearance from the toolbar
// hairline). The typewriter inset machinery overwrites this on
// its own syncs — that stays untouched; this is the open-state
// anchor.
tv.textContainerInset = NSSize(width: 0, height: 46)
let scroll = NSScrollView()
scroll.documentView = tv
scroll.hasVerticalScroller = true
@@ -482,6 +521,11 @@ struct ProseTextView: NSViewRepresentable {
var cursor = session.restoreCursor ?? PostStore.CursorState()
cursor.selectionLocation = min(max(0, cursor.selectionLocation), length)
cursor.selectionLength = min(max(0, cursor.selectionLength), length - cursor.selectionLocation)
// #ui-r1: a caret restored into leading blanks renders as the
// detached stroke above the title — hop to the first content line.
if cursor.selectionLength == 0 {
cursor.selectionLocation = Self.caretPastLeadingBlanks(cursor.selectionLocation, in: tv.string)
}
tv.setSelectedRange(NSRange(location: cursor.selectionLocation, length: cursor.selectionLength))
// ponytail: TextKit lays out async — a sync scroll on a fresh mount
// lands short of the target (clamps to what's laid out). One runloop
@@ -502,7 +546,9 @@ struct ProseTextView: NSViewRepresentable {
if let hint = caretHint, context.coordinator.appliedCaretToken != hint.token {
context.coordinator.appliedCaretToken = hint.token
let length = (tv.string as NSString).length
let loc = min(max(0, hint.location), length)
// #ui-r1: same leading-blank hop as the load restore — a reading
// flip-back must never park the caret above the first content line.
let loc = min(Self.caretPastLeadingBlanks(max(0, hint.location), in: tv.string), length)
tv.setSelectedRange(NSRange(location: loc, length: 0))
// ponytail: same layout race as the cursor-restore scroll above —
// this was the click-to-edit "always lands at top" defect: the sync