Talk to Claude Code and Codex agents from an Apple Watch and an iPhone. Each agent is a character on the watch.
Expressions the type checker found slow, in typed steps (Xcode 26.6 gave up on three of them)
Lucas Coutoae1b290806cd
diff --git a/app/ChumsPhone/Design.swift b/app/ChumsPhone/Design.swiftindex 0a2d338..0f1f011 100644--- a/app/ChumsPhone/Design.swift+++ b/app/ChumsPhone/Design.swift@@ -53,8 +53,9 @@ struct EdgeFade: View {var topReach: CGFloat = 30, topDepth: CGFloat = 0.25 // gone before the name under the charactervar bottomReach: CGFloat = 14, bottomDepth: CGFloat = 0.6 // gone by the middle of the box- private static let stops: [Gradient.Stop] = stride(from: 0.0, through: 1.0, by: 0.0625).map { t in- .init(color: .black.opacity(t * t * (3 - 2 * t)), location: t)+ private static let stops: [Gradient.Stop] = stride(from: 0.0, through: 1.0, by: 0.0625).map { (t: Double) -> Gradient.Stop in+ let eased: Double = t * t * (3 - 2 * t)+ return Gradient.Stop(color: Color.black.opacity(eased), location: CGFloat(t))}var body: some View {diff --git a/app/ChumsWatch/Rig/Chalk.swift b/app/ChumsWatch/Rig/Chalk.swiftindex 661b53f..5f06a9b 100644--- a/app/ChumsWatch/Rig/Chalk.swift+++ b/app/ChumsWatch/Rig/Chalk.swift@@ -184,13 +184,15 @@ enum Chalk {var out: [P2] = [pts[0]]for i in 0..<(m - 1) {let p0 = pts[max(0, i - 1)], p1 = pts[i], p2 = pts[i + 1], p3 = pts[min(m - 1, i + 2)]- let per = max(1, min(8, Int(simd_length(p2 - p1) / 0.6)))+ let gap: Double = simd_length(p2 - p1)+ let per = max(1, min(8, Int(gap / 0.6)))for k in 1...per {let u = Double(k) / Double(per), u2 = u * u, u3 = u2 * ulet a: P2 = p1 * 2, b: P2 = (p2 - p0) * ulet c1: P2 = p0 * 2 - p1 * 5, c2: P2 = p2 * 4 - p3, c: P2 = (c1 + c2) * u2let d1: P2 = p1 * 3 - p0, d2: P2 = p3 - p2 * 3, d: P2 = (d1 + d2) * u3- out.append((a + b + c + d) * 0.5)+ let sum: P2 = a + b + c + d+ out.append(sum * 0.5)}}return outdiff --git a/app/ChumsWatch/Rig/NoodleStage.swift b/app/ChumsWatch/Rig/NoodleStage.swiftindex 19a3ba4..e6f9d84 100644--- a/app/ChumsWatch/Rig/NoodleStage.swift+++ b/app/ChumsWatch/Rig/NoodleStage.swift@@ -152,12 +152,12 @@ final class NoodleStage: Staged {if i + 1 < legs.count && s > end - r {let a = Self.ease((s - (end - r)) / (2 * r))let p1 = pose(leg: i, at: min(d, L)), p2 = pose(leg: i + 1, at: max(0, s - end))- return (0..<NoodleStage.N).map { p1[$0] * (1 - a) + p2[$0] * a }+ return (0..<NoodleStage.N).map { (j: Int) -> V3 in p1[j] * (1 - a) + p2[j] * a }}if i > 0 && s < start + r {let a = Self.ease((s - (start - r)) / (2 * r))let p1 = pose(leg: i - 1, at: NoodleStage.travel[legs[i - 1].edge].last!), p2 = pose(leg: i, at: d)- return (0..<NoodleStage.N).map { p1[$0] * (1 - a) + p2[$0] * a }+ return (0..<NoodleStage.N).map { (j: Int) -> V3 in p1[j] * (1 - a) + p2[j] * a }}return pose(leg: i, at: d)}@@ -375,8 +375,9 @@ final class NoodleStage: Staged {P[i].y = Self.ground + (P[i].y - Self.ground) * (1 + breathe) * stretch.k}// the head nods: the last stretch of it turns about where the neck starts; the knock starts from rest- let nodWant: Double = state == .needs ? 0.3 * max(0, sin(min(1, knock / 1.0) * 4 * .pi)) * Self.ease(knock / 0.15)- : state == .speaking ? voice * 0.15 : 0+ let knockTurn: Double = min(1, knock / 1.0) * 4 * Double.pi+ let knockNod: Double = 0.3 * max(0, sin(knockTurn)) * Self.ease(knock / 0.15)+ let nodWant: Double = state == .needs ? knockNod : state == .speaking ? voice * 0.15 : 0let wn = TAU * 2.5nod.v += (-wn * wn * (nod.a - nodWant) - 2 * wn * nod.v) * dt; nod.a += nod.v * dtif abs(nod.a) > 1e-4 {@@ -429,9 +430,12 @@ final class NoodleStage: Staged {toward = fw - P2(W[n - 1].x, W[n - 1].y)let l = simd_length(toward); if l > 34 { toward *= 34 / l }}- let wr = TAU * 1.5, wj = TAU * 2.2- reach.v += ((toward - reach.p) * (wr * wr) - reach.v * (2 * 0.5 * wr)) * dt; reach.p += reach.v * dt- jig.v += (jig.p * (-wj * wj) - jig.v * (2 * 0.3 * wj)) * dt; jig.p += jig.v * dt+ // in parts, with their types: whole, these were more than Xcode 26.6's type checker would take+ let wr: Double = TAU * 1.5, wj: Double = TAU * 2.2+ let reachPull: P2 = (toward - reach.p) * (wr * wr), reachDamping: P2 = reach.v * (2 * 0.5 * wr)+ reach.v += (reachPull - reachDamping) * dt; reach.p += reach.v * dt+ let jigPull: P2 = jig.p * (-wj * wj), jigDamping: P2 = jig.v * (2 * 0.3 * wj)+ jig.v += (jigPull - jigDamping) * dt; jig.p += jig.v * dtlet jl = simd_length(jig.p); if jl > 26 { jig.p *= 26 / jl }hop.v += 950 * dt; hop.y += hop.v * dt; if hop.y > 0 { if hop.v > 120 { flow.kickWant = max(flow.kickWant, 0.04) }; hop.y = 0; hop.v = 0 }happyFor = max(0, happyFor - dt)@@ -770,7 +774,8 @@ final class NoodleStage: Staged {return Double(ao[i * m + k0]) * (1 - wk) + Double(ao[i * m + k0 + 1]) * wk}let sh = aoAt(i0) * (1 - wi) + aoAt(i0 + 1) * wi- let zc = clamp(Double(zb[idx]) / 60, -1, 1), cue = 1 - 0.25 * (0.5 - 0.5 * zc)+ let zc: Double = clamp(Double(zb[idx]) / 60, -1, 1)+ let cue: Double = 1 - 0.25 * (0.5 - 0.5 * zc)col = col * (one - dark * sh) * cuelet a = Double(cov)px[o] = UInt8(clamp(col.x, 0, 1) * a * 255 + 0.5)@@ -818,7 +823,8 @@ final class NoodleStage: Staged {}let line = StrokeStyle(lineWidth: 1.6, lineCap: .round)for side in [-1.0, 1.0] {- let dir = Self.unit(fd + right * (side * 0.42) + up * 0.1)+ let aside: V3 = right * (side * 0.42), lift: V3 = up * 0.1+ let dir = Self.unit(fd + aside + lift)if dir.z < 0.12 { continue }let at: V3 = E - tE * (0.55 * R) + dir * Rlet pp = project(at), s = pp.sdiff --git a/app/ChumsWatch/Rig/PeepsStage.swift b/app/ChumsWatch/Rig/PeepsStage.swiftindex 5c5cdcb..a8088e6 100644--- a/app/ChumsWatch/Rig/PeepsStage.swift+++ b/app/ChumsWatch/Rig/PeepsStage.swift@@ -259,7 +259,10 @@ final class PeepsStage: Staged {bubbles.removeAll { $0.y < -$0.r - 6 || $0.y > 262 + $0.r }// they watch the biggest one near themlet c = CGPoint(x: Double(eyes.l.x + eyes.r.x) / 2, y: Double(eyes.l.y + eyes.r.y) / 2)- if let b = bubbles.filter({ $0.pop == nil && $0.y < 236 && $0.y > 20 }).max(by: { $0.r / (hypot($0.x - c.x, $0.y - c.y) + 40) < $1.r / (hypot($1.x - c.x, $1.y - c.y) + 40) }) {+ // the bubble that draws the eyes most: big and near+ let cx = Double(c.x), cy = Double(c.y)+ func pull(_ b: Bubble) -> Double { b.r / (hypot(b.x - cx, b.y - cy) + 40) }+ if let b = bubbles.filter({ $0.pop == nil && $0.y < 236 && $0.y > 20 }).max(by: { pull($0) < pull($1) }) {look = CGPoint(x: b.x, y: b.y); lookFor = max(lookFor, 0.35)}}@@ -343,8 +346,9 @@ final class PeepsStage: Staged {let c = CGPoint(x: p.cx + off.x + head.x + sin(t * TAU * 8) * 5 * shakeOff, y: p.cy + off.y + head.y + hopY)let rot = p.tilt + (dizzyT != nil ? sin(dz * 3.1) * 0.2 * orbit : 0) + sin(t * 1.6) * 0.12 * woozelet ca = cos(rot), sa = sin(rot), R = 6 * orbit- var pos = [CGPoint(x: c.x - sep * ca + cos(orbitA) * R, y: c.y - sep * sa + sin(orbitA) * R),- CGPoint(x: c.x + sep * ca - cos(orbitA) * R, y: c.y + sep * sa - sin(orbitA) * R)]+ let cx = Double(c.x), cy = Double(c.y)+ let dx: Double = sep * ca, dy: Double = sep * sa, ox: Double = cos(orbitA) * R, oy: Double = sin(orbitA) * R+ var pos = [CGPoint(x: cx - dx + ox, y: cy - dy + oy), CGPoint(x: cx + dx - ox, y: cy + dy - oy)]pos[0].y += sin(t * 2.1) * 5 * wooze; pos[1].y += sin(t * 2.1 + 2.2) * 5 * wooze // woozy: out of stepeyes = (pos[0], pos[1], w, h)@@ -470,7 +474,8 @@ final class PeepsStage: Staged {// dizzy: a ring of little glass beads circling over themif halo > 0, let d = dizzyT {let k = clamp(d / 0.3, 0, 1)- let cx = Double(f.eye[0].p.x + f.eye[1].p.x) / 2, cy = max(34, Double(min(f.eye[0].p.y, f.eye[1].p.y)) - f.h * 0.55 - 10)+ let cx: Double = Double(f.eye[0].p.x + f.eye[1].p.x) / 2, top: Double = Double(min(f.eye[0].p.y, f.eye[1].p.y))+ let cy: Double = max(34, top - f.h * 0.55 - 10)for i in 0..<5 {let a = t * TAU * 1.1 + Double(i) * TAU / 5, depth = sin(a), x = cx + cos(a) * 28 * k, y = cy + depth * 6, rad = 3 + 1 * depthbead(ctx.faded(k * (0.55 + 0.45 * (depth + 1) / 2)), x: x, y: y, r: rad)diff --git a/app/ChumsWatch/Rig/RayStage.swift b/app/ChumsWatch/Rig/RayStage.swiftindex 32ce0c8..291af21 100644--- a/app/ChumsWatch/Rig/RayStage.swift+++ b/app/ChumsWatch/Rig/RayStage.swift@@ -376,7 +376,8 @@ final class RayStage: Staged {for j in 0..<(dd.count / 6) {let p0 = P2(dd[j * 6], dd[j * 6 + 1]), c = P2(dd[j * 6 + 2], dd[j * 6 + 3]), p1 = P2(dd[j * 6 + 4], dd[j * 6 + 5])let m = (p0 + p1) / 2, out = m / max(0.01, simd_length(m))- let o: P2 = out * (0.035 * sin(st * 38 + Double(j) * 1.9) + 0.12 * outQ(min(1, st / 0.3)) - 0.12)+ let wobble: Double = 0.035 * sin(st * 38 + Double(j) * 1.9), grow: Double = 0.12 * outQ(min(1, st / 0.3))+ let o: P2 = out * (wobble + grow - 0.12)var path = Path()path.move(to: CGPoint(x: p0.x + o.x, y: p0.y + o.y))path.addQuadCurve(to: CGPoint(x: p1.x + o.x, y: p1.y + o.y), control: CGPoint(x: c.x + o.x, y: c.y + o.y))diff --git a/app/ChumsWatch/Rig/Strokes.swift b/app/ChumsWatch/Rig/Strokes.swiftindex 4d7a328..cee64f5 100644--- a/app/ChumsWatch/Rig/Strokes.swift+++ b/app/ChumsWatch/Rig/Strokes.swift@@ -27,7 +27,7 @@ enum Strokes {(0...48).map { i in let a = a0 + (a1 - a0) * Double(i) / 48; return c + P2(cos(a) * (rx ?? r), sin(a) * r) }}static func mirrored(_ g: [P2]) -> [P2] { g.map { P2(-$0.x, $0.y) } }- static func mix(_ a: [P2], _ b: [P2], _ k: Double) -> [P2] { zip(a, b).map { $0 + ($1 - $0) * k } }+ static func mix(_ a: [P2], _ b: [P2], _ k: Double) -> [P2] { zip(a, b).map { (p: P2, q: P2) -> P2 in p + (q - p) * k } }static func length(_ g: [P2]) -> Double { zip(g, g.dropFirst()).reduce(0) { $0 + simd_length($1.1 - $1.0) } }@inline(__always) static func hash(_ a: Double, _ b: Double) -> Double {diff --git a/app/ChumsWatch/Rig/TangleStage.swift b/app/ChumsWatch/Rig/TangleStage.swiftindex 726e797..78b7842 100644--- a/app/ChumsWatch/Rig/TangleStage.swift+++ b/app/ChumsWatch/Rig/TangleStage.swift@@ -867,7 +867,7 @@ final class TangleStage: Staged {}// keep last frame's way unless another is clearly shorter (switching would make the arm jump)if let k = kept, let b = best, k.len < b.len * 1.15 { best = k } else { keep = bestKind }- guard let b = best else { return (1...count).map { p0 + (p1 - p0) * (Double($0) / Double(count)) } }+ guard let b = best else { return (1...count).map { (j: Int) -> P2 in p0 + (p1 - p0) * (Double(j) / Double(count)) } }let l0 = rho * b.a0, ls = simd_length(b.q1 - b.q0)return (1...count).map { k inlet x = b.len * Double(k) / Double(count)@@ -905,8 +905,9 @@ final class TangleStage: Staged {private static let mini: Path = {var p: [P2] = []for i in 0..<90 {- let s = Double(i) / 89, th = TAU * 5 * s, c = P2(cos(TAU * 1.2 * s), sin(TAU * 1.2 * s)) * 30- p.append(c + P2(cos(th), sin(th) * 0.8) * (52 + 10 * sin(TAU * 3 * s)))+ let s = Double(i) / 89, th: Double = TAU * 5 * s, c: P2 = P2(cos(TAU * 1.2 * s), sin(TAU * 1.2 * s)) * 30+ let reach: Double = 52 + 10 * sin(TAU * 3 * s)+ p.append(c + P2(cos(th), sin(th) * 0.8) * reach)}var path = Path(); addRun(&path, p, 0, p.count - 1)return path@@ -917,8 +918,9 @@ final class TangleStage: Staged {if sparkle > 0.02 {for (i, d) in ScribbleArt.deco("01").enumerated() where d.kind == 1 {let c = Self.centroid(d.pts), ph = t * 5 + Double(i) * 1.7- let k = (0.7 + 0.3 * sin(ph)) * sparkle * (state == .done ? outQ(min(1, stateT / 0.5)) : 1)- let pts = d.pts.map { c * (0.9 + 0.1 * sparkle) + ($0 - c) * k }+ let grow: Double = state == .done ? outQ(min(1, stateT / 0.5)) : 1+ let k: Double = (0.7 + 0.3 * sin(ph)) * sparkle * grow, home: P2 = c * (0.9 + 0.1 * sparkle)+ let pts: [P2] = d.pts.map { (q: P2) -> P2 in home + (q - c) * k }g.faded(sparkle * (0.75 + 0.25 * sin(ph))).fill(Strokes.smoothClosed(pts), with: .color(Self.blue))}}@@ -1001,7 +1003,10 @@ enum ScribbleArt {private static func values(_ s: String) -> [Double] {guard let d = Data(base64Encoded: s) else { return [] }let b = [UInt8](d)- return stride(from: 0, to: b.count - 1, by: 2).map { i in Double(Int16(bitPattern: UInt16(b[i]) | UInt16(b[i + 1]) << 8)) / 8 }+ return stride(from: 0, to: b.count - 1, by: 2).map { (i: Int) -> Double in+ let bits: UInt16 = UInt16(b[i]) | (UInt16(b[i + 1]) << 8)+ return Double(Int16(bitPattern: bits)) / 8+ }}private static let decos: [String: [(kind: Int, pts: [P2])]] = decoRaw.mapValues { raw inlet v = values(raw.1), h = raw.0diff --git a/app/ChumsWatch/Rig/Yarn.swift b/app/ChumsWatch/Rig/Yarn.swiftindex 669adb7..19dfa6d 100644--- a/app/ChumsWatch/Rig/Yarn.swift+++ b/app/ChumsWatch/Rig/Yarn.swift@@ -137,7 +137,7 @@ final class Yarn {let span = simd_length(tip - a)let len = onSpool < 0.02 ? 26.0 : max(26 * (1 - onSpool), span * (1 + slack))if rope.isEmpty {- rope = (0..<Self.K).map { i in a + (tipFree - a) * (Double(i) / Double(Self.K - 1)) }; was = rope+ rope = (0..<Self.K).map { (i: Int) -> P2 in a + (tipFree - a) * (Double(i) / Double(Self.K - 1)) }; was = rope// turned from the start so the thread leaves it where it shouldfor _ in 0..<60 {let v = simd_normalize(q.act(endLocal)), ax = simd_cross(v, toward), s = simd_length(ax)diff --git a/app/ChumsWatch/Screen.swift b/app/ChumsWatch/Screen.swiftindex c6d4df1..2c9b5e1 100644--- a/app/ChumsWatch/Screen.swift+++ b/app/ChumsWatch/Screen.swift@@ -221,7 +221,8 @@ final class ScreenModel {static func voiceLike(_ t: Double) -> Double {let word = 0.5 + 0.5 * sin(t * 2.3) * sin(t * 1.1 + 1)let syllable = max(0, sin(t * TAU * 4.7)) * (0.6 + 0.4 * sin(t * 13.1))- return clamp(0.12 + 0.75 * syllable * (0.35 + 0.65 * max(0, word)), 0, 1)+ let level: Double = 0.12 + 0.75 * syllable * (0.35 + 0.65 * max(0, word))+ return clamp(level, 0, 1)}// MARK: touch