fix: ulid API + tolerate missing tmux + dispatch-first endpoint
- coordinator: use `ulid.new().str` (ulid-py 1.x API), not `ULID()` - coordinator._submit: swallow tmux errors so game logic continues - app: split first-prompt dispatch into POST /api/dispatch-first - start.sh: POST /api/dispatch-first ~12s after tmux create - test_coordinator: isolate GAMES_DIR via tmp_path
This commit is contained in:
@@ -4,7 +4,7 @@ import asyncio
|
||||
import random
|
||||
from typing import Any
|
||||
|
||||
from ulid import ULID
|
||||
import ulid
|
||||
|
||||
from ai_chess.chess_game import ChessGame
|
||||
from ai_chess.persistence import save_game
|
||||
@@ -45,7 +45,7 @@ async def start_new_game(state: AppState) -> ChessGame:
|
||||
state.bindings = make_bindings(side_to_agent)
|
||||
state.first_move_sent = {Side.WHITE: False, Side.BLACK: False}
|
||||
state.nudge_count = {Side.WHITE: 0, Side.BLACK: 0}
|
||||
gid = str(ULID())
|
||||
gid = ulid.new().str
|
||||
state.game = ChessGame(
|
||||
game_id=gid,
|
||||
agents={s.value: b.to_dict() for s, b in state.bindings.items()},
|
||||
@@ -74,7 +74,12 @@ class Coordinator:
|
||||
return self.pane_for[side.value]
|
||||
|
||||
async def _submit(self, side: Side, text: str) -> None:
|
||||
await self.tmux.submit(pane=self._pane(side), text=text)
|
||||
# Tmux failures (missing session, dead pane) should not break the game
|
||||
# state machine. Log and continue.
|
||||
try:
|
||||
await self.tmux.submit(pane=self._pane(side), text=text)
|
||||
except Exception as e:
|
||||
print(f"[coordinator] tmux submit to {side.value} failed: {e}", flush=True)
|
||||
|
||||
async def _send_first(self, side: Side, *, opponent_san: str | None,
|
||||
opponent_comment: str | None) -> None:
|
||||
|
||||
Reference in New Issue
Block a user