Add DM typing indicator to the game chat

The server broadcasts a "typing" event to the whole room right when
it starts the DM turn, and broadcasts turn failures to everyone too
(previously only the sender saw them, which would've left other
players' indicators stuck forever). The frontend shows a pulsing
"Dungeon Master schreibt …" line that clears once the real reply or
an error arrives.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Thorsten
2026-09-01 07:59:10 +02:00
parent 9d378a1eb0
commit ec53ed3aba
4 changed files with 24 additions and 4 deletions
+2 -1
View File
@@ -118,12 +118,13 @@ async def game_websocket(websocket: WebSocket, game_id: uuid.UUID, ticket: str)
game_id,
{"type": "message", "message": await _serialize_message(session, player_message)},
)
await manager.broadcast(game_id, {"type": "typing"})
try:
dm_message = await run_dm_turn(session, game_id, latest_player_message=content)
except Exception: # noqa: BLE001
logger.exception("DM turn failed for game %s", game_id)
await websocket.send_json({"type": "error", "detail": "dm_turn_failed"})
await manager.broadcast(game_id, {"type": "error", "detail": "dm_turn_failed"})
continue
await manager.broadcast(