Skip to content

Conversation

@dthlss26
Copy link

@dthlss26 dthlss26 commented Oct 15, 2025

Description:

I’ve implemented a modal that appears when #login=cancel is present in the URL after login through discord is cancelled. The modal explains the benefits of being logged in and asks the user if they’d like to try again. If they choose to retry, the current modal closes and the login modal opens again.

Solves: #1031

image

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:

dthlss

@dthlss26 dthlss26 requested a review from a team as a code owner October 15, 2025 14:23
@CLAassistant
Copy link

CLAassistant commented Oct 15, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Walkthrough

Adds a new translation group and a LitElement LoginCancelledModal component, inserts the component into the page HTML, and wires Client to initialize and open it when the URL hash is #login=cancel.

Changes

Cohort / File(s) Summary
Translations
resources/lang/en.json
Adds top-level login_cancelled_modal with title, benefits_title, benefits_discord, benefits_patterns, benefits_stats, button_cancel, and button_try_again; ensured player_stats_tree is closed before this key.
New Modal Component
src/client/LoginCancelledModal.ts
Adds exported LoginCancelledModal LitElement component that renders a translated modal with benefits list, divider, and Cancel / Try again buttons; exposes async open() and close() methods; tryAgain() closes this modal and opens AccountModal if present.
Client Wiring
src/client/Main.ts
Imports LoginCancelledModal, adds private loginCancelledModal field, queries/initializes it with a runtime check, and opens it when hash equals #login=cancel.
HTML Integration
src/client/index.html
Adds <login-cancelled-modal> element to the page markup near other UI components.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant URL as Browser URL Hash
  participant Main as Client (Main)
  participant LCM as LoginCancelledModal
  participant AM as AccountModal

  U->>URL: Navigate with #login=cancel
  URL->>Main: Hash change detected
  Main->>LCM: open()
  LCM-->>U: Render "login cancelled" modal

  alt User clicks "Try again"
    U->>LCM: Click Try again
    LCM->>LCM: close()
    LCM->>AM: find + open()
    AM-->>U: Show account modal
  else User clicks "Cancel"
    U->>LCM: Click Cancel
    LCM->>LCM: close()
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Potential attention points:

  • LoginCancelledModal.tryAgain() interaction with AccountModal lookup and lifecycle.
  • Translation key presence and fallback behavior in translateText usage.
  • Runtime type assertion / query in Main.ts to ensure no null/undefined.

Possibly related PRs

Suggested labels

Translation - New, UI/UX

Suggested reviewers

  • evanpelle
  • scottanderson
  • Aotumuri

Poem

A hash in the URL whispered "try once more",
A modal appeared with benefits to explore.
Cancel to rest, or try again and see —
Account's door opens, new paths to be. 🚪✨

Pre-merge checks

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "implemented login cancelled modal" directly corresponds to the main objective of the changeset. The pull request adds a new LoginCancelledModal component, translation strings, DOM integration, and routing logic—all centered around implementing this modal feature. The title is concise, specific, and clearly communicates the primary change without unnecessary noise or vague language.
Description Check ✅ Passed The description is directly related to the changeset and provides meaningful context about the implementation. It explains the modal's purpose (appearing when #login=cancel is in the URL), its behavior (displaying login benefits and offering to retry), and references the GitHub issue it solves. The author also confirms completion of important requirements including screenshots, translation handling, testing, and thorough testing—all of which are relevant to the changes introduced.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 47c504a and c0e03f6.

📒 Files selected for processing (3)
  • resources/lang/en.json (1 hunks)
  • src/client/Main.ts (4 hunks)
  • src/client/index.html (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • resources/lang/en.json
  • src/client/Main.ts
  • src/client/index.html

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
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: 2

🧹 Nitpick comments (3)
src/client/LoginCancelledModal.ts (3)

10-13: Consider extracting the modal element type.

While the inline type definition works, you could extract it to a shared interface if multiple components need to reference the modal element type. This is optional.

Example:

interface ModalElement extends HTMLElement {
  open: () => void;
  close: () => void;
}

@query("o-modal") private modalEl!: ModalElement;

15-17: Remove unnecessary empty constructor.

The constructor only calls super() without additional logic. In TypeScript, this is unnecessary and can be removed. The parent constructor is automatically called.

-  constructor() {
-    super();
-  }
-

70-73: Consider removing async modifier and clarify requestUpdate usage.

The open() method is marked async but doesn't await anything. Unless you plan to add async operations later, the async keyword can be removed.

Additionally, requestUpdate() is typically used when reactive properties change. Since you're only calling modalEl.open(), verify if requestUpdate() is necessary here.

-  public async open() {
+  public open() {
     this.modalEl?.open();
-    this.requestUpdate();
   }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5540eff and a966255.

📒 Files selected for processing (4)
  • resources/lang/en.json (1 hunks)
  • src/client/LoginCancelledModal.ts (1 hunks)
  • src/client/Main.ts (4 hunks)
  • src/client/index.html (1 hunks)
🔇 Additional comments (4)
resources/lang/en.json (1)

790-798: LGTM! Clean translation structure.

The translation keys are well-organized and follow the existing naming conventions. The benefit messages are clear and the button labels are concise.

src/client/LoginCancelledModal.ts (1)

46-47: Verify the empty span in the divider.

The divider contains an empty <span> element with background styling. If this is purely decorative, consider adding an aria-hidden="true" attribute for accessibility or removing it if it serves no purpose.

src/client/index.html (1)

402-402: LGTM! Consistent placement.

The modal element is correctly positioned alongside other modal components. The tag name matches the custom element definition.

src/client/Main.ts (1)

251-259: LGTM! Consistent modal initialization.

The initialization follows the established pattern used for other modals in the codebase. The instance check and warning message are helpful for debugging.

Copy link
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: 0

🧹 Nitpick comments (3)
src/client/LoginCancelledModal.ts (3)

15-17: Remove the empty constructor.

An empty constructor that only calls super() with no arguments is unnecessary and can be removed.

-  constructor() {
-    super();
-  }
-

70-73: Remove async or add await if needed.

The open() method is declared async but doesn't await anything. Either remove async or document why it's needed for future compatibility.

-  public async open() {
+  public open() {
     this.modalEl?.open();
     this.requestUpdate();
   }

4-5: Remove unused component registrations. The imports for ./components/Difficulties and ./components/PatternButton only register <difficulty-display> and <pattern-button>, but neither tag is used in this template. Drop these imports or move them to a shared entry-point.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a966255 and 47c504a.

📒 Files selected for processing (2)
  • src/client/LoginCancelledModal.ts (1 hunks)
  • src/client/Main.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/client/Main.ts
🔇 Additional comments (2)
src/client/LoginCancelledModal.ts (2)

79-88: Great job addressing the previous review comment!

The null check for AccountModal has been properly added, preventing runtime errors if the element is missing. This handles the concern raised in the previous review.


19-21: Document or revert disabled Shadow DOM
Overriding createRenderRoot() to return this removes style encapsulation and breaks Shadow-DOM features (scoped CSS, :host, slots, event retargeting). If you need global styles (e.g. Tailwind) to apply here, add a comment explaining why; otherwise remove this override to restore isolated Shadow DOM.

coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 15, 2025
@github-actions
Copy link

This pull request is stale because it has been open for fourteen days with no activity. If you want to keep this pull request open, add a comment or update the branch.

@github-actions github-actions bot added the Stale PRs that haven't been touched for over three weeks. label Oct 30, 2025
@TheGiraffe3
Copy link
Member

Could you resolve conflicts?

@TheGiraffe3 TheGiraffe3 removed the Stale PRs that haven't been touched for over three weeks. label Oct 30, 2025
@TheGiraffe3 TheGiraffe3 added this to the v27 milestone Oct 30, 2025
@dthlss26
Copy link
Author

Could you resolve conflicts?

Conflict resolved

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.

3 participants