Skip to content

Bug/roast fixes (#86)#88

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

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

Conversation

@YnotMax

@YnotMax YnotMax commented Jun 27, 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
    • Roast generation now streams live progress instead of waiting for the full result.
    • Added an option to delete an existing roast with a confirmation dialog.
  • Bug Fixes
    • Roast and profile updates now handle errors more cleanly during generation and deletion.
    • Improved long name display in onboarding and profile cards so names wrap and stay readable.
  • Chores
    • Removed extra debug logging from profile loading.

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

coderabbitai Bot commented Jun 27, 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: de1bcf79-f5e1-4fbd-ad35-cdc899166092

📥 Commits

Reviewing files that changed from the base of the PR and between ca56499 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 roast generation flow is changed from a single-response JSON endpoint to SSE streaming end-to-end: the server service yields chunks via an async generator, the controller writes them as SSE events, and the client service reads the stream with an optional onChunk callback. A new roast-deletion path is added (server repository function, controller handler, DELETE route, client service function, hook mutation) and surfaced in the UI via an updated RoastModal with a streaming display and trash button, plus a new DeleteRoastConfirmModal.

Changes

Roast SSE Streaming and Delete

Layer / File(s) Summary
Server: streaming service, delete repository, controller, and route
src/server/features/roast/roast.service.ts, src/server/features/roast/roast.repository.ts, src/server/features/roast/roast.controller.ts, src/server/features/roast/roast.routes.ts, src/server/shared/lib/firebase-admin.server.ts
generateRoast replaced by generateRoastStream async generator; deleteProfileRoast added to repository; postRoast reworked to SSE (headers, chunk events, [DONE], error event); deleteRoast handler and DELETE /:memberId route added; Firestore DB ID read from env.
Client service: SSE requestRoast + deleteRoast, and useRoastProfile hook
src/shared/services/roast.service.ts, src/features/discover/hooks/useRoastProfile.ts, src/features/discover/hooks/useProfilesRealtime.ts
requestRoast rewritten to stream SSE chunks via ReadableStream with optional onChunk; deleteRoast added; useRoastProfile accumulates streamingText, clears it on mutate/success/error, and exposes executeDeleteRoast/isDeleting; debug console.log removed.
RoastModal streaming UI + DeleteRoastConfirmModal
src/shared/components/ui/RoastModal.tsx, src/shared/components/ui/DeleteRoastConfirmModal.tsx, src/features/discover/components/RoastModal.tsx
RoastModal gains animated streamingText display and a Trash2 delete button; new DeleteRoastConfirmModal provides full-screen motion-animated confirmation with isDeleting state; discover-scoped RoastModal wrapper forwards new props.
DiscoverPage: confirmDelete state + modal wiring
src/features/discover/pages/DiscoverPage.tsx
confirmDeleteOpen state introduced; onDeleteRoast/onDeleteSuccess wired through hook and RoastModal; DeleteRoastConfirmModal conditionally rendered via AnimatePresence.
Tests: server service/controller, client service, and hook
src/server/features/roast/__tests__/*, src/shared/services/__tests__/roast.service.test.ts, src/features/discover/hooks/__tests__/useRoastProfile.test.tsx
New Vitest suites cover generateRoastStream (chunk yielding, persistence, config, empty filtering), postRoast SSE headers/output/error/validation, requestRoast SSE parsing/onChunk/errors, deleteRoast URL and error handling, and useRoastProfile streaming and delete behaviors.
Minor UI: ProfileCard/GuildPassport title attrs, useFirestoreSubscription cleanup
src/shared/components/ui/ProfileCard.tsx, src/features/onboarding/components/GuildPassport.tsx, src/shared/hooks/useFirestoreSubscription.ts
ProfileCard h3/h4 gain title attributes; GuildPassport name switches to line-clamp-2 with min-w-0; useFirestoreSubscription uses a stable EMPTY_CONSTRAINTS constant.

Sequence Diagram(s)

sequenceDiagram
  participant DiscoverPage
  participant useRoastProfile
  participant requestRoast
  participant Server as roast.controller
  participant generateRoastStream

  DiscoverPage->>useRoastProfile: executeRoast(persona)
  useRoastProfile->>useRoastProfile: clear streamingText
  useRoastProfile->>requestRoast: requestRoast(payload, onChunk)
  requestRoast->>Server: POST /api/roast (SSE)
  Server->>generateRoastStream: iterate chunks
  generateRoastStream-->>Server: chunk text
  Server-->>requestRoast: data: {"chunk": "..."}\n\n
  requestRoast->>useRoastProfile: onChunk(text) → append streamingText
  useRoastProfile-->>DiscoverPage: streamingText update → RoastModal re-renders
  Server-->>requestRoast: data: [DONE]\n\n
  requestRoast-->>useRoastProfile: resolve {roast: fullText}
  useRoastProfile->>useRoastProfile: store roast in selectedProfile, clear streamingText

  DiscoverPage->>useRoastProfile: executeDeleteRoast(persona)
  useRoastProfile->>requestRoast: deleteRoast(memberId, persona)
  requestRoast->>Server: DELETE /api/roast/:memberId?persona=brutal
  Server-->>requestRoast: 200 OK
  useRoastProfile->>useRoastProfile: clear roastBrutal in selectedProfile
  useRoastProfile->>DiscoverPage: onDeleteSuccess → confirmDeleteOpen=false
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • MatchDock/match-tech#87: Directly modifies the same core files (useRoastProfile, RoastModal, DiscoverPage, roast controller/service/repository) with overlapping SSE streaming and deleteRoast wiring changes.

Poem

🐇 Hop hop, the roast now streams in bits,
No waiting whole — it flows and fits!
A trash can button, pink and bright,
Deletes the verdict with a click tonight.
The rabbit cheers each chunky line,
SSE events, so fine, so fine! ✨

✨ 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

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.

@YnotMax
YnotMax merged commit c5cce10 into main Jun 27, 2026
5 of 6 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jun 29, 2026
5 tasks
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