Skip to content

Gamehistory#3987

Closed
ryanbarlow97 wants to merge 8 commits into
mainfrom
gamehistory
Closed

Gamehistory#3987
ryanbarlow97 wants to merge 8 commits into
mainfrom
gamehistory

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:

Describe the PR.

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 May 22, 2026 15:20
@ryanbarlow97 ryanbarlow97 requested a review from a team as a code owner May 22, 2026 15:20
@ryanbarlow97 ryanbarlow97 self-assigned this May 22, 2026
@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 22, 2026
@ryanbarlow97 ryanbarlow97 added this to the v32 milestone May 22, 2026
@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds clan game history schemas and client fetch, a full ClanGameHistoryView with filters and infinite scroll, integrates it as a clan-detail sub-tab, defers member loading to the Members tab, and removes the deprecated clan-stats API and rendering.

Changes

Clan Game History Feature

Layer / File(s) Summary
Game data schemas and fetch API
src/core/ClanApiSchemas.ts, src/client/ClanApi.ts
Adds Zod schemas/types for ClanGame, ClanGameFilter, ClanGameResult, and ClanGamesResponse with pagination. Makes ClanStatsSchema.stats optional. Adds fetchClanGames(tag, opts?) returning validated data or `{ error: "forbidden"
Game history component, rendering, and localization
src/client/components/clan/ClanGameHistoryView.ts, src/client/Utils.ts, resources/lang/en.json
Adds clan-game-history-view with filter tabs (ffa/team/hvn/ranked), infinite-scroll pagination, async race protection, day-grouped rendering, map imagery, result badges (partial-win logic), split winner/loser player lists, replay navigation, ClanGameHistoryCache export, renderDuration formatting change, and month/game-history localization keys.
Modal sub-tabs and cache integration
src/client/ClanModal.ts
Extends modal tabs to include game-history detail sub-tab, adds gameHistoryCache, mounts clan-game-history-view when active, routes tab/back/close behavior, and updates members-loaded/detail-loaded handling to avoid stale cache updates.
Detail view lazy member loading and tab support
src/client/components/clan/ClanDetailView.ts
Loads only overview via fetchClanDetail initially, removes clan-stats state, adds detailTab property, implements guarded loadInitialMembers() triggered when switching to Members, and reorganizes render to branch early for Members vs Overview.
Remove obsolete stats code and update tests
src/client/components/clan/ClanShared.ts, tests/client/clan/*, resources/lang/en.json
Removes renderClanWL and ClanStats imports, deletes the standalone statistics localization key, removes fetchClanStats test suite and mocks, and updates test utilities to stop exposing fetchClanStats.

Sequence Diagram(s)

sequenceDiagram
  participant Modal as ClanModal
  participant DetailView as ClanDetailView
  participant HistoryView as ClanGameHistoryView
  participant API as ClanApi
  participant Observer as IntersectionObserver

  Modal->>DetailView: open detail (detailTab=overview)
  DetailView->>API: fetchClanDetail(tag)
  API-->>DetailView: overview data

  Modal->>Modal: user switches to game-history tab
  Modal->>HistoryView: mount with clanTag + cachedState
  HistoryView->>API: fetchClanGames(tag, filter)
  API-->>HistoryView: games + nextCursor
  HistoryView->>HistoryView: group by day & render

  HistoryView->>Observer: attach sentinel
  Observer->>HistoryView: sentinel intersect -> load append
  HistoryView->>API: fetchClanGames(tag, filter, cursor)
  API-->>HistoryView: more games
  HistoryView->>Modal: dispatch history-updated
  HistoryView->>Modal: user clicks watch replay -> close modal, navigate worker
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • evanpelle

Poem

🎮 A clan's past rounds now scroll and sing,
Filtered tabs and days in tidy rings.
Replay clicks that open maps and time,
Members load later, stats no longer rhyme. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description contains only the repository template with no actual implementation details, specific changes, or linked issues. Replace the template with a clear description of the implemented features, such as adding game history UI, new API endpoints, filtering/pagination, and any related architectural changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 7.69% 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 'Gamehistory' is vague and does not clearly describe the main changes, such as adding clan game history viewing, API endpoints, or specific UI components. Use a more descriptive title like 'Add clan game history view with filtering and pagination' to clearly convey the primary changes.
✅ Passed checks (2 passed)
Check name Status Explanation
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.

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

Adds a new “Game History” experience to the clan modal, including a client API + schema for paginated clan game history and a new Lit view to browse/filter games and jump to replays. It also simplifies the clan detail fetch path by removing the legacy clan stats fetch and deferring member-list loading until the Members tab is opened.

Changes:

  • Introduce fetchClanGames() + Zod schemas for clan game history responses and filters.
  • Add clan-game-history-view UI (filters, infinite scroll pagination, replay deep-linking) and wire it into ClanModal as a new detail tab.
  • Remove fetchClanStats usage/tests and adjust clan detail logic to lazy-load member data; update renderDuration() to support hours and suppress trailing zero units.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/client/clan/ClanModalTestUtils.ts Removes fetchClanStats from the Clan API mock factory.
tests/client/clan/ClanModal.rendering.test.ts Updates rendering test to stop mocking removed fetchClanStats.
tests/client/clan/ClanModal.handlers.test.ts Updates handler tests to stop mocking removed fetchClanStats.
tests/client/clan/ClanApiQueries.test.ts Removes fetchClanStats query tests (API removed).
src/core/ClanApiSchemas.ts Makes ClanStats.stats optional; adds clan game history schemas/types.
src/client/Utils.ts Enhances renderDuration() with hours and cleaner formatting.
src/client/components/clan/ClanShared.ts Removes the old renderClanWL() helper (stats UI path).
src/client/components/clan/ClanGameHistoryView.ts New game history tab UI with filters, paging, and replay navigation.
src/client/components/clan/ClanDetailView.ts Removes stats fetch; defers members fetch until Members tab is opened.
src/client/ClanModal.ts Adds detail tabs (Overview/Members/Game History) and caches history state.
src/client/ClanApi.ts Removes fetchClanStats; adds fetchClanGames() and re-exports new types.
resources/lang/en.json Adds translations for new tabs/history UI + common month names; removes statistics key.

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

Comment thread src/client/components/clan/ClanGameHistoryView.ts
Comment thread src/client/ClanApi.ts
Comment thread src/client/components/clan/ClanGameHistoryView.ts
Comment thread src/client/ClanModal.ts Outdated
@ryanbarlow97 ryanbarlow97 marked this pull request as draft May 22, 2026 15:27

@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

🤖 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/components/clan/ClanDetailView.ts`:
- Around line 151-190: Before awaiting fetchClanMembers in loadInitialMembers
capture the current request context (e.g., const expectedTag = this.clanTag;
const expectedSort = this.memberSort; const expectedOrder = this.memberOrder;
const expectedPage = 1; and optionally this.myPublicId) and after the await
return check that those captured values still match the instance fields
(this.clanTag, this.memberSort, this.memberOrder, etc.) before assigning
this.members, this.membersTotal, this.pendingRequestCount, this.memberPage or
dispatching the "members-loaded" event; if the context changed, bail out without
applying the stale response (still ensure membersLoadInFlight is cleared in the
finally block).

In `@src/client/components/clan/ClanGameHistoryView.ts`:
- Around line 85-90: The reload flow can leave loadingMore stuck true if an
append request is in flight; in reload() set this.loadingMore = false (in
addition to this.games = [], this.nextCursor = null, this.appendFailed = false)
before calling await this.load({ append: false }); and also update the load(...)
implementation so any branch that performs a full refresh (when append ===
false) always resets this.loadingMore = false at the start of that path
(reference the reload() and load(...) methods, this.loadingMore, appendFailed
and nextCursor symbols).

In `@src/core/ClanApiSchemas.ts`:
- Around line 157-201: Add unit tests for the new schemas: ClanGamePlayerSchema,
ClanGameResultSchema, ClanGameFilterSchema, ClanGameSchema, and
ClanGamesResponseSchema that assert (1) valid payloads parse successfully, (2)
nullish/optional fields (e.g. playerTeams null, totalPlayers nullish,
map/mode/rankedType/result omitted) are accepted, and (3) clearly invalid
payloads reject parsing. Use the schema .parse or .safeParse APIs to verify
success and failure cases and include at least one negative test per schema
asserting a thrown error or safeParse().success === false. Ensure tests live
alongside other core schema tests and target wire/contract behaviors only.
🪄 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: b16e81c2-fd07-4713-851a-d219a28a92c7

📥 Commits

Reviewing files that changed from the base of the PR and between 458d04e and 1f70ac6.

📒 Files selected for processing (12)
  • resources/lang/en.json
  • src/client/ClanApi.ts
  • src/client/ClanModal.ts
  • src/client/Utils.ts
  • src/client/components/clan/ClanDetailView.ts
  • src/client/components/clan/ClanGameHistoryView.ts
  • src/client/components/clan/ClanShared.ts
  • src/core/ClanApiSchemas.ts
  • tests/client/clan/ClanApiQueries.test.ts
  • tests/client/clan/ClanModal.handlers.test.ts
  • tests/client/clan/ClanModal.rendering.test.ts
  • tests/client/clan/ClanModalTestUtils.ts
💤 Files with no reviewable changes (3)
  • tests/client/clan/ClanModalTestUtils.ts
  • tests/client/clan/ClanApiQueries.test.ts
  • src/client/components/clan/ClanShared.ts

Comment thread src/client/components/clan/ClanDetailView.ts
Comment thread src/client/components/clan/ClanGameHistoryView.ts
Comment thread src/core/ClanApiSchemas.ts
@github-project-automation github-project-automation Bot moved this from Triage to Development in OpenFront Release Management May 22, 2026

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

Caution

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

⚠️ Outside diff range comments (1)
src/client/components/clan/ClanGameHistoryView.ts (1)

665-665: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix Prettier formatting before merge.

CI reports formatting issues. Run npx prettier --write . to resolve.

🤖 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/components/clan/ClanGameHistoryView.ts` at line 665, The file
ClanGameHistoryView.ts has Prettier formatting issues; run the formatter (e.g.,
npx prettier --write .) and commit the changed formatting for the component
ClanGameHistoryView (look for the ClanGameHistoryView React component and any
exported functions/handlers in that file) so CI passes; ensure no functional
code is changed—only whitespace/formatting.
🤖 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/ClanModal.ts`:
- Around line 42-44: The helper function isDetailTab is defined but unused;
remove the isDetailTab function to satisfy ESLint or, if intended for logic in
tab handling, integrate it into onTabEnter to explicitly detect DETAIL_TABS
instead of relying on type assertions. Locate the isDetailTab declaration and
either delete it or replace the current detail-tab checks in onTabEnter to call
isDetailTab(key) (using DETAIL_TABS as the source of truth) so the function is
actually referenced.

---

Outside diff comments:
In `@src/client/components/clan/ClanGameHistoryView.ts`:
- Line 665: The file ClanGameHistoryView.ts has Prettier formatting issues; run
the formatter (e.g., npx prettier --write .) and commit the changed formatting
for the component ClanGameHistoryView (look for the ClanGameHistoryView React
component and any exported functions/handlers in that file) so CI passes; ensure
no functional code is changed—only whitespace/formatting.
🪄 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: af028f90-bb55-4399-87f1-3ba17dbb5808

📥 Commits

Reviewing files that changed from the base of the PR and between 1f70ac6 and d565414.

📒 Files selected for processing (7)
  • resources/lang/en.json
  • src/client/ClanApi.ts
  • src/client/ClanModal.ts
  • src/client/Utils.ts
  • src/client/components/clan/ClanDetailView.ts
  • src/client/components/clan/ClanGameHistoryView.ts
  • src/client/components/clan/ClanShared.ts
💤 Files with no reviewable changes (1)
  • src/client/components/clan/ClanShared.ts

Comment thread src/client/ClanModal.ts
@github-project-automation github-project-automation Bot moved this from Complete to Development in OpenFront Release Management May 22, 2026
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