Class: Events::SessionStateChanged

Inherits:
Object
  • Object
show all
Defined in:
lib/events/session_state_changed.rb

Overview

Emitted when a session’s transport-level state changes. Carries the AASM state after a transition (+“idle”/“awaiting”/“executing”+) or a transient UI signal (+“interrupting”+).

Subscribers broadcast the state over ActionCable so the TUI spinner and sub-agent HUD update in sync.

Constant Summary collapse

TYPE =
"session.state_changed"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session_id:, state:) ⇒ SessionStateChanged

Returns a new instance of SessionStateChanged.

Parameters:

  • session_id (Integer)

    the session the state change belongs to

  • state (String)

    transport state name



17
18
19
20
# File 'lib/events/session_state_changed.rb', line 17

def initialize(session_id:, state:)
  @session_id = session_id
  @state = state
end

Instance Attribute Details

#session_idObject (readonly)

Returns the value of attribute session_id.



13
14
15
# File 'lib/events/session_state_changed.rb', line 13

def session_id
  @session_id
end

#stateObject (readonly)

Returns the value of attribute state.



13
14
15
# File 'lib/events/session_state_changed.rb', line 13

def state
  @state
end

Instance Method Details

#event_nameObject



22
23
24
# File 'lib/events/session_state_changed.rb', line 22

def event_name
  "#{Bus::NAMESPACE}.#{TYPE}"
end

#to_hObject



26
27
28
# File 'lib/events/session_state_changed.rb', line 26

def to_h
  {type: TYPE, session_id: session_id, state: state}
end