feat(simulation): add discussion switching and truncation simulation logic
This commit is contained in:
10
gui.py
10
gui.py
@@ -1168,9 +1168,9 @@ class App:
|
|||||||
hint="New discussion name",
|
hint="New discussion name",
|
||||||
width=-180,
|
width=-180,
|
||||||
)
|
)
|
||||||
dpg.add_button(label="Create", callback=self.cb_disc_create)
|
dpg.add_button(label="Create", tag="btn_disc_create", callback=self.cb_disc_create)
|
||||||
dpg.add_button(label="Rename", callback=self.cb_disc_rename)
|
dpg.add_button(label="Rename", tag="btn_disc_rename", callback=self.cb_disc_rename)
|
||||||
dpg.add_button(label="Delete", callback=self.cb_disc_delete)
|
dpg.add_button(label="Delete", tag="btn_disc_delete", callback=self.cb_disc_delete)
|
||||||
|
|
||||||
def _make_remove_file_cb(self, idx: int):
|
def _make_remove_file_cb(self, idx: int):
|
||||||
def cb():
|
def cb():
|
||||||
@@ -2068,7 +2068,7 @@ class App:
|
|||||||
dpg.add_button(label="+All", callback=self.cb_disc_expand_all)
|
dpg.add_button(label="+All", callback=self.cb_disc_expand_all)
|
||||||
dpg.add_text("Keep Pairs:", color=(160, 160, 160))
|
dpg.add_text("Keep Pairs:", color=(160, 160, 160))
|
||||||
dpg.add_input_int(tag="disc_truncate_pairs", default_value=2, width=80, min_value=1)
|
dpg.add_input_int(tag="disc_truncate_pairs", default_value=2, width=80, min_value=1)
|
||||||
dpg.add_button(label="Truncate", callback=self.cb_disc_truncate)
|
dpg.add_button(label="Truncate", tag="btn_disc_truncate", callback=self.cb_disc_truncate)
|
||||||
dpg.add_button(label="Clear All", callback=self.cb_disc_clear)
|
dpg.add_button(label="Clear All", callback=self.cb_disc_clear)
|
||||||
dpg.add_button(label="Save", callback=self.cb_disc_save)
|
dpg.add_button(label="Save", callback=self.cb_disc_save)
|
||||||
|
|
||||||
@@ -2139,7 +2139,7 @@ class App:
|
|||||||
dpg.add_text("Status: idle", tag="ai_status", color=(200, 220, 160))
|
dpg.add_text("Status: idle", tag="ai_status", color=(200, 220, 160))
|
||||||
dpg.add_spacer(width=16)
|
dpg.add_spacer(width=16)
|
||||||
dpg.add_button(label="Clear", callback=self.cb_clear_comms)
|
dpg.add_button(label="Clear", callback=self.cb_clear_comms)
|
||||||
dpg.add_button(label="Load Log", callback=self.cb_load_prior_log)
|
dpg.add_button(label="Load Log", tag="btn_load_log", callback=self.cb_load_prior_log)
|
||||||
dpg.add_button(label="Exit Prior", tag="exit_prior_btn", callback=self.cb_exit_prior_session, show=False)
|
dpg.add_button(label="Exit Prior", tag="exit_prior_btn", callback=self.cb_exit_prior_session, show=False)
|
||||||
|
|
||||||
dpg.add_text("PRIOR SESSION VIEW", tag="prior_session_indicator", color=(255, 100, 100), show=False)
|
dpg.add_text("PRIOR SESSION VIEW", tag="prior_session_indicator", color=(255, 100, 100), show=False)
|
||||||
|
|||||||
@@ -16,6 +16,30 @@ class WorkflowSimulator:
|
|||||||
self.client.click("btn_project_save")
|
self.client.click("btn_project_save")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
def create_discussion(self, name):
|
||||||
|
print(f"Creating discussion: {name}")
|
||||||
|
self.client.set_value("disc_new_name_input", name)
|
||||||
|
self.client.click("btn_disc_create")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
def switch_discussion(self, name):
|
||||||
|
print(f"Switching to discussion: {name}")
|
||||||
|
self.client.select_list_item("disc_listbox", name)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
def load_prior_log(self):
|
||||||
|
print("Loading prior log")
|
||||||
|
self.client.click("btn_load_log")
|
||||||
|
# This usually opens a file dialog which we can't easily automate from here
|
||||||
|
# without more hooks, but we can verify the button click.
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
def truncate_history(self, pairs):
|
||||||
|
print(f"Truncating history to {pairs} pairs")
|
||||||
|
self.client.set_value("disc_truncate_pairs", pairs)
|
||||||
|
self.client.click("btn_disc_truncate")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
def run_discussion_turn(self, user_message=None):
|
def run_discussion_turn(self, user_message=None):
|
||||||
if user_message is None:
|
if user_message is None:
|
||||||
# Generate from AI history
|
# Generate from AI history
|
||||||
|
|||||||
@@ -26,3 +26,22 @@ def test_setup_new_project():
|
|||||||
client.click.assert_any_call("btn_project_new")
|
client.click.assert_any_call("btn_project_new")
|
||||||
client.set_value.assert_any_call("project_git_dir", "/tmp/test_git")
|
client.set_value.assert_any_call("project_git_dir", "/tmp/test_git")
|
||||||
client.click.assert_any_call("btn_project_save")
|
client.click.assert_any_call("btn_project_save")
|
||||||
|
|
||||||
|
def test_discussion_switching():
|
||||||
|
client = MagicMock()
|
||||||
|
sim = WorkflowSimulator(client)
|
||||||
|
|
||||||
|
sim.create_discussion("NewDisc")
|
||||||
|
client.set_value.assert_called_with("disc_new_name_input", "NewDisc")
|
||||||
|
client.click.assert_called_with("btn_disc_create")
|
||||||
|
|
||||||
|
sim.switch_discussion("NewDisc")
|
||||||
|
client.select_list_item.assert_called_with("disc_listbox", "NewDisc")
|
||||||
|
|
||||||
|
def test_history_truncation():
|
||||||
|
client = MagicMock()
|
||||||
|
sim = WorkflowSimulator(client)
|
||||||
|
|
||||||
|
sim.truncate_history(3)
|
||||||
|
client.set_value.assert_called_with("disc_truncate_pairs", 3)
|
||||||
|
client.click.assert_called_with("btn_disc_truncate")
|
||||||
|
|||||||
Reference in New Issue
Block a user