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

+68 -4
View File
@@ -118,12 +118,20 @@ nonisolated enum ProsePresenter {
if range.location > 0, out.string.contains("```") || out.string.contains("~~~") {
inFence = fenceState(nsText, upTo: range.location)
}
// Title detection (#ui-r1): the title is the document's FIRST
// non-blank line (Post.scan's rule — blank lines above it are
// skipped, so paragraph edits anchor past 0 and a location-0 test
// would miss them). Absolute position match: whichever range is
// styled, the line sitting at the title location takes the title
// step; lines outside the range keep what the full pass gave them.
let titleLocation = firstContentLocation(nsText)
for line in contentLines(nsText, in: range) {
let kind = classify(line.text, inFence: inFence)
if kind == .fence {
inFence.toggle()
}
styleLine(out, line: line, kind: kind)
let isTitle = titleLocation == line.content.location && kind == .body
styleLine(out, line: line, kind: kind, isTitle: isTitle)
}
}
@@ -171,9 +179,9 @@ nonisolated enum ProsePresenter {
return inFence
}
private static func styleLine(_ out: NSMutableAttributedString, line: Line, kind: LineKind) {
private static func styleLine(_ out: NSMutableAttributedString, line: Line, kind: LineKind, isTitle: Bool = false) {
guard line.full.length > 0 else { return }
out.setAttributes(attributes(for: kind), range: line.full)
out.setAttributes(isTitle ? ProseTypography.titleAttributes : attributes(for: kind), range: line.full)
let dim = ProseTypography.codeAttributes // codeFont + syntaxColor
switch kind {
case .heading1, .heading2, .heading3, .heading4Plus:
@@ -189,7 +197,31 @@ nonisolated enum ProsePresenter {
}
case .listMarker:
if let marker = markerRangeUTF16(listMarkerPattern, in: line.text), marker.length > 0 {
out.addAttributes(dim, range: shifted(marker, into: line.content))
out.addAttributes(ProseTypography.listMarkerAttributes, range: shifted(marker, into: line.content))
// Hanging indent (#ui-r1, sol#13; #ui-r2 argon#53 flush
// fix): wrapped list lines align with the item's text, not
// the paragraph margin — the marker prefix (leading
// whitespace + "- "/"1. ") sets headIndent, mirroring
// reading.css's hanging lists (padding-left + outside
// markers). Nested items hang at their own prefix width.
// The prefix is measured in the EXACT attributes it
// renders in (listMarkerAttributes — the line's face and
// size), so the continuation lands flush; a different
// measuring face drifts per-glyph (~4pt left in r1).
// ponytail: a tab in the prefix measures at the default tab
// stop; the corpus uses spaces — widen if tabbed lists drift.
let prefix = String(line.text.prefix(NSMaxRange(marker)))
let indent = NSAttributedString(
string: prefix,
attributes: ProseTypography.listMarkerAttributes,
).size().width
let hanging = NSMutableParagraphStyle()
hanging.setParagraphStyle(paragraph(.body))
hanging.headIndent = indent
// #ui-r7 sol#29: inter-item rhythm (reading.css list margins)
// — before-space only, the CSS block has no bottom margin.
hanging.paragraphSpacingBefore = ProseTypography.listSpacingBefore
out.addAttribute(.paragraphStyle, value: hanging, range: line.full)
}
case .syntaxOnly:
if line.content.length > 0 {
@@ -442,3 +474,35 @@ nonisolated extension Range<String.Index> {
return lo ..< hi
}
}
// MARK: - Title detection (#ui-r1 — file scope: the enum body sits at its ceiling)
nonisolated extension ProsePresenter {
/// UTF-16 start of the first non-blank line, or nil when the whole
/// buffer is blank. Walks only the leading blank lines. Post.scan
/// skips leading blanks to find the title; the editor styles the same
/// line the library shows.
static func firstContentLocation(_ nsText: NSString) -> Int? {
var lineStart = 0
while lineStart < nsText.length {
let line = nsText.lineRange(for: NSRange(location: lineStart, length: 0))
var len = line.length
while len > 0 {
let char = nsText.character(at: line.location + len - 1)
if char == 0x0A || char == 0x0D {
len -= 1
} else {
break
}
}
if len > 0 {
let text = nsText.substring(with: NSRange(location: line.location, length: len))
if !text.trimmingCharacters(in: .whitespaces).isEmpty {
return line.location
}
}
lineStart = NSMaxRange(line)
}
return nil
}
}