Skip to content

feat: add POST /v1/rooms/{roomId}/global-variables endpoint#360

Merged
from2001 merged 5 commits intodevelopfrom
claude/issue-357-20260303-1105
Mar 9, 2026
Merged

feat: add POST /v1/rooms/{roomId}/global-variables endpoint#360
from2001 merged 5 commits intodevelopfrom
claude/issue-357-20260303-1105

Conversation

@from2001
Copy link
Collaborator

@from2001 from2001 commented Mar 3, 2026

Closes #357

Add support for updating global variables per room via the FastAPI REST bridge.

Changes

  • GlobalVarStore class for in-memory queued room-level global variables
  • MAX_GLOBAL_VARS = 100 constant (matches server default)
  • RoomBridge.apply_global_now_or_queue / _apply_global / flush_global_vars
  • RoomBridge._loop now flushes global vars when connected
  • New endpoint: POST /v1/rooms/{room_id}/global-variables
  • httpx added as dev dependency for FastAPI TestClient
  • tests/test_rest_bridge.py with 19 unit/endpoint tests

Generated with Claude Code

Add support for updating global variables per room via the FastAPI REST bridge, mirroring the existing client-variables endpoint.

- Add GlobalVarStore class for in-memory queued room-level global vars
- Add MAX_GLOBAL_VARS = 100 constant (matches server default)
- Add RoomBridge.apply_global_now_or_queue / _apply_global / flush_global_vars
- Update RoomBridge._loop to flush global vars when connected
- Add POST /v1/rooms/{room_id}/global-variables endpoint
- Add httpx dev dependency for FastAPI TestClient
- Add test_rest_bridge.py with 19 unit/endpoint tests

Closes #357

Co-authored-by: Masahiro Yamaguchi <from2001@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds room-scoped global variable updates to the FastAPI REST bridge, enabling REST clients to set NetSync global variables per room (issue #357).

Changes:

  • Introduces GlobalVarStore + MAX_GLOBAL_VARS and extends RoomBridge to apply/flush queued global variables.
  • Adds POST /v1/rooms/{room_id}/global-variables endpoint returning per-key state.
  • Adds REST bridge unit/endpoint tests and adds httpx to dev dependencies for FastAPI TestClient.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
STYLY-NetSync-Server/src/styly_netsync/rest_bridge.py Adds global-var queue/store, bridge apply/flush logic, and the new REST endpoint.
STYLY-NetSync-Server/tests/test_rest_bridge.py Adds unit tests for GlobalVarStore, RoomBridge global behavior, and endpoint validation/response.
STYLY-NetSync-Server/pyproject.toml Adds httpx to dev deps to support FastAPI TestClient.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@from2001 from2001 requested a review from 0suu March 3, 2026 12:15
@from2001
Copy link
Collaborator Author

from2001 commented Mar 3, 2026

@0suu The feature was implemented. Test the feature with your environment.

This is a sample command to update global variables.

curl -X POST http://localhost:8800/v1/rooms/default_room/global-variables \
 -H "Content-Type: application/json" \
 -d '{"vars": {"score": "43"}}'

@0suu
Copy link
Collaborator

0suu commented Mar 6, 2026

@from2001
The line-break-only change in client_simulator.py looks like it may have been included unintentionally (possibly due to an auto-formatter/editor).

Other than that, I verified the behavior of the new endpoint and everything looks good. LGTM.

@from2001 from2001 merged commit b4164bc into develop Mar 9, 2026
7 checks passed
@from2001 from2001 deleted the claude/issue-357-20260303-1105 branch March 9, 2026 22:47
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.

support updating global variables via FastAPI

3 participants