Conversation
|
""" WalkthroughThis change introduces a "Clear Chat" feature for disappearing messages, enabling users to clear all chat history through a new dropdown option. It adds constants for special retention values, updates mutation and utility functions to support chat clearing, adjusts message update logic for new retention semantics, and ensures UI and data refresh after clearing. Additionally, it removes an explicit input focus callback from the conversation text input component and gates app state listeners behind user authentication. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI
participant Alert
participant Mutation
participant XMTPUtil
participant Query
User->>UI: Selects "Clear Chat" from dropdown
UI->>Alert: Shows confirmation dialog
Alert-->>User: User confirms action
UI->>Mutation: Calls updateDisappearingMessageSettings(clearChat: true)
Mutation->>XMTPUtil: updateXmtpDisappearingMessageSettings(clearChat: true)
XMTPUtil->>XMTPUtil: Sets timestamp = CLEAR_CHAT_RETENTION_DURATION_NS (1)
XMTPUtil-->>Mutation: Completes clearing messages
Mutation->>Query: Refetch conversation messages
Query-->>UI: Updates message list to reflect cleared chat
UI->>User: Shows success or error alert
Possibly related PRs
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (4)
🧰 Additional context used🧬 Code Graph Analysis (2)utils/react-query/react-query.helpers.ts (3)
features/current-user/current-user.query.ts (2)
🔇 Additional comments (10)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
...es/conversation/conversation-chat/conversation-message/conversation-message-group-update.tsx
Outdated
Show resolved
Hide resolved
thierryskoda
left a comment
There was a problem hiding this comment.
Looks great! Just few improvements 🙏
features/disappearing-messages/disappearing-messages-header-action.tsx
Outdated
Show resolved
Hide resolved
features/xmtp/xmtp-disappearing-messages/xmtp-disappearing-messages.ts
Outdated
Show resolved
Hide resolved
features/disappearing-messages/disappearing-messages-header-action.tsx
Outdated
Show resolved
Hide resolved
...es/conversation/conversation-chat/conversation-message/conversation-message-group-update.tsx
Outdated
Show resolved
Hide resolved
Add clear chat functionality to conversation messages with minimum retention duration of 1nsImplements chat clearing functionality across multiple components:
📍Where to StartStart with the clear chat implementation in disappearing-messages-header-action.tsx which contains the main UI entry point and core logic for the clear chat functionality. Changes since #67 opened
Macroscope summarized d7c57a3. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
features/streams/stream-messages.ts (1)
168-189: Clear chat detection and message refresh implementation.The implementation correctly identifies clear chat events by checking for the special
MIN_RETENTION_DURATION_NSvalue and refreshes the conversation message list accordingly. The error handling is comprehensive.Two minor suggestions:
- The comment on line 169 mentions "look for value of 1" but compares to
MIN_RETENTION_DURATION_NS- consider updating the comment to be more generic or align with the actual constant.- The indentation after line 168 contains an extra space that differs from the project's coding style.
- + // Check if this is a clear chat operation - look for value of 1 + // Check if this is a clear chat operation - look for MIN_RETENTION_DURATION_NS value
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
features/disappearing-messages/disappearing-messages-header-action.tsx(6 hunks)features/streams/stream-messages.ts(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- features/disappearing-messages/disappearing-messages-header-action.tsx
🔇 Additional comments (3)
features/streams/stream-messages.ts (3)
7-10: Import refactoring to support clear chat functionality.Nice organization of the imports by grouping related functionality together. The addition of
refetchConversationMessagesInfiniteQueryaligns with the new clear chat feature requirements.
30-30: Addition of MIN_RETENTION_DURATION_NS constant.This constant import supports the clear chat detection mechanism. Good practice to use a named constant rather than hardcoding the value.
178-187: Verify error handling for message refresh operation.The error handling appears robust, but it's important to verify how the UI behaves if the message refresh fails after a clear chat event.
Consider testing the error scenario to ensure users still get appropriate feedback if the refresh fails. The UI should still indicate that the chat was cleared, even if refreshing the message list encounters an error.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
features/streams/stream-messages.ts (1)
168-171: Consider adding type annotation for clarityThe code correctly identifies clear chat events by looking for the special
MIN_RETENTION_DURATION_NSvalue, but adding a type annotation would improve readability.// Check if this is a clear chat operation - look for value of 1 - const clearChatField = disappearingMessageFields.find( + const clearChatField = disappearingMessageFields.find<{ fieldName: string; newValue: string }>( field => parseInt(field.newValue, 10) === MIN_RETENTION_DURATION_NS )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
features/conversation/conversation-chat/conversation-composer/conversation-composer-text-input.tsx(0 hunks)features/conversation/conversation-chat/conversation-composer/hooks/use-conversation-composer-send.ts(0 hunks)features/conversation/conversation-chat/conversation-message/conversation-message-group-update.tsx(2 hunks)features/disappearing-messages/disappearing-messages-header-action.tsx(6 hunks)features/disappearing-messages/disappearing-messages.constants.ts(1 hunks)features/disappearing-messages/update-disappearing-message-settings.mutation.ts(1 hunks)features/streams/stream-messages.ts(3 hunks)features/xmtp/xmtp-disappearing-messages/xmtp-disappearing-messages.ts(2 hunks)
💤 Files with no reviewable changes (2)
- features/conversation/conversation-chat/conversation-composer/hooks/use-conversation-composer-send.ts
- features/conversation/conversation-chat/conversation-composer/conversation-composer-text-input.tsx
🚧 Files skipped from review as they are similar to previous changes (5)
- features/disappearing-messages/disappearing-messages.constants.ts
- features/disappearing-messages/update-disappearing-message-settings.mutation.ts
- features/xmtp/xmtp-disappearing-messages/xmtp-disappearing-messages.ts
- features/conversation/conversation-chat/conversation-message/conversation-message-group-update.tsx
- features/disappearing-messages/disappearing-messages-header-action.tsx
🧰 Additional context used
🪛 GitHub Check: tsc
features/streams/stream-messages.ts
[failure] 9-9:
'"@/features/conversation/conversation-chat/conversation-messages.query"' has no exported member named 'addMessageToConversationMessagesInfiniteQueryData'. Did you mean 'addMessagesToConversationMessagesInfiniteQueryData'?
[failure] 175-175:
Cannot find name 'streamLogger'.
🪛 GitHub Actions: Validate Code Quality
features/streams/stream-messages.ts
[error] 9-9: TypeScript error TS2724: '"@/features/conversation/conversation-chat/conversation-messages.query"' has no exported member named 'addMessageToConversationMessagesInfiniteQueryData'. Did you mean 'addMessagesToConversationMessagesInfiniteQueryData'?
🔇 Additional comments (2)
features/streams/stream-messages.ts (2)
173-187: Well-implemented clear chat event handling logicThe clear chat event handling logic is well-implemented. It correctly:
- Identifies when a chat has been cleared (by checking for the
MIN_RETENTION_DURATION_NSvalue)- Refreshes the message list to reflect the cleared state
- Properly handles errors that might occur during the refresh
🧰 Tools
🪛 GitHub Check: tsc
[failure] 175-175:
Cannot find name 'streamLogger'.
29-29: Good addition of the MIN_RETENTION_DURATION_NS constant importThis import properly enables the clear chat detection logic.
c57f6f6 to
45ece45
Compare
…hen users are focus on the conversation, but not when they're away from it/swiped up)
e103822 to
98633b6
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
utils/react-query/react-query.utils.ts (1)
5-8: Improved type safety but consider addressing the empty object type warning.The type constraint using conditional types is a good approach to prevent passing a "caller" key at compile-time. However, the static analysis tool correctly flags the use of
{}as a type, which can be misleading (it means "any non-nullable value" rather than "empty object").Consider using a more explicit type:
export function getReactQueryKey<ArgType extends { baseStr: string; [key: string]: unknown }>( args: ArgType & // We don't want people to pass in a "caller" key. - ("caller" extends keyof ArgType ? never : {}), + ("caller" extends keyof ArgType ? never : Record<string, never>), ): string[] {🧰 Tools
🪛 Biome (1.9.4)
[error] 8-8: Don't use '{}' as a type.
Prefer explicitly define the object shape. '{}' means "any non-nullable value".
(lint/complexity/noBannedTypes)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
features/conversation/conversation-chat/conversation-composer/conversation-composer-text-input.tsx(0 hunks)features/conversation/conversation-chat/conversation-message/conversation-message-group-update.tsx(2 hunks)features/disappearing-messages/disappearing-messages-header-action.tsx(6 hunks)features/disappearing-messages/disappearing-messages.constants.ts(1 hunks)features/disappearing-messages/update-disappearing-message-settings.mutation.ts(1 hunks)features/streams/stream-messages.ts(3 hunks)features/xmtp/xmtp-disappearing-messages/xmtp-disappearing-messages.ts(2 hunks)utils/react-query/react-query.utils.ts(1 hunks)
💤 Files with no reviewable changes (1)
- features/conversation/conversation-chat/conversation-composer/conversation-composer-text-input.tsx
🚧 Files skipped from review as they are similar to previous changes (6)
- features/disappearing-messages/update-disappearing-message-settings.mutation.ts
- features/disappearing-messages/disappearing-messages.constants.ts
- features/xmtp/xmtp-disappearing-messages/xmtp-disappearing-messages.ts
- features/conversation/conversation-chat/conversation-message/conversation-message-group-update.tsx
- features/streams/stream-messages.ts
- features/disappearing-messages/disappearing-messages-header-action.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
utils/react-query/react-query.utils.ts
[error] 8-8: Don't use '{}' as a type.
Prefer explicitly define the object shape. '{}' means "any non-nullable value".
(lint/complexity/noBannedTypes)
🔇 Additional comments (2)
utils/react-query/react-query.utils.ts (2)
10-13: Good documentation and type assertion.The explicit type assertion before destructuring ensures consistent typing, and the added comment clearly explains the purpose of filtering out the "caller" key, enhancing code maintainability.
15-15: Improved robustness with explicit string conversion.Using
String(value)instead of relying on implicit string conversion in template literals is a good practice. This change makes the code more robust when handling complex objects or values with unpredictable string representations.
Add clear chat functionality to disappearing messages feature by implementing special timestamp handling in XMTP settings
Implements clear chat functionality across multiple components:
setTimestampToClearChatparameter📍Where to Start
Start with the clear chat implementation in disappearing-messages-header-action.tsx which contains the main logic for the new feature and shows how it integrates with the existing disappearing messages functionality.
Macroscope summarized a251d1e.
Summary by CodeRabbit