Skip to content

fix: sync main agent state to agents-state.json#104

Open
shuai-clawd wants to merge 1 commit intoringhyacinth:masterfrom
shuai-clawd:fix/set-state-sync
Open

fix: sync main agent state to agents-state.json#104
shuai-clawd wants to merge 1 commit intoringhyacinth:masterfrom
shuai-clawd:fix/set-state-sync

Conversation

@shuai-clawd
Copy link
Copy Markdown

Problem

Both set_state.py and the /set_state API endpoint only update state.json, but the multi-agent view reads the main agent's state from agents-state.json. This means state changes are invisible in the multi-agent UI.

Data flow (before fix):

  • set_statestate.json/status → sprite animation (works)
  • agents-state.json/agents → agent list icons (stale - only initialized at startup)

Solution

Added sync functions to both paths:

set_state.py

  • Added STATE_AREA_MAP dict for canonical state-to-area mapping (idle to breakroom, error to error, others to writing)
  • save_state() now calls _sync_main_agent() to update the main agent entry in agents-state.json

backend/app.py

  • save_state() now calls _sync_main_agent_state() to update the main agent entry
  • Uses existing state_to_area() for consistent area mapping

Verification

All three area mappings tested and verified via API:

  • set_state.py idle → area: breakroom
  • set_state.py writing → area: writing
  • set_state.py error → area: error

Both set_state.py and the /set_state API endpoint previously only
updated state.json. The multi-agent view reads from agents-state.json,
so the main agent's state changes were invisible in the UI.

This commit adds sync functions to both paths, ensuring state.json
changes are reflected in agents-state.json with the correct area
mapping (breakroom/writing/error) via the canonical STATE_AREA_MAP
(set_state.py) and state_to_area() (app.py).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant