mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
Remove unused DeveloperMessage model (#1207)
DeveloperMessage was a debug-only STI subclass of Message that was never created by any production code. Remove the model, view partial, test, and fixtures, and simplify Chat#conversation_messages accordingly. https://claude.ai/code/session_012pm5HKGKFs1tpAsvXMr4Tp Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -75,10 +75,6 @@ class Chat < ApplicationRecord
|
||||
end
|
||||
|
||||
def conversation_messages
|
||||
if debug_mode?
|
||||
messages
|
||||
else
|
||||
messages.where(type: [ "UserMessage", "AssistantMessage" ])
|
||||
end
|
||||
messages.where(type: [ "UserMessage", "AssistantMessage" ])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
class DeveloperMessage < Message
|
||||
def role
|
||||
"developer"
|
||||
end
|
||||
|
||||
private
|
||||
def broadcast?
|
||||
chat.debug_mode?
|
||||
end
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
<%# locals: (developer_message:) %>
|
||||
|
||||
<div id="<%= dom_id(developer_message) %>" class="my-2 <%= developer_message.debug? ? "bg-yellow-50 border-yellow-200" : "bg-blue-50 border-blue-200" %> px-3 py-2 rounded-lg max-w-[85%] ml-auto border">
|
||||
<span class="text-secondary text-xs"><%= developer_message.debug? ? "Debug message (internal only)" : "System instruction (sent to AI)" %></span>
|
||||
<p class="text-primary text-sm"><%= developer_message.content %></p>
|
||||
</div>
|
||||
14
test/fixtures/messages.yml
vendored
14
test/fixtures/messages.yml
vendored
@@ -1,17 +1,3 @@
|
||||
chat1_developer:
|
||||
type: DeveloperMessage
|
||||
content: You are a personal finance assistant. Be concise and helpful.
|
||||
chat: one
|
||||
created_at: 2025-03-20 12:00:00
|
||||
debug: false
|
||||
|
||||
chat1_developer_debug:
|
||||
type: DeveloperMessage
|
||||
content: An internal debug message
|
||||
chat: one
|
||||
created_at: 2025-03-20 12:00:02
|
||||
debug: true
|
||||
|
||||
chat1_user:
|
||||
type: UserMessage
|
||||
content: Can you help me understand my spending habits?
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
require "test_helper"
|
||||
|
||||
class DeveloperMessageTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@chat = chats(:one)
|
||||
end
|
||||
|
||||
test "does not broadcast" do
|
||||
message = DeveloperMessage.create!(chat: @chat, content: "Some instructions")
|
||||
message.update!(content: "updated")
|
||||
|
||||
assert_no_turbo_stream_broadcasts(@chat)
|
||||
end
|
||||
|
||||
test "broadcasts if debug mode is enabled" do
|
||||
with_env_overrides AI_DEBUG_MODE: "true" do
|
||||
message = DeveloperMessage.create!(chat: @chat, content: "Some instructions")
|
||||
message.update!(content: "updated")
|
||||
|
||||
streams = capture_turbo_stream_broadcasts(@chat)
|
||||
assert_equal 2, streams.size
|
||||
assert_equal "append", streams.first["action"]
|
||||
assert_equal "messages", streams.first["target"]
|
||||
assert_equal "update", streams.last["action"]
|
||||
assert_equal "developer_message_#{message.id}", streams.last["target"]
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user