Module: RubyCoded::Chat::State::PlanTracking

Included in:
RubyCoded::Chat::State
Defined in:
lib/ruby_coded/chat/state/plan_tracking.rb

Overview

Manages plan mode state and the clarification UI flow. Plan mode tracks the current plan in memory and exposes a clarification overlay (similar to ModelSelection) when the LLM needs user input before generating the plan.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clarification_custom_inputObject (readonly)

Returns the value of attribute clarification_custom_input.



11
12
13
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 11

def clarification_custom_input
  @clarification_custom_input
end

#clarification_indexObject (readonly)

Returns the value of attribute clarification_index.



11
12
13
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 11

def clarification_index
  @clarification_index
end

#clarification_input_modeObject (readonly)

Returns the value of attribute clarification_input_mode.



11
12
13
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 11

def clarification_input_mode
  @clarification_input_mode
end

#clarification_optionsObject (readonly)

Returns the value of attribute clarification_options.



11
12
13
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 11

def clarification_options
  @clarification_options
end

#clarification_questionObject (readonly)

Returns the value of attribute clarification_question.



11
12
13
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 11

def clarification_question
  @clarification_question
end

Instance Method Details

#activate_plan_mode!Object



28
29
30
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 28

def activate_plan_mode!
  @plan_mode_active = true
end

#append_to_clarification_input(text) ⇒ Object



118
119
120
121
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 118

def append_to_clarification_input(text)
  @clarification_custom_input << text
  mark_dirty!
end

#clarification_downObject



102
103
104
105
106
107
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 102

def clarification_down
  return if @clarification_options.empty?

  @clarification_index = (@clarification_index + 1) % @clarification_options.size
  mark_dirty!
end

#clarification_upObject



95
96
97
98
99
100
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 95

def clarification_up
  return if @clarification_options.empty?

  @clarification_index = (@clarification_index - 1) % @clarification_options.size
  mark_dirty!
end

#clear_plan!Object



62
63
64
65
66
67
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 62

def clear_plan!
  @mutex.synchronize do
    @current_plan = nil
    @plan_saved = true
  end
end

#current_planObject



46
47
48
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 46

def current_plan
  @mutex.synchronize { @current_plan }
end

#deactivate_plan_mode!Object



32
33
34
35
36
37
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 32

def deactivate_plan_mode!
  @plan_mode_active = false
  @current_plan = nil
  @plan_saved = true
  reset_clarification_state
end

#delete_last_clarification_charObject



123
124
125
126
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 123

def delete_last_clarification_char
  @clarification_custom_input.chop!
  mark_dirty!
end

#enter_plan_clarification!(question, options) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 75

def enter_plan_clarification!(question, options)
  @mutex.synchronize do
    @clarification_question = question
    @clarification_options = options
    @clarification_index = 0
    @clarification_custom_input = String.new
    @clarification_input_mode = :options
    @mode = :plan_clarification
    @dirty = true
  end
end

#exit_plan_clarification!Object



87
88
89
90
91
92
93
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 87

def exit_plan_clarification!
  @mutex.synchronize do
    @mode = :chat
    reset_clarification_state
    @dirty = true
  end
end

#has_unsaved_plan?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 58

def has_unsaved_plan?
  @mutex.synchronize { @current_plan && !@plan_saved }
end

#init_plan_trackingObject



15
16
17
18
19
20
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 15

def init_plan_tracking
  @plan_mode_active = false
  @current_plan = nil
  @plan_saved = true
  reset_clarification_state
end

#mark_plan_saved!Object



54
55
56
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 54

def mark_plan_saved!
  @mutex.synchronize { @plan_saved = true }
end

#plan_clarification?Boolean

— Clarification UI (pattern: ModelSelection) —

Returns:

  • (Boolean)


71
72
73
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 71

def plan_clarification?
  @mode == :plan_clarification
end

#plan_mode_active?Boolean

— Plan mode —

Returns:

  • (Boolean)


24
25
26
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 24

def plan_mode_active?
  @plan_mode_active
end

#plan_saved?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 50

def plan_saved?
  @mutex.synchronize { @plan_saved }
end

#selected_clarification_optionObject



109
110
111
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 109

def selected_clarification_option
  @clarification_options[@clarification_index]
end

#toggle_clarification_input_mode!Object



113
114
115
116
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 113

def toggle_clarification_input_mode!
  @clarification_input_mode = @clarification_input_mode == :options ? :custom : :options
  mark_dirty!
end

#update_current_plan!(content) ⇒ Object



39
40
41
42
43
44
# File 'lib/ruby_coded/chat/state/plan_tracking.rb', line 39

def update_current_plan!(content)
  @mutex.synchronize do
    @current_plan = content
    @plan_saved = false
  end
end