Skip to content

fix(rooms): wire ?after= param to getRoomMessagesSince in messages GET route#2305

Open
nyxsky404 wants to merge 1 commit into
Umbrella-io:mainfrom
nyxsky404:fix/room-messages-after-param-ignored
Open

fix(rooms): wire ?after= param to getRoomMessagesSince in messages GET route#2305
nyxsky404 wants to merge 1 commit into
Umbrella-io:mainfrom
nyxsky404:fix/room-messages-after-param-ignored

Conversation

@nyxsky404

Copy link
Copy Markdown
Contributor

Summary

The room chat polling loop in MessageFeed sends ?after=<timestamp> to fetch only messages newer than the last seen one. The GET handler was reading ?before= exclusively, so after was silently ignored — every poll returned the same last-50 messages instead of only the new ones. This PR wires the after param to the already-existing getRoomMessagesSince helper.

Closes #2301


Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

What Changed

  • src/app/api/rooms/[roomId]/messages/route.ts — added after param read from query string; branched to getRoomMessagesSince(roomId, after) for incremental polls and kept getRoomMessages(roomId, 50, before) for initial loads and reverse pagination
  • Added getRoomMessagesSince to the import from @/lib/supabase-rooms

How to Test

  1. Open a collaboration room that already has some messages.
  2. Open the browser Network tab and filter by the room's message endpoint.
  3. In another browser session (same room), send a new message.
  4. Observe the polling request: the response should now contain only the new message, not the full history.
  5. Confirm the new message appears in the first session within ~5 seconds.

Expected result: Each poll response returns only messages sent after the last-known timestamp. Initial page load still returns the most recent 50 messages as before.


Checklist

  • Linked the related issue above
  • Self-reviewed my own diff
  • No unnecessary console.log, debug code, or commented-out blocks
  • No TypeScript errors (pnpm run type-check — errors shown are all pre-existing)
  • No new tests required — the logic change is a direct routing fix to an already-tested helper (getRoomMessagesSince has existing coverage in test/rooms-messages.test.ts)

@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

@nyxsky404 is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix labels Jun 10, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@github-actions github-actions Bot added type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) type:testing GSSoC type bonus: tests (+10 pts) type:design GSSoC type bonus: UI/design (+10 pts) type:devops GSSoC type bonus: devops (+15 pts) labels Jun 10, 2026
@nyxsky404

nyxsky404 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

The CI failures on this PR (Playwright smoke tests and Playwright visual regression) are pre-existing broken tests on main — they are not caused by the changes in this PR.

Root causes fixed:

  • e2e/streak.spec.ts — duplicate aria-label on streak card div and tooltip button caused a strict-mode locator violation
  • Visual regression — test heading selector @playwright-user's profile never matched the actual h1 (@playwright-user)
  • landing-page-dark.png snapshot was accidentally zeroed in a prior merged commit
  • Public profile test — no Supabase mock for server-side profile fetch in CI, so the page returned 404

Fixes have been applied to this branch. CI is Green.

@Priyanshu-byte-coder Priyanshu-byte-coder added the gssoc:approved GSSoC: PR approved for scoring label Jun 16, 2026
@Priyanshu-byte-coder

Copy link
Copy Markdown
Member

This PR has merge conflicts with the current main branch. Please rebase or merge main into your branch to resolve the conflicts, then push the updated branch. Once conflicts are resolved, this PR will be merged.

git fetch origin main
git merge origin/main
# resolve conflicts
git push

…T route

The polling loop in MessageFeed sent ?after=<timestamp> to fetch only
new messages, but the GET handler read ?before= exclusively, leaving
the after param silently ignored. Every poll returned the same last-50
messages instead of only the messages newer than the last seen one.

getRoomMessagesSince already existed in supabase-rooms.ts for this
exact purpose. The route now branches on the presence of after vs
before so incremental polls are efficient and initial loads / reverse
pagination continue to work via getRoomMessages.

Fixes Umbrella-io#2301
@nyxsky404 nyxsky404 force-pushed the fix/room-messages-after-param-ignored branch from 7e1b1f5 to 9d82b88 Compare June 17, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC: PR approved for scoring gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:devops GSSoC type bonus: devops (+15 pts) type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Room chat polling ignores ?after= parameter — always fetches full message history on every poll

2 participants