Building a Multi-Agent Token Usage Widget in Under 500 KB —…
    Neura Market
    Neura Market
    /Midjourney
    Marketplace
    Directories
    Resources
    Midjourney
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeekCoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    OverviewPromptsBlogVideosGuidesCoursesCommunityStylesTrending
    MidjourneyBlogBuilding a Multi-Agent Token Usage Widget in Under 500 KB
    Back to Blog
    Building a Multi-Agent Token Usage Widget in Under 500 KB
    gemini

    Building a Multi-Agent Token Usage Widget in Under 500 KB

    JimmyLiao October 22, 2026
    0 views

    How we built a 483 KB zero-WebKit macOS Universal Binary and a single-file Ubuntu HUD with...

    How we built a 483 KB zero-WebKit macOS Universal Binary and a single-file Ubuntu HUD with Gemini 4 Argon to track multi-agent token burn pace.

    Series 2/2: Multi-Model Collaboration & Quota Management in Practice (Part 1: Building a Cross-Model Collaborative Workflow with Google Antigravity)

    Leap EDGE 4×1 + 1×4 + 2×2 Layouts

    When you run tasks in parallel across Google Antigravity (Gemini), Claude Code, OpenAI Codex, and GitHub Copilot, a progress bar that simply says 40% used is not very useful.

    Burning 40% in the first 30 minutes of a 5-hour quota window means you will hit a wall in another hour; burning 40% with 20 minutes left before reset means you have more quota than you can finish.

    To make an always-on desktop quota monitor answer "At my current pace, how much longer can I keep working today?", I worked with the agents to build two things:

    1. A time-pace marker (paceFraction) on every progress bar that calculates the exact clock time a quota pool will run out.
    2. Instead of our original Tauri v2 / WebView plan, a native Swift binary on macOS and a single-file, zero-dependency Tkinter floating bar on Ubuntu—keeping idle CPU at 0.0%.

    Leap EDGE Quota HUD on macOS


    But... One Dimension Was Still Missing: Right Now, Can We Actually Burn Through Our Tokens in Time?

    To know whether a quota pool is about to blow up—or whether it still has plenty of slack—you only need to compare two ratios:

    • usedFraction (colored fill length): The fraction of quota consumed so far.
    • paceFraction (white vertical tick): The fraction of the current reset window (5 hours or 7 days) that has already elapsed.
    usedFraction    = consumed / total
    paceFraction    = 1.0 - (resetsAt - now) / windowDuration
    rate            = usedFraction / paceFraction
    projectedRunOut = windowStart + windowDuration / rate
    

    For example: suppose a 5-hour window starts at 09:00 and resets at 14:00. At 10:00, one-fifth of the window has passed (paceFraction = 20%, so the white tick sits at 20%).

    If you have already used 40% by then, your burn rate is 2x the sustainable pace (rate = 2.0). At that speed, your entire quota will bottom out 5 / 2 = 2.5 hours after the window started—at 11:30.

    So on each Leap EDGE card:

    • When the colored fill outruns the white tick (rate > 1.15), the bar shifts color and lights up a red pill: ▲ RUNS OUT 11:30.
    • When the colored fill stays to the left of the white tick, it shows a blue pill: ⏱ LASTS TO RESET.

    With a single glance, you immediately know whether to route the next heavy task to another AI subscription.

    All of this came out of iterating back and forth with Gemini 4 Argon while designing and tuning the implementation.


    Why Not Tauri v2?

    I already had a 22 KB vanilla HTML/CSS/JS web dashboard (?mode=edge). My initial idea was to wrap it in Tauri v2 (Rust + system WebView) as a desktop widget for macOS and Linux.

    However, this widget isn't used like a normal app: you don't open it for five minutes and close it—it stays pinned to your desktop all day as a background monitor.

    After looking into how macOS handles WebView processes, I decided not to put a WebView in the default path:

    DimensionElectronTauri v2 (Rust + WKWebView)Leap EDGE (Swift Dual-Engine Universal Binary)
    Binary size~220 MB~6 MB (target/ build cache ~800 MB)483 KB (arm64 + x86_64 combined)
    Persistent processes4+ (Chromium)3 (Host + WebKit.WebContent + GPU)1 (pure CoreGraphics by default, zero WebKit)
    Background wakeups & App NapHigh idle drain1s JS setInterval clock keeps waking IPC300s data poll + 60s clock tick (with 5s tolerance)
    macOS desktop integrationNeeds pluginsRequires objc2 FFI for low-level window flagsNative 1-line desktop-level pinning & 👻 Click-Through

    According to Apple's WebKit WKProcessPool documentation and the Apple App Nap Power Efficiency Guide, simply instantiating a WKWebView spawns separate web-content and rendering subprocesses; on top of that, a 1-second JavaScript setInterval for a live clock keeps waking the rendering pipeline.

    Just to draw five fixed-format dark quota cards, the default path doesn't need a browser engine running 24/7.

    So we built a dual-engine switch inside a single leap-edge.swift file:

    1. Native CoreGraphics by Default (⚡ Zero WebKit): Directly parses the /api/usage JSON and draws the five cards (Copilot, AGY, Claude Pro/Team, Codex) plus live macOS Menu Bar indicators using AppKit and NSBezierPath. Idle CPU stays at 0.0%, and it supports window.ignoresMouseEvents = true so mouse clicks pass straight through to the Terminal or IDE behind it.
    2. On-Demand WKWebView (🌐 Web Mode): A WKWebView is created dynamically only when you switch to Web Mode from the Menu Bar; the moment you switch back to native mode or hide the window, it calls removeFromSuperview() and sets the instance to nil, returning all WebKit subprocess memory to the OS.
    3. One-Line Universal Binary: A single 483 KB executable runs natively on both M1 and Intel Macs.

    Bonus: Supporting Landscape & Portrait on Ubuntu Laptops and Tablets

    With both Macs covered, I also have two Ubuntu machines on my desk: a ThinkPad X1 Carbon, and a Surface Pro 7 used for demos and meetings.

    On Linux, we applied the exact same philosophy—a single-file, zero-third-party-dependency leap-edge.py that supports two modes:

    • Terminal / tmux Mode (leap-edge.py --status and --json): Embeds directly into a terminal status bar or lets AI agent scripts query which quota pool still has headroom.
    • X11 / Tkinter Minimal Floating Bar (--gui): Shares the exact same paceFraction math and docks flush against the Ubuntu screen edge (automatically adapting between vertical and horizontal layouts when the tablet rotates between Landscape and Portrait).

    Takeaway: Decide the Usage Pattern First, Then Pick the Tool

    Looking back at this two-day build, the biggest win wasn't saving a few dozen megabytes of RAM—it was clarifying two things:

    1. Quota monitoring must be tied to a timeline.
    2. Always-on utilities and regular applications have different architectural boundaries.

    Thanks for reading.

    Tags

    geminiagentswidgettoken

    Comments

    More Blog

    View all
    Congrats to the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Winners!devchallenge

    Congrats to the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Winners!

    We're excited to announce the winners of the Hacktoberfest Open-Source AI Challenge Week 2: Side...

    J
    Jem
    Building a Multimodal, Suggestion-Based AI Writing Coach with Gemini and Google Docsai

    Building a Multimodal, Suggestion-Based AI Writing Coach with Gemini and Google Docs

    When we use generative AI to proofread our daily writing—whether technical reports, business...

    T
    Tanaike
    926 Steps, Two Lobotomies, and Zero Nudges: Flight-Testing the Commitment Machine Across Gemini, Claude, and GPT-OSSai

    926 Steps, Two Lobotomies, and Zero Nudges: Flight-Testing the Commitment Machine Across Gemini, Claude, and GPT-OSS

    A 2026 Harvard study of 718 companies found that AI agents write 30% more code and close zero additional tickets because review times jump 49%. Here is what happened when I put my 1986 Commitment Machine into live production across Gemini, Claude, and GPT-OSS.

    R
    Randal L. Schwartz
    Two ways to build with Claude models on Google Cloud!claude

    Two ways to build with Claude models on Google Cloud!

    Choose Claude Models on Google Cloud (Google managed) for in-boundary security, regional data...

    J
    Jen Harvey
    Congrats to the Sanity Challenge Winners!devchallenge

    Congrats to the Sanity Challenge Winners!

    We are thrilled to announce the winners of the Sanity Challenge, our partnership with Sanity built...

    J
    Jem
    Building a Cross-Model Collaborative Workflow with Google Antigravitygemini

    Building a Cross-Model Collaborative Workflow with Google Antigravity

    Orchestrating Multiple AI Agents in Parallel via Custom Skills Series 1/2: Multi-Model...

    J
    JimmyLiao

    Stay up to date

    Get the latest Midjourney prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for Midjourney and more.

    Content Types

    • Prompts
    • Blog
    • Videos
    • Guides
    • Courses
    • Community
    • Styles

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.

    Neura Market

    Custom AI Systems & Services

    Our team of experienced AI builders will help build custom AI systems, workflows, and solutions.

    Request custom work

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this Midjourney resource

    • Building a RAG Chatbot for Movie Recommendations with Qdrant and OpenAIn8n · $14.99 · Related topic
    • Bitrix24 Task Form Widget Application Workflow with Webhook Integrationn8n · $14.99 · Related topic
    • Automate Graphic Wallpaper Creation with Midjourney and Canvas APIsn8n · $9.99 · Related topic
    • Automate Profile List Building with Airtop and Google Sheetsn8n · $4.99 · Related topic
    Browse all workflows