Compare commits

...

10 Commits

Author SHA1 Message Date
semantic-release-bot
678f4423b6 chore(release): 2.8.4 [skip ci]
## [2.8.4](https://github.com/antialias/soroban-abacus-flashcards/compare/v2.8.3...v2.8.4) (2025-10-09)

### Bug Fixes

* prevent redirect loops by checking if already at target URL ([c5268b7](c5268b79de))
2025-10-09 01:11:33 +00:00
Thomas Hallock
c5268b79de fix: prevent redirect loops by checking if already at target URL
Both useArcadeRedirect and useArcadeGuard were causing infinite loops:
1. User navigates to /arcade/room
2. Room page redirects to /arcade (if roomData null during loading)
3. /arcade sees active session at /arcade/room, redirects back
4. Loop repeats

Fix: Check if pathname already matches target URL before redirecting.
If already at target, skip the redirect and log that we're already there.

This fixes the infinite redirect loop when navigating to /arcade/room.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-08 20:10:40 -05:00
semantic-release-bot
d9aadd1f81 chore(release): 2.8.3 [skip ci]
## [2.8.3](https://github.com/antialias/soroban-abacus-flashcards/compare/v2.8.2...v2.8.3) (2025-10-08)

### Bug Fixes

* remove ArcadeGuardedPage from room page to prevent redirect loop ([4686f59](4686f59d24))
2025-10-08 19:25:16 +00:00
Thomas Hallock
4686f59d24 fix: remove ArcadeGuardedPage from room page to prevent redirect loop
ArcadeGuardedPage's redirect logic was conflicting with the room page's
own redirect logic, causing an infinite loop:
1. Room page would redirect to /arcade if no roomData
2. /arcade would see active session and redirect back to /arcade/room
3. Loop repeats

Room-based games don't need ArcadeGuardedPage because:
- They have their own navigation logic via useRoomData
- Arcade sessions are created dynamically when starting games in rooms
- We don't want to redirect away from the room page

This fixes the infinite redirect loop when navigating to /arcade/room.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-08 14:24:29 -05:00
semantic-release-bot
1219539585 chore(release): 2.8.2 [skip ci]
## [2.8.2](https://github.com/antialias/soroban-abacus-flashcards/compare/v2.8.1...v2.8.2) (2025-10-08)

### Bug Fixes

* revert to showing only active players in room games ([87cc0b6](87cc0b64fb))
2025-10-08 16:55:40 +00:00
Thomas Hallock
87cc0b64fb fix: revert to showing only active players in room games
Reverted getRoomActivePlayers() to use getActivePlayers() instead of
getAllPlayers(). Room games should show only players marked isActive=true
from each room member, not all players regardless of status.

Behavior:
- Room mode: Active players from all room members
- Solo mode: Active players from current user

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-08 11:54:43 -05:00
semantic-release-bot
c640a79a44 chore(release): 2.8.1 [skip ci]
## [2.8.1](https://github.com/antialias/soroban-abacus-flashcards/compare/v2.8.0...v2.8.1) (2025-10-08)

### Bug Fixes

* include all players from room members in room games ([28a2e7d](28a2e7d651))
2025-10-08 16:41:59 +00:00
Thomas Hallock
0d85331652 chore: remove debug logging after fixing player sync issue
Clean up verbose console.log statements that were added to diagnose
the player synchronization issue. The root cause has been identified
and fixed in player-manager.ts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-08 11:41:02 -05:00
Thomas Hallock
28a2e7d651 fix: include all players from room members in room games
Change getRoomActivePlayers() to fetch ALL players from room members,
not just those marked with isActive=true. In room mode, the concept of
"active" means "all players from all room members participate", not
"players individually marked as active".

This fixes the issue where users with no active players (activeCount: 0)
would have empty player arrays in memberPlayers, causing inconsistent
player lists across room members.

Changes:
- Add getAllPlayers(viewerId) function (no isActive filter)
- Update getRoomActivePlayers() to use getAllPlayers()
- Keep getActivePlayers() for solo mode (with isActive filter)
- Update comments to clarify room vs solo mode behavior

Note: Committing despite pre-existing TypeScript errors in unrelated
files (@soroban/abacus-react imports, tutorial components, tests).
player-manager.ts changes are type-safe and don't introduce new errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-08 11:40:15 -05:00
Thomas Hallock
a27c36193e debug: add logging to diagnose player sync issue
Add console logging to track:
- When GameModeContext computes activePlayers from room data
- Which players are being added to the active set
- What activePlayers are sent when starting the game

This will help diagnose why different room members see different
player sets when the game starts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-08 11:22:27 -05:00
7 changed files with 73 additions and 15 deletions

View File

@@ -1,3 +1,31 @@
## [2.8.4](https://github.com/antialias/soroban-abacus-flashcards/compare/v2.8.3...v2.8.4) (2025-10-09)
### Bug Fixes
* prevent redirect loops by checking if already at target URL ([c5268b7](https://github.com/antialias/soroban-abacus-flashcards/commit/c5268b79dee66aa02e14e2024fe1c6242a172ed3))
## [2.8.3](https://github.com/antialias/soroban-abacus-flashcards/compare/v2.8.2...v2.8.3) (2025-10-08)
### Bug Fixes
* remove ArcadeGuardedPage from room page to prevent redirect loop ([4686f59](https://github.com/antialias/soroban-abacus-flashcards/commit/4686f59d245b2b502dc0764c223a5ce84bf1af44))
## [2.8.2](https://github.com/antialias/soroban-abacus-flashcards/compare/v2.8.1...v2.8.2) (2025-10-08)
### Bug Fixes
* revert to showing only active players in room games ([87cc0b6](https://github.com/antialias/soroban-abacus-flashcards/commit/87cc0b64fb5f3debaf1d2f122aecfefc62922fed))
## [2.8.1](https://github.com/antialias/soroban-abacus-flashcards/compare/v2.8.0...v2.8.1) (2025-10-08)
### Bug Fixes
* include all players from room members in room games ([28a2e7d](https://github.com/antialias/soroban-abacus-flashcards/commit/28a2e7d6511e70b83adf7d0465789a91026bc1f7))
## [2.8.0](https://github.com/antialias/soroban-abacus-flashcards/compare/v2.7.4...v2.8.0) (2025-10-08)

View File

@@ -198,7 +198,7 @@ export function ArcadeMemoryPairsProvider({ children }: { children: ReactNode })
activePlayers,
},
})
}, [state.gameType, state.difficulty, activePlayers, sendMove])
}, [state.gameType, state.difficulty, activePlayers, sendMove, roomData])
const flipCard = useCallback(
(cardId: string) => {

View File

@@ -2,7 +2,6 @@
import { useRouter } from 'next/navigation'
import { useEffect } from 'react'
import { ArcadeGuardedPage } from '@/components/ArcadeGuardedPage'
import { useRoomData } from '@/hooks/useRoomData'
import { MemoryPairsGame } from '../matching/components/MemoryPairsGame'
import { ArcadeMemoryPairsProvider } from '../matching/context/ArcadeMemoryPairsContext'
@@ -46,14 +45,14 @@ export default function RoomPage() {
}
// Render the appropriate game based on room's gameName
// Note: We don't use ArcadeGuardedPage here because room-based games
// have their own navigation logic via useRoomData
switch (roomData.gameName) {
case 'matching':
return (
<ArcadeGuardedPage>
<ArcadeMemoryPairsProvider>
<MemoryPairsGame />
</ArcadeMemoryPairsProvider>
</ArcadeGuardedPage>
<ArcadeMemoryPairsProvider>
<MemoryPairsGame />
</ArcadeMemoryPairsProvider>
)
// TODO: Add other games (complement-race, memory-quiz, etc.)

View File

@@ -74,10 +74,13 @@ export function useArcadeGuard(options: UseArcadeGuardOptions = {}): UseArcadeGu
})
// Redirect if we're not already on the active game page (only if enabled)
if (enabled && pathname !== data.gameUrl) {
const isAlreadyAtTarget = pathname === data.gameUrl
if (enabled && !isAlreadyAtTarget) {
console.log('[ArcadeGuard] Redirecting to active session:', data.gameUrl)
onRedirect?.(data.gameUrl)
router.push(data.gameUrl)
} else if (isAlreadyAtTarget) {
console.log('[ArcadeGuard] Already at target URL, no redirect needed')
}
},
@@ -127,10 +130,13 @@ export function useArcadeGuard(options: UseArcadeGuardOptions = {}): UseArcadeGu
})
// Redirect if we're not already on the active game page (only if enabled)
if (enabled && pathname !== session.gameUrl) {
const isAlreadyAtTarget = pathname === session.gameUrl
if (enabled && !isAlreadyAtTarget) {
console.log('[ArcadeGuard] Redirecting to active session:', session.gameUrl)
onRedirect?.(session.gameUrl)
router.push(session.gameUrl)
} else if (isAlreadyAtTarget) {
console.log('[ArcadeGuard] Already at target URL, no redirect needed')
}
} else if (response.status === 404) {
// No active session

View File

@@ -71,10 +71,13 @@ export function useArcadeRedirect(options: UseArcadeRedirectOptions = {}): UseAr
// Determine if we need to redirect
const isArcadeLobby = currentGame === null || currentGame === undefined
const isWrongGame = currentGame && currentGame !== data.currentGame
const isAlreadyAtTarget = _pathname === data.gameUrl
if (isArcadeLobby || isWrongGame) {
if ((isArcadeLobby || isWrongGame) && !isAlreadyAtTarget) {
console.log('[ArcadeRedirect] Redirecting to active game:', data.gameUrl)
router.push(data.gameUrl)
} else if (isAlreadyAtTarget) {
console.log('[ArcadeRedirect] Already at target URL, no redirect needed')
}
},

View File

@@ -8,8 +8,29 @@ import { db, schema } from '@/db'
import type { Player } from '@/db/schema/players'
/**
* Get a user's active players
* These are the players that will participate when the user joins a game
* Get all players for a user (regardless of isActive status)
* @param viewerId - The guestId from the cookie (same as what getViewerId() returns)
*/
export async function getAllPlayers(viewerId: string): Promise<Player[]> {
// First get the user record by guestId
const user = await db.query.users.findFirst({
where: eq(schema.users.guestId, viewerId),
})
if (!user) {
return []
}
// Now query all players by the actual user.id (no isActive filter)
return await db.query.players.findMany({
where: eq(schema.players.userId, user.id),
orderBy: schema.players.createdAt,
})
}
/**
* Get a user's active players (solo mode)
* These are the players that will participate when the user joins a solo game
* @param viewerId - The guestId from the cookie (same as what getViewerId() returns)
*/
export async function getActivePlayers(viewerId: string): Promise<Player[]> {
@@ -30,7 +51,8 @@ export async function getActivePlayers(viewerId: string): Promise<Player[]> {
}
/**
* Get all active players for all members in a room
* Get active players for all members in a room
* Returns only players marked isActive=true from each room member
* Returns a map of userId -> Player[]
*/
export async function getRoomActivePlayers(roomId: string): Promise<Map<string, Player[]>> {
@@ -39,7 +61,7 @@ export async function getRoomActivePlayers(roomId: string): Promise<Map<string,
where: eq(schema.roomMembers.roomId, roomId),
})
// Fetch active players for each member
// Fetch active players for each member (respects isActive flag)
const playerMap = new Map<string, Player[]>()
for (const member of members) {
const players = await getActivePlayers(member.userId)

View File

@@ -1,6 +1,6 @@
{
"name": "soroban-monorepo",
"version": "2.8.0",
"version": "2.8.4",
"private": true,
"description": "Beautiful Soroban Flashcard Generator - Monorepo",
"workspaces": [