Skip to content

feat: persist Text Snippet + Link transfers (#91) - #93

Merged
izolyte merged 3 commits into
mainfrom
feat/91-persist-text-link
Jul 19, 2026
Merged

feat: persist Text Snippet + Link transfers (#91)#93
izolyte merged 3 commits into
mainfrom
feat/91-persist-text-link

Conversation

@izolyte

@izolyte izolyte commented Jul 19, 2026

Copy link
Copy Markdown
Owner

What

Text Snippet and Link transfers were socket-only — RoomGateway.handleSendText broadcast 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

  • Schema: new TextPayload table (transferId @unique, content) — text lives inline in Postgres, not object storage. Migration included.
  • Persist-then-broadcast: the gateway writes Transfer + TextPayload before broadcasting; the broadcast and the ack share the persisted row id, so both sides key on the same transferId.
  • Hydrate: listTransfers batch-reads TextPayload and returns content; room-transfers DTO gains content.
  • FE: the Transfer Log renders persisted snippets/links on load and late-join (copy for Snippet, open for Link), deduped against the live socket feed by transferId.
  • Cascade: deleteById/deleteByRoomId drop TextPayload, so the expiry sweeper purges it with the rest of a Room.

Tests

  • Gateway: persists the Transfer + TextPayload; a Receiver's send persists/broadcasts nothing.
  • Service: listTransfers maps text/link content; file rows carry content: null.
  • FE: history snippet/link hydration + live/history dedup to a single row.
  • Full API (238) + web room (234) suites green; lint + typecheck clean.

Closes #91

Summary by CodeRabbit

  • New Features
    • Text snippet and link transfers are now persisted and stay available after reload/reconnect.
    • Transfer history now includes persisted text content and link destinations, with correct snippet previews.
    • Room transfer records now expose a content field for text/link items (and null for files).
  • Bug Fixes
    • Receiver-initiated text sends no longer persist or broadcast transfers.
    • Improved delivery/merge behavior so persisted text/link history correctly combines with live updates.

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
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@izolyte, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 27 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2df8ecac-55b8-48da-ae72-7dedc5b17faf

📥 Commits

Reviewing files that changed from the base of the PR and between fb22f9f and 836e32c.

📒 Files selected for processing (1)
  • apps/api/src/room/room.gateway.spec.ts
📝 Walkthrough

Walkthrough

Text snippets and links now persist through a new TextPayload model, are saved before socket broadcasting, appear in transfer-history responses, and render from persisted content in the web transfer log.

Changes

Text transfer persistence

Layer / File(s) Summary
TextPayload storage and repository contracts
apps/api/prisma/*, apps/api/src/domain/transfer/*, apps/api/src/infrastructure/persistence/repositories/*
Adds the TextPayload schema, domain types, repository methods, Prisma persistence, fake-repository support, and deletion cleanup.
Persist-then-broadcast gateway flow
apps/api/src/room/room.gateway.ts, apps/api/src/room/room.gateway.spec.ts
Persists transfer metadata and text content before broadcasting, returns the persisted transfer ID, handles persistence failures, and tests sender authorization and retrieval.
Transfer history content hydration
apps/api/src/room/dto/room-transfers.dto.ts, apps/api/src/room/room.service.ts, apps/api/src/room/room.service.spec.ts
Adds nullable text content to transfer-history items and batch-loads persisted text payloads alongside file payloads and deliveries.
Persisted text transfer-log rendering
apps/web/src/features/room/utils/transfer-log.*
Renders persisted snippets and links from content, deduplicates them with live events, and preserves persisted timestamps.

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
Loading

Possibly related PRs

  • izolyte/synxor#32: Established the Prisma/PostgreSQL transfer persistence setup extended here for TextPayload.
  • izolyte/synxor#77: Overlaps with the persisted transfer-history hydration and transfer-log merge pipeline.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: persisting text snippet and link transfers.
Linked Issues check ✅ Passed The PR covers schema, persistence, hydration, UI rendering, deduping, and cascade deletion for text/link transfers.
Out of Scope Changes check ✅ Passed The changes stay focused on persisting and displaying text/link transfers, with no clear unrelated additions.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/91-persist-text-link

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.

@izolyte

izolyte commented Jul 19, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 88608c9 and fb22f9f.

📒 Files selected for processing (8)
  • apps/api/src/domain/transfer/transfer.entity.ts
  • apps/api/src/domain/transfer/transfer.repository.fake.ts
  • apps/api/src/domain/transfer/transfer.repository.ts
  • apps/api/src/infrastructure/persistence/repositories/prisma-transfer.repository.ts
  • apps/api/src/room/room.gateway.spec.ts
  • apps/api/src/room/room.gateway.ts
  • apps/web/src/features/room/utils/transfer-log.spec.ts
  • apps/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

Comment thread apps/api/src/room/room.gateway.spec.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.
@izolyte
izolyte merged commit 1e7c2d2 into main Jul 19, 2026
6 checks passed
@izolyte
izolyte deleted the feat/91-persist-text-link branch July 19, 2026 20:05
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.

feat: persist Text Snippet + Link transfers

1 participant