Skip to content

Bug/roast fixes (#86)#87

Merged
YnotMax merged 1 commit into
mainfrom
develop
Jun 20, 2026
Merged

Bug/roast fixes (#86)#87
YnotMax merged 1 commit into
mainfrom
develop

Conversation

@YnotMax

@YnotMax YnotMax commented Jun 20, 2026

Copy link
Copy Markdown
Member
  • fix(server): update roast controller, repository, routes and service

  • fix(firebase): update firebase-admin server initialization

  • fix(services): update roast client service and firestore subscription hook

  • fix(hooks): update useRoastProfile and useProfilesRealtime hooks

  • fix(ui): add delete confirm modal and update roast and profile card components

  • test: add unit tests for roast controller, service and client hooks

  • chore: update package-lock.json

  • fix: update import

Summary by CodeRabbit

  • New Features

    • Experience roast generation in real-time with text streaming as it's created
    • Delete roasts with a confirmation dialog to prevent accidental removal of verdicts
  • Style

    • Improved profile name text display with better text overflow handling and hover tooltips for complete name visibility

* fix(server): update roast controller, repository, routes and service

* fix(firebase): update firebase-admin server initialization

* fix(services): update roast client service and firestore subscription hook

* fix(hooks): update useRoastProfile and useProfilesRealtime hooks

* fix(ui): add delete confirm modal and update roast and profile card components

* test: add unit tests for roast controller, service and client hooks

* chore: update package-lock.json

* fix: update import
@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
match-tech Ready Ready Preview, Comment Jun 20, 2026 4:58am

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4b562ba2-3059-43ab-acb4-f9dfc19185ce

📥 Commits

Reviewing files that changed from the base of the PR and between 522fb22 and be6aab4.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (19)
  • src/features/discover/components/RoastModal.tsx
  • src/features/discover/hooks/__tests__/useRoastProfile.test.tsx
  • src/features/discover/hooks/useProfilesRealtime.ts
  • src/features/discover/hooks/useRoastProfile.ts
  • src/features/discover/pages/DiscoverPage.tsx
  • src/features/onboarding/components/GuildPassport.tsx
  • src/server/features/roast/__tests__/roast.controller.test.ts
  • src/server/features/roast/__tests__/roast.service.test.ts
  • src/server/features/roast/roast.controller.ts
  • src/server/features/roast/roast.repository.ts
  • src/server/features/roast/roast.routes.ts
  • src/server/features/roast/roast.service.ts
  • src/server/shared/lib/firebase-admin.server.ts
  • src/shared/components/ui/DeleteRoastConfirmModal.tsx
  • src/shared/components/ui/ProfileCard.tsx
  • src/shared/components/ui/RoastModal.tsx
  • src/shared/hooks/useFirestoreSubscription.ts
  • src/shared/services/__tests__/roast.service.test.ts
  • src/shared/services/roast.service.ts

📝 Walkthrough

Walkthrough

The PR converts roast generation from a single JSON response to SSE streaming on both the Express server (generateRoastStream async generator, SSE controller) and client (requestRoast incremental reader). A new deleteRoast endpoint and matching deleteProfileRoast repository function are added. The client hook, shared RoastModal, and DiscoverPage are updated to display streaming chunks and trigger a new DeleteRoastConfirmModal. Minor fixes address UI text clamping, title attributes, a stable Firestore hook reference, and debug log removal.

Changes

Roast SSE Streaming and Delete Feature

Layer / File(s) Summary
Server streaming service, repository, controller, and routes
src/server/shared/lib/firebase-admin.server.ts, src/server/features/roast/roast.repository.ts, src/server/features/roast/roast.service.ts, src/server/features/roast/roast.controller.ts, src/server/features/roast/roast.routes.ts, src/server/features/roast/__tests__/roast.service.test.ts, src/server/features/roast/__tests__/roast.controller.test.ts
adminDb is initialized with an explicit Firestore database ID. saveProfileRoast is replaced with deleteProfileRoast using FieldValue.delete(). generateRoast is replaced by generateRoastStream async generator that yields chunks and persists after streaming. postRoast switches to SSE headers and a streaming loop; deleteRoast handler and DELETE /:memberId route are added. Tests cover chunk yielding, persistence, thinkingBudget, empty-chunk skipping, SSE header and payload format, and error/400 handling.
Client SSE service (requestRoast + deleteRoast)
src/shared/services/roast.service.ts, src/shared/services/__tests__/roast.service.test.ts
requestRoast is rewritten to read response.body incrementally, parse data: ... SSE lines, invoke an optional onChunk callback, and accumulate fullText until [DONE]; streaming error events throw immediately. New deleteRoast sends a DELETE with optional persona query param. Tests cover chunk accumulation, onChunk ordering, SSE error rejection, non-OK response handling, and DELETE URL formation.
useRoastProfile hook: streaming state and delete mutation
src/features/discover/hooks/useRoastProfile.ts, src/features/discover/hooks/__tests__/useRoastProfile.test.tsx
Hook gains streamingText state cleared on mutation start and error; roastMutation calls requestRoast with an onChunk callback accumulating chunks and on success directly patches selectedProfile without updateProfile. deleteRoastMutation calls deleteRoast, clears the roast field on success, and triggers an optional onDeleteSuccess. Return API adds streamingText, isDeleting, and executeDeleteRoast. Tests cover all streaming and delete lifecycle scenarios.
Streaming display, delete button, confirmation modal, and page wiring
src/shared/components/ui/RoastModal.tsx, src/shared/components/ui/DeleteRoastConfirmModal.tsx, src/features/discover/components/RoastModal.tsx, src/features/discover/pages/DiscoverPage.tsx
RoastModal shows streamingText with a pulsing | cursor while generating and renders a Trash2 delete button when a roast exists. New DeleteRoastConfirmModal presents persona label, irreversibility warning, and disabled-during-deletion actions. The discover RoastModal wrapper forwards streamingText and onDeleteRoast. DiscoverPage adds confirmDeleteOpen state, opens the confirm modal on delete request, and renders it via AnimatePresence.
ProfileCard titles, GuildPassport layout, Firestore hook stability, debug log removal
src/shared/components/ui/ProfileCard.tsx, src/features/onboarding/components/GuildPassport.tsx, src/shared/hooks/useFirestoreSubscription.ts, src/features/discover/hooks/useProfilesRealtime.ts
ProfileCard name headings gain a title attribute with a "NOME_NULO" fallback. GuildPassport switches from truncate to line-clamp-2 with min-w-0 and a title attribute. useFirestoreSubscription replaces the inline [] default with a module-level EMPTY_CONSTRAINTS constant for stable useEffect deps and converts QueryConstraint to a type-only import. useProfilesRealtime removes three console.log debug calls.

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant DiscoverPage
  participant useRoastProfile
  participant requestRoast as requestRoast (SSE client)
  participant ExpressServer as Express /roast
  participant generateRoastStream

  User->>DiscoverPage: click "Generate Roast"
  DiscoverPage->>useRoastProfile: executeRoast(persona)
  useRoastProfile->>requestRoast: requestRoast(payload, onChunk)
  requestRoast->>ExpressServer: POST /roast (fetch)
  ExpressServer->>generateRoastStream: iterate async generator
  loop SSE chunks
    generateRoastStream-->>ExpressServer: yield text chunk
    ExpressServer-->>requestRoast: data: { chunk }
    requestRoast-->>useRoastProfile: onChunk(text)
    useRoastProfile-->>DiscoverPage: streamingText updated
  end
  ExpressServer-->>requestRoast: data: [DONE]
  requestRoast-->>useRoastProfile: resolve { roast: fullText }
  useRoastProfile-->>DiscoverPage: selectedProfile.roastBrutal set, streamingText cleared

  User->>DiscoverPage: click "Delete Roast"
  DiscoverPage->>DiscoverPage: setConfirmDeleteOpen(true)
  User->>DiscoverPage: confirm deletion
  DiscoverPage->>useRoastProfile: executeDeleteRoast(persona)
  useRoastProfile->>ExpressServer: DELETE /roast/:memberId?persona=brutal
  ExpressServer-->>useRoastProfile: { success: true }
  useRoastProfile-->>DiscoverPage: onDeleteSuccess() → setConfirmDeleteOpen(false)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • MatchDock/match-tech#73: Directly modifies the same src/features/discover/hooks/useProfilesRealtime.ts file — this PR removes debug console.log calls that the referenced PR added.

Poem

🐇 Hop hop, the roast now streams,
No more waiting, chunk by chunk it gleams!
A trash icon appears, bold and bright,
"APAGAR" the verdict with a click tonight.
The bunny typed SSE with glee,
And deleted roasts for all to see! 🗑️✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch develop

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

@YnotMax
YnotMax merged commit ca56499 into main Jun 20, 2026
4 of 5 checks passed
This was referenced Jun 27, 2026
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