# Implementation Plan: Series Result History UI ## Overview Replace the existing completed-Game mini-card grid with a tested chronological Series result history. Keep data derivation pure, render responsive semantic rows, and preserve all current Competition/API contracts. ## Architecture Decisions - Derive a local view model from `projection.series` and `projection.games`; no API or persistence change is required. - Anchor a played Series to its earliest accepted Game start. Anchor a game-less completed decision to its decision time only for grouping and sorting. - Keep the original narrowed Series and Game objects in each row so the UI does not duplicate domain state or collapse outcome semantics. - Use a native `details/summary` disclosure for Game history and omit it when a Series has no Games. - Extract the new UI from `CompetitionResults.tsx` so the format selector remains focused. ## Task List ### Phase 1: Result-History Contract #### Task 1: Specify aggregation and chronology test-first **Acceptance criteria:** - [x] Tests cover Series aggregation, ordinal Game order, KST date boundaries, chronological order, outcome variants, and deterministic fallbacks. - [x] The focused test fails because the model module does not yet exist. **Verification:** - [x] Run the focused Node test and record the expected RED failure. **Files likely touched:** - `apps/web/test/competition-series-history.test.ts` #### Task 2: Implement the pure history model **Acceptance criteria:** - [x] Only recorded in-progress and completed Series are returned. - [x] Date grouping and format helpers are explicitly KST-aware. - [x] Decision outcomes and missing legacy durations remain distinguishable. **Verification:** - [x] Focused history tests pass. - [x] Existing web tests still pass. **Files likely touched:** - `apps/web/src/components/competition/competition-series-history.ts` - `apps/web/test/competition-series-history.test.ts` ### Checkpoint: Model - [x] Pure tests pass without a React or browser dependency. ### Phase 2: Responsive Result UI #### Task 3: Render date sections and Series rows **Acceptance criteria:** - [x] Desktop uses a flat schedule-like row; mobile stacks metadata and matchup without horizontal scrolling. - [x] Status and official winner are communicated with visible text and typography, not color alone. - [x] Game-less decisions do not show fake start times or `0 : 0`. **Verification:** - [x] Changed component files pass ESLint. - [x] Web build succeeds. **Files likely touched:** - `apps/web/src/components/competition/CompetitionSeriesHistory.tsx` #### Task 4: Integrate accessible Game disclosures **Acceptance criteria:** - [x] Each Series with Games exposes a native keyboard-operable disclosure. - [x] Games use Series-local ordinal, team-ID winner lookup, and omit unknown zero-duration values. - [x] The old completed-Game mini-card block is removed. **Verification:** - [x] Full web tests, changed-file lint, and build pass. Repository-wide lint remains blocked by pre-existing errors outside this change. - [x] Source review checks heading order, disclosure semantics, and 320px layout. **Files likely touched:** - `apps/web/src/components/competition/CompetitionSeriesHistory.tsx` - `apps/web/src/components/competition/CompetitionResults.tsx` ### Checkpoint: Complete - [x] All specification success criteria are met. - [x] Git diff contains only the feature spec, plan, tests, model, and UI integration. - [x] Unrelated working-tree files are unchanged. ### Phase 3: Game Detail Navigation #### Task 5: Specify the canonical Game route test-first **Acceptance criteria:** - [x] A Game whose `ordinal` and `displayNumber` differ links with `displayNumber`. - [x] Non-positive or non-integer legacy display numbers do not produce a broken detail link. - [x] The focused test is observed failing before the route adapter exists. **Verification:** - [x] Run the focused Node test for RED and GREEN states. **Files likely touched:** - `apps/web/test/competition-series-history.test.ts` - `apps/web/src/components/competition/competition-series-history.ts` #### Task 6: Make disclosed Game rows navigable **Acceptance criteria:** - [x] The full Game row is one React Router link with an always-visible detail cue. - [x] The link carries the current Competition location as `backTo` and a Korean return label. - [x] Mobile targets are at least 44px high; keyboard focus is visible; hover and active states use restrained semantic-primary coral accents. - [x] The scoped primary token keeps that coral accent in both themes without a global dark-theme color migration. - [x] Winner, score, and status colors retain their existing domain meaning. **Verification:** - [x] Focused and full web tests pass. - [x] Changed-file ESLint and the production web build pass. - [x] Independent review checks route identity, interaction semantics, accessibility, and unrelated working-tree preservation. **Files likely touched:** - `apps/web/src/components/competition/CompetitionGameHistory.tsx` - `apps/web/src/components/competition/CompetitionSeriesHistory.tsx` - `apps/web/src/components/competition/CompetitionResults.tsx` #### Task 7: Refuse incorrect Game-detail fallbacks **Acceptance criteria:** - [x] Exact requested Game numbers resolve to that Game. - [x] Missing or invalid requested Game numbers return no selection instead of the first Game. - [x] The detail page renders an explicit missing-Game state with the preserved return target. - [x] The policy is covered by an observed RED→GREEN pure regression test. **Verification:** - [x] Focused selection tests, full web tests, changed-file ESLint, and build pass. **Files likely touched:** - `apps/web/src/lib/internal-match-game-selection.ts` - `apps/web/src/pages/MatchGameDetailPage.tsx` - `apps/web/test/internal-match-game-selection.test.ts` ### Checkpoint: Navigable Game History - [x] Every valid recorded Game opens its own internal-stat detail view. - [x] Browser back and the detail page return link restore the Competition result page. - [x] Invalid legacy route data degrades to a non-clickable row instead of a wrong destination. - [x] A stale detail payload cannot substitute a different Game for the requested route. ## Risks and Mitigations | Risk | Impact | Mitigation | |---|---|---| | Game sides are mistaken for Series slots | High | Use Series A/B entries and outcome team IDs; test side swaps. | | Completion time is shown as start time | Medium | Track timestamp source and render a blank time for decisions. | | KST day changes by deploy environment | Medium | Use explicit `Intl.DateTimeFormat` timezone and boundary tests. | | Long team names break mobile rows | Medium | Use balanced minmax columns and allow wrapping. | | Existing dirty work is overwritten | High | Restrict patches and verification to named feature files. | | Series-local ordinal opens another Series' Game | High | Generate routes only from tested global `displayNumber`. | | Coral is mistaken for the winning side | Medium | Restrict primary color to interaction edges, focus, and arrows. | ## Open Questions None.