Feature: model retry + rejoin on login + 5-min inactivity detection

**Feature 1 — Model retry (client)**
- `ModelCache.gd`: add `evict(url)` to remove failed entries so re-download is possible
- `game_screen.gd`: when GLB load fails, `_schedule_model_retry` queues a 60-second
  retry (up to 10 attempts); `_do_model_retry` evicts + re-downloads and swaps the
  placeholder mesh for the real model if/when it succeeds

**Feature 2 — Rejoin on login (server + client)**
- Server: `GameGetActiveSessionHandler` (`game.get_active_session`) — returns the
  caller's active session ID + phase, or null when no session exists
- Client: `init_screen.gd` checks for an active session after content sync; shows
  a "Rejoin / Concede" dialog when one is found; rejoin navigates to GameScreen with
  the session ID already set so `send_ready` → `AlreadyStarted` → `_fetch_state`

**Feature 3 — 5-minute inactivity detection (server + client)**
- `GameSession`: add `LastActionAt` column + EF migration
  (`20260317000001_AddLastActionAt`)
- `GameHandlerBase.SaveStateAsync`: sets `session.LastActionAt` on every action
- `GameInactivityMonitorService`: background poll every 60 s; when a session hasn't
  had an action in ≥ 5 min, pushes `game.inactive_warning` to the stalled player and
  `game.opponent_inactive` to their opponent (once per session per server lifetime)
- `GameForceConcedeHandler` (`game.force_concede`): lets the waiting player claim
  the win; validates caller is not the active player and `LastActionAt` is stale
- `Game.gd`: new `opponent_inactive` / `inactive_warning` signals + push handlers +
  `send_force_concede()` helper
- `game_screen.gd`: handles `opponent_inactive` with Accept/Wait dialog;
  handles `inactive_warning` with informational popup

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-03-17 09:05:05 -04:00
co-authored by Claude Happy
parent c0e9ffbd18
commit 3ba33275e3
14 changed files with 849 additions and 4 deletions
+24
View File
@@ -25,6 +25,14 @@ signal game_over(winner_account_id: String, win_condition: String,
## Emitted when the server abandons an Initializing session (e.g. server restart).
signal session_abandoned(reason: String)
## Emitted when the active player has been inactive for 5 minutes.
## The local player (waiting for opponent) can call send_force_concede() to claim a win.
signal opponent_inactive(session_id: String)
## Emitted when the local player has been flagged as inactive.
## Show a warning — the opponent may accept a forfeit.
signal inactive_warning(session_id: String)
# ── State ─────────────────────────────────────────────────────────────────────
var session_id : String = ""
@@ -194,6 +202,10 @@ func send_concede() -> void:
_game_request("game.concede", {})
func send_force_concede() -> void:
_game_request("game.force_concede", {})
func send_ascend(incoming_card_instance_id: String) -> void:
_game_request("game.ascend",
{ "incomingCardInstanceId": incoming_card_instance_id })
@@ -289,3 +301,15 @@ func _on_server_push(type: String, payload: Variant) -> void:
print("[Game] session abandoned: ", reason)
_clear_state()
session_abandoned.emit(reason)
"game.opponent_inactive":
var d := payload as Dictionary
var sid : String = str(d.get("sessionId", ""))
print("[Game] PUSH opponent_inactive session=", sid)
opponent_inactive.emit(sid)
"game.inactive_warning":
var d := payload as Dictionary
var sid : String = str(d.get("sessionId", ""))
print("[Game] PUSH inactive_warning session=", sid)
inactive_warning.emit(sid)
@@ -29,6 +29,15 @@ func _ready() -> void:
DirAccess.make_dir_recursive_absolute(_CACHE_DIR)
## Remove a cached entry (memory + disk) so the next load_model call re-downloads it.
## Use before retrying a previously-failed URL.
func evict(url: String) -> void:
_mem.erase(url)
var disk := _disk_path(url)
if FileAccess.file_exists(disk):
DirAccess.remove_absolute(disk)
## Request a model by CDN URL.
## callback(node: Node3D) is called on the main thread; node may be null.
## If the same URL is already downloading, callbacks are queued and all