refactor(workspace): finish-audit fixes — off-main scan, parser edges, dead code out
Reviewers' findings on 804b588: scan moved off MainActor (Task.detached),
PostLibrary struct folded into Post.scan, hidden dirs and symlinked dirs
now actually skipped (test de-vacuated), unterminated frontmatter no longer
leaks as the Title, quoted YAML values unquoted, leading blank line before
--- tolerated, #-only body reads untitled, persisted Home validated
isFileURL. Dead code deleted: radiusLarge, editorMinWidth, homeKey,
PaneHeader trailing slot, Settings ScrollView, PostRow fill dance.
Tests 56/56, lint 0.
[Generated by AI]
This commit is contained in:
1 parent
804b5889f6
commit
765d32d4d4
10 files changed
+158
-101
No files matched your search
+15
-15
@@ -17,8 +17,8 @@ struct PostsPaneView: View {
|
||||
var mentorBinaryPath: String?
|
||||
/// Width budget after the rail — drives column collapse (export media queries:
|
||||
/// library hides ≤1100, mentor hides ≤920).
|
||||
var availableWidth: CGFloat = .infinity
|
||||
@State private var library = PostLibrary()
|
||||
var availableWidth: CGFloat
|
||||
@State private var posts: [Post] = []
|
||||
@State private var selectedPostID: String?
|
||||
|
||||
private var showsLibrary: Bool {
|
||||
@@ -41,7 +41,10 @@ struct PostsPaneView: View {
|
||||
mentorColumn
|
||||
}
|
||||
}
|
||||
.task(id: home) { library = PostLibrary.scan(home: home) }
|
||||
.task(id: home) {
|
||||
// Scan off-main: .task inherits MainActor; a big Home must not freeze the UI.
|
||||
posts = await Task.detached(priority: .userInitiated) { Post.scan(home: home) }.value
|
||||
}
|
||||
}
|
||||
|
||||
private var paneBorder: some View {
|
||||
@@ -54,18 +57,16 @@ struct PostsPaneView: View {
|
||||
|
||||
private var libraryColumn: some View {
|
||||
VStack(spacing: 0) {
|
||||
PaneHeader(title: "Posts") {
|
||||
// New Post arrives with #18 (Post lifecycle: lazy folder + slug).
|
||||
EmptyView()
|
||||
}
|
||||
if library.posts.isEmpty {
|
||||
// New Post arrives with #18 (Post lifecycle: lazy folder + slug).
|
||||
PaneHeader(title: "Posts")
|
||||
if posts.isEmpty {
|
||||
emptyState
|
||||
} else {
|
||||
ScrollView {
|
||||
LazyVStack(alignment: .leading, spacing: 4) {
|
||||
ForEach(Post.PassState.allCases, id: \.self) { state in
|
||||
let posts = library.posts.filter { $0.passState == state }
|
||||
if !posts.isEmpty {
|
||||
let grouped = posts.filter { $0.passState == state }
|
||||
if !grouped.isEmpty {
|
||||
Text(state.rawValue.uppercased())
|
||||
.font(.system(size: 11, design: DesignTokens.mono))
|
||||
.kerning(0.6)
|
||||
@@ -73,7 +74,7 @@ struct PostsPaneView: View {
|
||||
.padding(.horizontal, 14)
|
||||
.padding(.top, 18)
|
||||
.padding(.bottom, 7)
|
||||
ForEach(posts) { post in
|
||||
ForEach(grouped) { post in
|
||||
PostRow(post: post, selected: post.id == selectedPostID) {
|
||||
selectedPostID = post.id
|
||||
}
|
||||
@@ -105,7 +106,7 @@ struct PostsPaneView: View {
|
||||
|
||||
private var editorPlaceholder: some View {
|
||||
VStack(spacing: 10) {
|
||||
if let post = library.posts.first(where: { $0.id == selectedPostID }) {
|
||||
if let post = posts.first(where: { $0.id == selectedPostID }) {
|
||||
Text(post.title)
|
||||
.font(.system(size: 16, weight: .semibold, design: DesignTokens.serif))
|
||||
}
|
||||
@@ -151,10 +152,9 @@ private struct PostRow: View {
|
||||
.buttonStyle(.plain)
|
||||
.foregroundStyle(DesignTokens.foreground)
|
||||
.background {
|
||||
let fill: Color? = selected ? DesignTokens.surface : (hover ? DesignTokens.foreground.opacity(0.06) : nil)
|
||||
if let fill {
|
||||
if selected || hover {
|
||||
RoundedRectangle(cornerRadius: DesignTokens.radius)
|
||||
.fill(fill)
|
||||
.fill(selected ? DesignTokens.surface : DesignTokens.foreground.opacity(0.06))
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: DesignTokens.radius)
|
||||
.strokeBorder(selected ? DesignTokens.border : .clear),
|
||||
|
||||
Reference in new issue
Block a user