Crew Agent Shows Stale "7 IN FLIGHT" Count #75
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_shrimp#75
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?
The backend crew agent shows WORKING · 7 IN FLIGHT even though the Dashboard shows 0 active jobs. The in-flight counter is stale/not syncing correctly with actual job state.
Implementation Spec for Issue #75: Crew Agent Shows Stale "7 IN FLIGHT" Count
Objective
Fix the crew agent status label so the "WORKING · N IN FLIGHT" count reflects the actual number of in-flight asks. The count must drop to 0 (and the agent must read "idle") once its asks have been delivered or failed, matching the Dashboard's 0-active-jobs view.
Root Cause Analysis
The crew agent status label is computed by
statusOf()incrates/hero_shrimp_web/ui/src/components/CrewPage.tsx(lines 143-157). It classifies anaskmessage as "in flight" unless its status is one of:The backend never produces any of those three statuses. The agent-message (mailbox) status lifecycle, set in
crates/hero_shrimp_server/src/rpc/methods/crew/mod.rs(crew_tick), is exactly:So every
askever sent to an agent has statusdelivered(orfailed) once finished — neither of which is in["replied", "done", "completed"]. Result:statusOfcounts every historically-delivered ask as "in flight" forever. After 7 asks to one agent, the card permanently reads "WORKING · 7 IN FLIGHT", even though all jobs are long done and the Dashboard correctly shows 0 active jobs.This is a vocabulary desync between two sources of truth:
agents.statuscolumn (working/idle), maintained bycrew_tick. The Dashboard/TopBar crew badge uses this correctly (store.ts,a.status === "working").statusOfre-derives "working/in flight" from theagent_messageshistory using a status set that can never match a terminal message.Corroborating evidence that the correct vocabulary is
["delivered", "failed"]: the two other in-flight checks in the SAME file already use it correctly:anyAskInFlight()— CrewPage.tsx lines 99-107 (s === "delivered" || s === "failed"=> not in flight)inFlight()inFocusedAgent— CrewPage.tsx lines 609-617 (same)Only
statusOf(line 147) uses the wrong set.Requirements
pendingordispatched).deliveredorfailed) must NOT be counted.delivered/failedvocabulary already used byanyAskInFlightandinFlightin the same file.Files to Modify
crates/hero_shrimp_web/ui/src/components/CrewPage.tsx— primary and only required change. Fix the terminal-status set instatusOfso delivered/failed asks are excluded from the in-flight filter.Implementation Plan
Step 1: Fix the in-flight filter vocabulary in
statusOfFiles:
crates/hero_shrimp_web/ui/src/components/CrewPage.tsxstatusOf(lines 143-157), change the terminal-status exclusion list in theinflightfilter (lines 145-147) from the non-existent["replied", "done", "completed"]to the actual backend terminal statuses["delivered", "failed"].deliveredand NOTfailed(i.e. it ispending,dispatched, or empty/unknown). This matchesanyAskInFlight()(line 103) andinFlight()(line 613).pending|dispatched|delivered|failedfor agent messages; excludingdelivered/failedmakes the count drop to 0 once all asks finish, fixing the stale "7 IN FLIGHT".Step 2 (recommended): De-duplicate the terminal-status predicate
Files:
crates/hero_shrimp_web/ui/src/components/CrewPage.tsxaskInFlight(status?: string): booleanreturning!["delivered","failed"].includes((status||"").toLowerCase()), and use it in all three places:statusOf(Step 1),anyAskInFlight(lines 99-107), andinFlight(lines 609-617).Step 3: Verify the build and the count
Files: none (verification only)
hero_shrimp_web, UI undercrates/hero_shrimp_web/ui). Confirm the AgentCard label transitions from "working · N in flight" to "idle · last replied" once all replies land, and the "working in parallel" band disappears.Acceptance Criteria
delivered), its CrewPage card shows "idle · last replied" with no "in flight" count.pendingordispatched) shows "working · N in flight" with N = the count of non-terminal asks only.failedask does not inflate the in-flight count.crew.messagesstatus values unchanged.Notes
working · ${inflight.length} in flightrendered through anuppercaseTailwind class on the AgentCard status pill. No string/case change is needed — only the count logic.anyAskInFlightorinFlightto matchstatusOf— they are already correct;statusOfis the outlier.SHRIMP_AGENT_DISPATCH_MAX_SECS, default 1200s) that transitions a truly-hungdispatchedask tofailed. With the fix this also correctly clears such an ask from the in-flight count.Verification Results
The fix is frontend-only (SolidJS UI in
crates/hero_shrimp_web/ui). There is no unit-test harness for this component; verification was done via the production build and the embedding crate compile.npm run build-> vite): PASScargo build -p hero_shrimp_web, which embeds the rebuilt static assets): PASSChange summary
statusOf()now derives "in flight" from the actual backend terminal statuses (delivered/failed) instead of the non-existent set["replied", "done", "completed"]. A shared module-level helperaskInFlight(status)is now the single source of truth, used by all three derivations (statusOf,anyAskInFlight,inFlight) so they can no longer drift apart.Expected behavior after fix
delivered) no longer counted -> card reads "idle - last replied", count drops to 0.pending/dispatchedasks are counted as in flight.failedasks do not inflate the count.Implementation Summary
Fixed the stale "WORKING - N IN FLIGHT" count on the crew agent cards.
Root cause
statusOf()incrates/hero_shrimp_web/ui/src/components/CrewPage.tsxfiltered out finished asks using["replied", "done", "completed"]— statuses the backend never emits. The backend mailbox lifecycle ispending -> dispatched -> delivered/failed, so every completed ask kept being counted as "in flight" forever. After 7 asks to an agent, the card permanently showed "7 IN FLIGHT" while the Dashboard correctly showed 0 active jobs.Changes
Files modified:
crates/hero_shrimp_web/ui/src/components/CrewPage.tsxaskInFlight(status)— the single source of truth for whether an ask is unfinished (lowercased status notdeliveredand notfailed).statusOf()now usesaskInFlight()instead of the bogus["replied","done","completed"]set, so the in-flight count only includespending/dispatchedasks.anyAskInFlight()andinFlight()(FocusedAgent) to use the same helper, removing the duplicated inline checks that allowed the original drift.crates/hero_shrimp_web/static/index.htmlandcrates/hero_shrimp_web/static/assets/*— regenerated production bundle.No backend changes — the backend status values were already correct.
Verification
Notes
failedasks no longer inflate the count.