Skip to content

REF-18: Implement chat history feature with /conversations endpoint#22

Merged
hramini merged 6 commits intomainfrom
devin/REF-18-1746446789
May 5, 2025
Merged

REF-18: Implement chat history feature with /conversations endpoint#22
hramini merged 6 commits intomainfrom
devin/REF-18-1746446789

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented May 5, 2025

REF-18: Implement Chat History Feature

This PR implements the chat history feature for our AI chatbot app by:

  1. Updating the API service in lib/services/api-service.ts to use the "/api/conversations" endpoint with the base URL "localhost:3333"
  2. Adding token authentication to API calls with "token=${API_CONFIG.AUTH_TOKEN}"
  3. Modifying the SidebarHistory component to use the real API service instead of the mock one
  4. Updating the ChatSummary interface based on the backend conversation structure:
    {
      content: any,
      conversation_id: string,
      message_id: string,
      timestamp: string,
      _id: string
    }
  5. Implementing lazy-load pagination on scroll for better performance with large chat histories
  6. Maintaining all existing functionality including:
    • Time-based grouping (Today, Yesterday, Last 7 Days, etc.)
    • Loading skeletons during data fetching
    • Empty state handling
    • Chat deletion capability using the "/api/conversations/:id" endpoint with token authentication
  7. Added chat history refresh when creating a new chat to ensure the sidebar is always up-to-date

Implementation Details

  • Transformed backend conversation data to match the UI requirements
  • Updated the groupChatsByDate function to use timestamp instead of createdAt
  • Added proper error handling for API calls
  • Implemented optimistic UI updates for deletion
  • Used SWR for efficient chat history management and refreshing
  • Added chat history refresh to "New Chat" buttons in both sidebar and header

Testing

  • Verified that the chat history loads correctly from the "/api/conversations" endpoint
  • Confirmed that lazy-loading pagination works when scrolling
  • Tested deletion functionality with the new endpoint
  • Verified that the chat history refreshes when creating a new chat

Link to Devin run

https://app.devin.ai/sessions/b160ef899760430e9fc99d96ea89b5d6

Requested by

dev@refact.co

Co-Authored-By: dev@refact.co <dev@refact.co>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration bot and others added 5 commits May 5, 2025 12:08
Co-Authored-By: dev@refact.co <dev@refact.co>
Co-Authored-By: dev@refact.co <dev@refact.co>
Co-Authored-By: dev@refact.co <dev@refact.co>
Co-Authored-By: dev@refact.co <dev@refact.co>
…esponse

Co-Authored-By: dev@refact.co <dev@refact.co>
@hramini hramini merged commit 77dd6d5 into main May 5, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant