UI: liquid opening, staggered content, answer wave, haptics, gaze, notch drop
- Opening: the notch spreads sideways then pours down with a slight overshoot; header and screen come out of a soft blur one after the other. - Chat: a purple→orange wave of bars instead of three dots while Claude answers. - Haptic tap (Force Touch trackpad) when the notch opens and on Allow/Deny. - Memoji turns its head toward the cursor clearly (slide, lean, slight shear). - A drop of the folded notch stretches toward the approaching cursor (within 130 pt), leaning to its side; its own ObservableObject so only the drop redraws at 30 Hz. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -768,6 +768,14 @@ final class AppState: ObservableObject {
|
||||
|
||||
// MARK: - Supporting types
|
||||
|
||||
/// 0…1 while the folded notch waits for the cursor (1 = touching it). Its own object so
|
||||
/// that updating it at 30 Hz redraws only the drop, not every view watching AppState.
|
||||
@MainActor
|
||||
final class NotchProximity: ObservableObject {
|
||||
static let shared = NotchProximity()
|
||||
@Published var value: CGFloat = 0
|
||||
}
|
||||
|
||||
enum PromptContext {
|
||||
case window(appName: String, title: String, url: String?)
|
||||
case file(name: String, fileURL: URL?)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import AppKit
|
||||
|
||||
/// A light tap on the Force Touch trackpad (felt only while a finger rests on it).
|
||||
@MainActor
|
||||
enum Haptic {
|
||||
static func tap() {
|
||||
NSHapticFeedbackManager.defaultPerformer.perform(.levelChange, performanceTime: .now)
|
||||
}
|
||||
}
|
||||
@@ -755,6 +755,7 @@ final class HookServer: @unchecked Sendable {
|
||||
/// Called by ApprovalView buttons. Writes the decision to the waiting nb-hook and cleans up.
|
||||
@MainActor
|
||||
func sendApprovalDecision(_ decision: String) {
|
||||
Haptic.tap()
|
||||
let fd = pendingApprovalFD
|
||||
pendingApprovalFD = -1
|
||||
// Capture source before nulling — we send the decision first, then cancel the source.
|
||||
|
||||
@@ -49,6 +49,11 @@ struct IslandContainer: View {
|
||||
let greetingActive = state.mode == .expanded && state.view == .greeting
|
||||
|
||||
return ZStack(alignment: .topLeading) {
|
||||
// Folded notch: a drop of the notch stretches toward the approaching cursor.
|
||||
if state.mode != .expanded {
|
||||
NotchDrop(islandW: islandWidth, islandH: islandHeight)
|
||||
}
|
||||
|
||||
// Black island shape
|
||||
IslandShape(width: islandWidth, height: islandHeight,
|
||||
cornerRadius: cornerRadius, topRadius: islandTopRadius)
|
||||
@@ -128,11 +133,25 @@ struct IslandContainer: View {
|
||||
nw: state.notchWidth, nh: state.notchHeight)
|
||||
let cr = newMode == .expanded ? IslandConst.expandedCorner : IslandConst.roundedCorner
|
||||
let tr: CGFloat = 0
|
||||
withAnimation(anim) {
|
||||
islandWidth = w
|
||||
islandHeight = (newMode == .expanded && state.view.isTall) ? chatPromptHeight : h
|
||||
cornerRadius = cr
|
||||
islandTopRadius = tr
|
||||
let targetH = (newMode == .expanded && state.view.isTall) ? chatPromptHeight : h
|
||||
if shrinking {
|
||||
withAnimation(anim) {
|
||||
islandWidth = w
|
||||
islandHeight = targetH
|
||||
cornerRadius = cr
|
||||
islandTopRadius = tr
|
||||
}
|
||||
} else {
|
||||
// Liquid opening: the notch spreads sideways first and pours down a beat
|
||||
// later, both with a little overshoot.
|
||||
withAnimation(.spring(response: 0.42, dampingFraction: 0.66)) {
|
||||
islandWidth = w
|
||||
cornerRadius = cr
|
||||
islandTopRadius = tr
|
||||
}
|
||||
withAnimation(.spring(response: 0.52, dampingFraction: 0.7).delay(0.05)) {
|
||||
islandHeight = targetH
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: state.view) { _, newView in
|
||||
@@ -489,6 +508,8 @@ struct CountdownBar: View {
|
||||
|
||||
struct IslandContentView: View {
|
||||
@ObservedObject var state: AppState
|
||||
/// Header and screen come out of a soft blur one after the other on every opening.
|
||||
@State private var shown = false
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
@@ -496,6 +517,10 @@ struct IslandContentView: View {
|
||||
.frame(height: 34)
|
||||
.opacity(state.view == .confused ? 0 : 1)
|
||||
.animation(.easeInOut(duration: 0.2), value: state.view == .confused)
|
||||
.opacity(shown ? 1 : 0)
|
||||
.offset(y: shown ? 0 : -6)
|
||||
.blur(radius: shown ? 0 : 5)
|
||||
.animation(.spring(response: 0.38, dampingFraction: 0.8).delay(0.08), value: shown)
|
||||
|
||||
ZStack {
|
||||
// Only the visible screen is built (plus the chat, to keep its draft and
|
||||
@@ -522,10 +547,41 @@ struct IslandContentView: View {
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.padding(.horizontal, 10)
|
||||
.opacity(shown ? 1 : 0)
|
||||
.offset(y: shown ? 0 : 10)
|
||||
.blur(radius: shown ? 0 : 6)
|
||||
.animation(.spring(response: 0.45, dampingFraction: 0.82).delay(0.16), value: shown)
|
||||
}
|
||||
.padding(.top, 8)
|
||||
.padding(.bottom, 10)
|
||||
.foregroundColor(Color(hex: "#F5F6F8"))
|
||||
.onAppear { shown = true }
|
||||
.onDisappear { shown = false }
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Drop under the folded notch
|
||||
|
||||
/// A drop of the notch that stretches toward the cursor as it approaches (proximity 0…1):
|
||||
/// tells you the notch will open, and leans to the side the cursor comes from.
|
||||
struct NotchDrop: View {
|
||||
@ObservedObject private var near = NotchProximity.shared
|
||||
let islandW: CGFloat
|
||||
let islandH: CGFloat
|
||||
|
||||
var body: some View {
|
||||
let p = near.value
|
||||
let lean = max(-1, min(1, (AppState.shared.mousePosition.x - (NSScreen.main?.frame.width ?? 0) / 2) / 200))
|
||||
let w = islandW * (0.34 + 0.22 * p)
|
||||
let h = 4 + 16 * p
|
||||
Ellipse()
|
||||
.fill(Color.black)
|
||||
.frame(width: w, height: h * 2)
|
||||
.shadow(color: Color(hex: "#A78BFA").opacity(0.35 * p), radius: 8 * p)
|
||||
.position(x: islandW / 2 + lean * 14 * p, y: islandH + h * 0.3)
|
||||
.opacity(p > 0.01 ? 1 : 0)
|
||||
.animation(.spring(response: 0.3, dampingFraction: 0.62), value: p)
|
||||
.allowsHitTesting(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1524,24 +1524,25 @@ struct ChatBubble: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// "Claude is answering": a soft wave of bars with a moving purple→orange shimmer.
|
||||
struct TypingDotsView: View {
|
||||
@State private var phase = false
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 4) {
|
||||
ForEach(0..<3, id: \.self) { i in
|
||||
Circle()
|
||||
.fill(Color(hex: "#6B7079"))
|
||||
.frame(width: 5, height: 5)
|
||||
.scaleEffect(phase ? 1.2 : 0.6)
|
||||
.animation(
|
||||
.easeInOut(duration: 0.45).repeatForever().delay(Double(i) * 0.14),
|
||||
value: phase
|
||||
)
|
||||
TimelineView(.animation(minimumInterval: 1.0 / 30.0)) { tl in
|
||||
let t = tl.date.timeIntervalSinceReferenceDate
|
||||
HStack(alignment: .center, spacing: 3) {
|
||||
ForEach(0..<5, id: \.self) { i in
|
||||
let k = (sin(t * 5.2 - Double(i) * 0.7) + 1) / 2
|
||||
Capsule()
|
||||
.fill(LinearGradient(colors: [Color(hex: "#A78BFA"), Color(hex: "#D97757")],
|
||||
startPoint: .top, endPoint: .bottom))
|
||||
.frame(width: 3, height: 4 + 10 * k)
|
||||
.opacity(0.45 + 0.55 * k)
|
||||
}
|
||||
}
|
||||
.frame(height: 16)
|
||||
.hueRotation(.degrees(sin(t * 0.8) * 18))
|
||||
}
|
||||
.padding(.horizontal, 2).padding(.vertical, 4)
|
||||
.onAppear { phase = true }
|
||||
.padding(.horizontal, 4).padding(.vertical, 4)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -242,6 +242,8 @@ final class IslandWindowController: NSWindowController {
|
||||
/// 10 Hz when folded (hover still reacts within 0.1 s).
|
||||
private var desiredPollInterval: TimeInterval {
|
||||
if inAttachDrag || attachDragStart != nil || state.chatDragHeight != nil { return 1.0 / 60.0 }
|
||||
// The drop under the folded notch follows the cursor smoothly.
|
||||
if NotchProximity.shared.value > 0 { return 1.0 / 30.0 }
|
||||
return state.mode == .expanded ? 1.0 / 30.0 : 1.0 / 10.0
|
||||
}
|
||||
|
||||
@@ -296,6 +298,18 @@ final class IslandWindowController: NSWindowController {
|
||||
AppState.shared.mousePosition = newPos
|
||||
}
|
||||
|
||||
// Drop under the folded notch: grows as the cursor comes within 130 pt.
|
||||
var proximity: CGFloat = 0
|
||||
if state.mode != .expanded && !inIsland && !inAttachDrag {
|
||||
let dx = max(islandRect.minX - local.x, 0, local.x - islandRect.maxX)
|
||||
let dy = max(islandRect.minY - local.y, 0, local.y - islandRect.maxY)
|
||||
proximity = max(0, 1 - hypot(dx, dy) / 130)
|
||||
}
|
||||
let near = NotchProximity.shared
|
||||
if abs(proximity - near.value) > 0.03 || (proximity == 0 && near.value != 0) {
|
||||
near.value = proximity
|
||||
}
|
||||
|
||||
// AppState can hide the island by itself (last task ended): keep the FSM in step.
|
||||
if state.mode == .hidden && fsm.state == .petit { fsm.hiddenExternally() }
|
||||
|
||||
@@ -388,7 +402,7 @@ final class IslandWindowController: NSWindowController {
|
||||
? .timingCurve(0.45, 0, 0.2, 1, duration: 0.34)
|
||||
: .spring(response: 0.5, dampingFraction: 0.72)
|
||||
withAnimation(anim) { state.mode = mode }
|
||||
if mode == .expanded { SoundEngine.shared.play("open") }
|
||||
if mode == .expanded { SoundEngine.shared.play("open"); Haptic.tap() }
|
||||
if prev == .expanded {
|
||||
SoundEngine.shared.play("close")
|
||||
if fsm.isHeldOpen?() != true { state.isPinned = false }
|
||||
|
||||
@@ -110,10 +110,12 @@ extension BotEngine {
|
||||
var c = context
|
||||
c.opacity = opacity
|
||||
c.translateBy(x: center.x, y: center.y)
|
||||
// Head turn: slide toward the gaze and narrow a little, like turning a sphere.
|
||||
c.translateBy(x: yaw * R * 0.18, y: -pitch * R * 0.12)
|
||||
c.rotate(by: .radians(tilt + roll))
|
||||
c.scaleBy(x: sx * (1 - abs(yaw) * 0.10), y: sy * (1 - abs(pitch) * 0.06))
|
||||
// Head turn toward the gaze (the cursor): slide, lean into the turn and narrow a
|
||||
// little, like turning a sphere — strong enough to read at notch size.
|
||||
c.translateBy(x: yaw * R * 0.32, y: -pitch * R * 0.22)
|
||||
c.rotate(by: .radians(tilt + roll + yaw * 0.09))
|
||||
c.concatenate(CGAffineTransform(a: 1, b: yaw * 0.05, c: 0, d: 1, tx: 0, ty: 0))
|
||||
c.scaleBy(x: sx * (1 - abs(yaw) * 0.08), y: sy * (1 - abs(pitch) * 0.06))
|
||||
// Status tint as a soft glow behind the head.
|
||||
if tint > 0.02 {
|
||||
let glow = Color(red: col.0, green: col.1, blue: col.2)
|
||||
|
||||
Reference in New Issue
Block a user