Adds a cloud-only flow for agents to flag incorrect or problematic Captain (AI) responses. Right-clicking a Captain message surfaces a "Report message" option that opens a dialog to pick a problem type and add a description, persisted to a new captain_message_reports table for the team to review. <img width="636" height="542" alt="Screenshot 2026-06-20 at 9 15 56 AM" src="https://github.com/user-attachments/assets/afaa233d-6bd6-455a-8a33-a3796a3e3ef6" /> <img width="580" height="502" alt="Screenshot 2026-06-20 at 9 16 03 AM" src="https://github.com/user-attachments/assets/2d220d99-98cc-4c5e-a325-778ceb4f7bc9" /> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
47 lines
1.5 KiB
Ruby
47 lines
1.5 KiB
Ruby
# == Schema Information
|
|
#
|
|
# Table name: captain_message_reports
|
|
#
|
|
# id :bigint not null, primary key
|
|
# description :text
|
|
# report_reason :string not null
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# account_id :bigint not null
|
|
# conversation_id :bigint not null
|
|
# message_id :bigint not null
|
|
# user_id :bigint not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_captain_message_reports_on_account_id (account_id)
|
|
# index_captain_message_reports_on_conversation_id (conversation_id)
|
|
# index_captain_message_reports_on_message_id (message_id)
|
|
# index_captain_message_reports_on_user_id (user_id)
|
|
#
|
|
class Captain::MessageReport < ApplicationRecord
|
|
self.table_name = 'captain_message_reports'
|
|
|
|
REPORT_REASONS = %w[incorrect_information inappropriate_response incomplete_response outdated_information other].freeze
|
|
|
|
belongs_to :account
|
|
# `Captain::Conversation` exists as a job namespace, so the association would
|
|
# resolve to that module instead of the top-level model without this override.
|
|
belongs_to :conversation, class_name: '::Conversation'
|
|
belongs_to :message
|
|
belongs_to :user
|
|
|
|
validates :report_reason, presence: true, inclusion: { in: REPORT_REASONS }
|
|
|
|
before_validation :ensure_account_and_conversation
|
|
|
|
private
|
|
|
|
def ensure_account_and_conversation
|
|
return if message.blank?
|
|
|
|
self.account ||= message.account
|
|
self.conversation ||= message.conversation
|
|
end
|
|
end
|