Conversation
also updates the specs
There was a problem hiding this comment.
Pull request overview
This PR introduces session cancellation functionality and refactors the session management system by separating creation and cancellation into dedicated operation classes. The changes include a new cancel session endpoint, updated response handling with a base response class, and removal of the VCR test dependency.
- Introduced
Session::CreateandSession::Cancelclasses to handle session operations explicitly - Added session cancellation capability with dedicated response and scope classes
- Refactored response handling with a new
Session::BaseResponsebase class
Reviewed changes
Copilot reviewed 43 out of 75 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/chatkit/version.rb | Bumped version to 0.2.0 for breaking changes |
| lib/chatkit/session/create.rb | New class encapsulating session creation logic |
| lib/chatkit/session/cancel.rb | New class implementing session cancellation |
| lib/chatkit/session/base_response.rb | Renamed Response to BaseResponse as parent class |
| lib/chatkit/session/create/response.rb | Response class for session creation |
| lib/chatkit/session/cancel/response.rb | Response class with cancellation-specific fields |
| lib/chatkit/session/cancel/scope.rb | New scope class for cancel response data |
| lib/chatkit/request/endpoints.rb | Added cancel endpoint and dynamic path parameter support |
| lib/chatkit/session/workflow.rb | Added nil check guard in deserialize method |
| lib/chatkit/conversation/response/thread/item/workflow.rb | Added nil check in from_event method |
| spec/chatkit/request/endpoints_spec.rb | Updated test for renamed endpoint method |
| spec/chatkit/client_spec.rb | Simplified configuration tests using direct assignment |
| Gemfile | Removed vcr gem dependency |
| spec/cassettes/* | Removed VCR cassette files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| define_method "#{const_name.to_s.downcase}_endpoint" do |path_params = {}| | ||
| if path_params | ||
| raise ArgumentError, "Path parameters must be provided as a Hash" unless path_params.is_a?(Hash) | ||
|
|
||
| format(ChatKit::Request::Endpoints.const_get(const_name), **path_params) | ||
| else | ||
| ChatKit::Request::Endpoints.const_get(const_name) | ||
| end |
There was a problem hiding this comment.
The condition if path_params will always be true since it defaults to {}. An empty hash is truthy in Ruby, so the else branch at line 28 is unreachable. Change the condition to if path_params.any? or unless path_params.empty? to properly detect when parameters are provided.
|
|
||
| private | ||
|
|
||
| # Performs the HTTP request to create a session. |
There was a problem hiding this comment.
Comment incorrectly states "create a session" when the method actually cancels a session. Update to "Performs the HTTP request to cancel a session."
| # Performs the HTTP request to create a session. | |
| # Performs the HTTP request to cancel a session. |
CHANGELOG 📝
Note
This pull request introduces a significant refactor and expansion of the ChatKit session management subsystem, adding explicit support for session creation and cancellation operations, and restructuring response handling for clarity and maintainability. The changes also improve endpoint handling and error management.
The most important changes are:
Session Management Refactor & Features:
Sessionclass to delegate session creation and cancellation to new dedicated classes (Session::CreateandSession::Cancel), simplifying the interface and improving separation of concerns. Now, session creation and cancellation are performed via theCreate.callandCancel.callmethods, and session state is managed through a single@sessionattribute. [1] [2] [3]Session::Create,Session::Cancel, and corresponding response and scope classes (Session::Create::Response,Session::Cancel::Response,Session::Cancel::Scope) to encapsulate the logic and data for session creation and cancellation operations. [1] [2] [3] [4] [5]Session::BaseResponse) and updated response classes to inherit from it, replacing the previousSession::Response.API Endpoint and Error Handling Improvements:
Request::Endpointsto explicitly distinguish between session creation and cancellation, and improved the endpoint method to accept path parameters for dynamic endpoint construction. [1] [2]Workflow and Data Handling Adjustments:
nilworkflow data and avoid unnecessary method indirection in conversation response items. [1] [2] [3] [4] [5]Other Changes:
vcrgem from the Gemfile, possibly to clean up unused test dependencies.0.2.0to reflect these breaking changes and new features.