Skip to content

Conversation

@neph1
Copy link
Owner

@neph1 neph1 commented Nov 26, 2025

reset_story command
add websocket api

Copilot AI and others added 30 commits November 22, 2025 20:04
- Added FastAPI, websockets, and uvicorn to requirements.txt
- Created TaleFastAPIApp class with WebSocket endpoint in if_browser_io.py
- Updated HttpIo class to support both WSGI and FastAPI modes
- Modified driver_if.py to support WebSocket mode via use_websocket flag
- Updated script.js to support WebSocket connections with EventSource fallback
- WebSocket sends/receives JSON messages for bidirectional communication

Co-authored-by: neph1 <[email protected]>
- Added --websocket flag to main.py for enabling WebSocket mode
- Updated aiohttp requirement to >=3.9.0 for Python 3.12 compatibility
- WebSocket mode can now be enabled with: python -m tale.main --game <path> --web --websocket

Co-authored-by: neph1 <[email protected]>
- Extract error message display logic into reusable function in script.js
- Remove unused Empty exception import from if_browser_io.py
- Fix WebSocket exception handling to remove unreachable code
- Fix JavaScript syntax error in protocol detection
- Add documentation for WebSocket feature (WEBSOCKET.md)

Co-authored-by: neph1 <[email protected]>
- Fix race condition in WebSocket connection detection using connectionEstablished flag
- Add adaptive timeout in WebSocket loop: short timeout (0.1s) when active, long timeout (0.5s) when idle
- Reduce CPU usage by sleeping longer (0.1s) when no activity detected
- Improve error handling for initial connection failures vs established connection errors

Co-authored-by: neph1 <[email protected]>
- Add error handling for WebSocket send failures with fallback to AJAX
- Extract sendViaAjax helper function to reduce code duplication
- Improve WebSocket exception handling with proper logging and traceback
- Add specific handling for asyncio.CancelledError
- Extract _process_command method to eliminate duplicate command processing logic
- Add player context to error messages for better debugging

Co-authored-by: neph1 <[email protected]>
- Created IMPLEMENTATION_SUMMARY.md with complete implementation details
- Documented all components, message protocol, and quality assurance
- Added testing recommendations and future enhancement ideas
- Includes compatibility notes and usage examples

Co-authored-by: neph1 <[email protected]>
…layer_connection

The player_connection object doesn't have a driver attribute. Changed to access
story config through self.fastapi_server.driver.story.config instead of
player_connection.driver.story.config in singleplayer_mainloop method.

Co-authored-by: neph1 <[email protected]>
…er to server

The HttpIo.__init__() signature was changed to use 'server' instead of 'wsgi_server'
as part of the WebSocket implementation. Updated the tests to use the new parameter name.

Co-authored-by: neph1 <[email protected]>
Add WebSocket support to browser IO using FastAPI
Add !reset_story wizard command to restart story without server restart
Remove EventSource-based WSGI API from IF mode
fix items and races in prancing llama
@neph1 neph1 marked this pull request as ready for review November 29, 2025 08:46
@neph1 neph1 changed the title prepare v0.42.0 update v0.42.0 Nov 29, 2025
@neph1 neph1 merged commit 90fab26 into master Nov 29, 2025
1 check passed
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.

2 participants