fix(workspace): audit fixes — dedupe failure chip, width-guard mentor overlay, a11y, NSColor bridge (#87)
Reviewer fan-out (ponytail/security/general) synthesis: - one failure surface in focus (chip carries it; toolbar stays recessed) - draft '⌘S saves' cue in focus (drafts have no autosave) - mentor reveal honors the #17 width verdict - hidden overlay panels leave the accessibility tree - NSColor(DesignTokens.background) bridge replaces the twin constant - HoverZone width plumbing deleted, zoneWidth hoisted as the knob - single >=1100 threshold read in WorkspaceView
This commit is contained in:
1 parent
9c2926f027
commit
d07d41859a
6 files changed
+51
-48
No files matched your search
@@ -86,25 +86,20 @@ struct PostEditorView: View {
|
||||
.frame(width: 1, height: 1)
|
||||
.accessibilityHidden(true)
|
||||
}
|
||||
// #21: save failure is LOUD in focus — the full unfocused widget
|
||||
// (dot + "Save failed") reappears, floating at the top edge where
|
||||
// the toolbar row stood. Autosave keeps running underneath.
|
||||
// #21: save failure is LOUD in focus — the full widget floats where
|
||||
// the toolbar stood. Drafts (no autosave): a muted cue appears once
|
||||
// there is text to lose; ⌘S stays armed either way (body level).
|
||||
.overlay(alignment: .top) {
|
||||
if gate.isFocused, session?.saveState == .failed {
|
||||
HStack(spacing: 7) {
|
||||
Circle()
|
||||
.fill(DesignTokens.accent)
|
||||
.frame(width: 6, height: 6)
|
||||
Text("Save failed")
|
||||
if gate.isFocused {
|
||||
if session?.saveState == .failed {
|
||||
focusChip { SaveStateDot(state: .failed) }
|
||||
} else if session == nil, draftMirror != (draftText ?? "") {
|
||||
focusChip {
|
||||
Text("⌘S saves")
|
||||
.font(.system(size: 11, design: DesignTokens.mono))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
}
|
||||
}
|
||||
.font(.system(size: 12))
|
||||
.foregroundStyle(DesignTokens.accent)
|
||||
.padding(.horizontal, 14)
|
||||
.padding(.vertical, 7)
|
||||
.background(DesignTokens.surface.opacity(0.96), in: RoundedRectangle(cornerRadius: DesignTokens.radius))
|
||||
.accessibilityElement(children: .ignore)
|
||||
.accessibilityLabel("Save state: Save failed")
|
||||
.transition(.move(edge: .top).combined(with: .opacity))
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
@@ -135,9 +130,19 @@ struct PostEditorView: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// #21: the toolbar row recedes in focus (unless failure is loud).
|
||||
/// #21: the toolbar row recedes in focus — the floating chip above is
|
||||
/// the failure surface there (never both at once).
|
||||
private var showsToolbar: Bool {
|
||||
!gate.isFocused || session?.saveState == .failed
|
||||
!gate.isFocused
|
||||
}
|
||||
|
||||
/// The floating focus-mode chip: pill background + top-edge transition.
|
||||
private func focusChip(@ViewBuilder _ content: () -> some View) -> some View {
|
||||
content()
|
||||
.padding(.horizontal, 14)
|
||||
.padding(.vertical, 7)
|
||||
.background(DesignTokens.surface.opacity(0.96), in: RoundedRectangle(cornerRadius: DesignTokens.radius))
|
||||
.transition(.move(edge: .top).combined(with: .opacity))
|
||||
}
|
||||
|
||||
/// #21: focus runs on the workspace background, not the surface card —
|
||||
@@ -331,9 +336,9 @@ struct ProseTextView: NSViewRepresentable {
|
||||
// #77: squiggles follow the posture toggle (default off).
|
||||
tv.isContinuousSpellCheckingEnabled = spellChecking
|
||||
tv.usesFindBar = true
|
||||
// #21: focus ground joins the workspace background; drawsBackground
|
||||
// stays true either way (white in the unfocused card).
|
||||
tv.backgroundColor = focused ? DesignTokens.workspaceBackground : NSColor.white
|
||||
// #21: focus ground joins the workspace background (NSColor(Color)
|
||||
// bridges; white in the unfocused card).
|
||||
tv.backgroundColor = focused ? NSColor(DesignTokens.background) : NSColor.white
|
||||
tv.typingAttributes = ProseTypography.bodyAttributes
|
||||
tv.delegate = context.coordinator
|
||||
tv.layoutManager?.allowsNonContiguousLayout = true
|
||||
@@ -356,7 +361,7 @@ struct ProseTextView: NSViewRepresentable {
|
||||
// out at rest (iOS-like), instead of always occupying the right edge.
|
||||
scroll.scrollerStyle = .overlay
|
||||
scroll.drawsBackground = true
|
||||
scroll.backgroundColor = focused ? DesignTokens.workspaceBackground : NSColor.white
|
||||
scroll.backgroundColor = focused ? NSColor(DesignTokens.background) : NSColor.white
|
||||
context.coordinator.textView = tv
|
||||
context.coordinator.sessionRef = session // strong: both die with the editor
|
||||
return scroll
|
||||
@@ -367,7 +372,7 @@ struct ProseTextView: NSViewRepresentable {
|
||||
// #77: posture toggle while editing — cheap idempotent set.
|
||||
tv.isContinuousSpellCheckingEnabled = spellChecking
|
||||
// #21: the ground follows focus in/out without a remount.
|
||||
let ground = focused ? DesignTokens.workspaceBackground : NSColor.white
|
||||
let ground = focused ? NSColor(DesignTokens.background) : NSColor.white
|
||||
tv.backgroundColor = ground
|
||||
scroll.backgroundColor = ground
|
||||
context.coordinator.focused = focused
|
||||
|
||||
Reference in new issue
Block a user