feat(usage-queue): at-limit toggle button + timed simulation demo mode - #239
Merged
Conversation
Button: now appears only when at the usage cap (new 'capped' field on /api/usage-queue, computed fresh from usage so the control surfaces before anything is armed). Rendered as an on/off switch — yellow border off, green on — with intent copy clarifying it auto-presses Enter at reset and you queue by typing in the terminal. Hardcoded width so the on/off subtitle never resizes it. Server: export evaluateCap() for the stateless at-cap read; GET /api/usage-queue returns capped + nearest reset. Dev /_simulate gains resetInSec — caps now and auto-clears after N seconds (extracted applySimulatedClear), so you can arm a pane and watch the auto-Enter fire on its own. Tests: button visibility/switch states, hook capped wiring, resetInSec parsing + applySimulatedClear, and a real-spawn integration test that arms a pane, sets capped&resetInSec=2, and asserts a real CC auto-submits when the timer elapses. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UpGRD3fxgWmCKyp9nZtrQs
aterrylu
enabled auto-merge (squash)
June 21, 2026 00:22
nox-0x
approved these changes
Jun 21, 2026
nox-0x
left a comment
Collaborator
There was a problem hiding this comment.
Approving — the at-limit visibility gate, the toggle UX rework, and the timed-reset simulation control all hang together cleanly, with the new evaluateCap correctly separating stateless visibility from the watcher's hysteresis-smoothed blocked.
Notes worth a follow-up (none blocking):
GET /api/usage-queueis now async and awaitsgetRateLimits()on every poll. The scanner's 60s cache absorbs most of it, but a slow claude.ai call can now stall a status response that used to be sync.applySimulatedClear()builds its 'cleared' override withDEFAULT_RESET_SEC(2h13m) in the future — harmless because util=2 makesevaluateCapreturncapped:false, but the stale reset hint is mildly weird.- Minor comment rot in
UsageQueueButton.tsx: the Switch comment says 'amber track' (it's GREEN), and the border comment says '2px' (it's 1.5px).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Follow-up to the usage-queue feature (#232) — refines the overlay control based on live UX review, and adds a timed simulation mode so the auto-Enter can be watched firing on its own.
Button → at-limit toggle
cappedfield onGET /api/usage-queue, computed fresh from usage (via exportedevaluateCap) so the control can show before anything is armed — independent of the watcher's armed-onlyblocked.Auto-Enter when limit resets+Type in the terminal to queue(off) /Sends in ~2h13m(on). Spells out both halves: it auto-presses Enter at reset, and you queue by typing in the terminal yourself.role="switch"for accessibility.Dev simulation: timed reset
POST /api/usage-queue/_simulate?state=capped&resetInSec=Ncaps now and auto-clears after N seconds, firing any armed pane via the server's own countdown — so you can arm a pane and watch the auto-Enter fire with no second call. ExtractedapplySimulatedClear()keeps the timed transition testable. Still gated behindAUTONOMOS_ENABLE_USAGE_SIMULATION.Testing
cappedwiring, optimistic toggle + rollback.resetInSecparsing (set / ignored-for-non-capped / ignored-invalid),applySimulatedClearflips to cleared.capped&resetInSec=2, and asserts a realclaudeauto-submits when the countdown elapses. ✅ Verified passing locally.Notes
🤖 Generated with Claude Code
https://claude.ai/code/session_01UpGRD3fxgWmCKyp9nZtrQs