Gamehistory#3987
Conversation
WalkthroughAdds 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. ChangesClan Game History Feature
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
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-viewUI (filters, infinite scroll pagination, replay deep-linking) and wire it intoClanModalas a new detail tab. - Remove
fetchClanStatsusage/tests and adjust clan detail logic to lazy-load member data; updaterenderDuration()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.
There was a problem hiding this comment.
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
📒 Files selected for processing (12)
resources/lang/en.jsonsrc/client/ClanApi.tssrc/client/ClanModal.tssrc/client/Utils.tssrc/client/components/clan/ClanDetailView.tssrc/client/components/clan/ClanGameHistoryView.tssrc/client/components/clan/ClanShared.tssrc/core/ClanApiSchemas.tstests/client/clan/ClanApiQueries.test.tstests/client/clan/ClanModal.handlers.test.tstests/client/clan/ClanModal.rendering.test.tstests/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
There was a problem hiding this comment.
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 winFix 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
📒 Files selected for processing (7)
resources/lang/en.jsonsrc/client/ClanApi.tssrc/client/ClanModal.tssrc/client/Utils.tssrc/client/components/clan/ClanDetailView.tssrc/client/components/clan/ClanGameHistoryView.tssrc/client/components/clan/ClanShared.ts
💤 Files with no reviewable changes (1)
- src/client/components/clan/ClanShared.ts
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:
Please put your Discord username so you can be contacted if a bug or regression is found:
w.o.n