Class: Aidp::Harness::UI::Navigation::MenuState

Inherits:
Object
  • Object
show all
Defined in:
lib/aidp/harness/ui/navigation/menu_state.rb

Overview

Manages navigation state and history

Defined Under Namespace

Classes: InvalidStateError, StateError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMenuState

Returns a new instance of MenuState.



13
14
15
16
17
18
19
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 13

def initialize
  @navigation_history = []
  @current_menu = nil
  @menu_stack = []
  @breadcrumbs = []
  @last_selection = nil
end

Instance Attribute Details

#current_menuObject (readonly)

Returns the value of attribute current_menu.



88
89
90
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 88

def current_menu
  @current_menu
end

#last_selectionObject (readonly)

Returns the value of attribute last_selection.



90
91
92
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 90

def last_selection
  @last_selection
end

Instance Method Details

#can_go_back?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 96

def can_go_back?
  @menu_stack.size > 1
end

#clear_breadcrumbsObject



104
105
106
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 104

def clear_breadcrumbs
  @breadcrumbs.clear
end

#clear_historyObject



100
101
102
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 100

def clear_history
  @navigation_history.clear
end

#clear_menu_stackObject



108
109
110
111
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 108

def clear_menu_stack
  @menu_stack.clear
  @current_menu = nil
end

#export_stateObject



120
121
122
123
124
125
126
127
128
129
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 120

def export_state
  {
    current_menu: @current_menu,
    menu_stack: @menu_stack,
    breadcrumbs: @breadcrumbs,
    last_selection: @last_selection,
    navigation_history: @navigation_history,
    menu_depth: menu_depth
  }
end

#get_breadcrumbsObject



80
81
82
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 80

def get_breadcrumbs
  @breadcrumbs.dup
end

#get_menu_stackObject



84
85
86
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 84

def get_menu_stack
  @menu_stack.dup
end

#get_navigation_historyObject



76
77
78
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 76

def get_navigation_history
  @navigation_history.dup
end


92
93
94
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 92

def menu_depth
  @menu_stack.size
end

#pop_menuObject



29
30
31
32
33
34
35
36
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 29

def pop_menu
  return nil if @menu_stack.empty?

  @menu_stack.pop
  @breadcrumbs.pop
  @current_menu = @menu_stack.last
  @current_menu
end

#push_menu(menu_title) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 21

def push_menu(menu_title)
  validate_menu_title(menu_title)

  @menu_stack << menu_title
  @breadcrumbs << menu_title
  @current_menu = menu_title
end

#record_keyboard_navigation(key, action) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 60

def record_keyboard_navigation(key, action)
  @navigation_history << {
    menu: @current_menu,
    selection: "keyboard: #{key} -> #{action}",
    timestamp: Time.now
  }
end

#record_progressive_disclosure(level, action) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 68

def record_progressive_disclosure(level, action)
  @navigation_history << {
    menu: @current_menu,
    selection: "progressive: level #{level} -> #{action}",
    timestamp: Time.now
  }
end

#record_selection(selection) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 43

def record_selection(selection)
  @last_selection = selection
  @navigation_history << {
    menu: @current_menu,
    selection: selection,
    timestamp: Time.now
  }
end

#record_workflow_mode_selection(mode) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 52

def record_workflow_mode_selection(mode)
  @navigation_history << {
    menu: @current_menu,
    selection: "workflow_mode: #{mode}",
    timestamp: Time.now
  }
end

#resetObject



113
114
115
116
117
118
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 113

def reset
  clear_history
  clear_breadcrumbs
  clear_menu_stack
  @last_selection = nil
end

#set_current_menu(menu_title) ⇒ Object



38
39
40
41
# File 'lib/aidp/harness/ui/navigation/menu_state.rb', line 38

def set_current_menu(menu_title)
  validate_menu_title(menu_title)
  @current_menu = menu_title
end