Skip to content

feat: persistence chat message#45

Merged
foxminchan merged 1 commit into
mainfrom
feat/persistence-chat
May 28, 2025
Merged

feat: persistence chat message#45
foxminchan merged 1 commit into
mainfrom
feat/persistence-chat

Conversation

@foxminchan

@foxminchan foxminchan commented May 27, 2025

Copy link
Copy Markdown
Owner

Pull Request Description

Checklist

  • My code follows the DDD principles
  • I've used the latest C# features and idioms
  • I've added/updated unit tests for business logic
  • Service boundaries are maintained (no cross-service direct dependencies)
  • Repository pattern is used for data access
  • Domain Events are used for cross-service communication
  • I've registered new services in AppHost project (if applicable)
  • I've updated both entities and DTOs (if applicable)

@foxminchan foxminchan self-assigned this May 27, 2025
@foxminchan foxminchan changed the title feat: add chat endpoints feat: persistence chat message May 27, 2025
@foxminchan foxminchan added the enhancement New feature or request label May 27, 2025
@netlify

netlify Bot commented May 27, 2025

Copy link
Copy Markdown

Deploy Preview for bookwormdev canceled.

Name Link
🔨 Latest commit ed47707
🔍 Latest deploy log https://app.netlify.com/projects/bookwormdev/deploys/68372628139211000835e1ea

@github-actions

github-actions Bot commented May 27, 2025

Copy link
Copy Markdown

Test Results

841 tests  +189   841 ✅ +189   5m 7s ⏱️ - 1m 22s
  8 suites ±  0     0 💤 ±  0 
  8 files   ±  0     0 ❌ ±  0 

Results for commit ed47707. ± Comparison against base commit a430591.

This pull request removes 2 and adds 191 tests. Note that renamed tests count towards both.
BookWorm.Chat.UnitTests.Features.Create.CreateChatEndpointTests ‑ GivenValidPrompt_WhenHandlingCreateChat_ThenShouldReturnCreatedWithCorrectGuid
BookWorm.Chat.UnitTests.Features.Stream.ChatStreamHubTests ‑ GivenValidText_WhenAddingStreamingMessage_ThenShouldReturnMessageId
BookWorm.Chat.UnitTests.Domain.ConversationAggregatorTests ‑ GivenConversation_WhenAccessingMessages_ThenShouldReturnReadOnlyCollection
BookWorm.Chat.UnitTests.Domain.ConversationAggregatorTests ‑ GivenEmptyName_WhenCreatingConversation_ThenShouldThrowConversationDomainException
BookWorm.Chat.UnitTests.Domain.ConversationAggregatorTests ‑ GivenMultipleMessages_WhenAddingMessages_ThenShouldAddAllToMessagesCollection
BookWorm.Chat.UnitTests.Domain.ConversationAggregatorTests ‑ GivenNullName_WhenCreatingConversation_ThenShouldThrowConversationDomainException
BookWorm.Chat.UnitTests.Domain.ConversationAggregatorTests ‑ GivenParameterlessConstructor_WhenCreatingConversation_ThenShouldInitializeCorrectly
BookWorm.Chat.UnitTests.Domain.ConversationAggregatorTests ‑ GivenValidMessage_WhenAddingMessage_ThenShouldAddToMessagesCollection
BookWorm.Chat.UnitTests.Domain.ConversationAggregatorTests ‑ GivenValidNameAndNullUserId_WhenCreatingConversation_ThenShouldSetPropertiesCorrectly
BookWorm.Chat.UnitTests.Domain.ConversationAggregatorTests ‑ GivenValidNameAndUserId_WhenCreatingConversation_ThenShouldSetPropertiesCorrectly
BookWorm.Chat.UnitTests.Domain.ConversationAggregatorTests ‑ GivenWhitespaceOnlyName_WhenCreatingConversation_ThenShouldThrowConversationDomainException
BookWorm.Chat.UnitTests.Domain.ConversationMessageTests ‑ GivenDifferentRoleValues_WhenCreatingConversationMessage_ThenShouldAcceptValidRoles
…

♻️ This comment has been updated with latest results.

@foxminchan
foxminchan requested a review from Copilot May 27, 2025 18:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request introduces persistence for chat messages by refactoring the chat creation and cancellation endpoints to use command/mediator patterns. Key changes include:

  • Updating the CreateChat and CancelChat endpoints to use ISender and LinkGenerator.
  • Adding new commands and handlers for chat creation and cancellation.
  • Enhancing unit tests and updating dependency configuration in the AppHost and project files.

Reviewed Changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
CreateChatEndpoint.cs Refactored to use CreateChatCommand, ISender, and LinkGenerator with updated HTTP response type.
CreateChatCommand.cs Added command record and corresponding handler for chat creation.
ConversationMessageDto.cs & ConversationDto.cs Defined DTOs for chat conversations and messages for data persistence.
CancelChatEndpoint.cs & CancelChatCommand.cs Updated cancellation to use sender-based commands instead of a dedicated manager.
Extensions.cs Updated dependency injection to configure MediatR, validators, and exception handlers.
Domain Files Added domain exceptions and specifications, and updated Conversation and ConversationMessage implementations for persistence.
Unit Tests Updated tests to account for changes in endpoint signatures and behaviors.
Project Files Added new package references and updated configuration to support new features.

Comment thread src/Services/Chat/BookWorm.Chat/Domain/AggregatesModel/Conversation.cs Outdated
@foxminchan
foxminchan requested a review from Copilot May 28, 2025 11:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces persistence functionality for chat messages and improves the testing coverage of chat features. Key changes include updates to the unit tests for streaming, getting, creating, deleting, and canceling chats; modifications to the command and handler implementations; and integration changes in the AppHost for registering the new chat database.

Reviewed Changes

Copilot reviewed 60 out of 60 changed files in this pull request and generated no comments.

Show a summary per file
File Description
BookWorm.Chat.UnitTests/Features/Stream/ChatStreamHubTests.cs Updated tests to pass conversation ID and adjust verification.
BookWorm.Chat.UnitTests/Features/Get/*.cs Expanded unit tests covering query, endpoint behavior and error scenarios.
BookWorm.Chat.UnitTests/Features/Delete/*.cs Added tests and command handling for deleting chats.
BookWorm.Chat.UnitTests/Features/Create/*.cs Updated validator, endpoint, and command tests for chat creation including special characters and boundary conditions.
BookWorm.Chat.UnitTests/Features/Cancel/*.cs Refactored cancel endpoints and command tests to use sender patterns.
BookWorm.Chat.UnitTests/Fakers/*.cs Adjusted fakers using new C# collection initialization syntax.
BuildingBlocks/BookWorm.SharedKernel/SeedWork/AuditableEntity.cs Set default CreatedAt initializer to UtcNow.
BuildingBlocks/BookWorm.Constants/Aspire/Components.cs Added chat component constant.
Aspire/BookWorm.AppHost/AppHost.cs Registered the chat database and added dependency references.
Directory.Packages.props Updated package versions and added Bogus usage.
Catalog UnitTests for Publishers Updated test to use Guid.CreateVersion7() for expected publisher ID.

@foxminchan
foxminchan force-pushed the feat/persistence-chat branch from aa7b95a to ed47707 Compare May 28, 2025 15:05
@foxminchan
foxminchan marked this pull request as ready for review May 28, 2025 15:05
@sonarqubecloud

Copy link
Copy Markdown

@foxminchan
foxminchan merged commit 89d43a1 into main May 28, 2025
@foxminchan
foxminchan deleted the feat/persistence-chat branch May 28, 2025 15: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.

2 participants