Module: Silas::Inbox

Defined in:
lib/silas/inbox.rb,
lib/silas/inbox/cost.rb,
lib/silas/inbox/delta_broadcaster.rb,
app/helpers/silas/inbox/trace_helper.rb,
app/controllers/silas/inbox/base_controller.rb,
app/controllers/silas/inbox/turns_controller.rb,
app/models/concerns/silas/inbox/broadcastable.rb,
app/controllers/silas/inbox/sessions_controller.rb,
app/controllers/silas/inbox/invocations_controller.rb

Overview

The mountable inbox UI (at /silas/inbox). It renders the existing rows (Session -> Turn -> Step -> ToolInvocation) as a live trace — no events table — and streams changes over Turbo when the host has turbo-rails.

Defined Under Namespace

Modules: Broadcastable, Cost, DeltaBroadcaster, TraceHelper Classes: BaseController, InvocationsController, SessionsController, TurnsController

Class Method Summary collapse

Class Method Details

.mount_pathObject

Where the host mounted the engine ("/silas" by the installer's convention), discovered from the app's route set. Used to build paths that work in EVERY render context — including Turbo's bare broadcast renderer, which has no routing scope for the mounted proxy to lean on.



27
28
29
30
31
32
33
34
# File 'lib/silas/inbox.rb', line 27

def mount_path
  @mount_path ||= begin
    route = Rails.application.routes.routes.find do |r|
      r.app.respond_to?(:app) && r.app.app == Silas::Engine
    end
    route&.path&.spec.to_s.sub(/\(.*\z/, "").presence || "/silas"
  end
end

.reset_mount_path!Object

specs remount



36
# File 'lib/silas/inbox.rb', line 36

def reset_mount_path! = (@mount_path = nil) # specs remount

.stream_name(session_id) ⇒ Object



19
20
21
# File 'lib/silas/inbox.rb', line 19

def stream_name(session_id)
  "silas:inbox:session:#{session_id}"
end

.streaming?Boolean

Broadcasting is on when Turbo is present. A host can hard-disable it.

Returns:

  • (Boolean)


15
16
17
# File 'lib/silas/inbox.rb', line 15

def streaming?
  streaming_available? && Silas.config.inbox_streaming != false
end

.streaming_available?Boolean

turbo-rails is NOT a gem dependency (the core stays lean, like the solid_queue guard). Broadcasting activates only when the host bundles it.

Returns:

  • (Boolean)


10
11
12
# File 'lib/silas/inbox.rb', line 10

def streaming_available?
  defined?(Turbo::StreamsChannel)
end