Skip to content

Conversation

@DenelDuck
Copy link

Resolves #2820

Description:

Add colored borders to the chat-option-button corresponding to each players territory color.

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:

denelduck

@DenelDuck DenelDuck requested a review from a team as a code owner January 8, 2026 11:52
@CLAassistant
Copy link

CLAassistant commented Jan 8, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

Walkthrough

A styling change adds a 2px border to player option buttons in the Quick-Chat (ChatModal), using each player's territory color converted to hex. No control flow or data handling changes.

Changes

Cohort / File(s) Summary
Chat Modal Styling
src/client/graphics/layers/ChatModal.ts
Adds an inline border: 2px solid #rrggbb`` style to player selection buttons, using the player's territory color converted to hex. UI-only change affecting Quick-Chat player list rendering.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested reviewers

  • LoackyBit
  • kmk142789

Poem

🎨 A thin bright ring on every name,
Quick-chat finds its vivid frame,
Borders whisper, colors say,
"Pick the player, not the gray." ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding colored borders to player quickchat option buttons, matching the primary objective in the changeset.
Description check ✅ Passed The description is directly related to the changeset, explaining the feature, providing a screenshot, and documenting completed checklist items for the UI update.
Linked Issues check ✅ Passed The pull request implements the requirement from #2820 by adding colored borders to player buttons in the quickchat window using each player's territory color.
Out of Scope Changes check ✅ Passed All changes are scoped to adding inline styles for colored borders to the chat player option button, directly addressing the linked issue requirement with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6932de4 and 47611c0.

📒 Files selected for processing (1)
  • src/client/graphics/layers/ChatModal.ts
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: Ble4Ch
Repo: openfrontio/OpenFrontIO PR: 1063
File: src/core/configuration/Colors.ts:114-330
Timestamp: 2025-06-06T15:36:31.739Z
Learning: In the OpenFrontIO project, color improvements are implemented incrementally. The current focus for player colors is ensuring sufficient unique color availability rather than optimizing for visual distinction or accessibility features.
📚 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/graphics/layers/ChatModal.ts
📚 Learning: 2025-06-22T05:48:19.241Z
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 786
File: src/client/TerritoryPatternsModal.ts:337-338
Timestamp: 2025-06-22T05:48:19.241Z
Learning: In src/client/TerritoryPatternsModal.ts, the bit shifting operators (<<) used in coordinate calculations with decoder.getScale() are intentional and should not be changed to multiplication. The user scottanderson confirmed this is functioning as intended.

Applied to files:

  • src/client/graphics/layers/ChatModal.ts
📚 Learning: 2025-06-10T09:56:44.473Z
Learnt from: Ble4Ch
Repo: openfrontio/OpenFrontIO PR: 1063
File: src/core/configuration/PastelThemeDark.ts:53-53
Timestamp: 2025-06-10T09:56:44.473Z
Learning: In ColorAllocator class in src/core/configuration/Colors.ts, the correct method names are assignColor(id: string): Colord for general color assignment and assignTeamColor(team: Team): Colord for team-specific colors. There are no assignPlayerColor() or assignBotColor() methods.

Applied to files:

  • src/client/graphics/layers/ChatModal.ts
🧬 Code graph analysis (1)
src/client/graphics/layers/ChatModal.ts (1)
src/core/game/GameImpl.ts (1)
  • player (483-489)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Has Milestone
  • GitHub Check: Validate Description
🔇 Additional comments (1)
src/client/graphics/layers/ChatModal.ts (1)

145-147: The colored border is safe; consider complementary accessibility indicators.

The inline border style using player.territoryColor().toHex() is safe and well-handled—territoryColor() always returns a valid Colord object, and toHex() produces a valid hex string.

For accessibility: while the colored borders help visual distinction, the player name text (line 150) already provides a text-based fallback. To further improve accessibility for color-blind users, consider adding a subtle icon, pattern, or additional indicator to the button.

⛔ Skipped due to learnings
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.
Learnt from: scamiv
Repo: openfrontio/OpenFrontIO PR: 2607
File: src/core/execution/PlayerExecution.ts:271-295
Timestamp: 2025-12-13T14:58:29.645Z
Learning: In src/core/execution/PlayerExecution.ts surroundedBySamePlayer(), the `as Player` cast on `mg.playerBySmallID(scan.enemyId)` is intentional. Since scan.enemyId comes from ownerID() on an owned tile and playerBySmallID() only returns Player or undefined, the cast expresses a known invariant. The maintainers prefer loud failures (runtime errors) over silent masking (early returns with guards) for corrupted game state scenarios at trusted call sites.
Learnt from: Ble4Ch
Repo: openfrontio/OpenFrontIO PR: 1063
File: src/core/configuration/PastelThemeDark.ts:53-53
Timestamp: 2025-06-10T09:56:44.473Z
Learning: In ColorAllocator class in src/core/configuration/Colors.ts, the correct method names are assignColor(id: string): Colord for general color assignment and assignTeamColor(team: Team): Colord for team-specific colors. There are no assignPlayerColor() or assignBotColor() methods.
Learnt from: GlacialDrift
Repo: openfrontio/OpenFrontIO PR: 2298
File: src/client/graphics/layers/TerritoryLayer.ts:200-210
Timestamp: 2025-10-26T15:37:07.732Z
Learning: In GameImpl.ts lines 124-139, team assignment logic varies by number of teams: when numPlayerTeams < 8, teams are assigned ColoredTeams values (Red, Blue, Yellow, Green, Purple, Orange, Teal); when numPlayerTeams >= 8, teams are assigned generic string identifiers like "Team 1", "Team 2", etc., which are not members of ColoredTeams.
Learnt from: Ble4Ch
Repo: openfrontio/OpenFrontIO PR: 1063
File: src/core/configuration/Colors.ts:114-330
Timestamp: 2025-06-06T15:36:31.739Z
Learning: In the OpenFrontIO project, color improvements are implemented incrementally. The current focus for player colors is ensuring sufficient unique color availability rather than optimizing for visual distinction or accessibility features.

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

🤖 Fix all issues with AI agents
In @src/client/graphics/layers/ChatModal.ts:
- Around line 145-147: Collapse the multi-line style attribute in ChatModal.ts
into a single properly formatted style attribute that contains the template
expression using player.territoryColor().toHex(), then run the formatter; after
editing the style attribute (the block containing
player.territoryColor().toHex()) run npx prettier --write
src/client/graphics/layers/ChatModal.ts to fix remaining formatting issues.
🧹 Nitpick comments (2)
src/client/graphics/layers/ChatModal.ts (2)

145-147: Consider using CSS custom properties instead of inline styles.

Inline styles make the template harder to maintain. You could set the border color as a CSS custom property (CSS variable) and keep the styling in CSS:

style="--player-border-color: ${player.territoryColor().toHex()};"

Then in your CSS:

.chat-option-button {
  border: 2px solid var(--player-border-color, transparent);
}

This separates styling concerns from the template and makes the code cleaner.


145-147: Consider accessibility for colorblind users

The colored border alone doesn't fully convey player information. While the player name is displayed as text, adding a visual indicator alongside the color would improve accessibility for colorblind users and better align with WCAG Success Criterion 1.4.1. Consider:

  • Player initials in a colored circle
  • A small icon or badge next to the player name
  • A pattern or texture in addition to the border color

This makes identification clearer for all users, especially those with color-vision deficiencies.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d9b834 and 6932de4.

📒 Files selected for processing (1)
  • src/client/graphics/layers/ChatModal.ts
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Ble4Ch
Repo: openfrontio/OpenFrontIO PR: 1063
File: src/core/configuration/Colors.ts:114-330
Timestamp: 2025-06-06T15:36:31.739Z
Learning: In the OpenFrontIO project, color improvements are implemented incrementally. The current focus for player colors is ensuring sufficient unique color availability rather than optimizing for visual distinction or accessibility features.
📚 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/graphics/layers/ChatModal.ts
🧬 Code graph analysis (1)
src/client/graphics/layers/ChatModal.ts (1)
src/core/game/GameImpl.ts (1)
  • player (483-489)
🪛 GitHub Actions: 🧪 CI
src/client/graphics/layers/ChatModal.ts

[warning] 1-1: Code style issues found in the above file. Run 'npx prettier --write' to fix.

🔇 Additional comments (1)
src/client/graphics/layers/ChatModal.ts (1)

145-147: All API methods exist and are correctly used.

PlayerView.territoryColor() returns a Colord object from the "colord" library, which provides the .toHex() method for converting colors to hex string format. The code chain is valid.

Comment on lines 145 to 147
style="border: 2px solid ${player
.territoryColor()
.toHex()};"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix the code formatting.

The pipeline reports a Prettier formatting issue. Run npx prettier --write src/client/graphics/layers/ChatModal.ts to fix the formatting of the multi-line style attribute.

🤖 Prompt for AI Agents
In @src/client/graphics/layers/ChatModal.ts around lines 145 - 147, Collapse the
multi-line style attribute in ChatModal.ts into a single properly formatted
style attribute that contains the template expression using
player.territoryColor().toHex(), then run the formatter; after editing the style
attribute (the block containing player.territoryColor().toHex()) run npx
prettier --write src/client/graphics/layers/ChatModal.ts to fix remaining
formatting issues.

@DenelDuck DenelDuck changed the title add colored borders add colored borders to player's quickchat option buttons Jan 8, 2026
@iiamlewis
Copy link
Contributor

My concern with this is for colourblind people with accessability issues, this could be a slightly weird feature as it would just assign them a weird grey colour (depending on their colour blind issue, i know)

@iiamlewis iiamlewis added the needs-grooming This feature has not been approved. label Jan 8, 2026
@github-project-automation github-project-automation bot moved this from Triage to Development in OpenFront Release Management Jan 8, 2026
@iiamlewis iiamlewis added this to the Backlog milestone Jan 8, 2026
@DenelDuck
Copy link
Author

As far as I know most colourblind issues lie in red-green and blue-yellow contrast. The contrast between the coloured border and the gray/white button should not have a big impact on colourblindness (only 1 out of 30.000 see only shades of gray).

Besides, if in the near future Openfront supports colourblind features like different colour palettes for the territory colours, this feature would adopt this automatically, as it refers to each player's territory colour.

@ryanhaticus
Copy link
Contributor

ryanhaticus commented Jan 9, 2026

I think this is pretty decent justification. @DenelDuck

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

Labels

needs-grooming This feature has not been approved.

Projects

Status: Development

Development

Successfully merging this pull request may close these issues.

Colored border in Quick-Chat window for each player

4 participants