Conversation
* docs: reestruturar documentacao principal e integrar guia de revisao de prs * feat: implement FirebaseProfileRepository with Zod validation and data mapping for Firestore operations --------- Co-authored-by: tony max <tonymaxonline@gmail.com>
…ções no Radar e integridade do Firestore (#68) * docs: reestruturar documentacao principal e integrar guia de revisao de prs * feat: implement FirebaseProfileRepository with Zod validation and data mapping for Firestore operations * feat(onboarding): adjust onboarding language to matchmaker identity (Issue #43, #44) * Revert "feat(onboarding): adjust onboarding language to matchmaker identity (Issue #43, #44)" This reverts commit 2cbe6ad. * fix(discover): restaurar design original do ProfileCard com bento layout, avatar, radar chart e grid 3 colunas * feat: add profile discovery UI components including roast modal, profile grid, and radar chart * fix(discover): resolve user ID mismatch in own profile check --------- Co-authored-by: tony max <tonymaxonline@gmail.com>
…estore (#71) * docs: reestruturar documentacao principal e integrar guia de revisao de prs * feat: implement FirebaseProfileRepository with Zod validation and data mapping for Firestore operations * feat(onboarding): adjust onboarding language to matchmaker identity (Issue #43, #44) * Revert "feat(onboarding): adjust onboarding language to matchmaker identity (Issue #43, #44)" This reverts commit 2cbe6ad. * fix(discover): restaurar design original do ProfileCard com bento layout, avatar, radar chart e grid 3 colunas * feat: add profile discovery UI components including roast modal, profile grid, and radar chart * fix(discover): resolve user ID mismatch in own profile check * feat: create ProfileCard component with neo-brutalist styling and compact mode support * feat: implement real-time messaging system and expand profile schema with visibility support * style: rename 'sinal' to 'mensagem' to improve clarity --------- Co-authored-by: tony max <tonymaxonline@gmail.com>
* docs: reestruturar documentacao principal e integrar guia de revisao de prs * feat: implement FirebaseProfileRepository with Zod validation and data mapping for Firestore operations * feat(onboarding): adjust onboarding language to matchmaker identity (Issue #43, #44) * Revert "feat(onboarding): adjust onboarding language to matchmaker identity (Issue #43, #44)" This reverts commit 2cbe6ad. * fix(discover): restaurar design original do ProfileCard com bento layout, avatar, radar chart e grid 3 colunas * feat: add profile discovery UI components including roast modal, profile grid, and radar chart * fix(discover): resolve user ID mismatch in own profile check * feat: create ProfileCard component with neo-brutalist styling and compact mode support * feat: implement real-time messaging system and expand profile schema with visibility support * style: rename 'sinal' to 'mensagem' to improve clarity * feat(messages): redesign inbox into threaded conversation UI with real-time history * fix(firestore): allow conversationId field and list permission for message threads * feat: implement messages page with real-time Firestore synchronization and conversation management --------- Co-authored-by: tony max <tonymaxonline@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughRemoves the entire Guilda member/roast feature (components, hooks, store, types, selectors, formatters, constants, page) and replaces it with a full real-time messaging system: Firestore security rules for messages, a ChangesMessaging Feature and Guilda Removal
Sequence Diagram(s)sequenceDiagram
participant User
participant DiscoverPage
participant SendMessageModal
participant FirebaseMessageRepository
participant Firestore
participant MessagesPage
User->>DiscoverPage: clicks "MANDAR MENSAGEM" on ProfileCard
DiscoverPage->>DiscoverPage: setContactTarget({ id, name })
DiscoverPage->>SendMessageModal: render with receiverId/receiverName
User->>SendMessageModal: types message and submits
SendMessageModal->>FirebaseMessageRepository: sendMessage(senderId, receiverId, text, ...)
FirebaseMessageRepository->>Firestore: setDoc /messages/{id} with conversationId, read=false, serverTimestamp
Firestore-->>FirebaseMessageRepository: write confirmed
FirebaseMessageRepository-->>SendMessageModal: success
SendMessageModal->>DiscoverPage: onSuccess() → toast shown
SendMessageModal->>MessagesPage: navigate to /messages?with=receiverId
MessagesPage->>FirebaseMessageRepository: subscribeToConversations(userId, onUpdate)
FirebaseMessageRepository->>Firestore: onSnapshot sent + received queries
Firestore-->>FirebaseMessageRepository: merged conversation list
FirebaseMessageRepository-->>MessagesPage: onUpdate(conversations[])
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 13
🤖 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 `@firestore.rules`:
- Line 113: The visibility field is allowlisted in the profile document
validation but is not actually validated by the isValidProfile() function,
allowing arbitrary values (null, numbers, invalid strings) to be stored in this
privacy-critical field. Add validation logic to the isValidProfile() function to
ensure that the visibility field is present, is a string, and only accepts the
valid values 'public' or 'private'.
- Around line 156-166: The isValidMessage function currently validates
conversationId only as a string with length constraints, but does not verify
that it is a valid derived combination of senderId and receiverId. Update the
function to add a validation check that ensures conversationId matches the
expected deterministic combination of senderId and receiverId (such as a sorted
concatenation or other application-specific format). This prevents users from
writing messages with arbitrary conversation IDs that don't correspond to the
correct participants.
In `@scripts/dump-profiles.ts`:
- Line 45: The main() promise rejection handler at line 45 currently only logs
the error to console but does not signal a failure to the operating system.
Modify the catch handler for the main() function call to set process.exitCode =
1 before or after logging the error with console.error, ensuring the script
exits with a non-zero status code when an error occurs.
- Around line 13-31: The code extracts projectId, clientEmail, and privateKey
from the parsed JSON but does not validate that these critical fields are
present before passing them to the cert() function. Add explicit guard checks
immediately after extracting these three values to ensure they are all defined
and non-empty strings. If any of these fields are missing, throw an error with a
clear message indicating which required field is absent, ensuring failures occur
immediately at this validation point rather than later inside cert() where error
messages are less actionable.
In `@scripts/migrate-members-to-profiles.ts`:
- Line 110: In migrate-members-to-profiles.ts at the getFirestore call, remove
the hardcoded fallback database ID
("ai-studio-a1333439-9ab3-4356-9f79-ac211cc82b20") and instead require the
VITE_FIREBASE_FIRESTORE_DATABASE_ID environment variable to be explicitly set.
Add validation before the getFirestore call that checks if the environment
variable is defined, and if not, throw an error or exit the process to fail fast
rather than silently using the wrong database. Apply the same validation logic
to scripts/dump-profiles.ts for consistency.
In `@src/features/discover/hooks/useProfilesRealtime.ts`:
- Around line 14-17: Remove all console.log statements from the
useProfilesRealtime hook that are logging the raw Firestore data, currentUserId,
and sorted profiles. These debug logs output potentially sensitive user
information on each subscription update and should not be present in production
code. Keep only the business logic by retaining the sortProfiles function call
and its result assignment, while removing the four console.log calls around it.
In `@src/features/messages/components/ChatThread.tsx`:
- Around line 73-84: The handleSend function (lines 73-84) and the onDelete
handler (lines 265-268) both await promises without catching potential
rejections, which can cause unhandled promise rejection errors. Add a catch
block to both functions that handles errors gracefully by logging them or
showing user feedback instead of allowing the error to propagate. The
try/finally structure exists but needs to be expanded to try/catch/finally to
properly handle rejection cases from the onSend and onDelete calls.
In `@src/features/messages/components/EmptyChat.tsx`:
- Around line 22-27: Replace the anchor element with href="/discover" containing
the text "Descobrir" in the EmptyChat component with a Link component from
react-router-dom. This will enable client-side navigation instead of triggering
a full page reload. Update the href attribute to the to prop and ensure the Link
component is properly imported at the top of the file.
In `@src/features/messages/model/messages.types.ts`:
- Around line 3-12: The Message interface in messages.types.ts is missing the
conversationId field that is required by firestore.rules and used by
messageRepository for writing and querying, causing a contract drift between the
TypeScript type and the persisted schema. Add a conversationId field of type
string to the Message interface to align the type definition with the actual
Firestore schema and how the repository layer operates.
In `@src/features/messages/pages/MessagesPage.tsx`:
- Around line 49-54: The useEffect hook in the MessagesPage component
unconditionally switches mobileView to "thread" whenever the user and withUserId
are available, without verifying that the target conversation actually exists in
the conversations state. This traps mobile users on an empty thread screen when
the conversation hasn't loaded yet. Gate the setMobileView("thread") call so it
only executes when the conversation with the ID generated by makeConversationId
actually exists in the conversations state, or alternatively keep the list
visible until the conversation data is available.
- Around line 198-199: The non-null assertion on `user!.uid` when passing
`currentUserId` to the ChatThread component can cause runtime errors during
authentication transitions or logout. Instead of using the non-null assertion
operator, wrap the ChatThread component rendering in a conditional guard that
checks if the user is authenticated before rendering. This ensures ChatThread
only renders when user is valid and prevents accessing uid on a potentially null
user object during auth state changes.
In `@src/features/onboarding/hooks/useOnboardingForm.ts`:
- Around line 183-185: The problem is that in the useOnboardingForm function,
the visibility field is being hard-coded to "public" in upsert operations (where
merge: true is used), which silently overwrites a user's previously chosen
visibility setting whenever they update their profile. Remove the hard-coded
`visibility: "public"` assignment from the upsert payload around lines 184 and
190 (in the objects that include eventId and serverTimestamp). This allows the
existing visibility value to be preserved during profile updates, rather than
forcing it back to public. If visibility needs to be explicitly set by the user
through the form, only include it in the update when the user has actually
changed that setting.
In `@src/infrastructure/firebase/messageRepository.ts`:
- Around line 205-222: The markConversationAsRead and markAllAsRead methods both
commit all matched documents in a single writeBatch call, which can exceed
Firestore's 500-operation batch limit for large inboxes, causing the entire
operation to fail. Chunk the snapshot.docs into groups of at most 500 documents
and commit each group in a separate batch sequentially. For each chunk, create a
new writeBatch, update the documents in that chunk, and commit before moving to
the next chunk. Apply this fix to both the markConversationAsRead method (lines
205-222) and the markAllAsRead method (lines 227-243).
🪄 Autofix (Beta)
❌ Autofix failed (check again to retry)
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: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a2e2082b-073f-4fab-a771-5ea1319aa3fe
📒 Files selected for processing (34)
firestore.rulesscripts/dump-profiles.tsscripts/migrate-members-to-profiles.tssrc/features/discover/components/ProfilesGrid.tsxsrc/features/discover/hooks/useProfilesRealtime.tssrc/features/discover/pages/DiscoverPage.tsxsrc/features/guilda/components/GuildAvatar.tsxsrc/features/guilda/components/GuildHeader.tsxsrc/features/guilda/components/GuildMemberCard.tsxsrc/features/guilda/components/GuildMembersGrid.tsxsrc/features/guilda/components/GuildRoastModal.tsxsrc/features/guilda/components/GuildStates.tsxsrc/features/guilda/constants/guilda.constants.tssrc/features/guilda/hooks/useGuildMembersRealtime.tssrc/features/guilda/hooks/useGuildRoast.tssrc/features/guilda/model/guilda.selectors.tssrc/features/guilda/model/guilda.types.tssrc/features/guilda/pages/GuildaPage.tsxsrc/features/guilda/services/guilda.repository.tssrc/features/guilda/store/guildRoast.tssrc/features/guilda/utils/guilda.formatters.tssrc/features/landing/Landing.tsxsrc/features/landing/components/HeroSection.tsxsrc/features/messages/components/ChatThread.tsxsrc/features/messages/components/ConversationList.tsxsrc/features/messages/components/EmptyChat.tsxsrc/features/messages/components/SendMessageModal.tsxsrc/features/messages/model/messages.types.tssrc/features/messages/pages/MessagesPage.tsxsrc/features/onboarding/hooks/useOnboardingForm.tssrc/infrastructure/firebase/messageRepository.tssrc/layouts/RootLayout.tsxsrc/routes/routes.tsxsrc/shared/components/ui/ProfileCard.tsx
💤 Files with no reviewable changes (15)
- src/features/guilda/pages/GuildaPage.tsx
- src/features/guilda/components/GuildHeader.tsx
- src/features/guilda/utils/guilda.formatters.ts
- src/features/guilda/components/GuildRoastModal.tsx
- src/features/guilda/constants/guilda.constants.ts
- src/features/guilda/components/GuildMemberCard.tsx
- src/features/guilda/model/guilda.types.ts
- src/features/guilda/hooks/useGuildMembersRealtime.ts
- src/features/guilda/components/GuildAvatar.tsx
- src/features/guilda/model/guilda.selectors.ts
- src/features/guilda/components/GuildMembersGrid.tsx
- src/features/guilda/services/guilda.repository.ts
- src/features/guilda/hooks/useGuildRoast.ts
- src/features/guilda/store/guildRoast.ts
- src/features/guilda/components/GuildStates.tsx
…es, and ChatThread rendering safety
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. An unexpected error occurred while generating fixes: Repository rule violations found Changes must be made through a pull request. |
💬 Sistema de Mensagens — Histórico de Conversas e UI de Chat
Resumo
Transforma a antiga caixa de entrada linear em uma interface de chat moderna com histórico por conversa, no padrão universal de apps de mensagens (WhatsApp, Messenger, Slack), mantendo a identidade visual neo-brutalista do Match Tech.
Este PR também resolve conflitos de mesclagem com a branch
main, sincroniza o banco de dados Firestore e corrige diversos bugs relacionados à experiência de leitura e envio de mensagens em tempo real.O que mudou
🏗️ Arquitetura — Camada de Dados
messageRepository.ts— refatorado para suportar histórico de conversas em tempo real de forma robusta:makeConversationId(uidA, uidB)— gera um ID determinístico[uid1, uid2].sort().join('_'), garantindo que ambos os usuários compartilhem a mesma thread, independente de quem iniciou.subscribeToConversations(userId)— escuta todas as mensagens enviadas e recebidas em tempo real e as agrupa por conversa.subscribeToThread(conversationId)— escuta as mensagens de uma conversa específica em tempo real.markConversationAsRead(conversationId, userId)— marca em batch todas as mensagens de uma conversa como lidas.markAllAsRead(userId)(novo) — marca todas as mensagens não lidas do usuário como lidas globalmente.orderBy("createdAt")das queries do Firestore, passando a ordenar os dados localmente. Isso evita que mensagens legadas ou em estado de sincronização que não possuam o campocreatedAtsejam ocultadas da interface, resolvendo o bug de dessincronização do contador de não-lidas.serverTimestamps: 'estimate'ao ler os dados do snapshot do Firestore. Isso corrige o bug visual em que mensagens recém-enviadas apareciam momentaneamente no topo do histórico (tempo0) antes de pularem para a base da conversa.🎨 UI — Novos Componentes e Melhorias
ConversationList.tsx(novo)ChatThread.tsx(novo)EmptyChat.tsx(novo)/discover.📄 Páginas Modificadas e Fluxos
MessagesPage.tsx— reescrita completa:?with=userIdpara abrir diretamente a conversa a partir da busca de perfis.SendMessageModal.tsx— atualizado:/messages?with={receiverId}para ver a thread iniciada.DiscoverPage.tsx,ProfilesGrid.tsxeProfileCard.tsx— atualizados:Checklist de Qualidade
mainresolvidos e integrados.tsc --noEmit) passando sem erros.Summary by CodeRabbit
visibilitysupport for messaging access control.