class Riffer::Rig::Terminal::Ticker
Constants
- CHARS_PER_TOKEN
- SPINNER
- TICK_SECONDS
Public Class Methods
(footer: Riffer::Rig::Terminal::Frame, theme: Riffer::Rig::Terminal::Theme, buffer: Riffer::Rig::Terminal::TurnBuffer, rates: ::Riffer::Catalog::Rates?) → void
Source
# File lib/riffer/rig/terminal/ticker.rb, line 25 def initialize(footer:, theme:, buffer:, rates:) @footer = footer @theme = theme @buffer = buffer @rates = rates @mutex = Mutex.new @halt = Queue.new @tick = 0 @unmetered = 0 end
@rbs footer: Riffer::Rig::Terminal::Frame @rbs theme: Riffer::Rig::Terminal::Theme @rbs buffer: Riffer::Rig::Terminal::TurnBuffer @rbs rates: ::Riffer::Catalog::Rates? @rbs return: void
Public Instance Methods
(::Riffer::StreamEvents::Base | Riffer::Rig::Events::_Event event) → void
Source
# File lib/riffer/rig/terminal/ticker.rb, line 44 def absorb(event) # The ticker thread reads the buffer, so the buffer takes each event under # the lock a frame is drawn under: no frame shows half of one. @mutex.synchronize do @buffer.absorb(event) case event when Riffer::StreamEvents::ReasoningDelta, Riffer::StreamEvents::TextDelta @unmetered += event.content.length when Riffer::StreamEvents::ToolCallDelta @unmetered += event.arguments_delta.length when Riffer::StreamEvents::TokenUsageDone @unmetered = 0 end end end
@rbs event: ::Riffer::StreamEvents::Base | Riffer::Rig::Events::_Event @rbs return: void
() → void
Source
# File lib/riffer/rig/terminal/ticker.rb, line 37 def start tick @thread = Thread.new { tick until @halt.pop(timeout: TICK_SECONDS) } end
@rbs return: void
() → void
Source
# File lib/riffer/rig/terminal/ticker.rb, line 72 def stop @halt << true @thread&.join @footer.status('') end
@rbs return: void
() → void
Source
# File lib/riffer/rig/terminal/ticker.rb, line 61 def tick room = @footer.status_room jobs = @footer.job_count reasoning = @footer.reasoning status = @mutex.synchronize do line(room, jobs, reasoning).tap { @tick += 1 } end @footer.status(status) end
@rbs return: void