Skip to content

feat: show the current user's ongoing games on the home page - #1389

Merged
itsalaidbacklife merged 16 commits into
mainfrom
feat/show-my-open-games
Oct 8, 2026
Merged

itsalaidbacklife merged 16 commits into
mainfrom
feat/show-my-open-games

Conversation

@itsalaidbacklife

@itsalaidbacklife itsalaidbacklife commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Issue number

What this does

Adds a My Current Games section to the top of the home page's Play tab, listing the signed-in user's STARTED games with a Continue button and an Archive button.

image

Today a player who closes the tab on an in-progress game has no way back in from the UI — open games are CREATED-only, the spectate list drops anything idle for 5 minutes, and game history is FINISHED-only. Abandoned games sit at STARTED forever, reachable only by whoever still has the /game/:id URL.

Design decisions worth a look

No new endpoint. The issue floated either parameterizing get-history or adding a dedicated endpoint. I did neither. get-history is built for the profile page's infinite scroll (limit/skip/sort whitelist, { finishedGames, totalCount, hasMore }); ongoing games are a bounded handful that must never be paginated away, so parameterizing it would make finishedGames a lie and inherit pagination the home page doesn't want. But a third endpoint wasn't needed either — the home page already calls GET /api/game on mount and on socket reconnect, so myCurrentGames rides along with zero extra round trips.

Consequence: the data lives in the gameList store, not myGames as the issue suggests. gameList already owns that endpoint and already receives every socket event that mutates this list.

ARCHIVED already existed. It's been in utils/GameStatus.json and read in 9 places as a synonym for "done" — move.js:47 rejects moves on it, get-game.js:21-26 demotes both players to spectators — but nothing ever wrote it. This is the first write. The model's doc comment has been updated, since it previously described ARCHIVED as a game removed before starting.

Three guards on DELETE /api/game/:gameId, shared with the list's canArchive flag via sails.helpers.canArchiveGame so the disabled button and the 403 can't disagree:

  1. the requester must be a player in the game;
  2. ranked games created inside the current season week are blocked (they still bear on this week's match);
  3. the game must be dormant — reusing findSpectatableGames' threshold, so a game can never be pulled out from under an opponent who is still playing. Per discussion on the issue, this plus a gameArchived socket event closes the griefing hole rather than leaving the opponent hitting silently-rejected moves.

One subtle trap worth flagging for review: lockGame writes lock/lockedAt to the Game row, which bumps updatedAt — the very signal dormancy is measured by. Locking first made every archive 403. The action now validates against the unlocked record and locks only to re-check status.

Shared week math. The season-week boundary is extracted out of findOrCreateCurrentMatch into sails.helpers.getCurrentSeasonWeek, so both callers share one implementation. StatsController's two other week-bucketing conventions are deliberately untouched — they bucket different things for the leaderboard.

vs-AI games are included: they're always STARTED and never ranked, so they're the main thing this cleans up.

Please check the following

  • Do the tests still pass?
  • Is the code formatted properly?
  • For New Features:
    • Have tests been added to cover any new features or fixes?
    • Has the documentation been updated accordingly?

Please describe additional details for testing this change

home.spec.js gains a My Current Games block (7 new tests) covering: header hidden when empty, Continue into a live board, archive-and-reload, Archive disabled while a game is still active, both ranked-week directions (current week blocked / previous week allowed), archived games excluded from the spectate list, and a 403 for a non-player.

Seeding note for anyone extending these: TestController.loadFinishedGameFixtures passes updatedAt through explicitly, which is what makes the dormancy cases testable. A game created via setupGameAsP0 is fresh, so its Archive button is correctly disabled — tests wanting an archivable game must seed a stale updatedAt.

Verified locally:

  • npm run lint clean, npm run test:unit 83/83
  • home.spec.js 32/32
  • Regression: rankedMatches + stats + profile 22/22, covering the week-math refactor

Known gap (deliberate)

The gameStarted blast payload is only { gameId }, with no player info, so a client can't tell whether a newly-started game is theirs. A game starting while you sit on the home page won't self-insert into the list; it's correct on next load. In practice the player who readied up navigates straight into the game. Left alone rather than reworking the socket payload.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KAEzsNrfdmwzM36fzPWxV9

A player who closed the tab on an in-progress game had no way back in from
the UI: open games are CREATED-only, the spectate list drops anything idle
for 5 minutes, and game history is FINISHED-only. Abandoned games sat at
STARTED forever, reachable only by whoever still had the /game/:id URL.

Adds a "My Current Games" section to the top of the home page's Play tab,
with Continue (a push to /game/:id, which is already the whole rejoin
mechanism) and Archive.

The data rides along on GET /api/game, which the home page already calls on
mount and on socket reconnect, so there is no extra round trip and no new
endpoint. It therefore lives in the gameList store rather than myGames.

Archiving writes GameStatus.ARCHIVED, which already existed in the enum and
was already read as a synonym for FINISHED -- moves are rejected and both
players are demoted to spectators -- but had never been written by anything.

Two guards keep DELETE /api/game/:gameId honest, shared with the list's
canArchive flag via sails.helpers.canArchiveGame so the disabled button and
the 403 cannot disagree:
  - the requester must be a player in the game
  - ranked games created inside the current season week are blocked, since
    they still bear on this week's match
  - the game must be dormant, reusing findSpectatableGames' threshold, so a
    game can never be pulled out from under an opponent who is still playing

Note that lockGame writes lock/lockedAt to the Game row and so bumps
updatedAt -- the very signal dormancy is measured by. The archive action
validates against the unlocked record and locks only to re-check status.

The season week boundary is extracted out of findOrCreateCurrentMatch into
sails.helpers.getCurrentSeasonWeek so both callers share one implementation.

Resolves #1387

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KAEzsNrfdmwzM36fzPWxV9
@itsalaidbacklife itsalaidbacklife added the version-minor An update that warrants a bumping the project's minor version (e.g. 4.0.0 => 4.1.0) label Oct 3, 2026
itsalaidbacklife and others added 2 commits October 4, 2026 13:43
Two design fixes from PR review.

The Archive button crowded its row: at the width the home card gives it, an
icon plus a text label left the name column squeezed enough that game names
wrapped. Dropping the label and keeping just an icon frees the space. The
button keeps its accessible name via aria-label, and the tooltip now fires
in both states -- naming the action when archiving is available, explaining
the block when it isn't -- so losing the visible label costs no clarity.

The "No Active Games" placeholder contradicted the new section directly
above it, since a user's current games are plainly active. That list is
specifically games awaiting a second player, so it is now labelled "Open
Games" with a "No Games to Join" placeholder, which names the absent action
rather than a state. Renames home.noGameslist to home.noOpenGames across all
five locales, fixing that key's odd casing on the way past.

Both lists now carry a header, so the Play tab reads as two labelled
sections instead of one labelled list above an anonymous one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KAEzsNrfdmwzM36fzPWxV9
The two section headers rendered smaller than the game names beneath them,
inverting the hierarchy they exist to establish.

Part of that was a stale rule. HomeView carried a scoped `h2 { font-size:
1.25rem }` that was dead on main -- the template had no h2 at all -- so the
headers added in 8c24a34 were the first elements to hit it. Being scoped,
it compiles to `h2[data-v-...]`, which outranks a plain class selector and
clamped the headers to 20px against the game names' 24px. Removing it also
clears the trap for the next h2 added to this view.

The headers now use .text-label-lg (Changa 32px/700), which is already the
h2 section style across the Rules page, so this adds no new CSS and keeps
the Play tab consistent with the rest of the app. Same family as the game
name, so the two read as one voice a size apart rather than as competing
typefaces.

Luckiest Guy was considered and set aside: it is reserved for page titles
here -- #home-card-title renders GAME FINDER in it at 5rem directly above
this card -- so reusing it two levels down flattens the hierarchy instead of
clarifying it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KAEzsNrfdmwzM36fzPWxV9
Comment thread api/controllers/game/archive.js Resolved
Comment thread src/plugins/sockets/inGameEvents.js Resolved
Two points from review.

api/controllers/game/archive.js: replace the switch over p0/p1 with an
includes check against the player ids, matching set-is-ranked.js.

src/plugins/sockets/inGameEvents.js: drop the raw `i18n.global.t()` call in
favour of the composable. It can't be used in this module directly --
useI18n() throws MUST_BE_CALL_SETUP_TOP outside a component setup, and
socket handlers run from io.socket.on with no component instance -- so the
handler now hands Home the i18n key through `query.error` instead of a
translated string. HomeView's $route watcher already reads that key and runs
it through the composable's t(), which is how router.js bounces failed game
loads, so the translation happens in a component the way it does elsewhere
and the raw import goes away entirely.

Moves the message from game.snackbar.global to home.snackbar alongside the
other "bounced back to Home" strings (cannotJoin, cantFindGame,
cannotSpectate), since that is now where it is displayed.

Adds a test pinning the key handover, so renaming the key cannot silently
degrade the message to a raw dotted string.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KAEzsNrfdmwzM36fzPWxV9
Comment thread api/controllers/game/archive.js Resolved
Comment thread src/routes/home/HomeView.vue Resolved
Comment thread src/stores/gameList.js Resolved
Replaces the Topdeck Nines announcement with one covering the new
My Current Games section: where in-progress games now appear, that Continue
drops you back into the game, and that the × archives an abandoned one.

The second paragraph states the two archive restrictions deliberately, since
both are cases where the button is visibly disabled with no inline
explanation -- games still being played, and ranked games from the current
week.

Illustrated with a screenshot of the real section, showing both the enabled
and disabled archive states. Note the image is English for every locale;
the surrounding copy is translated.

Bumps the id so everyone who dismissed the Nines announcement sees this one.
Drops the now-unused patreonLink key from all five translation files.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KAEzsNrfdmwzM36fzPWxV9
Comment thread api/controllers/game/archive.js Resolved
itsalaidbacklife and others added 4 commits October 5, 2026 11:56
archive.js: chain the filter and includes into a single isPlayerInGame
variable used by the conditional, per review. Keeps the filter -- an unset
p0/p1 would otherwise let an undefined session user match -- and says so in
the comment, since the question came up twice. Also applies the suggested
wording on the lock comment.

gameList.js: requestArchiveGame could reject with a bare string, an Error, or
whatever non-string `message` the response body happened to carry, and threw
outright on a null body. Normalises every failure path to an Error carrying a
string, which is the shape CurrentGameListItem already reads.

CurrentGameListItem.vue: replace the v-tooltip component and its activator
slot with the tooltip directive.

The directive binds to the span wrapper rather than the button itself. A
disabled v-btn renders as <button disabled> with pointer-events:none, so a
real pointer never reaches it and binding there would leave the blocked-state
tooltip permanently invisible -- while still passing a test that triggers
mouseenter on the button directly, since that dispatches straight to the
element. The two new tests hover the wrapper for that reason, and assert the
pointer-events:none that makes it necessary.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KAEzsNrfdmwzM36fzPWxV9
Per review: GameListItem already served both join and spectate, so the
current-games row becomes a third mode rather than a second component.

Replaces the isSpectatable boolean with an explicit `mode` prop
(join | spectate | current), exported as GAME_LIST_ITEM_MODE from a companion
<script> block since <script setup> cannot carry named exports. Three
booleans would have been three ways to express the same one-of-three choice,
including invalid combinations.

Converts the component to <script setup>, per AGENTS.md. That was the main
cost of merging: the existing component was Options API, and the new one had
to be script setup, so one of the two had to move.

Drops the p0ready/p1ready props. They only ever fed a numPlayersReady
computed that the template never referenced -- dead since before this branch,
and surfaced by having to account for every prop while merging.

Keeps distinct root data-cy values per mode: tests counting
[data-cy=game-list-item] would otherwise pick up current games too.

Verified across the full out-of-game suite (139 tests), since this component
backs the join, spectate and current lists.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KAEzsNrfdmwzM36fzPWxV9
#1391 added worktrees/ and .claude/worktrees/ to .gitignore so parallel dev
stacks don't show up as untracked, but eslint doesn't read .gitignore. Each
worktree holds a full checkout, so `npm run lint` walked into them and
reported errors for code belonging to another stack -- 30 of them locally,
none from this one's source.

CI never sees this because no worktree exists there, so it only breaks the
local run that AGENTS.md asks for before finishing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KAEzsNrfdmwzM36fzPWxV9
Comment thread api/helpers/can-archive-game.js Resolved
itsalaidbacklife and others added 7 commits October 8, 2026 07:30
The two section headings cost ~80px at the top of a list pinned to 50vh,
which pushed the first joinable game below the scroll fold -- the heading was
visible with nothing under it, so an empty-looking section read as "no open
games" rather than "scroll for more". Measured at a 760px viewport: the
first join row ended at 380px inside a 308px window; without the headings it
ends at 296px and clears it.

Removing them needs the two groups to stay distinguishable, which the rows
already half-managed through their secondary line and button verb ("vs
<name>" + Continue against "n / 2 players" + Join). Filling the Continue
button finishes the job: filled-against-outlined separates the groups at a
glance, and resuming a game you're part-way through outranks browsing for a
new one, so the weight sits in the right place.

Drops home.myCurrentGames and home.openGames across all five locales, now
that nothing references them.

Known trade-off: against a filled button the disabled archive icon is much
fainter, so on a blocked row the control is easy to miss entirely. Left as
is -- it only affects rows where the action is unavailable anyway, and the
opacity is adjustable on its own if it proves a problem.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KAEzsNrfdmwzM36fzPWxV9
…reference

The announcement shipped a screenshot of the previous design -- section
headings, outlined Continue -- which 3cbf5d4 replaced. Recaptures it against
the current layout, and now frames two in-progress games above a joinable one
so the image shows the arrangement the copy describes.

The copy pointed readers at a heading that no longer exists ("at the top of
the Play tab, under My Current Games"). Drops that clause in all five
locales; the rest of the paragraph still holds.

Leaves the announcement id alone: the content is the same announcement
corrected, not a new one, and it has not shipped yet, so nobody has a
dismissal to reset.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KAEzsNrfdmwzM36fzPWxV9
# Conflicts:
#	api/helpers/find-spectatable-games.js
#1397 made backend JSON imports explicit so the editor can resolve them;
these three files predate that merge and still used the extensionless form.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KAEzsNrfdmwzM36fzPWxV9
Per review, the input description named its source helper but never said what
the value holds or why it is needed. Now states both: the running season with
its current week's bounds, used to block archiving a ranked game created
inside that week.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KAEzsNrfdmwzM36fzPWxV9
…ayload

f82ec05 replaced the explicit field list with `...game`, which also spreads
the populated p0/p1 User records. User has an encryptedPassword attribute and
no customToJSON, so GET /api/game began returning both players' bcrypt hashes
to the client on every home page load:

  p0 keys: createdAt, encryptedPassword, id, isBot, pNum, rank, updatedAt, username

Keeps the spread, but destructures p0/p1 away first, along with the lock and
lockedAt concurrency fields. The `opponent` key below already carries the only
user data the client needs, and nothing on the frontend read the populated
records.

Verified against the running endpoint: encryptedPassword no longer appears in
the response.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KAEzsNrfdmwzM36fzPWxV9
@itsalaidbacklife itsalaidbacklife added enhancement New feature or request announcement labels Oct 8, 2026
@itsalaidbacklife
itsalaidbacklife merged commit 408fd2b into main Oct 8, 2026
11 of 12 checks passed
@itsalaidbacklife
itsalaidbacklife deleted the feat/show-my-open-games branch October 8, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

announcement enhancement New feature or request version-minor An update that warrants a bumping the project's minor version (e.g. 4.0.0 => 4.1.0)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Display current user’s open/ongoing games in the home page list of available games

2 participants