Skip to content

Enforce at-most-one active round per session#8

Draft
Copilot wants to merge 3 commits intofix/prodfrom
copilot/sub-pr-1-d769a649-b1d2-4e24-b0f0-fcba47e532f1
Draft

Enforce at-most-one active round per session#8
Copilot wants to merge 3 commits intofix/prodfrom
copilot/sub-pr-1-d769a649-b1d2-4e24-b0f0-fcba47e532f1

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 10, 2026

POST /api/sessions/[id]/rounds had no guard against concurrent active rounds — calling it twice would create duplicate active rounds and double-assign roles.

Changes

  • Active round check: Before creating a round, query for any existing status = 'active' round on the session. Return HTTP 409 if one is found, with a message directing the caller to end the current round first.
  • Explicit status on insert: New rounds are now inserted with status = 'active' so the guard reliably detects them.
const activeRound = await sql`
  SELECT id FROM rounds WHERE session_id = ${id} AND status = 'active'
`;
if (activeRound.length > 0) {
  return NextResponse.json(
    { error: 'A round is already active for this session. End the current round before starting a new one.' },
    { status: 409 }
  );
}

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
live-game Error Error Mar 10, 2026 5:45am

Copilot AI and others added 2 commits March 10, 2026 05:36
Co-authored-by: ghostleek <44336310+ghostleek@users.noreply.github.com>
Co-authored-by: ghostleek <44336310+ghostleek@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix sessions API, database library and layout issues Enforce at-most-one active round per session Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants