Class: UserMessageDecorator
- Inherits:
-
MessageDecorator
- Object
- Draper::Decorator
- ApplicationDecorator
- MessageDecorator
- UserMessageDecorator
- Defined in:
- app/decorators/user_message_decorator.rb
Overview
Decorates user_message records for display in the TUI. Basic mode returns role and content. Verbose mode adds a timestamp. Debug mode adds token count (exact when counted, estimated when not). Pending messages include ‘status: “pending”` so the TUI renders them with a visual indicator (dimmed, clock icon).
Constant Summary
Constants inherited from MessageDecorator
MessageDecorator::ERROR_ICON, MessageDecorator::MIDDLE_TRUNCATION_MARKER, MessageDecorator::RETURN_ARROW, MessageDecorator::TOOL_ICON
Instance Method Summary collapse
-
#render_basic ⇒ Hash
Structured user message data ‘:user, content: String` or with `status: “pending”` when queued.
-
#render_brain ⇒ String
User message for the analytical brain, middle-truncated if very long (preserves intent at start and conclusion at end).
-
#render_debug ⇒ Hash
Verbose output plus token count for debugging.
-
#render_verbose ⇒ Hash
Structured user message with nanosecond timestamp.
Methods inherited from MessageDecorator
Instance Method Details
#render_basic ⇒ Hash
Returns structured user message data ‘:user, content: String` or with `status: “pending”` when queued.
11 12 13 14 15 |
# File 'app/decorators/user_message_decorator.rb', line 11 def render_basic base = {role: :user, content: content} base[:status] = "pending" if pending? base end |
#render_brain ⇒ String
Returns user message for the analytical brain, middle-truncated if very long (preserves intent at start and conclusion at end).
31 32 33 |
# File 'app/decorators/user_message_decorator.rb', line 31 def render_brain "User: #{truncate_middle(content)}" end |
#render_debug ⇒ Hash
Returns verbose output plus token count for debugging.
25 26 27 |
# File 'app/decorators/user_message_decorator.rb', line 25 def render_debug render_verbose.merge(token_info) end |
#render_verbose ⇒ Hash
Returns structured user message with nanosecond timestamp.
18 19 20 21 22 |
# File 'app/decorators/user_message_decorator.rb', line 18 def render_verbose base = {role: :user, content: content, timestamp: } base[:status] = "pending" if pending? base end |