// // WorkspaceView.swift // Museion // // #17 (S1.1): the workspace shell — nav rail + panes, built from the design // contract's grid geometry (ref/Web-Prototype/museion-workspace.html): // rail 56 | library 232 | editor min 420 | mentor 356. // #108: the Archive rail destination (box icon, above Settings) + the // New Project ask both live here. // import SwiftUI /// The post-gate main surface. Posts shows the full four-column workspace; /// Sessions/Learnings/Settings fill the space after the rail until their /// tickets land (#28/#26; Settings is real here). struct WorkspaceView: View { @Environment(AppGateState.self) private var gate @State private var selection: Pane = .posts /// #151: the fail card's expansion — auto-expands on each failure /// arrival (`.onChange` of the visibility); chevron collapses, slot /// click re-opens. @State private var statusCardExpanded = false enum Pane: Hashable { case posts case sessions case learnings /// #32 (S5.2): the trend view — the writer's arc across unaided /// first-draft captures, sibling of Learnings (measurement beside /// memory). case trends /// #108: the archive rail destination — archive/ as a first-class /// pane (prototype variant B/C verdict: a destination, not a /// library disclosure). case archive case settings } var body: some View { GeometryReader { geo in Group { if gate.isFocused { // #21: the rail recedes; the pane takes the full width. The // measure stays centered — revealed panes float, never push. paneContent(geo) } else { HStack(spacing: 0) { navRail paneBorder paneContent(geo) } } } // #91: drag a markdown file onto the window — same guest slot as // File ▸ Open… Non-markdown drops are refused. .dropDestination(for: URL.self) { urls, _ in // #162: no new buffers while a Cold Turkey block holds — // the open Piece is the one being counted. guard !gate.writingLock.isLocked else { return false } // #141: the window destination is the only one that ever // fires (field-verified 2026-11-02 — nested editor-level // SwiftUI targets are never consulted, and AppKit views // registered for file drags are starved by it). // PURE-markdown sets keep #91's open-as-guest; a mixed // md+image set falls through and ingestDrop refuses it // loudly (images must not vanish silently behind the md). // Nil text view: bounce. if urls.allSatisfy(PostStore.isMarkdown), let url = urls.first { gate.posts.openExternal(url) selection = .posts return true } guard let textView = gate.proseDrop.textView else { return false } return textView.ingestDrop(urls) } // #21: left-edge hover slides rail+library back in as an overlay. // Library only while the window width allows it (#17 verdict stands: // a collapsed pane is not summoned by focus). // #162: suppressed while a Cold Turkey block holds — the library // stays hidden and the open Piece stable for counting (#158). .overlay { if gate.isFocused, !gate.writingLock.isLocked { // #17 verdict: the library reveal honors the width collapse. let showsLibrary = geo.size.width >= 1100 FocusOverlayPanel(edge: .leading, panelWidth: leftRevealWidth(showsLibrary)) { HStack(spacing: 0) { navRail paneBorder if showsLibrary { PostsLibraryColumn(home: gate.museionHome, model: gate.posts) } } } } } // #151: the anchored fail card — floats over content, never // blocks, never pushes layout (bottom-leading at railWidth + 12, // bottom 14 — #149's geometry). Fail auto-expands; chevron // collapses; slot click re-opens. Focus mode recesses the card // with the rail (chrome recedes for deep work; the pill stays // hover-reachable, and exiting focus restores the card — the // expanded state survives). .overlay(alignment: .bottomLeading) { if statusVisibility == .failed, statusCardExpanded, !gate.isFocused { EngineStatusCard(gate: gate) { statusCardExpanded = false } .padding(.leading, DesignTokens.railWidth + 12) .padding(.bottom, 14) .transition(.opacity.combined(with: .move(edge: .bottom))) } } .animation(.spring(duration: 0.3), value: statusVisibility) .background(DesignTokens.background) // #94: the ONE Origin ask per import batch. Dismissal without an // answer (Esc/Cancel) drops the batch. .sheet(isPresented: originAskBinding) { OriginAskSheet(count: gate.posts.pendingImportURLs?.count ?? 0) { origin in gate.posts.importFiles(origin: origin) } } // #108: File ▸ New Project… ask — commands can't present sheets, so // the model stages and this window presents (OriginAsk pattern). .sheet(isPresented: newProjectAskBinding) { NewProjectSheet { name in if let reason = gate.posts.createProject(named: name) { return reason } gate.posts.newProjectPending(named: name) return nil } } // #111 (S7): the mixed-content outline guard ask — presents over an // empty editor (select held the open; nothing can edit while it's // up). Prose = safe open; Outline = explicit consent to the save // drop; Esc/Cancel backs out with nothing opened. .sheet(isPresented: outlineGuardBinding) { OutlineGuardSheet { gate.posts.openGuardedOutlineInProse() } openAsOutline: { gate.posts.openGuardedOutlineAsOutline() } } // #114 (S4): the Convert to Post ask — which body the outline // piece becomes (verbatim bullets vs headings ladder). Verbatim // is the default: lossless. Esc/Cancel converts nothing. .sheet(isPresented: convertAskBinding) { ConvertSheet(lossy: gate.posts.pendingConversion?.lossy ?? false) { headingsLadder in gate.posts.convertToPost(headingsLadder: headingsLadder) } } } // #179 follow-up: the model bind rides the ROOT task — the Archive // pane and every root sheet (import / new project / convert) call // library verbs from any pane; a pane-local bind left `watchedHome` // stale after a Home repoint until Posts remounted. .task(id: gate.museionHome) { gate.posts.bind(home: gate.museionHome) } // Collapsed floor: rail 56 + editor placeholder (export ≤920 layout). .frame(minWidth: 480, minHeight: 320) // #151: every failure arrival auto-expands the card — a fresh // engine fail, a provisioning fail landing, a Re-check that fails // again. Collapse is the reader's call (chevron), re-open the // slot's. .onChange(of: statusVisibility) { _, newValue in if newValue == .failed { statusCardExpanded = true } } // #92/#94: the editor column lives in Posts — a guest buffer or an // import's opened post surfaces there, whatever pane was showing. .onChange(of: gate.posts.externalSession != nil) { _, isUp in if isUp { selection = .posts } } // #108 audit: ⌘N/New Project open a DRAFT — session is nil, so the // selectedPostID onChange below can't hop. Hop on the draft itself. .onChange(of: gate.posts.draft != nil) { _, isDraft in if isDraft { selection = .posts } } .onChange(of: gate.posts.selectedPostID) { _, _ in if gate.posts.session != nil { selection = .posts } } // #162 audit: View ▸ Start Cold Turkey… can fire while another // pane is up (the rail is hover-reachable in focus) — the bar // would pop stale on the next Posts mount. Any pane change // drops a pending arm-bar. .onChange(of: selection) { _, _ in gate.writingLock.showsArmBar = false } } /// #94: the ask presents while a batch is staged. private var originAskBinding: Binding { Binding( get: { gate.posts.pendingImportURLs != nil }, set: { if !$0 { gate.posts.cancelImport() } }, ) } /// #108: the New Project ask presents while staged. private var newProjectAskBinding: Binding { Binding( get: { gate.posts.askNewProject }, set: { if !$0 { gate.posts.cancelNewProject() } }, ) } /// #111 (S7): the outline guard ask presents while an open is held. private var outlineGuardBinding: Binding { Binding( get: { gate.posts.outlineGuardPieceID != nil }, set: { if !$0 { gate.posts.cancelOutlineGuard() } }, ) } /// #114 (S4): the Convert to Post ask — dismissal is the cancel. private var convertAskBinding: Binding { Binding( get: { gate.posts.pendingConversion != nil }, set: { if !$0 { gate.posts.cancelConversion() } }, ) } /// #151: the pill/card state — the gate's phase machine plus the /// provisioning failure verdict. private var statusVisibility: EngineStatusSurface.Visibility { EngineStatusSurface.visibility( phase: gate.gateModel.phase, provisioningFailed: gate.provisioning.hasFailure, ) } @ViewBuilder private func paneContent(_ geo: GeometryProxy) -> some View { @Bindable var gate = gate switch selection { case .posts: // #14: mentor column hands in the app-scoped model + gate's winner. // Column collapse mirrors the export's media queries (library ≤1100, // mentor ≤920) as macOS pane collapse per the PRD. PostsPaneView( home: gate.museionHome, mentor: gate.mentor, mentorBinaryPath: gate.gateModel.currentBinaryPath, model: gate.posts, availableWidth: geo.size.width - DesignTokens.railWidth, // #137: the pass bar's missing-key way out (ArchivePaneView // closure precedent). onOpenSettings: { selection = .settings }, ) case .sessions: // #28: the Sessions pane — roster + active transcript over the // app-scoped mentor model, the same reach as Learnings' home. SessionsPaneView( model: gate.mentor, posts: gate.posts, binaryPath: gate.gateModel.currentBinaryPath, home: gate.museionHome, gate: gate, ) case .learnings: // #26: list-only pane over /learnings/ — read side; // promoting a fix card (the fix-card rail) writes the files. LearningsPaneView(home: gate.museionHome) case .trends: // #32 (S5.2): the arc — rides PostsModel's watched scan, so // the pane refreshes with the library, no scan of its own. TrendsPaneView(model: gate.posts) case .archive: // #108: list-only pane — clicking a row selects the piece and // hops to Posts where its editor lives. ArchivePaneView(model: gate.posts) { selection = .posts } case .settings: // #137 (S4): a committed Chat model change restarts the resident // chat engine in place (slice A's engine-side API; deferred to // turn end while streaming). SettingsPaneView( home: $gate.museionHome, binaryPath: gate.gateModel.currentBinaryPath, onChatSurfaceWrite: { gate.mentor.requestRestart() }, ) } } /// The left reveal panel's width: rail + border (+ library when the /// unfocused width verdict grants it). private func leftRevealWidth(_ showsLibrary: Bool) -> CGFloat { DesignTokens.railWidth + 1 + (showsLibrary ? DesignTokens.libraryWidth : 0) } /// 1px contract border between rail and pane (`.rail { border-right }`). private var paneBorder: some View { Rectangle() .fill(DesignTokens.border) .frame(width: 1) } // MARK: Nav rail private var navRail: some View { VStack(spacing: 8) { RailButton(pane: .posts, selection: $selection, label: "Posts", systemImage: "doc.text") RailButton(pane: .sessions, selection: $selection, label: "Sessions", systemImage: "bubble.left") RailButton(pane: .learnings, selection: $selection, label: "Learnings", systemImage: "cube", weight: .light) // #32: Trends after Learnings — measurement beside memory. RailButton(pane: .trends, selection: $selection, label: "Trends", systemImage: "chart.xyaxis.line") Spacer() // #151: the engine-status slot above Archive (#149 variant A) — // quiet-when-healthy: nothing renders once the engine answered // and provisioning finished; the slot collapses and the rail // spacing closes. if statusVisibility != .hidden { EngineStatusPill(visibility: statusVisibility) { if statusVisibility == .failed { statusCardExpanded = true } } } // #108: Archive at the rail bottom, above Settings (prototype's // box icon). RailButton(pane: .archive, selection: $selection, label: "Archive", systemImage: "archivebox") RailButton(pane: .settings, selection: $selection, label: "Settings", systemImage: "gearshape", weight: .light) } .padding(.horizontal, 4) .padding(.vertical, 8) .frame(width: DesignTokens.railWidth) .frame(maxHeight: .infinity) .animation(.easeInOut(duration: 0.2), value: statusVisibility) } } /// #108: the Archive pane — archive/ as a rail destination (prototype /// verdict: a destination, not a library disclosure). List-only: clicking a /// piece selects it and hops to Posts, where the editor column lives. private struct ArchivePaneView: View { var model: PostsModel /// Fired after a row select — the pane can't reach WorkspaceView's /// selection itself. let onOpenPiece: () -> Void @State private var renamingPost: Post? /// #108: collapsed project sections — per-view state, not persisted /// (mirrors the library column). @State private var collapsed: Set = [] private var archivedByProject: [String: [Post]] { Dictionary(grouping: model.posts.filter(\.isArchived), by: \.project) } /// #108: the prototype's toggle — click the project name (or chevron). private func toggle(_ project: String) { if collapsed.contains(project) { collapsed.remove(project) } else { collapsed.insert(project) } } var body: some View { VStack(spacing: 0) { // No New button — things arrive here by being moved, not created. // r8 (argon#9, mercury#18/19): the hairline is bounded to the SAME // fixed 720pt column the rows live in — one framed block. PaneHeader(title: "Archive", hairlineMaxWidth: 720) if archivedByProject.isEmpty { emptyState } else { ScrollView { LazyVStack(alignment: .leading, spacing: 4) { // #108 audit: Finder order, matching the library's sort. ForEach(archivedByProject.keys.sorted { $0.localizedStandardCompare($1) == .orderedAscending }, id: \.self) { project in let pieces = archivedByProject[project] ?? [] // Same section-head shape as the library (#108 // variant B), plus the project-level way out. // r7 (mercury#55, argon#41 — FINAL, supersedes the // r6 D24 ladder): the content column is a FIXED // 720pt frame (width, not maxWidth — the r6 // content-hugging bound let the pill define the // right edge), left-anchored. TWO axes only, the // library's r7 ladder: the head row leads at x14 // (chevron in a 14pt slot) with its label at x28 — // the ONE indent, shared with the entry rows' // inner text via the shared LibraryPostRow (cards // lead at x14); the 'Unarchive Group' pill rides // the header row's trailing edge INSIDE the frame // (14 → 706), and the row hairlines are bounded by // the same frame. Nothing spans past it. HStack(alignment: .firstTextBaseline, spacing: 0) { Image(systemName: "chevron.down") .font(.system(size: 10, weight: .semibold)) .frame(width: 14, alignment: .leading) .rotationEffect(.degrees(collapsed.contains(project) ? -90 : 0)) .foregroundStyle(DesignTokens.muted) .onTapGesture { withAnimation { toggle(project) } } .accessibilityLabel("Toggle \(project)") .accessibilityHint(collapsed.contains(project) ? "Collapsed" : "Expanded") Text(project) .font(.system(size: 11, weight: .medium, design: DesignTokens.mono)) .kerning(0.6) .textCase(.uppercase) // #108: display-only — the folder name keeps its case .foregroundStyle(DesignTokens.muted) // r6: full ink — contrast final .lineLimit(1) .truncationMode(.tail) .onTapGesture { withAnimation { toggle(project) } } Text("· \(pieces.count)") .font(.system(size: 11, design: DesignTokens.mono)) .foregroundStyle(DesignTokens.muted) .padding(.leading, 8) Spacer(minLength: 8) // The 'New Post · Fork · Compact' language — a // bordered mono-11 secondary pill at the // trailing edge INSIDE the fixed 720pt frame. // r7 (mercury#55, argon#41): relabeled // 'Unarchive Group' — it moves the whole // project, not one piece. Button("Unarchive Group") { model.unarchiveProject(project) } .buttonStyle(BorderedSecondaryButtonStyle(minHeight: 24)) .help("Move the whole project back to projects/") .accessibilityLabel("Unarchive \(project)") } .padding(.top, 12) .padding(.horizontal, 14) .padding(.bottom, 2) if !collapsed.contains(project) { ForEach(pieces) { post in // r7: the shared LibraryPostRow ladder — // card leads at x14 (PRIMARY), title text // at x28 (the one indent). The hairline is // BOUNDED to the fixed frame: x14 → 706. LibraryPostRow(post: post, selected: post.id == model.selectedPostID) { model.select(post.id) onOpenPiece() } .overlay(alignment: .bottom) { Rectangle() .fill(DesignTokens.border) .frame(height: 1) .padding(.horizontal, 14) } .contextMenu { Button("Move Back to \(post.project)") { model.restorePost(post) } Button("Rename…") { renamingPost = post } // #114 (S4): works archived too — the piece // stays where it is, only type + body flip. if post.type == .outline { Button("Convert to Post…") { model.stageConversion(post) } } } } } } } // r7 (mercury#55, argon#41): the FIXED 720pt reading // column — width, not maxWidth (the r6 content-hugging // bound let the pill define the right edge); rows, // hairlines, and the pill all live inside it. // ponytail: fixed width clips on panes narrower than // 720 — a width-floored variant if a small-window // Archive ever matters. .frame(width: 720, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading) .padding(.bottom, 12) } } } .frame(maxWidth: .infinity, maxHeight: .infinity) .background(DesignTokens.background) .sheet(item: $renamingPost) { post in RenamePostSheet(post: post) { title in model.rename(post, to: title) } } } private var emptyState: some View { VStack(spacing: 8) { Text("Nothing archived") .font(.system(size: 16, weight: .semibold, design: DesignTokens.serif)) Text("Finished projects and pieces fold away here. Move things here from their context menu; they stay openable and editable.") .font(.callout) .foregroundStyle(DesignTokens.muted) .multilineTextAlignment(.center) } .padding(38) .frame(maxWidth: .infinity, maxHeight: .infinity) } } /// #94: the ONE Origin ask per import batch — writer (default) / ai, with the /// immutability line (CONTEXT.md: Origin). Answering runs the batch. private struct OriginAskSheet: View { let count: Int let answer: (Post.Origin) -> Void @Environment(\.dismiss) private var dismiss @State private var origin: Post.Origin = .writer var body: some View { VStack(alignment: .leading, spacing: 12) { Text("Who wrote this?") .font(.system(size: 15, weight: .semibold, design: DesignTokens.serif)) Text(count == 1 ? "Importing 1 file as a Post — the original is untouched." : "Importing \(count) files as Posts — the originals are untouched.") .font(.callout) .foregroundStyle(DesignTokens.muted) Picker("Origin", selection: $origin) { Text("I wrote it (writer)").tag(Post.Origin.writer) Text("AI-assisted (ai)").tag(Post.Origin.ai) } .pickerStyle(.radioGroup) Text("Origin is stamped once and never asked again — it decides whether the draft's stats can measure you.") .font(.caption) .foregroundStyle(DesignTokens.muted) HStack { Spacer() Button("Cancel", role: .cancel) { dismiss() } .keyboardShortcut(.cancelAction) Button("Import") { answer(origin) dismiss() } .keyboardShortcut(.defaultAction) } } .padding(20) .frame(width: 380) } } /// #111 (S7): the mixed-content outline guard ask. The piece has prose /// lines the outliner can't show — opening it as an outline would drop /// them on the next save. Prose = nothing drops; Outline = the explicit /// choice the ruling requires. private struct OutlineGuardSheet: View { let openInProse: () -> Void let openAsOutline: () -> Void var body: some View { VStack(alignment: .leading, spacing: 12) { Text("Open as outline or prose?") .font(.system(size: 15, weight: .semibold, design: DesignTokens.serif)) Text( "This outline has paragraph lines between its bullets. The outliner can't show them — opening as an outline " + "drops them on the next save. Prose mode shows everything.", ) .font(.callout) .foregroundStyle(DesignTokens.muted) Text("Outline mode keeps its bullets, indentation, and folding. You can convert or clean up later.") .font(.callout) .foregroundStyle(DesignTokens.muted) HStack { Spacer() // Dismissal itself is the cancel (binding set(false) → // cancelOutlineGuard) — Esc and ⌘. land here too. Button("Cancel", role: .cancel) {} .keyboardShortcut(.cancelAction) Button("Open as Outline") { openAsOutline() } Button("Open in Prose") { openInProse() } .keyboardShortcut(.defaultAction) } } .padding(20) .frame(width: 420) } } /// #114 (S4): the Convert to Post ask — which body the piece becomes. /// Verbatim (default) keeps every line; the ladder re-maps outline levels /// to headings. On mixed content the ladder would drop prose lines — /// the sheet says so. private struct ConvertSheet: View { let lossy: Bool /// false = verbatim bullets, true = headings ladder — one decision, /// one model call. let convert: (Bool) -> Void var body: some View { VStack(alignment: .leading, spacing: 12) { Text("Convert to Post") .font(.system(size: 15, weight: .semibold, design: DesignTokens.serif)) Text("The piece keeps its name, project, and Pass State — it becomes a prose post. How should the outline body read?") .font(.callout) .foregroundStyle(DesignTokens.muted) if lossy { Text("This outline has paragraph lines between its bullets. The headings ladder drops them; verbatim keeps every line.") .font(.callout) .foregroundStyle(DesignTokens.muted) } Text("Verbatim keeps the bullets as they are; Headings turns top-level blocks into section headings, deeper levels step down.") .font(.callout) .foregroundStyle(DesignTokens.muted) HStack { Spacer() // Dismissal itself is the cancel (binding set(false) → // cancelConversion) — Esc and ⌘. land here too. Button("Cancel", role: .cancel) {} .keyboardShortcut(.cancelAction) Button("Headings") { convert(true) } Button("Verbatim Bullets") { convert(false) } .keyboardShortcut(.defaultAction) } } .padding(20) .frame(width: 440) } } /// #108: New Project ask — the sheet behind File ▸ New Project… (and any /// future materialize path). Create runs through the model's raw op; the /// thrown reason is shown inline and the sheet stays up. private struct NewProjectSheet: View { /// Create + open a draft in it; nil = success, a string = the failure /// reason to show inline (keeps the sheet up). let create: (String) -> String? @Environment(\.dismiss) private var dismiss @State private var name = "" @State private var failure: String? var body: some View { VStack(alignment: .leading, spacing: 12) { Text("New Project") .font(.system(size: 15, weight: .semibold, design: DesignTokens.serif)) Text("Pieces land here when it's selected.") .font(.callout) .foregroundStyle(DesignTokens.muted) TextField("Name", text: $name) .textFieldStyle(.roundedBorder) .onSubmit { confirm() } if let failure { Text(failure) .font(.system(size: 11, design: DesignTokens.mono)) .foregroundStyle(DesignTokens.accent) } HStack { Spacer() Button("Cancel", role: .cancel) { dismiss() } .keyboardShortcut(.cancelAction) Button("Create", action: confirm) .keyboardShortcut(.defaultAction) .disabled(name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty) } } .padding(20) .frame(width: 360) } private func confirm() { let trimmed = name.trimmingCharacters(in: .whitespacesAndNewlines) guard !trimmed.isEmpty else { return } if let reason = create(trimmed) { failure = reason } else { dismiss() } } } /// Rail button: 44×44 muted icon, hover wash, the current pane raised as /// a tile. NO visible edge bar — ui-polish r2 re-ruling: the export's /// `::before` selection bar paints behind the app border in the export's /// own render, so a visible bar reads as a stray clipped mark; /// contract-faithful is tile + border + fg-ink icon alone. /// r5 (sol#40, mercury#54/56 — one final strength step, modest): the /// selected tile's fill steps from surface (invisible on the chrome /// background) to a 0.08 foreground wash with a muted-0.4 hairline — the /// fg-ink glyph reads stronger against it. Icon weight stays constant /// (sol#45: selection emphasis comes from the tile, never the glyph). private struct RailButton: View { let pane: WorkspaceView.Pane @Binding var selection: WorkspaceView.Pane let label: String let systemImage: String /// sol#45: one explicit size for all six icons; glyph-dense ones (cube, /// gearshape) opt down a weight so every icon reads the same apparent /// mass — selection emphasis comes from the tile, never icon weight. var weight: Font.Weight = .regular /// r7 (sol#33): the selected glyph's ONE step up (light→regular, /// regular→medium) — full-ink color on thin strokes still read /// near-muted; the step puts the current pane's icon at true ink. private var selectedWeight: Font.Weight { switch weight { case .light: .regular default: .medium } } @State private var hover = false var body: some View { let selected = selection == pane Button { selection = pane } label: { Image(systemName: systemImage) // r7 (sol#33): the selected glyph steps ONE weight up — // full ink on a thin-stroke symbol at .light/.regular // reads near-muted against the 0.08 wash. Unselected // icons keep their sol#45 mass exactly. .font(.system(size: 16, weight: selected ? selectedWeight : weight)) .frame(width: 44, height: 44) } .buttonStyle(.plain) .foregroundStyle(selected ? DesignTokens.foreground : DesignTokens.muted) .background { if selected || hover { RoundedRectangle(cornerRadius: DesignTokens.radius) // r5 (sol#40, mercury#54/56): selected = a 0.08 // foreground wash + muted-0.4 hairline (surface-on- // chrome was invisible); hover keeps the 0.06 wash, // borderless. Modest — the hierarchy holds. .fill(selected ? DesignTokens.foreground.opacity(0.08) : DesignTokens.foreground.opacity(0.06)) .overlay( RoundedRectangle(cornerRadius: DesignTokens.radius) .strokeBorder(selected ? DesignTokens.muted.opacity(0.4) : .clear), ) } } .onHover { hover = $0 } .help(label) .accessibilityLabel(label) } } /// r6 (mercury#49/52, argon#13): the shared selected-row strip — a 2pt /// accent capsule with radius-1 rounded ends, vertically inset 6pt from /// the row's edges so it sits INSIDE the card/fill (Posts library rows, /// Settings sidebar rows). Callers toggle it via opacity so the 2pt /// reservation keeps layout constant. struct SelectedRowStrip: View { var body: some View { RoundedRectangle(cornerRadius: 1) .fill(DesignTokens.accent) .frame(width: 2) .padding(.vertical, 6) } } /// ui-polish r2: the app's bordered secondary button — mono-11 ink on a /// surface fill with a #E8E5DF hairline (Archive's Unarchive, Settings' /// Choose…). 36pt tall by default — a real hit target, not a text-size /// pill; pass a smaller `minHeight` where the row is compact. struct BorderedSecondaryButtonStyle: ButtonStyle { var minHeight: CGFloat = 36 func makeBody(configuration: Configuration) -> some View { configuration.label .font(.system(size: 11, design: DesignTokens.mono)) .foregroundStyle(DesignTokens.foreground) .padding(.horizontal, 12) .frame(minHeight: minHeight) .background( RoundedRectangle(cornerRadius: 8) .fill(DesignTokens.surface) .overlay( RoundedRectangle(cornerRadius: 8) .strokeBorder(DesignTokens.border), ), ) .opacity(configuration.isPressed ? 0.7 : 1) } } /// Pane-head row per the export (52pt, serif 15 semibold title, bottom border). /// Trailing slot carries #18's New Post button (export `.pane-head .icon-btn`). struct PaneHeader: View { let title: String /// Leading inset of the title row. Export default 14; the Learnings pane /// passes 26 so its title shares one leading edge with headings + rows. var titleInset: CGFloat = 14 /// r8 (argon#9, mercury#18/19 — convergent): when set, the bottom /// hairline is bounded to the same column the pane's content sits in /// (Archive/Learnings' 720pt reading column) — title, hairline, and /// content read as one framed block instead of a full-width rule over /// a bounded column. nil = full width (every other pane's default). var hairlineMaxWidth: CGFloat? @ViewBuilder var trailing: () -> Trailing init( title: String, titleInset: CGFloat = 14, hairlineMaxWidth: CGFloat? = nil, @ViewBuilder trailing: @escaping () -> Trailing = { EmptyView() }, ) { self.title = title self.titleInset = titleInset self.hairlineMaxWidth = hairlineMaxWidth self.trailing = trailing } var body: some View { VStack(spacing: 0) { HStack { Text(title) .font(.system(size: 15, weight: .semibold, design: DesignTokens.serif)) Spacer() trailing() } .padding(.horizontal, titleInset) .frame(minHeight: 52) Rectangle() .fill(DesignTokens.border) .frame(height: 1) // r8: the bound shares the content column's leading edge // (x0) and width — leading-aligned, never centered. .frame(maxWidth: hairlineMaxWidth ?? .infinity, alignment: .leading) } } }