lab: AFK menu shows (N ready) count hint with minimal caching #66
Labels
No labels
bug
enhancement
in-progress
needs-info
needs-triage
p0
ready-for-agent
ready-for-human
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/nixos#66
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent
#61
What to build
Surface how many
ready-for-agentissues a project has, so the menu can showStart AFK run (N ready)and grey the action at zero — using only cached counts, so the per-poll render never blocks ontea.Acceptance criteria
ready-for-agentcount for auto-on projects (it already lists them each cycle).⋯menu showsStart AFK run (N ready)when a cached count is available, and greys/disables the action at a cached zero.teacall on the per-poll render path — counts come only from the scheduler's cache.Blocked by
Agent Brief
Category: enhancement
Summary: Show a cached "(N ready)" count on the per-project ⋯ menu's Start AFK run action, greying — but never blocking — the action at a cached zero, with counts sourced only from the auto-run scheduler's in-memory cache (no
teaon the render path).Current behavior:
The per-project ⋯ menu (Forgejo-hosted projects only) shows a plain Start AFK run button with no hint of whether there is anything to do. Clicking it claims the lowest-numbered
ready-for-agentissue, or on an empty queue flashes "No ready-for-agent issues to start." The auto-run scheduler (scheduleAFKRuns) already lists each auto-on project's ready queue every sweep viaTracker.ReadyIssues(which returns the openready-for-agentissues), but keeps only a boolean (ReadyExists = len(issues) > 0) and throws the count away.Desired behavior:
len(issues)) for each auto-on project it sweeps, in an in-memory, project-name-keyed cache on the server (keyed likeAutoEnabled/ConsecutiveFailures). It is not persisted: it re-derives within one sweep interval after a restart, and a stale value carried across a restart would mislead.projectGroup— the struct already carryingAutoEnabled/ConsecutiveFailures/Paused) gains a representation that distinguishes three states: unknown (no cache entry / not auto-on), cached N>0, and cached zero. A bareintcannot separate "unknown" from "cached 0" — use a companion bool or a pointer.snapshot) populates this from the in-memory cache only. Notea/Trackercall may be added to the per-poll render path (it makes none today; that must stay true).Resolved design point — grey-but-clickable at zero: the issue's criteria say both "disable at a cached zero" and "the click is always the source of truth." A hard-disabled control (the template's existing
.menu-item.disabledis a non-clickable<span>) would block the authoritative click when the cached zero is stale (an issue marked ready less than one sweep ago, or auto just toggled on). So a cached zero is greyed as a hint but stays a real submit button; clicking re-checks live and flashes the existing "No ready-for-agent issues" notice when the queue truly is empty. Do not use the HTMLdisabledattribute for the zero state.Key interfaces:
Tracker.ReadyIssues(dir) ([]Issue, error)— already called each sweep;len()of its result is the count. No interface change.scheduleAFKRuns— already lists the ready queue for every auto-on candidate before the launch gate; capture that length into the cache for every auto-on candidate swept, whether or not a launch happens.Server— project-name-keyedint, mutex-guarded in the style of the existingafkRunsMu/store mutex; not added to the persistedprojectState.projectGroup— gains the count + known/unknown representation, set insnapshotfrom the cache (read-only, no tea).shouldLaunchAuto/classifyAFKRun) mapping (autoEnabled, count, known?) -> (suffix, greyed?), so the decision is unit-tested without tmux/tea/clock.Acceptance criteria:
teacall added to the render path.Tracker/store seams) across unknown / N>0 / zero.go test ./...,go vet ./..., andgo buildpass in the lab module. (The repo pre-commit hook is eval-only and does not run Go tests — run them locally.)Out of scope:
handleAFKStartsemantics — the click stays authoritative exactly as it is.teaquery on the render path (even timed) — counts come only from the scheduler cache; stale counts are acceptable by design.projectState/the store file.