diff --git a/client/scripts/contract_hud_controller.gd b/client/scripts/contract_hud_controller.gd index 89f3c74..21e87d0 100644 --- a/client/scripts/contract_hud_controller.gd +++ b/client/scripts/contract_hud_controller.gd @@ -198,7 +198,7 @@ func _detect_and_apply_completion_transitions(snapshot: Dictionary) -> void: _tracked_instance_id = iid var prev_status := str(_previous_status_by_instance.get(iid, "")) var can_detect := not boot_seed or bool(_contract_was_active_in_session.get(iid, false)) - if can_detect and prev_status == "active" and new_status == "completed": + if can_detect and prev_status != "completed" and new_status == "completed": var summary := ContractClient.completion_reward_summary(iid, snapshot) if not summary.is_empty(): _last_reward_instance_id = iid diff --git a/client/test/contract_hud_controller_test.gd b/client/test/contract_hud_controller_test.gd index 3558b90..a28e043 100644 --- a/client/test/contract_hud_controller_test.gd +++ b/client/test/contract_hud_controller_test.gd @@ -220,6 +220,20 @@ func test_reward_label_populates_on_active_to_completed_transition() -> void: assert_str(built["reward_label"].text).contains("Salvage +15 XP") +func test_reward_label_populates_when_first_get_is_already_completed() -> void: + # Arrange — issue marks session active; encounter completes before GET returns active + var built: Dictionary = await _build_controller( + NoopHttpTransport.new(), NoopHttpTransport.new() + ) + var issue_row: Dictionary = (_active_snapshot()["contracts"] as Array)[0] as Dictionary + built["controller"].call("_on_issue_result_received", {"issued": true, "contract": issue_row}) + # Act + built["controller"].call("_on_contracts_received", _completed_snapshot()) + # Assert + assert_str(built["reward_label"].text).contains("Contract rewards:") + assert_str(built["reward_label"].text).contains("Salvage +15 XP") + + func test_completed_get_clears_stale_issue_patch_on_active_label() -> void: # Arrange — simulate successful issue patch still held when encounter-complete GET arrives var built: Dictionary = await _build_controller(