feat(ux): complete multi-panel case orchestration, presets, and main panel cognitive status
This commit is contained in:
@@ -4,6 +4,7 @@ import unittest
|
||||
from unittest.mock import MagicMock, patch
|
||||
import os
|
||||
import sys
|
||||
import curses
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
@@ -138,6 +139,160 @@ class TestBoxTUIHeadless(unittest.TestCase):
|
||||
app._handle_key(ord('\t'))
|
||||
mock_load.assert_called_with("pip", "upcoming")
|
||||
|
||||
def test_transcript_sub_header_render_and_mouse_click(self):
|
||||
app = muse_tui.MuseTUI(self.mock_stdscr, initial_mode="muse")
|
||||
app.data.active_node = "dev"
|
||||
app.focus_pane = "transcript"
|
||||
app._render_transcript(0, 0, 30, 100)
|
||||
self.assertIsNotNone(app._btn_case_actions_bounds)
|
||||
btn_y, b_start, b_end = app._btn_case_actions_bounds
|
||||
|
||||
# Click [w:Case] (offset +2)
|
||||
with patch.object(app, "_open_agent_menu") as mock_menu:
|
||||
handled = app._handle_mouse(b_start + 2, btn_y, curses.BUTTON1_CLICKED)
|
||||
self.assertTrue(handled)
|
||||
self.assertEqual(app.modal, "work_dispatch")
|
||||
app.modal = None
|
||||
|
||||
# Click [f:Refocus] (offset +12)
|
||||
with patch.object(app, "_async_refocus_main") as mock_refocus:
|
||||
handled = app._handle_mouse(b_start + 12, btn_y, curses.BUTTON1_CLICKED)
|
||||
self.assertTrue(handled)
|
||||
mock_refocus.assert_called_with("dev")
|
||||
|
||||
# Click [t:Thoughts] (offset +25)
|
||||
with patch.object(app, "_open_agent_thoughts") as mock_thoughts:
|
||||
handled = app._handle_mouse(b_start + 25, btn_y, curses.BUTTON1_CLICKED)
|
||||
self.assertTrue(handled)
|
||||
mock_thoughts.assert_called_with("dev")
|
||||
|
||||
# Click [p:Menu] (offset +38)
|
||||
with patch.object(app, "_open_agent_menu") as mock_menu:
|
||||
handled = app._handle_mouse(b_start + 38, btn_y, curses.BUTTON1_CLICKED)
|
||||
self.assertTrue(handled)
|
||||
mock_menu.assert_called_with("dev")
|
||||
|
||||
# Click [h:Heal] (offset +46)
|
||||
with patch.object(app, "_async_heal_agent") as mock_heal:
|
||||
handled = app._handle_mouse(b_start + 46, btn_y, curses.BUTTON1_CLICKED)
|
||||
self.assertTrue(handled)
|
||||
mock_heal.assert_called_with("dev")
|
||||
|
||||
def test_agent_context_twelve_actions_and_hotkeys(self):
|
||||
app = muse_tui.MuseTUI(self.mock_stdscr, initial_mode="muse")
|
||||
app.data.active_node = "646"
|
||||
app.context_agent = {"node": "646", "status": {}, "index": 0}
|
||||
app.modal = "agent_context"
|
||||
app._render_modal(40, 120)
|
||||
|
||||
self.assertEqual(len(app._agent_context_actions), 12)
|
||||
|
||||
# Hotkey 2 / w: Dispatch
|
||||
app.modal = "agent_context"
|
||||
app._handle_key(ord('2'))
|
||||
self.assertEqual(app.modal, "work_dispatch")
|
||||
self.assertEqual(app.dispatch_target_node, "646")
|
||||
|
||||
# Hotkey 3 / t: Thoughts
|
||||
app.modal = "agent_context"
|
||||
with patch.object(app, "_open_agent_thoughts") as mock_th:
|
||||
app._handle_key(ord('3'))
|
||||
mock_th.assert_called_with("646")
|
||||
|
||||
# Hotkey 4 / p: Menu
|
||||
app.modal = "agent_context"
|
||||
with patch.object(app, "_open_agent_menu") as mock_menu:
|
||||
app._handle_key(ord('4'))
|
||||
mock_menu.assert_called_with("646")
|
||||
|
||||
# Hotkey 5 / f: Refocus
|
||||
app.modal = "agent_context"
|
||||
with patch.object(app, "_async_refocus_main") as mock_ref:
|
||||
app._handle_key(ord('5'))
|
||||
mock_ref.assert_called_with("646")
|
||||
|
||||
# Hotkey 7 / h: Heal
|
||||
app.modal = "agent_context"
|
||||
with patch.object(app, "_async_heal_agent") as mock_heal:
|
||||
app._handle_key(ord('7'))
|
||||
mock_heal.assert_called_with("646")
|
||||
|
||||
# Hotkey 8 / l: Loopback
|
||||
app.modal = "agent_context"
|
||||
with patch.object(app, "_async_run_loopback") as mock_loop:
|
||||
app._handle_key(ord('8'))
|
||||
mock_loop.assert_called_once()
|
||||
|
||||
def test_work_dispatch_presets_f1_to_f4(self):
|
||||
app = muse_tui.MuseTUI(self.mock_stdscr, initial_mode="muse")
|
||||
app.modal = "work_dispatch"
|
||||
app.modal_input_buf = ""
|
||||
app.modal_input_cursor = 0
|
||||
app.dispatch_target_node = "dev"
|
||||
|
||||
app._handle_key(curses.KEY_F1)
|
||||
self.assertEqual(app.modal_input_buf, "Build: Implement feature specification and tests")
|
||||
|
||||
app._handle_key(curses.KEY_F2)
|
||||
self.assertEqual(app.modal_input_buf, "Bugfix: Investigate and resolve error trace")
|
||||
|
||||
app._handle_key(curses.KEY_F3)
|
||||
self.assertEqual(app.modal_input_buf, "Review: Code review and verify pull request changes")
|
||||
|
||||
app._handle_key(curses.KEY_F4)
|
||||
self.assertEqual(app.modal_input_buf, "Audit: Pre-flight health and security audit")
|
||||
|
||||
# Enter triggers dispatch
|
||||
with patch("threading.Thread") as mock_thread:
|
||||
app._handle_key(10)
|
||||
mock_thread.assert_called()
|
||||
self.assertIsNone(app.modal)
|
||||
|
||||
def test_main_panel_normal_mode_orchestration_hotkeys(self):
|
||||
app = muse_tui.MuseTUI(self.mock_stdscr, initial_mode="muse")
|
||||
app.data.active_node = "opm"
|
||||
app.focus_pane = "transcript"
|
||||
app.editor_mode = "NORMAL"
|
||||
|
||||
# 'w' -> work_dispatch
|
||||
app._handle_key(ord('w'))
|
||||
self.assertEqual(app.modal, "work_dispatch")
|
||||
self.assertEqual(app.dispatch_target_node, "opm")
|
||||
app.modal = None
|
||||
|
||||
# 'f' -> refocus
|
||||
with patch.object(app, "_async_refocus_main") as mock_ref:
|
||||
app._handle_key(ord('f'))
|
||||
mock_ref.assert_called_with("opm")
|
||||
|
||||
# 't' -> thoughts
|
||||
with patch.object(app, "_open_agent_thoughts") as mock_th:
|
||||
app._handle_key(ord('t'))
|
||||
mock_th.assert_called_with("opm")
|
||||
|
||||
# 'p' -> menu
|
||||
with patch.object(app, "_open_agent_menu") as mock_menu:
|
||||
app._handle_key(ord('p'))
|
||||
mock_menu.assert_called_with("opm")
|
||||
|
||||
# 'h' / 'H' -> heal
|
||||
with patch.object(app, "_async_heal_agent") as mock_heal:
|
||||
app._handle_key(ord('h'))
|
||||
mock_heal.assert_called_with("opm")
|
||||
|
||||
def test_work_pipeline_assign_and_merge_hotkeys(self):
|
||||
app = muse_tui.MuseTUI(self.mock_stdscr, initial_mode="box", initial_tab="work")
|
||||
app.box_tab = 7
|
||||
app.work_sel_idx = 1 # 646 in all_workers
|
||||
|
||||
with patch.object(app, "_async_merge_pr") as mock_merge:
|
||||
app._handle_key(ord('m'))
|
||||
mock_merge.assert_called_once()
|
||||
|
||||
with patch.object(app, "_async_assign_ticket") as mock_assign:
|
||||
app._handle_key(ord('a'))
|
||||
mock_assign.assert_called_with("646")
|
||||
|
||||
def test_muse_tui_all_tabs_fuzz_dimensions_and_corrupt_data(self):
|
||||
dimensions = [(8, 20), (12, 40), (24, 80), (50, 160)]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user