feat: persist Text Snippet + Link transfers (#91) - #93
Conversation
Text and link transfers were socket-only — broadcast then dropped, so a reload, reconnect, or late-joining Receiver lost them. Files already persisted; text/link now do too. - TextPayload table (content in Postgres, mirrors FilePayload) + migration - Gateway persists the Transfer + TextPayload before broadcasting, and the broadcast/ack share the persisted row id - listTransfers hydrates text/link content; Transfer Log renders persisted snippets/links on load, deduped against the live feed by transferId - deleteById/deleteByRoomId cascade TextPayload, so expiry sweep purges it
|
Warning Review limit reached
Next review available in: 27 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughText snippets and links now persist through a new ChangesText transfer persistence
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant Sender
participant RoomGateway
participant TransferRepository
participant RoomService
Sender->>RoomGateway: Send text
RoomGateway->>TransferRepository: Persist Transfer and TextPayload
RoomGateway-->>Sender: Return persisted transferId
RoomGateway-->>Sender: Broadcast text event
RoomService->>TransferRepository: Load text payloads by transfer IDs
RoomService-->>Sender: Return hydrated transfer history
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai full review |
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 28 minutes. |
Review follow-up on #93. - createTextTransfer writes the Transfer + TextPayload in one nested create, so a mid-write failure can't commit a Transfer row with no content - Transfer Log skips a text/link history row whose content is null instead of rendering a blank, dead row (defensive against any future orphan) - test the gateway persist-failure path: error ack, no broadcast, no orphan
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/api/src/room/room.gateway.spec.ts`:
- Around line 398-402: Update the test setup around the sender and receiver
sockets to await the receiver’s room-join event as well as the sender’s before
invoking sendText. Use the receiver socket’s corresponding room:joined event so
the negative broadcast assertion is evaluated only after both clients have
joined.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: db9a1416-37f3-441f-ad9c-97e14103e04c
📒 Files selected for processing (8)
apps/api/src/domain/transfer/transfer.entity.tsapps/api/src/domain/transfer/transfer.repository.fake.tsapps/api/src/domain/transfer/transfer.repository.tsapps/api/src/infrastructure/persistence/repositories/prisma-transfer.repository.tsapps/api/src/room/room.gateway.spec.tsapps/api/src/room/room.gateway.tsapps/web/src/features/room/utils/transfer-log.spec.tsapps/web/src/features/room/utils/transfer-log.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- apps/web/src/features/room/utils/transfer-log.ts
- apps/api/src/domain/transfer/transfer.repository.fake.ts
- apps/api/src/room/room.gateway.ts
- apps/web/src/features/room/utils/transfer-log.spec.ts
- apps/api/src/domain/transfer/transfer.repository.ts
…#91) CodeRabbit: the persist-failure test only awaited the Sender's room:joined, so 'nothing was broadcast' could pass just because the Receiver hadn't joined yet. Await the Receiver's own room:joined too.
What
Text Snippet and Link transfers were socket-only —
RoomGateway.handleSendTextbroadcast them and stored nothing, so a reload, reconnect, or late-joining Receiver lost every text/link ever sent. Files already persisted and survived; now text/link do too.Changes
TextPayloadtable (transferId @unique,content) — text lives inline in Postgres, not object storage. Migration included.Transfer+TextPayloadbefore broadcasting; the broadcast and the ack share the persisted row id, so both sides key on the sametransferId.listTransfersbatch-readsTextPayloadand returnscontent;room-transfersDTO gainscontent.transferId.deleteById/deleteByRoomIddropTextPayload, so the expiry sweeper purges it with the rest of a Room.Tests
listTransfersmaps text/link content; file rows carrycontent: null.Closes #91
Summary by CodeRabbit
contentfield for text/link items (andnullfor files).