Skip to content

UI refinements - #2858

Closed
ryanbarlow97 wants to merge 4 commits into
mainfrom
uirefinements
Closed

ryanbarlow97 wants to merge 4 commits into
mainfrom
uirefinements

Conversation

@ryanbarlow97

Copy link
Copy Markdown
Contributor

Description:

UI Refinements requested by @evanpelle

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

Copilot AI review requested due to automatic review settings January 10, 2026 22:54
@ryanbarlow97
ryanbarlow97 requested a review from a team as a code owner January 10, 2026 22:54
@coderabbitai

coderabbitai Bot commented Jan 10, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

This PR refactors the account navigation UI and flag/pattern selection controls. Changes include reorganizing the account button in the header, adding conditional label display to the FlagInput component, introducing helper functions for account authentication state, and updating styling for pattern selection across mobile and desktop layouts.

Changes

Cohort / File(s) Summary
Account Navigation & Avatar
index.html, src/client/Main.ts, src/client/AccountModal.ts
Restructured account button placement in navigation with new ID and accessibility attributes. Added helpers for building Discord avatar URLs and updating account nav UI based on authentication state. Removed decorative overlay elements from Discord login buttons to simplify markup.
FlagInput Component Enhancement
src/client/FlagInput.ts
Introduced new showSelectLabel property to conditionally display a label span when flag is in default state. Added private helper isDefaultFlagValue() to detect default/empty flags. Adjusted preview visibility binding and updated rendering logic.
Layout & Pattern Selection
index.html, src/client/Main.ts, src/client/components/PatternButton.ts
Restructured desktop pattern area into two-column flex layout combining territory-patterns preview with flag-input component. Updated territory-patterns button styling from white-based to slate-based theme (bg-slate-900/80). Simplified blank preview styling by removing background and border classes.
Localization
resources/lang/en.json
Changed "Solo Lobby" label to "Solo" in main localization strings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

UI/UX

Suggested reviewers

  • evanpelle
  • scottanderson

Poem

🎨 Buttons aligned in navigation's dance,
Avatars load when login's in the stance,
Flags find their labels when defaults appear,
Patterns and themes now crystal clear!

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
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.
Title check ❓ Inconclusive The title 'UI refinements' is vague and generic, lacking specific details about the primary changes made in the changeset. Consider a more descriptive title such as 'Refine account navigation and pattern area layout' or 'Update account button and desktop pattern layout' to better communicate the main changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description references UI refinements requested by a reviewer and includes proper checklists for screenshots, translations, tests, and testing confirmation, which are all related to the changeset.

✏️ 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.

Copilot AI 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.

Pull request overview

This PR implements UI refinements including visual styling updates and a new account button with Discord avatar display. The changes improve the user interface consistency and add user identity indicators to the navigation.

Changes:

  • Added Discord avatar display to the account navigation button with dynamic visibility based on login state
  • Updated pattern and flag button styling from white/opacity colors to slate-based colors for better visual consistency
  • Repositioned flag selector to desktop layout and added "Select Flag" label when no flag is chosen
  • Removed decorative UI elements (animated overlay, envelope icon) from the account modal for cleaner design
  • Updated "Solo Lobby" text to "Solo" in language file

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/client/Main.ts Added functions to fetch Discord avatars and update the account button based on user login state
src/client/FlagInput.ts Added show-select-label property to display instructional text when no flag is selected
src/client/components/PatternButton.ts Removed background and border styles from blank pattern preview for cleaner appearance
src/client/AccountModal.ts Removed decorative animated overlay and email icon for simpler UI
resources/lang/en.json Shortened "Solo Lobby" to "Solo" for more concise display
index.html Restructured account button with avatar support, repositioned flag input to desktop layout

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread index.html Resolved
Comment thread src/client/Main.ts
) as HTMLSpanElement | null;

const showAvatar = (src: string) => {
if (avatarEl) {

Copilot AI Jan 10, 2026

Copy link

Choose a reason for hiding this comment

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

The avatar image URL is directly set without error handling for failed image loads. Consider adding an onerror handler to fall back to the default sign-in display if the Discord avatar fails to load (e.g., due to network issues, invalid URL, or Discord CDN problems). This would improve the user experience by preventing a broken image state.

Suggested change
if (avatarEl) {
if (avatarEl) {
// Set up error handler to fall back to sign-in state if the avatar fails to load
avatarEl.onerror = () => {
avatarEl.classList.add("hidden");
personIconEl?.classList.remove("hidden");
signInTextEl?.classList.remove("hidden");
};

Copilot uses AI. Check for mistakes.
Comment thread index.html Resolved
Comment thread src/client/FlagInput.ts Resolved
Comment thread src/client/Main.ts Resolved

@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.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In @index.html:
- Around line 351-385: The button's user-facing strings are hard-coded; replace
the literal text and attributes on the element with i18n hooks: remove
title="Account", aria-label="Account" and the inner "Sign in" text and instead
add data-i18n-title="nav.account.title",
data-i18n-aria-label="nav.account.aria", and change the span
(id="nav-account-signin-text") to use data-i18n="nav.account.signin"; ensure the
element IDs (nav-account-button, nav-account-signin-text, nav-account-avatar,
nav-account-person-icon) remain unchanged so JS can target them, and add
matching keys ("nav.account.title", "nav.account.aria", "nav.account.signin") to
resources/lang/en.json.

In @src/client/FlagInput.ts:
- Around line 68-91: The button's tooltip/title
(translateText("flag_input.button_title")) doesn't match the visible label shown
when showSelectLabel is true (translateText("flag_input.title")); in render()
make the title use the same translation key as the shown label when showSelect
is true (use the same translateText("flag_input.title") value) so the tooltip
and the visible text are consistent, referencing the render() method and the
showSelect/showSelectLabel logic around isDefaultFlagValue(this.flag).

In @src/client/Main.ts:
- Around line 57-105: getDiscordAvatarUrl currently always returns a .png URL
which breaks animated Discord avatars whose hash starts with "a_"; change
getDiscordAvatarUrl to detect if user.avatar startsWith("a_") and use ".gif" for
animated avatars and ".png" otherwise (still encoding id and avatar via
encodeURIComponent and keeping the ?size=64 query), so updateAccountNavButton
can continue to call getDiscordAvatarUrl and show animated avatars correctly.
🧹 Nitpick comments (2)
src/client/Main.ts (1)

323-359: Optional: dedupe pattern button class strings.

The desktop/mobile patternButton.className = "..."; strings are nearly identical; consider a small const/helper to reduce drift when styles change again.

src/client/FlagInput.ts (1)

94-104: Avoid innerHTML for clearing preview nodes.

Even though you only assign "", switching to replaceChildren() removes the XSS smell and is simpler.

Proposed fix
   updated() {
     const preview = this.renderRoot.querySelector(
       "#flag-preview",
     ) as HTMLElement;
     if (!preview) return;

     if (this.showSelectLabel && this.isDefaultFlagValue(this.flag)) {
-      preview.innerHTML = "";
+      preview.replaceChildren();
       return;
     }

-    preview.innerHTML = "";
+    preview.replaceChildren();

Also applies to: 105-106

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eaf77cd and 12663d8.

📒 Files selected for processing (6)
  • index.html
  • resources/lang/en.json
  • src/client/AccountModal.ts
  • src/client/FlagInput.ts
  • src/client/Main.ts
  • src/client/components/PatternButton.ts
💤 Files with no reviewable changes (1)
  • src/client/AccountModal.ts
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: andrewNiziolek
Repo: openfrontio/OpenFrontIO PR: 1007
File: resources/lang/de.json:115-115
Timestamp: 2025-06-02T14:27:37.609Z
Learning: For OpenFrontIO project: When localization keys are renamed in language JSON files, the maintainers separate technical changes from translation content updates. They wait for community translators to update the actual translation values rather than attempting to translate in the same PR. This allows technical changes to proceed while ensuring accurate translations from native speakers.
📚 Learning: 2025-06-02T14:27:37.609Z
Learnt from: andrewNiziolek
Repo: openfrontio/OpenFrontIO PR: 1007
File: resources/lang/de.json:115-115
Timestamp: 2025-06-02T14:27:37.609Z
Learning: For OpenFrontIO project: When localization keys are renamed in language JSON files, the maintainers separate technical changes from translation content updates. They wait for community translators to update the actual translation values rather than attempting to translate in the same PR. This allows technical changes to proceed while ensuring accurate translations from native speakers.

Applied to files:

  • resources/lang/en.json
📚 Learning: 2025-08-16T10:52:08.292Z
Learnt from: TheGiraffe3
Repo: openfrontio/OpenFrontIO PR: 884
File: resources/lang/en.json:456-461
Timestamp: 2025-08-16T10:52:08.292Z
Learning: In OpenFrontIO, translation files in resources/lang/*.json (except en.json) should not be updated in regular PRs. Only dedicated translation PRs titled "mls" and made by Aotumori should update non-English locale files. Regular PRs should only update en.json when adding or modifying translation keys.

Applied to files:

  • resources/lang/en.json
📚 Learning: 2025-07-31T12:03:08.052Z
Learnt from: VariableVince
Repo: openfrontio/OpenFrontIO PR: 1655
File: resources/maps/giantworldmap/manifest.json:165-174
Timestamp: 2025-07-31T12:03:08.052Z
Learning: In OpenFrontIO draft PRs, flag names in map manifest files may be placeholders that will be updated to match the actual SVG flag file names when the assets are received. The final naming depends on the actual flag SVG files provided, not code naming conventions.

Applied to files:

  • src/client/FlagInput.ts
📚 Learning: 2025-06-09T02:20:43.637Z
Learnt from: VariableVince
Repo: openfrontio/OpenFrontIO PR: 1110
File: src/client/Main.ts:293-295
Timestamp: 2025-06-09T02:20:43.637Z
Learning: In src/client/Main.ts, during game start in the handleJoinLobby callback, UI elements are hidden using direct DOM manipulation with classList.add("hidden") for consistency. This includes modals, buttons, and error divs. The codebase follows this pattern rather than using component APIs for hiding elements during game transitions.

Applied to files:

  • src/client/Main.ts
📚 Learning: 2026-01-08T13:52:00.939Z
Learnt from: deshack
Repo: openfrontio/OpenFrontIO PR: 2777
File: src/client/Main.ts:374-378
Timestamp: 2026-01-08T13:52:00.939Z
Learning: In src/client/Main.ts, ensure the browser back/forward navigation ordering is correctly handled: when popstate fires before hashchange during a navigation rollback (e.g., user cancels leaving an active game), use a preventHashUpdate-like flag to suppress the hashchange listener (onHashUpdate) from running in that rollback scenario. This avoids applying an unintended hash update after a rollback and keeps the UI/game state consistent. Document the flag’s usage and the exact conditions under which it is set/reset to prevent subtle regressions.

Applied to files:

  • src/client/Main.ts
📚 Learning: 2025-12-29T23:33:17.920Z
Learnt from: wraith4081
Repo: openfrontio/OpenFrontIO PR: 2735
File: index.html:390-391
Timestamp: 2025-12-29T23:33:17.920Z
Learning: In Tailwind CSS v4, update blur-related utilities in HTML templates. The mappings are: backdrop-blur-sm (v3) -> backdrop-blur-xs (v4); backdrop-blur (bare) -> backdrop-blur-sm; blur-sm -> blur-xs. Apply these changes to all HTML files (e.g., index.html and other templates) to reflect the v4 naming. Consider updating a project-wide search/replace or using a codemod to ensure consistency across the codebase.

Applied to files:

  • index.html
🧬 Code graph analysis (2)
src/client/FlagInput.ts (2)
src/client/Utils.ts (1)
  • translateText (153-208)
src/client/LangSelector.ts (1)
  • translateText (248-268)
src/client/Main.ts (1)
src/core/ApiSchemas.ts (1)
  • UserMeResponse (78-78)
🪛 ast-grep (0.40.4)
src/client/FlagInput.ts

[warning] 100-100: Direct modification of innerHTML or outerHTML properties detected. Modifying these properties with unsanitized user input can lead to XSS vulnerabilities. Use safe alternatives or sanitize content first.
Context: preview.innerHTML = ""
Note: [CWE-79] Improper Neutralization of Input During Web Page Generation [REFERENCES]
- https://owasp.org/www-community/xss-filter-evasion-cheatsheet
- https://cwe.mitre.org/data/definitions/79.html

(dom-content-modification)


[warning] 104-104: Direct modification of innerHTML or outerHTML properties detected. Modifying these properties with unsanitized user input can lead to XSS vulnerabilities. Use safe alternatives or sanitize content first.
Context: preview.innerHTML = ""
Note: [CWE-79] Improper Neutralization of Input During Web Page Generation [REFERENCES]
- https://owasp.org/www-community/xss-filter-evasion-cheatsheet
- https://cwe.mitre.org/data/definitions/79.html

(dom-content-modification)

🔇 Additional comments (6)
resources/lang/en.json (1)

34-34: Good, low-risk copy tweak.

Changing main.solo to “Solo” is fine and keeps the key stable (no translator churn). Based on learnings, keeping this limited to en.json is the right approach.

src/client/components/PatternButton.ts (1)

176-199: Verify desktop “blank preview” contrast/readability after style reduction.

The md+ blank state now relies on parent styling (no background/border), so please double-check the “Select Skin” text stays readable in all themes and containers.

src/client/Main.ts (1)

450-476: Good: account button state updates with user-me results.

Calling updateAccountNavButton(userMeResponse) right after login-state detection keeps the nav UI in sync early.

src/client/FlagInput.ts (1)

13-18: Nice addition: explicit showSelectLabel API + default-flag helper.

Clean, easy-to-use control surface (show-select-label) and the default-flag check is straightforward.

index.html (2)

453-474: Desktop pattern+flag split is clean; keep click targets consistent.

The new wrapper + flag-input side-by-side layout looks good. Just ensure the flag-input outer styling doesn’t fight the inner button styling (double hover/scale, focus behavior) across browsers.


412-474: Flag selection remains reachable on mobile.

Mobile users can access flag selection through the hamburger menu (Options > Settings), where the UserSettingModal provides a clickable flag selector that opens the flag-input-modal. The functionality is not lost in the new layout—both desktop and mobile paths work correctly.

Comment thread index.html
Comment on lines +351 to +385
<button
id="nav-account-button"
class="nav-menu-item h-10 rounded-full overflow-hidden flex items-center justify-center gap-2 px-3 bg-transparent border border-white/20 text-white/80 hover:text-white cursor-pointer transition-colors [&.active]:text-white"
data-page="page-account"
aria-label="Account"
title="Account"
>
<img
id="nav-account-avatar"
class="hidden w-8 h-8 rounded-full object-cover"
alt=""
referrerpolicy="no-referrer"
/>
<svg
id="nav-account-person-icon"
class="w-5 h-5"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M20 21a8 8 0 0 0-16 0" />
<path d="M12 13a4 4 0 1 0-4-4 4 4 0 0 0 4 4Z" />
</svg>
<span
id="nav-account-signin-text"
class="text-xs font-bold tracking-widest"
>
Sign in
</span>
</button>

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.

⚠️ Potential issue | 🟠 Major

Localize the new “Sign in” + button labels (currently hard-coded).

“Sign in”, aria-label="Account", and title="Account" are user-facing strings but aren’t wired to i18n. Please switch to data-i18n / data-i18n-title / data-i18n-aria-label (and add the key(s) to resources/lang/en.json).

Example fix (HTML-side i18n hooks)
         <button
           id="nav-account-button"
           class="nav-menu-item h-10 rounded-full overflow-hidden flex items-center justify-center gap-2 px-3 bg-transparent border border-white/20 text-white/80 hover:text-white cursor-pointer transition-colors [&.active]:text-white"
           data-page="page-account"
-          aria-label="Account"
-          title="Account"
+          data-i18n-aria-label="main.account"
+          data-i18n-title="main.account"
         >
@@
           <span
             id="nav-account-signin-text"
             class="text-xs font-bold tracking-widest"
-          >
-            Sign in
-          </span>
+            data-i18n="common.sign_in"
+          ></span>
         </button>
🤖 Prompt for AI Agents
In @index.html around lines 351 - 385, The button's user-facing strings are
hard-coded; replace the literal text and attributes on the element with i18n
hooks: remove title="Account", aria-label="Account" and the inner "Sign in" text
and instead add data-i18n-title="nav.account.title",
data-i18n-aria-label="nav.account.aria", and change the span
(id="nav-account-signin-text") to use data-i18n="nav.account.signin"; ensure the
element IDs (nav-account-button, nav-account-signin-text, nav-account-avatar,
nav-account-person-icon) remain unchanged so JS can target them, and add
matching keys ("nav.account.title", "nav.account.aria", "nav.account.signin") to
resources/lang/en.json.

Comment thread src/client/FlagInput.ts
Comment on lines 68 to 91
render() {
const isDefaultFlag = this.isDefaultFlagValue(this.flag);
const showSelect = this.showSelectLabel && isDefaultFlag;

return html`
<button
id="flag-input_"
class="flag-btn m-0 border-0 bg-transparent hover:bg-white/10 w-full h-full flex cursor-pointer justify-center items-center focus:outline-none focus:ring-0 transition-colors duration-200"
class="flag-btn m-0 border-0 bg-transparent hover:bg-white/10 w-full h-full flex cursor-pointer justify-center items-center focus:outline-none focus:ring-0 transition-all duration-200 hover:scale-105"
style="padding: 0 !important;"
title=${translateText("flag_input.button_title")}
>
<span
id="flag-preview"
class="w-full h-full overflow-hidden"
style="display:block;"
class=${showSelect ? "hidden" : "w-full h-full overflow-hidden"}
></span>
${showSelect
? html`<span
class="text-[10px] font-black text-white/40 uppercase leading-none break-words w-full text-center px-1"
>
${translateText("flag_input.title")}
</span>`
: null}
</button>
`;

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.

⚠️ Potential issue | 🟡 Minor

Label/preview toggle looks correct; keep title text consistent.

When showSelectLabel is on, the button shows “Select Flag” while title remains “Pick a flag!”—that mismatch might be intentional, but worth a quick UX check.

🤖 Prompt for AI Agents
In @src/client/FlagInput.ts around lines 68 - 91, The button's tooltip/title
(translateText("flag_input.button_title")) doesn't match the visible label shown
when showSelectLabel is true (translateText("flag_input.title")); in render()
make the title use the same translation key as the shown label when showSelect
is true (use the same translateText("flag_input.title") value) so the tooltip
and the visible text are consistent, referencing the render() method and the
showSelect/showSelectLabel logic around isDefaultFlagValue(this.flag).

Comment thread src/client/Main.ts
Comment on lines +57 to +105
function getDiscordAvatarUrl(user: {
id: string;
avatar: string | null;
}): string | null {
if (!user.avatar) return null;
return `https://cdn.discordapp.com/avatars/${encodeURIComponent(user.id)}/${encodeURIComponent(user.avatar)}.png?size=64`;
}

function updateAccountNavButton(userMeResponse: UserMeResponse | false) {
const button = document.getElementById("nav-account-button");
if (!button) return;

const avatarEl = document.getElementById(
"nav-account-avatar",
) as HTMLImageElement | null;
const personIconEl = document.getElementById(
"nav-account-person-icon",
) as SVGElement | null;
const signInTextEl = document.getElementById(
"nav-account-signin-text",
) as HTMLSpanElement | null;

const showAvatar = (src: string) => {
if (avatarEl) {
avatarEl.src = src;
avatarEl.classList.remove("hidden");
}
personIconEl?.classList.add("hidden");
signInTextEl?.classList.add("hidden");
};

const showSignIn = () => {
avatarEl?.classList.add("hidden");
personIconEl?.classList.remove("hidden");
signInTextEl?.classList.remove("hidden");
};

const discord =
userMeResponse !== false ? userMeResponse.user.discord : undefined;
if (discord && avatarEl) {
const url = getDiscordAvatarUrl(discord);
if (url) {
showAvatar(url);
return;
}
}

showSignIn();
}

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.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

Discord CDN avatar URL format animated avatars a_ prefix file extension png gif webp

💡 Result:

Short answer:

  • CDN avatar URL pattern: https://cdn.discordapp.com/avatars/{USER_ID}/{AVATAR_HASH}.{EXT}?size={SIZE}. [1][2]
  • Animated avatars: the hash is prefixed with "a_" (e.g. a_abcdef...), and when animated Discord serves GIF by default (you can request gif for animated, static formats for non‑animated). [1][2]
  • Supported image extensions you can request include webp, png, jpg/jpeg; gif is valid only for animated avatars. You may also see a querystring like ?size=1024 (powers of two 16–4096). [2][3]

Sources: [1] Pycord asset code showing a_ -> gif and URL pattern. [2] CDN/format reference summary. [3] practical note about extensions/querystrings.


Handle animated Discord avatars correctly.

getDiscordAvatarUrl() always appends .png, but Discord avatars can be animated when the hash starts with a_. Animated avatars should use .gif format so they load properly.

Proposed fix
 function getDiscordAvatarUrl(user: {
   id: string;
   avatar: string | null;
 }): string | null {
   if (!user.avatar) return null;
-  return `https://cdn.discordapp.com/avatars/${encodeURIComponent(user.id)}/${encodeURIComponent(user.avatar)}.png?size=64`;
+  const ext = user.avatar.startsWith("a_") ? "gif" : "png";
+  return `https://cdn.discordapp.com/avatars/${encodeURIComponent(user.id)}/${encodeURIComponent(user.avatar)}.${ext}?size=64`;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function getDiscordAvatarUrl(user: {
id: string;
avatar: string | null;
}): string | null {
if (!user.avatar) return null;
return `https://cdn.discordapp.com/avatars/${encodeURIComponent(user.id)}/${encodeURIComponent(user.avatar)}.png?size=64`;
}
function updateAccountNavButton(userMeResponse: UserMeResponse | false) {
const button = document.getElementById("nav-account-button");
if (!button) return;
const avatarEl = document.getElementById(
"nav-account-avatar",
) as HTMLImageElement | null;
const personIconEl = document.getElementById(
"nav-account-person-icon",
) as SVGElement | null;
const signInTextEl = document.getElementById(
"nav-account-signin-text",
) as HTMLSpanElement | null;
const showAvatar = (src: string) => {
if (avatarEl) {
avatarEl.src = src;
avatarEl.classList.remove("hidden");
}
personIconEl?.classList.add("hidden");
signInTextEl?.classList.add("hidden");
};
const showSignIn = () => {
avatarEl?.classList.add("hidden");
personIconEl?.classList.remove("hidden");
signInTextEl?.classList.remove("hidden");
};
const discord =
userMeResponse !== false ? userMeResponse.user.discord : undefined;
if (discord && avatarEl) {
const url = getDiscordAvatarUrl(discord);
if (url) {
showAvatar(url);
return;
}
}
showSignIn();
}
function getDiscordAvatarUrl(user: {
id: string;
avatar: string | null;
}): string | null {
if (!user.avatar) return null;
const ext = user.avatar.startsWith("a_") ? "gif" : "png";
return `https://cdn.discordapp.com/avatars/${encodeURIComponent(user.id)}/${encodeURIComponent(user.avatar)}.${ext}?size=64`;
}
function updateAccountNavButton(userMeResponse: UserMeResponse | false) {
const button = document.getElementById("nav-account-button");
if (!button) return;
const avatarEl = document.getElementById(
"nav-account-avatar",
) as HTMLImageElement | null;
const personIconEl = document.getElementById(
"nav-account-person-icon",
) as SVGElement | null;
const signInTextEl = document.getElementById(
"nav-account-signin-text",
) as HTMLSpanElement | null;
const showAvatar = (src: string) => {
if (avatarEl) {
avatarEl.src = src;
avatarEl.classList.remove("hidden");
}
personIconEl?.classList.add("hidden");
signInTextEl?.classList.add("hidden");
};
const showSignIn = () => {
avatarEl?.classList.add("hidden");
personIconEl?.classList.remove("hidden");
signInTextEl?.classList.remove("hidden");
};
const discord =
userMeResponse !== false ? userMeResponse.user.discord : undefined;
if (discord && avatarEl) {
const url = getDiscordAvatarUrl(discord);
if (url) {
showAvatar(url);
return;
}
}
showSignIn();
}
🤖 Prompt for AI Agents
In @src/client/Main.ts around lines 57 - 105, getDiscordAvatarUrl currently
always returns a .png URL which breaks animated Discord avatars whose hash
starts with "a_"; change getDiscordAvatarUrl to detect if user.avatar
startsWith("a_") and use ".gif" for animated avatars and ".png" otherwise (still
encoding id and avatar via encodeURIComponent and keeping the ?size=64 query),
so updateAccountNavButton can continue to call getDiscordAvatarUrl and show
animated avatars correctly.

@ryanbarlow97
ryanbarlow97 deleted the uirefinements branch January 10, 2026 23:12

This branch was previously deployed

1 inactive deployment
staging — 12663d89 Deployed Jan 10, 2026 by openfrontio[bot]
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.

2 participants