fix(client): address PR #24 review — 5 critical bugs, 3 warnings, 8 suggestions

Critical:
- Protocol test assertions updated v6→v7 (test_protocol_v6.gd)
- Dialogue signal connections wired (option_selected→DialogueResponse,
  dialogue_dismissed→DialogueEnd sent to server via SimBridge)
- Consume-once race fixed: _consume_dialogue() checks is_dialogue_active()
  before re-showing; dialogue_id tracking prevents re-trigger during fade
- Dialogue box responsive: _update_layout() clamps width to MAX_WIDTH_PX
  (832px) or 65% viewport, height to 20% viewport (MAX_HEIGHT_RATIO)
- Auto-pause added: SimBridge.send_input(PAUSE) on dialogue open/close

Warnings:
- Test coverage: 16 new tests in test_protocol_v7.gd (pending_recognitions
  decode, current_dialogue, GameState, SimBridge mock data, insert colors)
- queue_redraw() optimization: early return when no entities and no pings
- Fixed 200px height → responsive 20% viewport via _update_layout()

Suggestions:
- WASD detection refactored to _WALK_AWAY_ACTIONS array loop
- Button colors reference Constants.INSERT_COLOR_TEXT/HOVER/ACTIVE
- Named constants: COLOR_TRANSITION_START, SILHOUETTE_APPEAR_THRESHOLD,
  SILHOUETTE_SIZE with explanatory comments
- Bounds check: MAX_PENDING_RECOGNITIONS=64 with truncation warning
- Mock dialogue sustained across ticks (not 1-tick flash)
- COLOR_PING coupling with cursor documented as intentional
- Consume helpers extracted: _consume_monologue(), _consume_dialogue()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-16 01:30:15 +01:00
co-authored by Claude Opus 4.6
parent 90a80e73df
commit 6d6b59c17b
9 changed files with 430 additions and 47 deletions
+9 -9
View File
@@ -25,21 +25,21 @@ func _load_fixture(name: String) -> PackedByteArray:
# -- Protocol version upgrade -------------------------------------------------
func test_protocol_version_is_6() -> void:
assert_that(Protocol.PROTOCOL_VERSION).is_equal(6)
func test_protocol_version_is_7() -> void:
assert_that(Protocol.PROTOCOL_VERSION).is_equal(7)
func test_fixtures_at_protocol_version_6() -> void:
# All regenerated fixtures should be at v6
func test_fixtures_at_protocol_version_7() -> void:
# All regenerated fixtures should be at v7
for fixture_name in ["snapshot_one_npc", "snapshot_empty", "snapshot_player", "snapshot_multi_entity"]:
var bytes = _load_fixture(fixture_name)
var snapshot = Protocol.decode_snapshot(bytes)
assert_that(snapshot).is_not_null()
assert_that(snapshot.version).is_equal(6)
assert_that(snapshot.version).is_equal(7)
func test_rejects_version_5() -> void:
var raw := {"tick": 1, "version": 5, "entities": []}
func test_rejects_version_6() -> void:
var raw := {"tick": 1, "version": 6, "entities": []}
var encoded = Messagepack.encode(raw)
var snapshot = Protocol.decode_snapshot(encoded.value)
assert_that(snapshot).is_null()
@@ -281,10 +281,10 @@ func test_sim_bridge_test_snapshot_has_player_inventory() -> void:
assert_that(snap.player_inventory is Array).is_true()
func test_sim_bridge_test_snapshot_version_6() -> void:
func test_sim_bridge_test_snapshot_version_7() -> void:
SimBridge.reset_test_state()
var snap = SimBridge._test_snapshot()
assert_that(snap.version).is_equal(6)
assert_that(snap.version).is_equal(7)
# -- Fixture: v6 snapshots include new fields ----------------------------------