Skip to content

Clantag#4013

Open
ryanbarlow97 wants to merge 17 commits into
mainfrom
clantag
Open

Clantag#4013
ryanbarlow97 wants to merge 17 commits into
mainfrom
clantag

Conversation

@ryanbarlow97
Copy link
Copy Markdown
Contributor

If this PR fixes an issue, link it below. If not, delete these two lines.
Resolves #(issue number)

Description:

enforce clantag - makes it so you cant use a tag for a clan that exists

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

Please put your Discord username so you can be contacted if a bug or regression is found:

w.o.n

@ryanbarlow97 ryanbarlow97 added this to the v32 milestone May 26, 2026
@ryanbarlow97 ryanbarlow97 self-assigned this May 26, 2026
Copilot AI review requested due to automatic review settings May 26, 2026 11:39
@ryanbarlow97 ryanbarlow97 requested a review from a team as a code owner May 26, 2026 11:39
@ryanbarlow97 ryanbarlow97 added Backend Server-side features and systems - lobbies, matchmaking, accounts, APIs, etc. UI/UX UI/UX changes including assets, menus, QoL, etc. Feature labels May 26, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eddf52d3-cc45-48bb-8a74-1ec9d4015ee8

📥 Commits

Reviewing files that changed from the base of the PR and between 590f044 and 87b69eb.

📒 Files selected for processing (12)
  • resources/lang/en.json
  • src/client/ClanApi.ts
  • src/client/ClanTagInput.ts
  • src/client/Main.ts
  • src/client/identity/IdentityReadyController.ts
  • src/client/identity/IdentityStore.ts
  • src/core/ApiSchemas.ts
  • src/server/ClanTagOwnership.ts
  • tests/client/IdentityStore.test.ts
  • tests/client/clan/ClanApiQueries.test.ts
  • tests/core/ApiSchemas.test.ts
  • tests/server/ClanTagOwnership.test.ts
💤 Files with no reviewable changes (1)
  • tests/client/clan/ClanApiQueries.test.ts
✅ Files skipped from review due to trivial changes (2)
  • tests/core/ApiSchemas.test.ts
  • resources/lang/en.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/client/ClanTagInput.ts
  • src/client/Main.ts
  • src/client/identity/IdentityStore.ts

<review_stack_artifact>

</review_stack_artifact>

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.91% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Clantag' is vague and does not clearly convey the main change—enforcing clan tag uniqueness by preventing use of existing clan tags. Use a more descriptive title like 'Enforce clan tag ownership and existence validation' to clarify the main feature being implemented.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description explains the core feature ('enforce clantag - makes it so you cant use a tag for a clan that exists'), which directly relates to the changeset covering clan tag validation, ownership checks, and UI integration.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

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

⚠️ Outside diff range comments (1)
src/client/SinglePlayerModal.ts (1)

647-715: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate identity before dispatching join-lobby.

After this modal opens, the player can still change the username or clan tag. This path closes the modal immediately and relies on Main.handleJoinLobby() to do the real async clan-tag check later. If that later validation fails, the game never starts and the player loses all the single-player settings they just configured.

💡 Possible fix
     const usernameInput = document.querySelector(
       "username-input",
     ) as UsernameInput;
     const clanTagInput = document.querySelector(
       "clan-tag-input",
     ) as ClanTagInput | null;
 
+    await clanTagInput?.awaitValidation();
+    if (clanTagInput && !clanTagInput.validateOrShowError()) return;
+    if (!usernameInput.validateOrShowError()) return;
+
     await crazyGamesSDK.requestMidgameAd();
🤖 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 `@src/client/SinglePlayerModal.ts` around lines 647 - 715, The code dispatches
"join-lobby" and closes the modal before validating the player's identity
(username/clan tag), which can cause loss of configured single-player settings
if later async validation fails; instead, call and await the existing async
validation routine for the clan tag/username (the same check
Main.handleJoinLobby would use) using the values from
usernameInput.getUsername() and clanTagInput?.getValue() before dispatching the
CustomEvent("join-lobby") and only call this.close() after validation succeeds;
on validation failure keep the modal open and surface the validation error to
the user so their configured game settings (e.g., selectedMap, gameMode, bots,
etc.) are preserved.
🤖 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.

Inline comments:
In `@src/client/ClanTagInput.ts`:
- Around line 140-166: Capture the current generation (this.checkCounter) into a
local const (e.g., const generation = this.checkCounter) before creating the
debounce Promise / setTimeout or before scheduling the immediate check, and when
resolving call a wrapper that first compares generation !== this.checkCounter
and if different returns a resolved Promise (no-op) otherwise calls
this.checkOwnership(tag); update the debounce.then and the immediate scheduling
path (and the analogous block at the later 186-189 code) to use this generation
guard so cancelled/stale tasks do not run getUserMe()/fetchClanExists().
- Around line 191-205: The async validation currently lets rejections from
getUserMe() or fetchClanExists() bubble out; wrap both awaits in try/catch so
any thrown error results in calling this.reject(tag) and returning (keeping the
stillCurrent() checks intact), ensuring currentCheck/awaitValidation always
resolves via reject(tag) instead of propagating exceptions; specifically, catch
errors around getUserMe() and around fetchClanExists(tag) and funnel them to
this.reject(tag).

In `@src/server/Worker.ts`:
- Around line 367-388: The fast-path using gm.peekClientIdentity and
gm.rejoinClient incorrectly skips later ownership re-validation for reconnects
when a clan tag is present; restrict this shortcut to only apply when the clan
tag is null by checking existingIdentity.clanTag (or censoredClanTag) === null
before returning, so that resolveClanTag(...) still runs for any reconnect that
has a non-null clan tag and triggers the proper ownership validation.

---

Outside diff comments:
In `@src/client/SinglePlayerModal.ts`:
- Around line 647-715: The code dispatches "join-lobby" and closes the modal
before validating the player's identity (username/clan tag), which can cause
loss of configured single-player settings if later async validation fails;
instead, call and await the existing async validation routine for the clan
tag/username (the same check Main.handleJoinLobby would use) using the values
from usernameInput.getUsername() and clanTagInput?.getValue() before dispatching
the CustomEvent("join-lobby") and only call this.close() after validation
succeeds; on validation failure keep the modal open and surface the validation
error to the user so their configured game settings (e.g., selectedMap,
gameMode, bots, etc.) are preserved.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6d3d3760-30a1-4c74-9a78-19d4d0230717

📥 Commits

Reviewing files that changed from the base of the PR and between 2d6342c and 1e14b88.

📒 Files selected for processing (18)
  • resources/lang/en.json
  • src/client/ClanApi.ts
  • src/client/ClanTagInput.ts
  • src/client/GameModeSelector.ts
  • src/client/LangSelector.ts
  • src/client/Main.ts
  • src/client/SinglePlayerModal.ts
  • src/client/UsernameInput.ts
  • src/client/components/PlayPage.ts
  • src/core/ApiSchemas.ts
  • src/server/ClanTagOwnership.ts
  • src/server/GameManager.ts
  • src/server/GameServer.ts
  • src/server/Worker.ts
  • tests/client/ClanTagInput.test.ts
  • tests/client/clan/ClanApiQueries.test.ts
  • tests/server/ClanTagOwnership.test.ts
  • tests/server/GameLifecycle.test.ts

Comment thread src/client/ClanTagInput.ts Outdated
Comment thread src/client/ClanTagInput.ts Outdated
Comment thread src/server/Worker.ts

This comment was marked as outdated.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 26, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend Server-side features and systems - lobbies, matchmaking, accounts, APIs, etc. Feature UI/UX UI/UX changes including assets, menus, QoL, etc.

Projects

Status: Development

Development

Successfully merging this pull request may close these issues.

2 participants