Class: Rubino::UI::QueuedIndicators
- Inherits:
-
Object
- Object
- Rubino::UI::QueuedIndicators
- Defined in:
- lib/rubino/ui/queued_indicators.rb
Overview
The BottomComposer's stack of EXPLICITLY-queued messages (Alt+Enter /
"/queued
Constant Summary collapse
- MAX_ROWS =
Hard cap on the visible rows so a burst of explicit queues can never push the prompt off-screen. Beyond the cap, a dim count row stands in for the overflow.
4
Instance Method Summary collapse
- #any? ⇒ Boolean
-
#initialize(list) ⇒ QueuedIndicators
constructor
A new instance of QueuedIndicators.
-
#push(msg, front: false) ⇒ Object
Add
msgto the pending stack. -
#remove(msg) ⇒ Object
Remove the FIRST pending indicator matching
msg(the chat loop calls through when the queued item's turn starts). -
#rows ⇒ Object
The "⏳ queued:
" indicator rows for the pending stack, in submission order.
Constructor Details
#initialize(list) ⇒ QueuedIndicators
Returns a new instance of QueuedIndicators.
21 22 23 |
# File 'lib/rubino/ui/queued_indicators.rb', line 21 def initialize(list) @list = list end |
Instance Method Details
#any? ⇒ Boolean
25 26 27 |
# File 'lib/rubino/ui/queued_indicators.rb', line 25 def any? @list.any? end |
#push(msg, front: false) ⇒ Object
Add msg to the pending stack. front jumps the queue (the
interrupt-by-default Enter): its indicator leads the pending rows so
the visible order matches the run order (#129).
32 33 34 |
# File 'lib/rubino/ui/queued_indicators.rb', line 32 def push(msg, front: false) front ? @list.unshift(msg) : @list.push(msg) end |
#remove(msg) ⇒ Object
Remove the FIRST pending indicator matching msg (the chat loop calls
through when the queued item's turn starts). Returns the removed
message, or nil when none matched.
39 40 41 42 43 44 |
# File 'lib/rubino/ui/queued_indicators.rb', line 39 def remove(msg) idx = @list.index(msg) return unless idx @list.delete_at(idx) end |
#rows ⇒ Object
The "⏳ queued:
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rubino/ui/queued_indicators.rb', line 49 def rows return [] if @list.empty? shown = @list.first(MAX_ROWS) # The queued message is USER-SUPPLIED, so neutralize terminal escapes # before it is rendered as a live indicator row (CWE-150 — H1): the same # render-boundary defense the submit echo and approval card use. The raw # message is what runs as the next turn's prompt; only this row is # sanitized. rows = shown.map { |msg| pastel.dim("⏳ queued: #{Util::Output.sanitize_terminal(msg.to_s)}") } overflow = @list.size - shown.size rows << pastel.dim("┄ +#{overflow} more queued ┄") if overflow.positive? rows end |