Skip to content

feat: sort conversations by start time in display function#7

Merged
ChristopherJHart merged 1 commit intomainfrom
sort-conversations-by-start-time
Aug 7, 2025
Merged

feat: sort conversations by start time in display function#7
ChristopherJHart merged 1 commit intomainfrom
sort-conversations-by-start-time

Conversation

@ChristopherJHart
Copy link
Collaborator

@ChristopherJHart ChristopherJHart commented Aug 7, 2025

Summary

This pull request implements chronological sorting for conversation display, ensuring conversations are shown in ascending order by start time (earliest to latest).

Problem

Previously, conversations were displayed in the order they were processed/grouped, which could be confusing for users trying to follow their daily communication timeline. While the conversation summary table already had chronological sorting, the detailed conversation display did not.

Solution

Modified the display_conversations() function in summarizer/console_ui.py to sort conversations by their start_time before displaying them. The implementation:

  • Sorts conversations in ascending chronological order (earliest to latest)
  • Handles conversations with None start times by treating them as the earliest (using datetime.min as fallback)
  • Uses the same sorting pattern already established in display_conversations_summary()
  • Maintains all existing functionality and display formatting

Changes Made

Modified Files

  • summarizer/console_ui.py: Added sorting logic to display_conversations() function

Code Changes

# Sort conversations by start time (earliest to latest)
sorted_conversations = sorted(
    conversations, key=lambda conv: conv.start_time or datetime.min
)

Impact

User Experience

  • Improved readability: Conversations now follow a logical chronological flow
  • Better context: Users can easily follow the timeline of their daily communications
  • Consistent behavior: Both detailed and summary views now use the same chronological ordering

Technical

  • Minimal change: Only 6 lines added, 1 line modified
  • Non-breaking: All existing functionality preserved
  • Performance: Negligible impact - sorting is O(n log n) on typically small conversation lists
  • Maintainable: Uses established patterns already present in the codebase

Testing

  • ✅ All existing tests pass (5/5)
  • ✅ Verified sorting behavior with manual testing
  • ✅ Confirmed edge cases (conversations with None start times) are handled correctly
  • ✅ Linting passes without issues

Backward Compatibility

This change is fully backward compatible. No breaking changes to:

  • API interfaces
  • Configuration options
  • Output formats
  • Existing functionality

The only change is the display order, which improves user experience without affecting any programmatic interfaces.

* Implemented sorting of conversations by their start time before displaying them in the console UI.
* This change ensures that conversations are presented in chronological order, enhancing user experience.
@ChristopherJHart ChristopherJHart added the enhancement New feature or request label Aug 7, 2025
@ChristopherJHart ChristopherJHart merged commit e7ac151 into main Aug 7, 2025
24 checks passed
@ChristopherJHart ChristopherJHart deleted the sort-conversations-by-start-time branch August 7, 2025 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant