Class: Collavre::AiAgent::ResponseFinalizer
- Inherits:
-
Object
- Object
- Collavre::AiAgent::ResponseFinalizer
- Defined in:
- app/services/collavre/ai_agent/response_finalizer.rb
Overview
Handles finalization of AI agent responses:
-
Review workflow processing
-
Comment creation/update
-
Activity log reassociation
Instance Attribute Summary collapse
-
#review_flow ⇒ Object
readonly
Whether the last finalization was a review-flow update (no new comment created).
Instance Method Summary collapse
-
#finalize ⇒ Object
Finalize the response, handling review workflow if applicable Returns the finalized comment or nil.
-
#initialize(task:, agent:, original_comment:, reply_comment:, response_content:) ⇒ ResponseFinalizer
constructor
A new instance of ResponseFinalizer.
Constructor Details
#initialize(task:, agent:, original_comment:, reply_comment:, response_content:) ⇒ ResponseFinalizer
Returns a new instance of ResponseFinalizer.
10 11 12 13 14 15 16 |
# File 'app/services/collavre/ai_agent/response_finalizer.rb', line 10 def initialize(task:, agent:, original_comment:, reply_comment:, response_content:) @task = task @agent = agent @original_comment = original_comment @reply_comment = reply_comment @response_content = response_content end |
Instance Attribute Details
#review_flow ⇒ Object (readonly)
Whether the last finalization was a review-flow update (no new comment created)
19 20 21 |
# File 'app/services/collavre/ai_agent/response_finalizer.rb', line 19 def review_flow @review_flow end |
Instance Method Details
#finalize ⇒ Object
Finalize the response, handling review workflow if applicable Returns the finalized comment or nil
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/services/collavre/ai_agent/response_finalizer.rb', line 23 def finalize @review_flow = false # If no content, destroy placeholder and return if @response_content.blank? @reply_comment&.destroy! return nil end review_handler = ReviewHandler.new(@original_comment, @agent) if @reply_comment finalize_reply_comment(review_handler) elsif @original_comment create_reply_comment end end |