refactor(workspace): split WorkspaceView into ArchivePaneView/Sheets/Chrome (#193)
This commit is contained in:
1 parent
902e860bd8
commit
70cd1c2b55
5 files changed
+468
-430
No files matched your search
+4
-1
@@ -23,7 +23,10 @@ Owned by the root AGENTS.md contract. The `.xcodeproj` uses **filesystem-synchro
|
||||
The map and the contracts, one bullet per file. Pin-level detail lives in the test files' scenario headers (see MuseionTests/AGENTS.md); devlog narratives in `docs/devlog/`.
|
||||
|
||||
- `DesignTokens.swift` — palette/geometry. Two-color world, live-calibrated (deliberate departure from the export palette): `background` #FAF9F3 (chrome + focus ground), `surface` #FFFEFB (one page color for edit AND read); light-only, the single semantic exception `readyGreen` (the mentor ready dot — a meaning, never a style color). Radius 10; column widths rail 56 / library 232 / mentor 356; chat face constructors `valkyrie`/`concourse`/`ubuntuMono` (Font.custom falls back to system).
|
||||
- `WorkspaceView.swift` — first-frame main surface, rendered unconditionally (gateless: the engine check runs async beside it). Nav rail Posts / Sessions / Learnings / Trends / Archive + engine-status pill + Settings. Column collapse mirrors the export's media queries as pane collapse — library hides < 1100 px, mentor < 920 px; never a fixed four-column minWidth. Window-level `.dropDestination` (markdown only → external guest): ONE window-level destination is the whole routing surface under this hosting — nested editor-level SwiftUI destinations and NSTextView drag registrations starve (field-verified); a mixed md+image set refuses loudly. The house ask sheets present here (pending-state + binding pattern): `OriginAskSheet` (one ask per import batch), `OutlineGuardSheet`, `ConvertSheet`, `NewProjectSheet`.
|
||||
- `WorkspaceView.swift` — first-frame main surface, rendered unconditionally (gateless: the engine check runs async beside it). Nav rail Posts / Sessions / Learnings / Trends / Archive + engine-status pill + Settings. Column collapse mirrors the export's media queries as pane collapse — library hides < 1100 px, mentor < 920 px; never a fixed four-column minWidth. Window-level `.dropDestination` (markdown only → external guest): ONE window-level destination is the whole routing surface under this hosting — nested editor-level SwiftUI destinations and NSTextView drag registrations starve (field-verified); a mixed md+image set refuses loudly. The house ask sheets present here (pending-state + binding pattern; the sheet structs live in `WorkspaceViewSheets.swift`, #193). #193 splits: `ArchivePaneView` → `ArchivePaneView.swift`, shared chrome (`SelectedRowStrip`/`BorderedSecondaryButtonStyle`/`PaneHeader`) → `WorkspaceChrome.swift`; `RailButton` stays here (the rail is its only caller).
|
||||
- `ArchivePaneView.swift` — #193: the #108 Archive pane (moved from WorkspaceView.swift) — archive/ as a rail destination, List-only: clicking a piece selects it and hops to Posts (where the editor column lives); reuses `LibraryPostRow`.
|
||||
- `WorkspaceViewSheets.swift` — #193: the house ask sheets (moved from WorkspaceView.swift) — `OriginAskSheet` (the ONE origin ask per import batch, #94), `OutlineGuardSheet` (#111 mixed-content), `ConvertSheet` (#114), `NewProjectSheet` (#108).
|
||||
- `WorkspaceChrome.swift` — #193: the shared chrome (moved from WorkspaceView.swift) — `SelectedRowStrip` (the selected-row capsule), `BorderedSecondaryButtonStyle` (the bordered secondary button), `PaneHeader` (the 52pt pane-head row); every pane reuses them.
|
||||
- `PostsPaneView.swift` — Posts destination: library column (`PostsLibraryColumn`: project section heads + Pass-State groups, collapse toggle per-view; `LibraryPostRow` — 2px leading strip, ✳ on outline pieces, row menu Rename/Convert/Move to Project/Move to Archive/Trash), editor column, mentor column (fixed 356). Library search: debounced, title+body over non-archived pieces, body scan off-main through `readBody` (frontmatter never searched). Editor column renders the external guest ahead of the post session (one guest at a time). Focused branch mounts the Cold Turkey chrome as overlays; lock transitions never restructure the editor column.
|
||||
- `PostLibrary.swift` — `Post` + `Post.scan`: two-level scan over `projects/<name>/<id>/post.md` AND `archive/<name>/<id>/post.md` (ADR-0012), skip guards at both levels (lazy folders, loose files, hidden dirs, symlinked dirs); frontmatter keys read leniently (First Draft/writer/post defaults); title = first non-empty body line, `untitled` fallbacks; runs off-main. `stats_*` keys load only if EVERY value parses finite (a non-finite peak would trap the chart y-domain); read-back re-gates on the named immutable pair (`PostFrontmatter.isUnaidedFirstDraftPair` — origin writer, type post; never pass_state, which legitimately advances). `scan(home:cache:)` takes a `PostScanCache` (path+mtime+size memo; the stamp is taken BEFORE the read, so a mid-scan rewrite can never pin as fresh). `micropubURL` gated on `Micropub.trustworthyURL` — imported YAML rides verbatim, so hostile values scan nil.
|
||||
- `PostFrontmatter.swift` — #180: the Post frontmatter codec — the ONE lenient read (`parse`/`split`/`decoded`) and the three write postures behind one known-key table (`ownedKeys`: type, pass_state, origin — one insertion-order rule): fresh stamp (`stamped`), merge-import (`mergingImport` — external keys verbatim, ours win), update-keys (`updating` — the in-place line-walk, every other line byte-identical). Absorbed and deleted `PostStore.stamped/splitFrontmatter/mergedFrontmatter` and `LearningDecay.stampingFrontmatter` byte-identically (merge-import's documented prefix-preservation divergence excepted). Owns the two named eligibility predicates both gates consume: `isUnaidedFirstDraftPair` (writer ∧ post — the scan's read-back gate) and `isCaptureEligible` (pair ∧ First Draft — the capture gate). Learning/Fix Card documents stay out of scope; the learnings dismiss stamp rides the generic update posture.
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
//
|
||||
// ArchivePaneView.swift
|
||||
// Museion
|
||||
//
|
||||
// #193: the #108 Archive pane, moved from WorkspaceView.swift
|
||||
// (file-length ceiling), code unchanged (private → internal:
|
||||
// WorkspaceView instantiates it cross-file now).
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// #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.
|
||||
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<String> = []
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// WorkspaceChrome.swift
|
||||
// Museion
|
||||
//
|
||||
// #193: the shared workspace chrome, moved from WorkspaceView.swift
|
||||
// (file-length ceiling) — SelectedRowStrip, BorderedSecondaryButtonStyle,
|
||||
// PaneHeader; every pane reuses them, code unchanged.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// 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<Trailing: View>: 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-429
@@ -7,6 +7,9 @@
|
||||
// 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.
|
||||
// #193: the split-out files — ArchivePaneView.swift, the house ask
|
||||
// sheets WorkspaceViewSheets.swift, the shared chrome
|
||||
// WorkspaceChrome.swift; RailButton stays (the rail is its only caller).
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
@@ -355,349 +358,6 @@ struct WorkspaceView: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// #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<String> = []
|
||||
|
||||
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
|
||||
@@ -764,89 +424,3 @@ private struct RailButton: View {
|
||||
.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<Trailing: View>: 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
//
|
||||
// WorkspaceViewSheets.swift
|
||||
// Museion
|
||||
//
|
||||
// #193: the house ask sheets, moved from WorkspaceView.swift
|
||||
// (file-length ceiling) — OriginAskSheet (#94), OutlineGuardSheet
|
||||
// (#111), ConvertSheet (#114), NewProjectSheet (#108) — code
|
||||
// unchanged (private → internal: WorkspaceView presents them
|
||||
// cross-file now).
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/// #94: the ONE Origin ask per import batch — writer (default) / ai, with the
|
||||
/// immutability line (CONTEXT.md: Origin). Answering runs the batch.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user