Feat: Add support to Action Text enabled content#365
Feat: Add support to Action Text enabled content#365chagel wants to merge 13 commits intocrmne:mainfrom
Conversation
Improved the `extract_content` method to correctly process Action Text. When `message` model uses `has_rich_text :content`, `message.content` becomes `ActionText:RichText`, returning HTML tags unintentionally. Adjustments ensure only the desired content is extracted.
@crmne Added basic tests and modified dummy app for instance double. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #365 +/- ##
==========================================
+ Coverage 86.16% 86.18% +0.01%
==========================================
Files 118 118
Lines 5334 5334
Branches 1350 1351 +1
==========================================
+ Hits 4596 4597 +1
+ Misses 738 737 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
crmne
left a comment
There was a problem hiding this comment.
Requesting changes for a couple of issues.
-
acts_as_messagestill does not work with a realhas_rich_text :contentmodel. The new path inMessageMethods#extract_contentreadsself[:content], but Action Text exposes rich text throughcontent, while the raw attribute slot is stillnil. When I reproduced this against a temporaryhas_rich_text :contentmessage model on the PR branch,m.content.to_plain_textreturned the expected text,m[:content]wasnil, andm.to_llm.contentcame back empty. The new spec passes because it stubsmessage.[]directly instead of exercising a real Action Text-backed model. -
Both extraction paths now coerce
nilcontent to""viato_s. That changes current behavior for persisted empty messages.RubyLLM::Messageonly normalizesnilto an empty string for assistant tool-call messages, but this patch makes plain persistednilcontent come back as""more broadly. I think we should preserve the existingnilsemantics unless that change is intentional and covered by tests. -
Minor: I would avoid hardcoding
gpt-4.1-nanoin the new spec. The model does not matter for this behavior, so I would prefer to use the default model and leave it unspecified.
…ribute self[:content] reads the raw DB column, which is nil for Action Text models (content lives in action_text_rich_texts table). Use content (the method) which Action Text overrides to return the RichText object. Also preserve nil semantics by removing .to_s coercion, and fix spec to stub content method instead of [] to match real Action Text behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@crmne Thanks for the thorough review. All three issues are addressed. |
What this does
Improved the
extract_contentmethod to correctly process Action Text. Whenmessagemodel useshas_rich_text :content,message.contentbecomesActionText:RichText, returning HTML tags unintentionally. Adjustments ensure only the desired content is extracted.Type of change
Scope check
Quality check
overcommit --installand all hooks passmodels.json,aliases.json)API changes
Related issues