Skip to content

Docs: Added Contributing.md file#36

Closed
Flashl3opard wants to merge 3 commits intoalphaonelabs:mainfrom
Flashl3opard:docs/contributing
Closed

Docs: Added Contributing.md file#36
Flashl3opard wants to merge 3 commits intoalphaonelabs:mainfrom
Flashl3opard:docs/contributing

Conversation

@Flashl3opard
Copy link
Copy Markdown

@Flashl3opard Flashl3opard commented Apr 8, 2026

Summary

Add a repository-specific contributing guide for learn and align contribution instructions with the actual project stack and workflows.

Changes

Added CONTRIBUTING.md tailored to the repo:

  • D1 (SQLite) database workflow
  • Static HTML/Tailwind/vanilla JS frontend workflow
  • Local setup with wrangler and .dev.vars
  • Manual validation checklist for core user flows
  • Conventional Commits and PR expectations

Summary

This PR combines documentation improvements with bug fixes addressing duplicate submissions and improving idempotency:

Documentation Changes:

  • Adds CONTRIBUTING.md with comprehensive contribution guidance including:
    • Repository-specific setup instructions (Wrangler, D1 database, .dev.vars configuration)
    • Coding standards across Python, JavaScript, and HTML/Tailwind
    • Conventional Commits format and PR expectations
    • Manual validation checklist for core user flows

Code Changes - Duplicate Submission Prevention:

Introduces client-side concurrency control across frontend pages and backend validation:

  1. Frontend (public/course.html, public/login.html, public/teach.html):

    • Added inFlight Set and withActionLock(key, action) helper to prevent concurrent submissions per action
    • Locks applied to: join activity, login/register, create activity, and add session handlers
    • Prevents users from triggering multiple async requests for the same action simultaneously
  2. Backend (src/worker.py):

    • Modified api_join to pre-check enrollment existence before database insert
    • Changed from INSERT OR IGNORE to explicit pre-check + exception handling
    • Returns "Already joined activity" response on duplicate attempts instead of generic errors
    • Enforces idempotency at the database constraint level

Impact:

  • Improves user experience by preventing accidental duplicate submissions
  • Hardens join operation against race conditions and network retries
  • Provides clear feedback to users attempting duplicate actions
  • Complements the new contribution guide with actual implementation improvements

Copilot AI review requested due to automatic review settings April 8, 2026 17:57
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

This pull request adds a contribution guide, implements client-side concurrency control across multiple frontend pages to prevent duplicate submissions, refactors HTML structure and Tailwind configuration formatting, and hardens the enrollment API endpoint to gracefully handle duplicate join attempts.

Changes

Cohort / File(s) Summary
Documentation
CONTRIBUTING.md
New contribution guide covering code of conduct, development setup (prerequisites, Wrangler authentication, D1 database initialization, .dev.vars configuration), coding standards (Python, JavaScript, HTML/Tailwind), commit conventions (Conventional Commits), PR process, merge expectations, and AGPLv3 licensing.
Frontend Concurrency Control
public/course.html, public/login.html, public/teach.html
Introduced inFlight set and withActionLock(key, action) pattern across all three pages to prevent concurrent form submissions and async operations. Login/register forms, activity joining, and session creation now wrapped with action locks to serialize requests by key.
HTML Restructuring & Formatting
public/course.html, public/login.html, public/teach.html
Normalized Tailwind config formatting, expanded CSS rules to multi-line format, adjusted HTML indentation and whitespace. Session rendering refactored to only build DOM when sessions exist; non-joined action logic reorganized for authenticated users.
Async Response Ordering
public/teach.html
Added hostedLoadVersion counter in loadHostedActivities() to ignore stale async responses when newer loads are initiated, preventing race conditions in activity list updates.
Enrollment Deduplication
src/worker.py
Updated api_join() to pre-check for existing enrollment before insert and return "Already joined activity" on duplicates; changed from INSERT OR IGNORE to INSERT with explicit UNIQUE constraint error handling for clearer intent.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Docs: Added Contributing.md file' accurately reflects the primary documentation addition, though the changeset also includes substantial frontend concurrency control improvements and backend join idempotency hardening.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a repository-specific contribution guide and also introduces a few functional changes to the join/enrollment flow and frontend form submission behavior.

Changes:

  • Added CONTRIBUTING.md with repo-specific setup, workflows, and contribution expectations.
  • Updated join/enrollment handling to be explicitly idempotent (“Already joined activity”) instead of relying on INSERT OR IGNORE.
  • Refactored several HTML pages and added a small in-flight action lock to prevent duplicate submissions.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
CONTRIBUTING.md Adds a contribution guide tailored to the project’s stack and workflows.
src/worker.py Makes /api/join explicitly handle “already joined” before/after insert.
public/teach.html Formatting cleanup + in-flight locking for host create flows.
public/login.html Formatting cleanup + in-flight locking for login/register flows.
public/course.html Formatting cleanup + in-flight locking for join flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +979 to 995
existing = await env.DB.prepare(
"SELECT id FROM enrollments WHERE activity_id=? AND user_id=?"
).bind(act_id, user["id"]).first()
if existing:
return ok(None, "Already joined activity")

enr_id = new_id()
try:
await env.DB.prepare(
"INSERT OR IGNORE INTO enrollments (id,activity_id,user_id,role)"
"INSERT INTO enrollments (id,activity_id,user_id,role)"
" VALUES (?,?,?,?)"
).bind(enr_id, act_id, user["id"], role).run()
except Exception as e:
if "UNIQUE" in str(e):
return ok(None, "Already joined activity")
capture_exception(e, req, env, "api_join.insert_enrollment")
return err("Failed to join activity — please try again", 500)
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title/description indicate a docs-only change (adding CONTRIBUTING.md), but this PR also includes functional backend/frontend changes (e.g., join enrollment behavior and in-flight request locks). Please update the PR title and/or description to accurately reflect the full scope so reviewers can assess risk and release impact correctly.

Copilot uses AI. Check for mistakes.
Comment on lines +88 to +93
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Password</label>
<input id="r-password" type="password" autocomplete="new-password" required minlength="6"
class="w-full px-4 py-2.5 rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-brand/40 text-sm"
placeholder="min 6 characters" />
</div>
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The registration password field enforces minlength="6", but the backend rejects passwords shorter than 8 characters (see src/worker.py validation). This will cause avoidable registration failures; align the client-side minlength (and any helper text) with the server requirement.

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +10
This project and everyone participating in it is expected to act respectfully and constructively.

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar: “everyone participating in it is expected” should be “everyone participating in it are expected” (or rephrase to avoid agreement issues, e.g., “everyone … is expected to act…”).

Copilot uses AI. Check for mistakes.
Comment on lines +120 to 130
const inFlight = new Set();

async function withActionLock(key, action) {
if (inFlight.has(key)) return;
inFlight.add(key);
try {
await action();
} finally {
inFlight.delete(key);
}
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same withActionLock/inFlight helper is now duplicated inline across multiple HTML pages (login/course/teach). Consider extracting it to a shared script (or otherwise centralizing) to avoid future drift when the locking behavior needs to change.

Copilot uses AI. Check for mistakes.
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