$ show rullerzhou-afk/clawd-on-desk
Clawd on Desk is a cross-platform Electron desktop companion application that visually reflects the real-time activity of AI coding agents (Claude Code, Codex, Cursor, Gemini, Kimi, Qwen, and 18+ others) as an animated pet on the user's screen. The application integrates with each agent via hook scripts that intercept lifecycle events (thinking, working, idle, error, etc.) and post state to a local HTTP server, which drives the pet's animations, permission bubbles, and system tray presence. It provides a sophisticated permission management system with local bubble UI, remote approval via Telegram/Feishu/Slack, and session automation policies, all while supporting custom themes, Discord Rich Presence, and a mobile companion PWA. The architecture is an Electron main process orchestrating multiple renderer windows (pet, bubble, settings, dashboard, quota ring, session HUD) with IPC bridges. The state machine resolves session states from multiple agents into a single dominant visual state using priority-based resolution. The codebase is modular with factory functions, dependency injection, and pure math modules that are testable in isolation. It includes a comprehensive theme system with SVG/GIF/APNG support, a doctor/health check system, remote SSH deployment of hooks, and a recap feature for local activity tracking. The project has over 1000 test files and extensive CI/CD pipelines for Windows, macOS, and Linux packaging.
The LLM identified 6 files worth highlighting for reuse:
Pure function module that computes safe window placement from display work areas. Handles empty displays array with synthetic fallback, viewport offset clamping, and virtual bounds materialization. No Electron or DOM dependencies, fully testable in isolation. Reusable in any desktop app needing multi-monitor geometry.
High-confidence secret redaction utility that masks API keys, tokens, Slack webhooks, Authorization headers, and home paths in display strings. Uses regex patterns with bounded replacement to avoid ReDoS. Zero dependencies, can be extracted into any Node.js or browser project needing log/UI sanitization.
Daily metrics aggregation module with schema versioning, row normalization, merging by composite key, and 400-day retention pruning. Implements a batch/flush pattern with delayed writes and quarantine for invalid data. Reusable for any application that needs to aggregate time-series events into daily summaries with safe fanout limits.
SVG sanitizer that removes dangerous tags (script, foreignObject, use with external), CSS URL sanitization, SMIL animation bounds checking, and safe raster reference collection. Uses a narrow allowlist grammar. Reusable in any application that loads user-provided SVG files and needs to prevent XSS or resource abuse.
Atomic JSON file read/write with backup creation, asar-unpacked path resolution, and hook command matching. Writes to temp file then renames to prevent corruption. Reusable in any Node.js application that needs safe configuration file persistence across multiple concurrent writers.
Defines priority constants and resolution logic for session states (error > notification > working > idle > sleeping). Pure function that selects the dominant state from a set of session states. No dependencies, can be extracted into any state machine system needing deterministic priority-based state selection.