did ai's job
This commit is contained in:
+152
-162
@@ -2747,185 +2747,175 @@ class App:
|
||||
imgui.text_disabled("Message & Response panels are detached.")
|
||||
|
||||
def _render_context_composition_panel(self) -> None:
|
||||
imgui.text("Context Composition")
|
||||
imgui.separator()
|
||||
|
||||
def _batch_helper(name: str, attr: str):
|
||||
if imgui.collapsing_header("Context Composition"):
|
||||
#region: Batch Action Bar
|
||||
imgui.text("Batch:")
|
||||
imgui.same_line()
|
||||
if imgui.button(name + "##batch"):
|
||||
if imgui.button("Full##batch"):
|
||||
for f in self.files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
if f_path in self.ui_selected_context_files:
|
||||
f.force_full = True
|
||||
f.auto_aggregate = False
|
||||
if hasattr(f, attr):
|
||||
if hasattr(f, "ast_signatures"):
|
||||
f.ast_signatures = False
|
||||
f.ast_definitions = False
|
||||
|
||||
# Batch Action Bar
|
||||
imgui.text("Batch:")
|
||||
imgui.same_line()
|
||||
if imgui.button("Full##batch"):
|
||||
for f in self.files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
if f_path in self.ui_selected_context_files:
|
||||
f.force_full = True
|
||||
f.auto_aggregate = False
|
||||
if hasattr(f, "ast_signatures"):
|
||||
f.ast_signatures = False
|
||||
f.ast_definitions = False
|
||||
imgui.same_line()
|
||||
if imgui.button("Agg##batch"):
|
||||
for f in self.files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
if f_path in self.ui_selected_context_files:
|
||||
f.auto_aggregate = True
|
||||
f.force_full = False
|
||||
if hasattr(f, "ast_signatures"):
|
||||
f.ast_signatures = False
|
||||
f.ast_definitions = False
|
||||
imgui.same_line()
|
||||
if imgui.button("Sig##batch"):
|
||||
for f in self.files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
if f_path in self.ui_selected_context_files:
|
||||
if hasattr(f, "ast_signatures"):
|
||||
f.ast_signatures = True
|
||||
imgui.same_line()
|
||||
if imgui.button("Agg##batch"):
|
||||
for f in self.files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
if f_path in self.ui_selected_context_files:
|
||||
f.auto_aggregate = True
|
||||
f.force_full = False
|
||||
if hasattr(f, "ast_signatures"):
|
||||
f.ast_signatures = False
|
||||
f.ast_definitions = False
|
||||
imgui.same_line()
|
||||
if imgui.button("Sig##batch"):
|
||||
for f in self.files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
if f_path in self.ui_selected_context_files:
|
||||
if hasattr(f, "ast_signatures"):
|
||||
f.ast_signatures = True
|
||||
f.force_full = False
|
||||
f.auto_aggregate = False
|
||||
f.ast_definitions = False
|
||||
imgui.same_line()
|
||||
if imgui.button("Def##batch"):
|
||||
for f in self.files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
if f_path in self.ui_selected_context_files:
|
||||
if hasattr(f, "ast_definitions"):
|
||||
f.ast_definitions = True
|
||||
f.force_full = False
|
||||
f.auto_aggregate = False
|
||||
f.ast_signatures = False
|
||||
imgui.same_line()
|
||||
if imgui.button("None##batch"):
|
||||
for f in self.files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
if f_path in self.ui_selected_context_files:
|
||||
f.auto_aggregate = False
|
||||
f.ast_definitions = False
|
||||
imgui.same_line()
|
||||
if imgui.button("Def##batch"):
|
||||
for f in self.files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
if f_path in self.ui_selected_context_files:
|
||||
if hasattr(f, "ast_definitions"):
|
||||
f.ast_definitions = True
|
||||
f.force_full = False
|
||||
f.auto_aggregate = False
|
||||
f.ast_signatures = False
|
||||
imgui.same_line()
|
||||
if imgui.button("None##batch"):
|
||||
for f in self.files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
if f_path in self.ui_selected_context_files:
|
||||
f.auto_aggregate = False
|
||||
f.force_full = False
|
||||
if hasattr(f, "ast_signatures"):
|
||||
f.ast_signatures = False
|
||||
f.ast_definitions = False
|
||||
imgui.same_line()
|
||||
if imgui.button("Sel All##selall"):
|
||||
for f in self.files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
self.ui_selected_context_files.add(f_path)
|
||||
imgui.same_line()
|
||||
if imgui.button("Unsel All##unselall"):
|
||||
self.ui_selected_context_files.clear()
|
||||
imgui.same_line()
|
||||
if imgui.button("Del##batch"):
|
||||
new_files = []
|
||||
for f in self.files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
if f_path not in self.ui_selected_context_files:
|
||||
new_files.append(f)
|
||||
self.files = new_files
|
||||
self.ui_selected_context_files.clear()
|
||||
|
||||
imgui.dummy(imgui.ImVec2(0, 4))
|
||||
if hasattr(f, "ast_signatures"):
|
||||
f.ast_signatures = False
|
||||
f.ast_definitions = False
|
||||
imgui.same_line()
|
||||
if imgui.button("Sel All##selall"):
|
||||
for f in self.files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
self.ui_selected_context_files.add(f_path)
|
||||
imgui.same_line()
|
||||
if imgui.button("Unsel All##unselall"):
|
||||
self.ui_selected_context_files.clear()
|
||||
imgui.same_line()
|
||||
if imgui.button("Del##batch"):
|
||||
new_files = []
|
||||
for f in self.files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
if f_path not in self.ui_selected_context_files:
|
||||
new_files.append(f)
|
||||
self.files = new_files
|
||||
self.ui_selected_context_files.clear()
|
||||
#endregion: Batch Action Bar
|
||||
|
||||
imgui.dummy(imgui.ImVec2(0, 4))
|
||||
|
||||
if imgui.begin_table("ctx_comp_table", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders):
|
||||
imgui.table_setup_column("File", imgui.TableColumnFlags_.width_stretch)
|
||||
imgui.table_setup_column("Flags", imgui.TableColumnFlags_.width_fixed, 200)
|
||||
imgui.table_headers_row()
|
||||
for i, f_item in enumerate(self.files):
|
||||
imgui.table_next_row()
|
||||
imgui.table_set_column_index(0)
|
||||
|
||||
# Checkbox for selection
|
||||
f_path = f_item.path if hasattr(f_item, "path") else str(f_item)
|
||||
is_sel = f_path in self.ui_selected_context_files
|
||||
changed_sel, is_sel = imgui.checkbox(f"##sel{i}", is_sel)
|
||||
if changed_sel:
|
||||
if imgui.get_io().key_shift and self._last_selected_context_index != -1:
|
||||
start = min(self._last_selected_context_index, i)
|
||||
end = max(self._last_selected_context_index, i)
|
||||
for idx in range(start, end + 1):
|
||||
item = self.files[idx]
|
||||
item_path = item.path if hasattr(item, "path") else str(item)
|
||||
if is_sel:
|
||||
self.ui_selected_context_files.add(item_path)
|
||||
else:
|
||||
self.ui_selected_context_files.discard(item_path)
|
||||
else:
|
||||
if is_sel:
|
||||
self.ui_selected_context_files.add(f_path)
|
||||
else:
|
||||
self.ui_selected_context_files.discard(f_path)
|
||||
self._last_selected_context_index = i
|
||||
imgui.same_line()
|
||||
imgui.text(f_path)
|
||||
|
||||
if f_path.lower().endswith(('.c', '.cpp', '.h', '.hpp', '.cxx', '.cc')):
|
||||
imgui.same_line()
|
||||
if imgui.button(f"[Inspect]##{i}"):
|
||||
self.ui_inspecting_ast_file = f_item
|
||||
imgui.open_popup('AST Inspector')
|
||||
|
||||
imgui.same_line()
|
||||
if imgui.button(f"[Slices]##{i}"):
|
||||
self.ui_editing_slices_file = f_item
|
||||
if imgui.begin_table("ctx_comp_table", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders):
|
||||
imgui.table_setup_column("File", imgui.TableColumnFlags_.width_stretch)
|
||||
imgui.table_setup_column("Flags", imgui.TableColumnFlags_.width_fixed, 200)
|
||||
imgui.table_headers_row()
|
||||
for i, f_item in enumerate(self.files):
|
||||
imgui.table_next_row()
|
||||
imgui.table_set_column_index(0)
|
||||
|
||||
# Checkbox for selection
|
||||
f_path = f_item.path if hasattr(f_item, "path") else str(f_item)
|
||||
self.text_viewer_title = f"Slices: {f_path}"
|
||||
self.text_viewer_content = f_item.content or ""
|
||||
self.text_viewer_type = 'cpp' if f_path.endswith(('.cpp', '.hpp', '.h')) else 'python' if f_path.endswith('.py') else 'text'
|
||||
self.show_text_viewer = True
|
||||
|
||||
imgui.table_set_column_index(1)
|
||||
if hasattr(f_item, "auto_aggregate"):
|
||||
changed_agg, f_item.auto_aggregate = imgui.checkbox(f"Agg##cc{i}", f_item.auto_aggregate)
|
||||
is_sel = f_path in self.ui_selected_context_files
|
||||
changed_sel, is_sel = imgui.checkbox(f"##sel{i}", is_sel)
|
||||
if changed_sel:
|
||||
if imgui.get_io().key_shift and self._last_selected_context_index != -1:
|
||||
start = min(self._last_selected_context_index, i)
|
||||
end = max(self._last_selected_context_index, i)
|
||||
for idx in range(start, end + 1):
|
||||
item = self.files[idx]
|
||||
item_path = item.path if hasattr(item, "path") else str(item)
|
||||
if is_sel:
|
||||
self.ui_selected_context_files.add(item_path)
|
||||
else:
|
||||
self.ui_selected_context_files.discard(item_path)
|
||||
else:
|
||||
if is_sel:
|
||||
self.ui_selected_context_files.add(f_path)
|
||||
else:
|
||||
self.ui_selected_context_files.discard(f_path)
|
||||
self._last_selected_context_index = i
|
||||
imgui.same_line()
|
||||
changed_full, f_item.force_full = imgui.checkbox(f"Full##cc{i}", f_item.force_full)
|
||||
if hasattr(f_item, "ast_signatures"):
|
||||
imgui.text(f_path)
|
||||
|
||||
if f_path.lower().endswith(('.c', '.cpp', '.h', '.hpp', '.cxx', '.cc')):
|
||||
imgui.same_line()
|
||||
_, f_item.ast_signatures = imgui.checkbox(f"Sig##cc{i}", f_item.ast_signatures)
|
||||
if imgui.button(f"[Inspect]##{i}"):
|
||||
self.ui_inspecting_ast_file = f_item
|
||||
imgui.open_popup('AST Inspector')
|
||||
|
||||
imgui.same_line()
|
||||
if imgui.button(f"[Slices]##{i}"):
|
||||
self.ui_editing_slices_file = f_item
|
||||
f_path = f_item.path if hasattr(f_item, "path") else str(f_item)
|
||||
self.text_viewer_title = f"Slices: {f_path}"
|
||||
self.text_viewer_content = f_item.content or ""
|
||||
self.text_viewer_type = 'cpp' if f_path.endswith(('.cpp', '.hpp', '.h')) else 'python' if f_path.endswith('.py') else 'text'
|
||||
self.show_text_viewer = True
|
||||
|
||||
imgui.table_set_column_index(1)
|
||||
if hasattr(f_item, "auto_aggregate"):
|
||||
changed_agg, f_item.auto_aggregate = imgui.checkbox(f"Agg##cc{i}", f_item.auto_aggregate)
|
||||
imgui.same_line()
|
||||
_, f_item.ast_definitions = imgui.checkbox(f"Def##cc{i}", f_item.ast_definitions)
|
||||
imgui.end_table()
|
||||
changed_full, f_item.force_full = imgui.checkbox(f"Full##cc{i}", f_item.force_full)
|
||||
if hasattr(f_item, "ast_signatures"):
|
||||
imgui.same_line()
|
||||
_, f_item.ast_signatures = imgui.checkbox(f"Sig##cc{i}", f_item.ast_signatures)
|
||||
imgui.same_line()
|
||||
_, f_item.ast_definitions = imgui.checkbox(f"Def##cc{i}", f_item.ast_definitions)
|
||||
imgui.end_table()
|
||||
# Context Composition collasping header
|
||||
|
||||
imgui.separator()
|
||||
imgui.text("Screenshots")
|
||||
for i, s in enumerate(self.screenshots):
|
||||
imgui.text(s)
|
||||
imgui.separator()
|
||||
imgui.text("Presets")
|
||||
presets = self.controller.project.get('context_presets', {})
|
||||
preset_names = [""] + sorted(presets.keys())
|
||||
active = getattr(self, "ui_active_context_preset", "")
|
||||
if active not in preset_names:
|
||||
active = ""
|
||||
try:
|
||||
idx = preset_names.index(active)
|
||||
except ValueError:
|
||||
idx = 0
|
||||
ch, new_idx = imgui.combo("##ctx_preset", idx, preset_names)
|
||||
if ch:
|
||||
self.ui_active_context_preset = preset_names[new_idx]
|
||||
if preset_names[new_idx]:
|
||||
self.load_context_preset(preset_names[new_idx])
|
||||
imgui.same_line()
|
||||
changed, new_name = imgui.input_text("##new_preset", getattr(self, "ui_new_context_preset_name", ""))
|
||||
if changed:
|
||||
self.ui_new_context_preset_name = new_name
|
||||
imgui.same_line()
|
||||
if imgui.button("Save##ctx"):
|
||||
if getattr(self, "ui_new_context_preset_name", "").strip():
|
||||
self.save_context_preset(self.ui_new_context_preset_name.strip())
|
||||
self.ui_new_context_preset_name = ""
|
||||
imgui.same_line()
|
||||
if imgui.button("Delete##ctx"):
|
||||
if getattr(self, "ui_active_context_preset", ""):
|
||||
self.delete_context_preset(self.ui_active_context_preset)
|
||||
self.ui_active_context_preset = ""
|
||||
|
||||
if imgui.collapsing_header("Screenshots"):
|
||||
for i, s in enumerate(self.screenshots):
|
||||
imgui.text(s)
|
||||
imgui.separator()
|
||||
imgui.text("Presets")
|
||||
presets = self.controller.project.get('context_presets', {})
|
||||
preset_names = [""] + sorted(presets.keys())
|
||||
active = getattr(self, "ui_active_context_preset", "")
|
||||
if active not in preset_names:
|
||||
active = ""
|
||||
try:
|
||||
idx = preset_names.index(active)
|
||||
except ValueError:
|
||||
idx = 0
|
||||
ch, new_idx = imgui.combo("##ctx_preset", idx, preset_names)
|
||||
if ch:
|
||||
self.ui_active_context_preset = preset_names[new_idx]
|
||||
if preset_names[new_idx]:
|
||||
self.load_context_preset(preset_names[new_idx])
|
||||
imgui.same_line()
|
||||
changed, new_name = imgui.input_text("##new_preset", getattr(self, "ui_new_context_preset_name", ""))
|
||||
if changed:
|
||||
self.ui_new_context_preset_name = new_name
|
||||
imgui.same_line()
|
||||
if imgui.button("Save##ctx"):
|
||||
if getattr(self, "ui_new_context_preset_name", "").strip():
|
||||
self.save_context_preset(self.ui_new_context_preset_name.strip())
|
||||
self.ui_new_context_preset_name = ""
|
||||
imgui.same_line()
|
||||
if imgui.button("Delete##ctx"):
|
||||
if getattr(self, "ui_active_context_preset", ""):
|
||||
self.delete_context_preset(self.ui_active_context_preset)
|
||||
self.ui_active_context_preset = ""
|
||||
|
||||
def _render_snapshot_tab(self) -> None:
|
||||
if imgui.begin_tab_bar("snapshot_tabs"):
|
||||
|
||||
Reference in New Issue
Block a user