Fix reading-safety and accessibility majors from review

- Transcript: drag suspends auto-follow; long-press selection suspends
  following; Latest is a trailing outlined capsule that re-enables follow
- Lightwell: pulse via isolated TimelineView (2.4s triangle wave), pauses
  when offscreen; Reduce Motion uses static geometry (no level resizing)
- Increase Contrast: solid Rosewood lightwell fill, 2pt Rosewood selected
  outlines on mode buttons
- Haptics: success only on entering ready, error only on entering failure
This commit is contained in:
snowspeeder committed 2026-09-12 08:27:48 -04:00
1 parent f043d6b078
commit afe37ad5f4
3 files changed
+121 -55

No files matched your search

@@ -26,9 +26,6 @@ struct LightwellView: View {
/// Compact (24×36) in the conversation status strip; full (64×96) on welcome.
var compact: Bool = false
@Environment(\.accessibilityReduceMotion) private var reduceMotion
/// Pending-state pulse driver, 0 → 1 → 0 over the 2.4s cycle.
@State private var pulse: Double = 0
/// Frame dimensions never animate; inner dimensions multiply by 0.375
/// in the compact frame.
private var frameSize: CGSize {
@@ -41,55 +38,87 @@ struct LightwellView: View {
: base
}
@Environment(\.colorSchemeContrast) private var contrast
var body: some View {
let inner = innerSize
ZStack {
Capsule()
.fill(Nearlight.surface)
Capsule()
.fill(
LinearGradient(
stops: [
.init(color: Nearlight.rosewood.opacity(0.35), location: 0),
.init(color: Nearlight.rosewood.opacity(1), location: 0.5),
.init(color: Nearlight.rosewood.opacity(0.55), location: 1),
],
startPoint: .top, endPoint: .bottom
)
)
.frame(width: inner.width, height: inner.height)
.opacity(overallOpacity)
.animation(reduceMotion ? nil : Nearlight.quick, value: overallOpacity)
.animation(reduceMotion ? nil : Nearlight.settle, value: innerSize)
}
.frame(width: frameSize.width, height: frameSize.height)
.overlay(
Capsule().strokeBorder(Nearlight.quiet, lineWidth: 1)
)
.accessibilityHidden(true)
.task(id: pulseActive) {
guard pulseActive else {
pulse = 0
return
}
while !Task.isCancelled {
withAnimation(reduceMotion ? nil : Nearlight.cycle) { pulse = pulse == 0 ? 1 : 0 }
try? await Task.sleep(for: .seconds(2.4))
Group {
if pulseWanted {
// Isolated TimelineView: ticks only while pending states are
// showing; pauses when offscreen/inactive automatically.
TimelineView(.periodic(from: .now, by: 0.05)) { context in
lightwell(pulse: pulseValue(at: context.date))
}
} else {
lightwell(pulse: 0)
}
}
}
/// Whether the pulse loop should run for this phase.
private var pulseActive: Bool {
private func lightwell(pulse: Double) -> some View {
let inner = innerSize
return ZStack {
Capsule()
.fill(Nearlight.surface)
Capsule()
.fill(innerFill)
.frame(width: inner.width, height: inner.height)
.opacity(overallOpacity(pulse: pulse))
}
.frame(width: frameSize.width, height: frameSize.height)
.overlay(
Capsule().strokeBorder(
contrast == .increased ? Nearlight.rosewood : Nearlight.quiet,
lineWidth: 1
)
)
.accessibilityHidden(true)
.animation(reduceMotion ? nil : Nearlight.settle, value: innerSize)
}
/// Increase Contrast promotes the gradient to solid Rosewood.
private var innerFill: AnyShapeStyle {
if contrast == .increased {
return AnyShapeStyle(Nearlight.rosewood)
}
return AnyShapeStyle(
LinearGradient(
stops: [
.init(color: Nearlight.rosewood.opacity(0.35), location: 0),
.init(color: Nearlight.rosewood.opacity(1), location: 0.5),
.init(color: Nearlight.rosewood.opacity(0.55), location: 1),
],
startPoint: .top, endPoint: .bottom
)
)
}
/// Whether a pulse TimelineView should run for this phase.
private var pulseWanted: Bool {
switch phase {
case .connecting, .waiting, .thinking: return !reduceMotion
default: return false
}
}
/// Triangle wave 0→1→0 over the 2.4s cycle from the timeline date.
private func pulseValue(at date: Date) -> Double {
let t = date.timeIntervalSinceReferenceDate.truncatingRemainder(dividingBy: 2.4) / 2.4
return t < 0.5 ? t * 2 : (1 - t) * 2
}
/// Inner capsule geometry per spec table. `a` is the smoothed level.
/// Reduce Motion: static 16×40 (idle/listening) and 16×48 (pending/
/// thinking/speaking) with no level-driven resizing.
private var innerSize: CGSize {
let base = baseInner
if reduceMotion {
switch phase {
case .waiting, .thinking, .speaking:
return CGSize(width: base.width, height: base.height + (compact ? 3 : 8))
default:
return base
}
}
switch phase {
case .listening(let a):
let level = min(max(a, 0), 1)
@@ -107,7 +136,7 @@ struct LightwellView: View {
}
}
private var overallOpacity: Double {
private func overallOpacity(pulse: Double) -> Double {
switch phase {
case .connecting, .waiting:
return 0.45 + 0.45 * pulse