All workCase study 02 of 03

Cookie

Role
Native app design and engineering
Year
2026
Built with
Swift, SwiftUI, SpriteKit, AppKit, Sparkle, C#

A tiny cat that lives on your desktop. She walks along your windows, sits on the Dock and naps when you stop working. The hard part is being a polite background app.

Cookie's website, where you can try her before installing anything.
Days from first commit to macOS and Windows
10
GitHub
macOS unit tests
126
From the code
macOS disk image, universal binary
24 MB
Measured
Accounts, analytics or cloud calls
0
From the code

Counted from the repository in November 2026: 330 commits, 15,741 lines of Swift and 14,542 lines of C#.

The problem

A desktop pet lives next to your real work.

Cookie runs all day beside whatever you're doing, so her bugs aren't cosmetic. One stolen click or a spinning fan and she gets uninstalled.

She has to know where windows and the Dock are without looking at what's on your screen. She has to feel alive, with moods and habits rather than a looping animation. And all of that has to work offline, with no account.

I built the macOS app in SwiftUI and SpriteKit, then wrote a separate C# version for Windows.

The architecture

How she finds her way around a desktop she can't read.

Click a part, or a step belowWindow list

Window list

In the machine: the measuring arm and three blank panels

Quartz's window list gives Cookie the position of every window, at most once every 0.4 seconds. The arm only ever touches corners: she gets bounds and no screenshots, so she can't see what's on your screen.

  1. Window list: Quartz's window list gives Cookie the position of every window, at most once every 0.4 seconds. The arm only ever touches corners: she gets bounds and no screenshots, so she can't see what's on your screen. (In the machine: the measuring arm and three blank panels.)
  2. Behavior engine: A state machine picks what she does next, with a scheduler, cooldowns and context rules. The dial is the minimum wait between actions on her own: 28, 14 or 7 seconds, depending on her activity setting. (In the machine: the pinned drum and its comb.)
  3. Jump planner: Each jump is a parabola from where she stands to a window's top edge. A landing too close to the edge is clamped 25 points inside, which is the dashed arc correcting itself. (In the machine: the drafting board.)
  4. SpriteKit scene: She renders at 60 FPS awake and 15 asleep, and the scene pauses completely when her window is fully hidden. The governor shows that here, following her as she naps and wakes. (In the machine: the governor.)
  5. Alpha-mask hit test: She lives in a floating panel, but it never steals a click. Her artwork is sampled into a 96 × 101 grid. A click on a clear cell passes through to the app underneath, and one on her artwork is hers. (In the machine: the glass mask.)
  6. Local JSON: Her profile, stats and memory are written atomically to one JSON file, and a corrupt file gets quarantined instead of crashing her. There's no account, analytics or cloud. The only network feature is the signed updater. (In the machine: the strongbox with no wires.)

The macOS architecture, drawn as a machine with every part running at once. The Windows version is a separate C# implementation of the same behavior.

Fig. 1Pick her up on the site's live desk mat.
Fig. 2Treats and toys, each with its own reaction.

The decisions

The calls that shaped her.

  1. Quartz window metadata

    Instead of screenshots or screen analysis

    CGWindowListCopyWindowInfo gives window positions without capturing a single pixel. Scans are throttled to one every 0.4 seconds at most.

    Trade-off She knows where windows are, never what's in them, so she can't react to content.

  2. An alpha-mask hit test

    Instead of a rectangular click area

    The app tests her actual artwork, so a click on a transparent pixel goes through to the app underneath. The same mask tells nose from tail for petting.

    Trade-off The mask has to stay in sync with the artwork.

  3. Frame rate that follows behavior

    Instead of a constant 60 FPS

    She renders at 60 FPS when active and 15 when asleep, and pauses completely when her window is hidden.

    Trade-off Every behavior change also has to think about rendering.

  4. Fully offline, with signed updates

    Instead of accounts and a backend

    Everything is stored as local JSON. The only network feature is the Sparkle updater, which verifies EdDSA signatures.

    Trade-off No usage data, so I have to ask people what they like.

Cookie/Cookie/CookieScene.swift
// Sleeping CPU optimization: run at 15 FPS while sleeping to reduce CPU to ~0%
if let engine = behaviorEngine {
    let targetFPS = engine.state == .sleeping ? 15 : 60
    if view?.preferredFramesPerSecond != targetFPS {
        view?.preferredFramesPerSecond = targetFPS
    }
}

That ~0% is the target in my comment, not a published measurement. Measuring it properly is on the list below.

The failures

What broke.

  1. Landing on the edge of nothing

    Jump targets on top of a window could land too close to its edge.

    Landing points are now clamped to a safe corridor along the window's top.

  2. She kept following after being told to stop

    Cursor following continued after the setting was turned off, and interaction state could outlive the behavior that started it.

    The setting is now checked directly, and ending a behavior resets interaction state and stops the movement interpolator.

  3. Update signatures that didn't match

    Early releases needed the Sparkle signature and file length corrected in the update feed. An incorrect feed means the update gets rejected.

    I corrected the feed for each release, and added cache headers so old website files stopped being served.

  4. A crash path in the hit tester

    Creating the mask's color space and drawing context assumed they could never fail.

    Both are now safely unwrapped.

Where it stands

  • Shipped on macOS and Windows, with a public website, in-app updates and installers.
  • Macs get a universal build for Apple Silicon and Intel, on macOS 14 or later.
  • Open source, and it never sends data anywhere.

What I'd do next

  • Sign and notarize the macOS build. It's ad-hoc signed today, so Gatekeeper warns on first launch.
  • Measure and publish real idle CPU and battery figures on both platforms.
  • Add an opt-in way to hear from users, since there's deliberately no analytics.