-
Notifications
You must be signed in to change notification settings - Fork 20
feat: Added Delete Conversation feature #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Added Delete Conversation feature #96
Conversation
- Implemented deleteConversation function to remove conversations and their messages from the database. - Added UI elements for deleting conversations, including a confirmation modal. - Enhanced chat history screen to handle conversation deletion and update state accordingly. - Updated styles for new modal and delete button interactions.
- Changed the delete button style to use a new class for modal interactions. - Removed the color specification from the trash icon for a cleaner look. - Adjusted padding and margin for the delete button to improve layout consistency.
- Added loading state management for conversation deletion to prevent multiple submissions. - Updated UI to reflect the loading state on delete button and cancel action. - Improved error handling and user feedback during the deletion process.
|
@Aayushgoyal00 is attempting to deploy a commit to the dark Team on Vercel. A member of the Team first needs to authorize it. |
|
this is awesome! great and easy feature add that definitely belongs in mallory one of the things i'm thinking about here - that i don't think we have a solution for yet, so we're kind of guinea pigging in this PR, is the right way to solve for the design piece of open source contributions. we're pretty design oriented and i'd love for mallory to continue to be cohesive on that front. here's what i'm thinking on this PR specifically:
need to take a closer look at:
but thought i'd drop these initial comments for now |
|
realized we're talking about another chat-history feature in #90 and was thinking: the three buttons with an additional dropdown feel kind of eh i feel like icons for actions next to the date would feel nicer something like that |
…ory UI - Added `is_visible` column to the conversations table to support soft deletion. - Updated conversation loading logic to filter out soft-deleted conversations. - Modified the delete functionality to soft delete conversations instead of permanently removing them. - Enhanced chat history UI to show delete action on hover for web users, improving user experience. - Refactored styles for better layout and interaction consistency.
✅ Changes Made1. Soft Deletion with
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Suggestion:
The handleConversationUpdate function doesn't check if a conversation has been soft-deleted (is_visible: false), which could cause soft-deleted conversations to be updated or displayed incorrectly when real-time events are received.
View Details
📝 Patch Details
diff --git a/apps/client/hooks/useChatHistoryData.ts b/apps/client/hooks/useChatHistoryData.ts
index e3a94c3..95209fa 100644
--- a/apps/client/hooks/useChatHistoryData.ts
+++ b/apps/client/hooks/useChatHistoryData.ts
@@ -178,9 +178,9 @@ export function useChatHistoryData(userId?: string) {
console.log('📝 [HANDLE INSERT] newRecord.token_ca:', newRecord.token_ca);
console.log('📝 [HANDLE INSERT] GLOBAL_TOKEN_ID:', GLOBAL_TOKEN_ID);
- // Only add global conversations
- if (newRecord.token_ca !== GLOBAL_TOKEN_ID) {
- console.log('⚠️ [HANDLE INSERT] Skipping - not a global conversation');
+ // Only add global conversations that are visible (not soft-deleted)
+ if (newRecord.token_ca !== GLOBAL_TOKEN_ID || newRecord.is_visible === false) {
+ console.log('⚠️ [HANDLE INSERT] Skipping - not a global conversation or soft-deleted');
return;
}
@@ -208,6 +208,23 @@ export function useChatHistoryData(userId?: string) {
}, []);
const handleConversationUpdate = useCallback((newRecord: any) => {
+ if (newRecord.is_visible === false) {
+ // Remove soft-deleted conversations instead of updating them
+ setConversations(prev => {
+ const updated = prev.filter(conv => conv.id !== newRecord.id);
+ cache.conversations = updated;
+ return updated;
+ });
+ setAllMessages(prev => {
+ const updated = { ...prev };
+ delete updated[newRecord.id];
+ cache.allMessages = updated;
+ return updated;
+ });
+ console.log('✅ [useChatHistoryData] Removed soft-deleted conversation:', newRecord.id);
+ return;
+ }
+
setConversations(prev => {
const updated = prev.map(conv =>
conv.id === newRecord.id
@@ -399,4 +416,3 @@ export function getCachedMessagesForConversation(conversationId: string): any[]
if (!cache.allMessages || !conversationId) return null;
return cache.allMessages[conversationId] || null;
}
-
Analysis
Real-time handlers ignore is_visible flag allowing soft-deleted conversations to persist
What fails: handleConversationUpdate() and handleConversationInsert() in useChatHistoryData.ts don't check is_visible field, causing soft-deleted conversations to remain visible when real-time UPDATE/INSERT events are received
How to reproduce:
# Multi-client scenario:
# 1. Client A has conversation in local state
# 2. Client B soft-deletes conversation (sets is_visible: false)
# 3. Client A receives UPDATE event with is_visible: false
# 4. handleConversationUpdate processes it without checking is_visible
# 5. Soft-deleted conversation remains in Client A's stateResult: Soft-deleted conversations remain visible to other clients and can be incorrectly updated instead of removed
Expected: Conversations with is_visible: false should be filtered out or removed from local state, consistent with initial query filter at line 85: .neq('is_visible', false)
Evidence: Supabase real-time docs confirm UPDATE events are sent when columns change, including is_visible field changes
Description
This PR adds conversation deletion functionality to allow users to remove unwanted or old chats from their chat history sidebar. The implementation includes a delete button for each conversation, a confirmation modal to prevent accidental deletions, and proper loading states during the deletion process.
Fixes #75
Key Changes:
deleteConversationfunction inuseChatHistoryDatahook that permanently removes conversations and associated messages from the databaseImplementation Details:
apps/client/app/(main)/chat-history.tsxto add UI components and deletion logicapps/client/hooks/useChatHistoryData.tswith database deletion functionalityType of Change
Release
Is this a release? No
Testing
Checklist