Skip to content

fix: name native commander opponents - #6529

Merged
matthewevans merged 3 commits into
mainfrom
ship/fix-name-native-commander-opponents
Jul 23, 2026
Merged

fix: name native commander opponents#6529
matthewevans merged 3 commits into
mainfrom
ship/fix-name-native-commander-opponents

Conversation

@matthewevans

@matthewevans matthewevans commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Improved commander avatar setup for AI game modes to update at the right times.
    • Ensured native AI opponents use the correct commander names when displaying avatar art.

@matthewevans
matthewevans enabled auto-merge July 23, 2026 01:53
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@matthewevans, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 32 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f59dd4fd-89b2-4288-9e8f-da58cb4a046e

📥 Commits

Reviewing files that changed from the base of the PR and between 964d471 and f89ed0b.

📒 Files selected for processing (2)
  • client/src/providers/GameProvider.tsx
  • client/src/providers/__tests__/GameProvider.nativeEngine.test.tsx
📝 Walkthrough

Walkthrough

GameProvider now limits commander-avatar setup to AI games and reruns it only for mode or game changes. Native AI tests add deterministic avatar-fetch mocking and verify commander names are written to multiplayer state.

Changes

Native AI routing

Layer / File(s) Summary
AI-only commander-avatar effect
client/src/providers/GameProvider.tsx
The commander-avatar effect now exits outside AI mode and depends only on mode and gameId.
Native AI commander-name coverage
client/src/providers/__tests__/GameProvider.nativeEngine.test.tsx
Avatar-art fetching is mocked and reset deterministically, while native AI tests verify commander names populate multiplayer state.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • phase-rs/phase#6305: Modifies the same GameProvider and native-engine test paths for commander and avatar routing.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: fixing how native commander opponents are named.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ship/fix-name-native-commander-opponents

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
client/src/providers/GameProvider.tsx (1)

595-611: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Guard against consuming the previous game’s command zone.

On an AI→AI gameId change, this effect can run before the main setup effect cancels the deferred reset and initializes the new game. The immediate store read at Line 604 may therefore see the previous game’s non-empty command_zone; Lines 605–608 then mark the effect applied and unsubscribe, so the new native game is never processed. Commander names and avatars can remain stale or missing.

Gate both the subscription callback and initial read on the store’s current gameId (or equivalent session generation), and add a back-to-back AI game regression test.

As per path instructions, useEffect dependencies must carry the right identity for back-to-back prompts.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@client/src/providers/GameProvider.tsx` around lines 595 - 611, Update the AI
commander-avatar initialization effect around setupCommanderAvatars so both the
store subscription callback and immediate state read only consume state matching
the current gameId (or equivalent session identity), preventing stale
command_zone data from the previous AI game from marking the effect applied.
Ensure the effect dependencies include the identity required for back-to-back AI
games, and add a regression test covering consecutive AI game changes.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@client/src/providers/GameProvider.tsx`:
- Around line 595-611: Update the AI commander-avatar initialization effect
around setupCommanderAvatars so both the store subscription callback and
immediate state read only consume state matching the current gameId (or
equivalent session identity), preventing stale command_zone data from the
previous AI game from marking the effect applied. Ensure the effect dependencies
include the identity required for back-to-back AI games, and add a regression
test covering consecutive AI game changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c452508f-3e86-46e9-a4d6-2f9e15782ce4

📥 Commits

Reviewing files that changed from the base of the PR and between 47118ea and e8b1f86.

📒 Files selected for processing (2)
  • client/src/providers/GameProvider.tsx
  • client/src/providers/__tests__/GameProvider.nativeEngine.test.tsx

@matthewevans
matthewevans force-pushed the ship/fix-name-native-commander-opponents branch from 3bd35ac to f89ed0b Compare July 23, 2026 02:09
@matthewevans
matthewevans added this pull request to the merge queue Jul 23, 2026
Merged via the queue into main with commit 05a4c9f Jul 23, 2026
14 checks passed
@matthewevans
matthewevans deleted the ship/fix-name-native-commander-opponents branch July 23, 2026 02:46
jsdevninja pushed a commit to jsdevninja/phase that referenced this pull request Jul 24, 2026
* fix: name native commander opponents

* fix: import native commander name test store

* fix: isolate commander names by game session

---------

Co-authored-by: matthewevans <matthewevans@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant