Skip to content

Conversation

@vats98754
Copy link
Contributor

Implemented a comprehensive conversation merge feature that allows users to combine adjacent conversations with long-press selection and a merge toolbar.

Backend Changes:

  • Added merge_conversations() function to database/conversations.py that:
    • Validates conversations are adjacent (max 1 hour gap)
    • Merges transcript segments, photos, action items, events, and audio files
    • Creates new merged conversation with combined data
    • Deletes source conversations after merge
  • Added POST /v1/conversations/merge endpoint that:
    • Validates user permissions
    • Calls merge function
    • Reprocesses merged conversation to generate new title/overview/summary
    • Returns the processed merged conversation
  • Added MergeConversationsRequest model for API request validation

Frontend Changes:

  • Added selection mode state to ConversationProvider with:
    • isSelectionMode, selectedConversationIds, isMerging flags
    • Methods to enable/disable selection mode
    • toggleConversationSelection() to select/deselect conversations
    • canMergeSelectedConversations() to validate adjacency
    • mergeSelectedConversations() to call API and update UI
  • Added mergeConversations() API method in conversations.dart
  • Updated ConversationListItem widget to:
    • Handle long-press gesture to enable selection mode
    • Show checkboxes and blue border when in selection mode
    • Toggle selection on tap when in selection mode
  • Added merge toolbar to ConversationsPage that:
    • Appears at bottom when selection mode is active
    • Shows selection count
    • Has Cancel button to exit selection mode
    • Has Merge button (disabled if not valid) to merge selected conversations
    • Shows loading indicator during merge operation
    • Displays success/error messages via SnackBar

Features:

  • Long-press on any conversation to enter selection mode
  • Select multiple conversations by tapping
  • Only adjacent conversations (within 1 hour) can be merged
  • Merge button disabled if selection is invalid
  • Merged conversation gets auto-generated title and overview
  • Original conversations are deleted after successful merge
  • Visual feedback with checkboxes, borders, and loading states

Fixes #1505

Implemented a comprehensive conversation merge feature that allows users to combine
adjacent conversations with long-press selection and a merge toolbar.

Backend Changes:
- Added merge_conversations() function to database/conversations.py that:
  * Validates conversations are adjacent (max 1 hour gap)
  * Merges transcript segments, photos, action items, events, and audio files
  * Creates new merged conversation with combined data
  * Deletes source conversations after merge
- Added POST /v1/conversations/merge endpoint that:
  * Validates user permissions
  * Calls merge function
  * Reprocesses merged conversation to generate new title/overview/summary
  * Returns the processed merged conversation
- Added MergeConversationsRequest model for API request validation

Frontend Changes:
- Added selection mode state to ConversationProvider with:
  * isSelectionMode, selectedConversationIds, isMerging flags
  * Methods to enable/disable selection mode
  * toggleConversationSelection() to select/deselect conversations
  * canMergeSelectedConversations() to validate adjacency
  * mergeSelectedConversations() to call API and update UI
- Added mergeConversations() API method in conversations.dart
- Updated ConversationListItem widget to:
  * Handle long-press gesture to enable selection mode
  * Show checkboxes and blue border when in selection mode
  * Toggle selection on tap when in selection mode
- Added merge toolbar to ConversationsPage that:
  * Appears at bottom when selection mode is active
  * Shows selection count
  * Has Cancel button to exit selection mode
  * Has Merge button (disabled if not valid) to merge selected conversations
  * Shows loading indicator during merge operation
  * Displays success/error messages via SnackBar

Features:
- Long-press on any conversation to enter selection mode
- Select multiple conversations by tapping
- Only adjacent conversations (within 1 hour) can be merged
- Merge button disabled if selection is invalid
- Merged conversation gets auto-generated title and overview
- Original conversations are deleted after successful merge
- Visual feedback with checkboxes, borders, and loading states

Fixes BasedHardware#1505
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a conversation merging feature, with changes across the backend and frontend. The implementation is comprehensive, covering API endpoints, database logic, and UI components for selecting and merging conversations. My review focuses on improving the correctness, performance, and data integrity of the backend logic. I've identified a critical issue with data being orphaned after a merge, as well as high-severity issues related to performance and data consistency. On the frontend, there's a correctness issue in the validation logic for merging. Addressing these points will make the feature more robust and reliable.

Copy link
Contributor Author

@vats98754 vats98754 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude read the feedback in the comments on the PR and completely fix and improve

Enhanced the conversation merge feature with better validation, error handling,
and user experience improvements.

Backend Improvements:
- Removed redundant decorators from merge_conversations() that were causing
  double-processing of data
- Now uses get_conversation() to properly fetch and decrypt conversations
- Added validation to prevent merging locked or discarded conversations
- Added logging for merge operations with print statements
- Fixed photo handling to avoid redundant calls

Frontend Improvements:
- Disabled swipe-to-delete when in selection mode
- Prevent selection of locked or discarded conversations
- Added visual opacity (50%) to locked/discarded items in selection mode
- Auto-exit selection mode when switching between discarded/regular views
- Auto-exit selection mode when performing a search
- Added analytics tracking for merge operations (initiate, success, failure)
- Improved error messages with better context (e.g., adjacency requirement)
- Extended snackbar duration for error messages (4s) for better readability
- Added validation in canMergeSelectedConversations() to check for locked/discarded

UX Polish:
- Long-press only works on mergeable (non-locked, non-discarded) conversations
- Tap to select only works on mergeable conversations
- Visual feedback with reduced opacity for non-selectable items
- Better error messages explaining adjacency requirements
- Haptic feedback maintained for merge actions
@aaravgarg
Copy link
Collaborator

wow, can we see a demo?

really important for quick review @vats98754

eulicesl pushed a commit to eulicesl/omi-fork that referenced this pull request Nov 15, 2025
Based on review of PR BasedHardware#3433, added missing validations:

Backend Improvements:
- Add validation to prevent merging locked conversations
- Add validation to prevent merging discarded conversations
- Return descriptive error messages for all failure cases

Frontend Improvements:
- Prevent selecting locked conversations in UI with user feedback
- Prevent selecting discarded conversations in UI with user feedback
- Return error messages from API as tuple (conversation, error)
- Display actual backend error messages to users
- Extend error message duration to 4 seconds for better visibility
- Success messages show for 3 seconds

These improvements align with the approach in PR BasedHardware#3433 while
maintaining our more robust chronological consecutiveness validation.
@beastoin
Copy link
Collaborator

beastoin commented Nov 26, 2025

>> #1505 (comment)

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.

Allowing to Merge Conversations

4 participants