Add collapsible left "Script State" drawer on the play screen

Exposes the scripting `state` object (every variable scripts read/write
via state.x, persisted per-adventure) in a collapsible left rail that
refreshes after each turn. New owner-scoped GET
/api/adventures/{id}/script-state endpoint; the drawer only fetches
while open and shows an empty-state hint until a script sets a variable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEpWMjnfPqzZ13nPMoGhs5
This commit is contained in:
parththakkar106
2026-07-20 17:59:16 +05:30
co-authored by Claude Opus 4.8
parent fdb13a2c19
commit f067ddb766
4 changed files with 133 additions and 0 deletions
+11
View File
@@ -141,6 +141,17 @@ def get_adventure(
return get_adventure_or_404(adventure_id, db, user)
@router.get("/{adventure_id}/script-state")
def get_script_state(
adventure_id: int, db: Session = Depends(get_db), user: models.User = CurrentUser
):
"""The scripting `state` object — every variable scripts read/write via
`state.x`, persisted after each hook. Empty {} until a script sets one."""
adventure = get_adventure_or_404(adventure_id, db, user)
state = adventure.script_state if isinstance(adventure.script_state, dict) else {}
return {"state": state}
@router.patch("/{adventure_id}", response_model=schemas.AdventureOut)
def update_adventure(
adventure_id: int,