Class: UserMessageDecorator

Inherits:
EventDecorator show all
Defined in:
app/decorators/user_message_decorator.rb

Overview

Decorates user_message events 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 EventDecorator

EventDecorator::ERROR_ICON, EventDecorator::MIDDLE_TRUNCATION_MARKER, EventDecorator::RETURN_ARROW, EventDecorator::TOOL_ICON

Instance Method Summary collapse

Methods inherited from EventDecorator

for, #render

Instance Method Details

#render_basicHash

Returns structured user message data ‘:user, content: String` or with `status: “pending”` when queued.

Returns:

  • (Hash)

    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_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)



31
32
33
# File 'app/decorators/user_message_decorator.rb', line 31

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



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

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



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

def render_verbose
  base = {role: :user, content: content, timestamp: timestamp}
  base[:status] = "pending" if pending?
  base
end