From 5e1b96531163e4e8a2336af67de17feb0ed33034 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 23 Feb 2026 19:26:51 -0500 Subject: [PATCH] feat(simulation): add discussion switching and truncation simulation logic --- gui.py | 10 +++++----- simulation/workflow_sim.py | 24 ++++++++++++++++++++++++ tests/test_workflow_sim.py | 19 +++++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/gui.py b/gui.py index 41792b5..9e3ad9c 100644 --- a/gui.py +++ b/gui.py @@ -1168,9 +1168,9 @@ class App: hint="New discussion name", width=-180, ) - dpg.add_button(label="Create", callback=self.cb_disc_create) - dpg.add_button(label="Rename", callback=self.cb_disc_rename) - dpg.add_button(label="Delete", callback=self.cb_disc_delete) + dpg.add_button(label="Create", tag="btn_disc_create", callback=self.cb_disc_create) + dpg.add_button(label="Rename", tag="btn_disc_rename", callback=self.cb_disc_rename) + dpg.add_button(label="Delete", tag="btn_disc_delete", callback=self.cb_disc_delete) def _make_remove_file_cb(self, idx: int): def cb(): @@ -2068,7 +2068,7 @@ class App: dpg.add_button(label="+All", callback=self.cb_disc_expand_all) 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_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="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_spacer(width=16) 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_text("PRIOR SESSION VIEW", tag="prior_session_indicator", color=(255, 100, 100), show=False) diff --git a/simulation/workflow_sim.py b/simulation/workflow_sim.py index b77a822..f2b3a2d 100644 --- a/simulation/workflow_sim.py +++ b/simulation/workflow_sim.py @@ -16,6 +16,30 @@ class WorkflowSimulator: self.client.click("btn_project_save") 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): if user_message is None: # Generate from AI history diff --git a/tests/test_workflow_sim.py b/tests/test_workflow_sim.py index f3de681..aebfca1 100644 --- a/tests/test_workflow_sim.py +++ b/tests/test_workflow_sim.py @@ -26,3 +26,22 @@ def test_setup_new_project(): client.click.assert_any_call("btn_project_new") client.set_value.assert_any_call("project_git_dir", "/tmp/test_git") 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")