diff --git a/src/gui_2.py b/src/gui_2.py index 1c3c754..7a7394d 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -2318,6 +2318,11 @@ def hello(): if name != self.active_discussion: self._switch_discussion(name) imgui.end_tab_item() + + if imgui.begin_tab_item("Synthesis")[0]: + self._render_synthesis_panel() + imgui.end_tab_item() + imgui.end_tab_bar() if "_take_" in self.active_discussion: @@ -2558,7 +2563,40 @@ def hello(): if self._scroll_disc_to_bottom: imgui.set_scroll_here_y(1.0) self._scroll_disc_to_bottom = False - imgui.end_child() + imgui.end_child() + + def _render_synthesis_panel(self) -> None: + """Renders a panel for synthesizing multiple discussion takes.""" + imgui.text("Select takes to synthesize:") + discussions = self.project.get('discussion', {}).get('discussions', {}) + if not hasattr(self, 'ui_synthesis_selected_takes'): + self.ui_synthesis_selected_takes = {name: False for name in discussions} + if not hasattr(self, 'ui_synthesis_prompt'): + self.ui_synthesis_prompt = "" + for name in discussions: + _, self.ui_synthesis_selected_takes[name] = imgui.checkbox(name, self.ui_synthesis_selected_takes.get(name, False)) + imgui.spacing() + imgui.text("Synthesis Prompt:") + _, self.ui_synthesis_prompt = imgui.input_text_multiline("##synthesis_prompt", self.ui_synthesis_prompt, imgui.ImVec2(-1, 100)) + if imgui.button("Generate Synthesis"): + selected = [name for name, sel in self.ui_synthesis_selected_takes.items() if sel] + if len(selected) > 1: + from src import synthesis_formatter + discussions_dict = self.project.get('discussion', {}).get('discussions', {}) + takes_dict = {name: discussions_dict.get(name, {}).get('history', []) for name in selected} + diff_text = synthesis_formatter.format_takes_diff(takes_dict) + prompt = f"{self.ui_synthesis_prompt}\n\nHere are the variations:\n{diff_text}" + + new_name = "synthesis_take" + counter = 1 + while new_name in discussions_dict: + new_name = f"synthesis_take_{counter}" + counter += 1 + + self._create_discussion(new_name) + with self._disc_entries_lock: + self.disc_entries.append({"role": "User", "content": prompt, "collapsed": False, "ts": project_manager.now_ts()}) + self._handle_generate_send() def _render_persona_selector_panel(self) -> None: if self.perf_profiling_enabled: self.perf_monitor.start_component("_render_persona_selector_panel")