跪拜 Guibai
← All articles
AI Programming

A Desktop Pet That Reacts to Your AI Coding Agent

By 树下有只猫 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Hooking a lightweight desktop companion into coding-agent hooks turns an opaque background process into a glanceable status display without adding latency. The sprite-sheet pipeline and Tauri shell together keep the whole thing under 40 MB, a practical alternative to heavier Electron-based desktop toys.

Summary

AI video generation tools turn a single character image into short action clips. A Python script then extracts frames, removes white backgrounds, finds loopable segments, and stitches them into compact sprite sheets—quantizing the palette cuts file size by about 85% with no visible loss. The sprite sheet gets wrapped in a Tauri 2 + Svelte 5 shell that runs as a transparent, always-on-top window using roughly 37 MB of memory. A lightweight bridge script attached to the coding agent's hooks POSTs state changes to a local server inside the pet, which plays matching animations: chin-resting for thinking, gear-spinning for tool execution, a V-sign on completion, and sweat drops on errors. The bridge is designed to exit fast and never block the agent. The pet now supports three agents, skin switching, scaling, session-locked monitoring, auto-start, and auto-update. The builder is currently stuck on the next step—adding voice or text dialogue so the pet can execute desktop commands—and is asking for architectural guidance on whether to embed a dialogue loop directly or reuse an existing agent.

Takeaways
AI video generators like Doubao and Jimeng can produce usable character animations from a single static image, but semi-transparent watermarks survive background removal and camera drift must be trimmed out.
Quantizing a flat-shaded cartoon sprite sheet to 256 colors shrinks file size by roughly 85% with no visible quality loss.
A Tauri 2 + Svelte 5 desktop pet runs at about 37 MB resident memory, compared to 150 MB+ for a typical Electron equivalent.
Agent hooks in Cursor, Claude Code, and Codex POST state-change messages to a local server; the pet plays corresponding animations without blocking the agent.
Other desktop pets can overwrite `~/.claude/settings.json` and silently steal hook registrations, causing event loss.
Transparent windows on Windows need shadow borders explicitly disabled, or a thin visible rim appears.
Completion animations that play for only a fraction of a second are invisible to the user; state-hold time must be deliberately extended.
Conclusions

The hardest technical problem isn't generating the art or wiring the hooks—it's the invisible failure modes: stolen hook registrations, sub-second animation playback, and watermark artifacts that only appear after background removal.

Keeping the bridge script non-blocking is the right instinct, but it also means the pet has no back-pressure mechanism; if the agent fires events faster than the pet can render, frames will drop silently.

The jump from a passive status display to a voice-controlled execution agent is a genuine architectural fork—embedding a dialogue loop inside the pet versus routing through an existing agent have completely different security and permission models.

Concepts & terms
Sprite sheet
A single large image that packs multiple animation frames into a grid. The program displays one frame at a time by changing which rectangular region it samples, creating the illusion of motion.
Agent hooks
Extension points in AI coding tools like Cursor, Claude Code, and Codex that trigger user-defined shell commands when the agent changes state—starting to think, executing a tool, finishing a task, or hitting an error.
Tauri
A framework for building desktop applications using a Rust backend and a web-technology frontend. It produces significantly smaller binaries and uses less memory than Electron by relying on the operating system's own webview instead of bundling Chromium.
From the discussion

The conversation orbits around prompt engineering and the fragility of AI-generated desktop pets. One detailed prompt recipe surfaces, splitting a shared character base from per-action state descriptors and routing generation through free-tier image services. A separate thread flags that Codex updates can silently break drag-and-drop, with click-through and hit-zone misalignment offered as likely culprits.

Codex can produce a pet that only spins without the right prompt, implying the default behavior is a fallback loop when action mapping fails.
A reusable prompt structure separates a persistent character description from action-specific state tokens, then feeds the combined prompt to free image generators like Doubao or Jimeng.
Codex updates can break previously working desktop pets, particularly drag-and-drop, and AI-assisted fixes often fail to restore the functionality.
Mouse click-through and incorrect hit-zone definitions are recurring implementation bugs that mimic broken drag-and-drop.
Featured comments
Halifax

What's the prompt? I'm using Codex and it just spins left and right.

树下有只猫  · 1 likes

chibi girl, long dark brown wavy hair, big round glasses, cute round face, big brown eyes, wearing light green oversized sweater with a small pocket patch, white shorts, simple flat 2d cartoon style, thick outlines, solid colors, white background,chibi girl, long dark brown wavy hair, big round glasses, cute round face, big brown eyes, wearing light green oversized sweater with a small pocket patch, white shorts, simple flat 2d cartoon style, thick outlines, solid colors, white background,thinking state, one hand raised touching chin, head tilted slightly to the side, eyes looking upward, thoughtful expression, a glowing yellow lightbulb icon or question mark floating above head, cartoon logic. That's one of the prompts. I generated it with DeepSeek. The first half is shared across all actions, and the part after that is the action-specific prompt you need. I sent it to Doubao or Jimeng — both have free credits you can use.

Halifax  → 树下有只猫

[Fist salute]

绵绵土豆冰

I gave the image to Codex and had it generate a Luo Xiaohei for me, but one Codex update broke compatibility. I had the AI tweak it for ages and still couldn't get drag-and-drop working. Swore off the whole thing...

树下有只猫

Could it be a mouse click-through issue or the desktop pet's hit zone being off? I ran into both of those problems when I was building mine before.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗