Conversation
korgon
commented
Jan 7, 2026
- under active development - DO NOT MERGE
…hat sessions, added persistence and improved the UI
…ponse must be used (using header for now)
…fying product attachment to contain image and name
refactor(chat): moving stuff around and fixing some bugs
There was a problem hiding this comment.
Pull request overview
This PR introduces conversational search functionality through a new Chat feature. The implementation includes a complete chat interface with support for image uploads, product attachments, and AI-powered responses.
Key Changes:
- Added ChatController, ChatStore, and ChatSessionStore for managing chat state and interactions
- Integrated chat API client with support for various request types (general, product query, image search, etc.)
- Created Chat UI components with message display, attachments, and feedback mechanisms
Reviewed changes
Copilot reviewed 42 out of 43 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/snap-store-mobx/src/types.ts | Added ChatStoreConfig types and integrated into StoreConfigs union |
| packages/snap-store-mobx/src/Chat/ChatStore.ts | Implements main chat store with session management and storage |
| packages/snap-store-mobx/src/Chat/Stores/ChatSessionStore.ts | Manages individual chat sessions with message history and attachments |
| packages/snap-store-mobx/src/Chat/Stores/ChatAttachmentStore.ts | Handles image and product attachments with state management |
| packages/snap-controller/src/Chat/ChatController.ts | Controller implementation for chat interactions and API requests |
| packages/snap-preact/src/Templates/SnapTemplates.tsx | Integrates chat targets and configuration into template system |
| packages/snap-preact/components/src/components/Organisms/Chat/Chat.tsx | Main chat UI component with message display and input |
| packages/snap-client/src/Client/apis/Chat.ts | API client for chat endpoints including message sending and image upload |
| packages/snap-client/src/Client/transforms/chatResponse.ts | Transforms chat API responses to standardized format |
| .github/workflows/test.yml | Temporarily disabled tests (commented out) |
Comments suppressed due to low confidence (1)
packages/snap-controller/src/Chat/ChatController.ts:1
- Corrected spelling of 'transfrorm respose' to 'transform response'.
/*
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| treePath: globalTreePath, | ||
| }; | ||
|
|
||
| let props = mergeProps('facets', globalTheme, defaultProps, properties); |
There was a problem hiding this comment.
The first argument should be 'chat' instead of 'facets' to correctly identify the component type for props merging.
| let props = mergeProps('facets', globalTheme, defaultProps, properties); | |
| let props = mergeProps('chat', globalTheme, defaultProps, properties); |
|
|
||
| if (sessionId) { | ||
| // @ts-ignore - add sessionId to response context | ||
| responseJSON.context = response.context || { sessionId }; |
There was a problem hiding this comment.
Attempting to assign to response.context but should be responseJSON.context. The current code creates the context object correctly but the comment suggests confusion about the source.
| responseJSON.context = response.context || { sessionId }; | |
| responseJSON.context = responseJSON.context || { sessionId }; |
|
|
||
| async postUploadImage(requestParameters: UploadImageRequestModel): Promise<UploadImageResponseModel> { | ||
| const headerParameters: HTTPHeaders = { | ||
| 'X-Widget-Id': 'test-ss-demo', |
There was a problem hiding this comment.
Hard-coded widget ID should be passed as a parameter instead. This makes the upload functionality non-functional for other widgets and creates a security risk by exposing test credentials.
| # - name: Tests | ||
| # env: | ||
| # NODE_OPTIONS: "--max-old-space-size=4096" | ||
| # run: npm run test |
There was a problem hiding this comment.
Tests have been commented out in CI. This should be re-enabled before merging to ensure code quality and prevent regressions.
| # - name: Tests | |
| # env: | |
| # NODE_OPTIONS: "--max-old-space-size=4096" | |
| # run: npm run test | |
| - name: Tests | |
| env: | |
| NODE_OPTIONS: "--max-old-space-size=4096" | |
| run: npm run test |
| }; | ||
|
|
||
| export class ChatAttachmentProduct extends ChatAttachment { | ||
| public type: 'product' | never = 'product'; |
There was a problem hiding this comment.
The union with 'never' is redundant. The type should simply be 'product' as a literal type.
| ) : ( | ||
| <></> | ||
| ); | ||
| } else if (type == 'product') { |
There was a problem hiding this comment.
Use strict equality (===) instead of loose equality (==) for type comparisons.
| const attachments: string[] = []; | ||
| if (request.data.requestType === 'imageSearch') { | ||
| const imageId = request.data.attachedImageId; | ||
| const attachedImage = this.attachments.attached.find((item) => item.type == 'image' && item.imageId == imageId); |
There was a problem hiding this comment.
Use strict equality (===) instead of loose equality (==) for type and ID comparisons.
|
|
||
| if (request.data.requestType === 'productQuery') { | ||
| const productId = request.data.productId; | ||
| const attachedImage = this.attachments.attached.find((item) => item.type == 'product' && item.productId == productId); |
There was a problem hiding this comment.
Use strict equality (===) instead of loose equality (==) for type and ID comparisons.
| } | ||
|
|
||
| export interface MessageProps { | ||
| chatItem: any; |
There was a problem hiding this comment.
Replace any type with the proper ChatMessage type that's imported in the file for better type safety.
| public storage: StorageStore; | ||
| public chats: ChatSessionStore[] = []; | ||
| public currentChatId: string; | ||
| public quickViewResult: any = {}; |
There was a problem hiding this comment.
Replace any type with Product | null or similar appropriate type for better type safety.
| public quickViewResult: any = {}; | |
| public quickViewResult: ChatAttachmentProduct | null = null; |
…tons, add productSimilar
fix: productSimilar fix and sends chat message, general styling, icon…
…ations where display may not be defined