Skip to content

fix(social): re-fetch realtime messages via decrypting REST + drop dead reactions sub (#124, #231)#230

Merged
Jose-Gael-Cruz-Lopez merged 4 commits into
mainfrom
fix/124-realtime-decrypt-display
Jun 14, 2026
Merged

fix(social): re-fetch realtime messages via decrypting REST + drop dead reactions sub (#124, #231)#230
Jose-Gael-Cruz-Lopez merged 4 commits into
mainfrom
fix/124-realtime-decrypt-display

Conversation

@Jose-Gael-Cruz-Lopez

@Jose-Gael-Cruz-Lopez Jose-Gael-Cruz-Lopez commented Jun 13, 2026

Copy link
Copy Markdown
Member

Closes #124 (display bug). Also removes the dead room_reactions realtime subscription surfaced by the #231 audit.

#124 — display fix

room_messages.text is column-encrypted; only the REST read path decrypts. The realtime subscription rendered payload.new.text (ciphertext) for other users' messages until a manual reload. Now: treat a realtime message event as a change signal and re-fetch via the decrypting getRoomMessages (mirroring how reactions used to). Own messages keep optimistic plaintext; own edits/deletes take only server flags. Decision logic is the pure, unit-tested planMessageRealtimeAction. Display-only — does not address authorization (#231).

#231 cleanup — drop dead room_reactions subscription

Live check confirmed room_reactions is not in the supabase_realtime publication, so its INSERT/DELETE realtime handlers never fired. Removed as dead code; pruned the two now-unused no-explicit-any eslint baseline entries (11→9). Reactions still update on load/refresh via REST; live reactions can return post-RLS by publishing the table with a membership-scoped policy.

Tests

Social.realtime.test.ts covers the planner (foreign INSERT/UPDATE → refetch; own INSERT → ignore; own UPDATE → applyOwnFlags; malformed → ignore). eslint . exits clean after the prune; tsc clean.

⚠️ Do not merge — opened for your review.

room_messages.text is column-encrypted at rest; only the REST read path
decrypts it. The realtime subscription stored payload.new and rendered
payload.new.text directly, so messages from other users (which arrive only via
realtime) displayed as ciphertext until a manual reload. The UPDATE handler had
the same defect for edits.

Treat a realtime message event as a 'something changed' signal and re-fetch
through the decrypting getRoomMessages endpoint — mirroring how this component
already handles room_reactions. Own messages keep their optimistic plaintext
(reconciled by the POST response); own edits/deletes take only the server-side
flags. The decision is a pure, unit-tested planMessageRealtimeAction.

DISPLAY-ONLY: this does not address the realtime channel's missing
authorization (RLS / Realtime Authorization) — tracked separately.
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Jose-Gael-Cruz-Lopez, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 38 minutes and 22 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 99f44762-ff14-47b3-b80c-4b3411051cbd

📥 Commits

Reviewing files that changed from the base of the PR and between a785304 and f41dbec.

📒 Files selected for processing (3)
  • frontend/eslint-suppressions.json
  • frontend/src/components/screens/Social.realtime.test.ts
  • frontend/src/components/screens/Social.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/124-realtime-decrypt-display

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.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 13, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
frontend f41dbec Commit Preview URL

Branch Preview URL
Jun 14 2026, 02:55 AM

room_reactions is not in the supabase_realtime publication (confirmed live), so
its INSERT/DELETE realtime handlers never fired — dead code. Remove them. Prune
the two now-unused @typescript-eslint/no-explicit-any baseline entries (11->9)
so the eslint ratchet stays exact. Reactions still update on load/refresh via
REST; live reactions can return post-RLS by publishing the table with a
membership-scoped policy (see docs/security/realtime-jwt-bridge-design.md).
@Jose-Gael-Cruz-Lopez Jose-Gael-Cruz-Lopez changed the title fix(social): re-fetch realtime room messages via decrypting REST — display fix (#124) fix(social): re-fetch realtime messages via decrypting REST + drop dead reactions sub (#124, #231) Jun 13, 2026
Jose-Gael-Cruz-Lopez added a commit that referenced this pull request Jun 14, 2026
…n plans (#231)

Carved from the #232 draft so the planning docs live in main (the SQL stays in
#232 as the applied-to-prod record, not merged). The RLS lockdown is already
applied to production (anon locked out, confirmed). #230 references the
realtime-jwt-bridge design doc landed here.
@Jose-Gael-Cruz-Lopez Jose-Gael-Cruz-Lopez merged commit 84aee68 into main Jun 14, 2026
6 checks passed
@Jose-Gael-Cruz-Lopez Jose-Gael-Cruz-Lopez deleted the fix/124-realtime-decrypt-display branch June 14, 2026 02:55
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.

[P0] Realtime room chat renders encrypted ciphertext for incoming messages

1 participant