fix: sync main agent state to agents-state.json#104
Open
shuai-clawd wants to merge 1 commit intoringhyacinth:masterfrom
Open
fix: sync main agent state to agents-state.json#104shuai-clawd wants to merge 1 commit intoringhyacinth:masterfrom
shuai-clawd wants to merge 1 commit intoringhyacinth:masterfrom
Conversation
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).
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.
Problem
Both
set_state.pyand the/set_stateAPI endpoint only updatestate.json, but the multi-agent view reads the main agent's state fromagents-state.json. This means state changes are invisible in the multi-agent UI.Data flow (before fix):
set_state→state.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
STATE_AREA_MAPdict 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 inagents-state.jsonbackend/app.py
save_state()now calls_sync_main_agent_state()to update the main agent entrystate_to_area()for consistent area mappingVerification
All three area mappings tested and verified via API:
set_state.py idle→ area: breakroomset_state.py writing→ area: writingset_state.py error→ area: error