Class: UserMessageDecorator

Inherits:
MessageDecorator show all
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).

Constant Summary

Constants inherited from MessageDecorator

MessageDecorator::ERROR_ICON, MessageDecorator::MIDDLE_TRUNCATION_MARKER, MessageDecorator::RETURN_ARROW, MessageDecorator::TOOL_ICON

Instance Method Summary collapse

Methods inherited from MessageDecorator

for, #render

Instance Method Details

#render_basicHash

Returns structured user message data ‘:user, content: String`.

Returns:

  • (Hash)

    structured user message data ‘:user, content: String`



8
9
10
# File 'app/decorators/user_message_decorator.rb', line 8

def render_basic
  {role: :user, content: content}
end

#render_brainString

Returns user message for the analytical brain, middle-truncated if very long (preserves intent at start and conclusion at end).

Returns:

  • (String)

    user message for the analytical brain, middle-truncated if very long (preserves intent at start and conclusion at end)



24
25
26
# File 'app/decorators/user_message_decorator.rb', line 24

def render_brain
  "User: #{truncate_middle(content)}"
end

#render_debugHash

Returns verbose output plus token count for debugging.

Returns:

  • (Hash)

    verbose output plus token count for debugging



18
19
20
# File 'app/decorators/user_message_decorator.rb', line 18

def render_debug
  render_verbose.merge(token_info)
end

#render_verboseHash

Returns structured user message with nanosecond timestamp.

Returns:

  • (Hash)

    structured user message with nanosecond timestamp



13
14
15
# File 'app/decorators/user_message_decorator.rb', line 13

def render_verbose
  {role: :user, content: content, timestamp: timestamp}
end