Files
6a262287d2 feat(captain): allow agents to report Captain messages (#14799)
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>
2026-06-20 14:47:08 -07:00

41 lines
1.5 KiB
Ruby

require 'rails_helper'
RSpec.describe Captain::MessageReport, type: :model do
describe 'associations' do
it { is_expected.to belong_to(:account) }
it { is_expected.to belong_to(:conversation) }
it { is_expected.to belong_to(:message) }
it { is_expected.to belong_to(:user) }
it 'resolves the conversation association to the top-level Conversation model' do
# `Captain::Conversation` exists as a job namespace, so without an explicit
# class_name the association would resolve to that module instead.
expect(described_class.reflect_on_association(:conversation).klass).to eq(Conversation)
end
end
describe 'validations' do
it { is_expected.to validate_presence_of(:report_reason) }
it { is_expected.to validate_inclusion_of(:report_reason).in_array(described_class::REPORT_REASONS) }
end
describe 'callbacks' do
let(:account) { create(:account) }
let(:conversation) { create(:conversation, account: account) }
let(:message) { create(:message, account: account, conversation: conversation) }
it 'derives the account and conversation from the message' do
report = described_class.create!(message: message, user: create(:user, account: account), report_reason: 'other')
expect(report.account).to eq(account)
expect(report.conversation).to eq(conversation)
end
end
describe 'factory' do
it 'creates a valid message report' do
expect(build(:captain_message_report)).to be_valid
end
end
end