feat(context): Implement view mode UI in context composition panel
This commit is contained in:
+21
-58
@@ -2819,56 +2819,13 @@ class App:
|
||||
#region: Batch Action Bar
|
||||
imgui.text("Batch:")
|
||||
imgui.same_line()
|
||||
if imgui.button("Full##batch"):
|
||||
for f in self.context_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.context_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.context_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.context_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.context_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()
|
||||
for mode in ["full", "summary", "skeleton", "outline", "masked", "none"]:
|
||||
if imgui.button(f"{mode.capitalize()}##batch"):
|
||||
for f in self.context_files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
if f_path in self.ui_selected_context_files:
|
||||
f.view_mode = mode
|
||||
imgui.same_line()
|
||||
if imgui.button("Sel All##selall"):
|
||||
for f in self.context_files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
@@ -2970,15 +2927,21 @@ class App:
|
||||
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)
|
||||
if not hasattr(f_item, "view_mode"):
|
||||
f_item.view_mode = "summary"
|
||||
view_modes = ["full", "summary", "skeleton", "outline", "masked", "none"]
|
||||
try:
|
||||
current_idx = view_modes.index(f_item.view_mode)
|
||||
except ValueError:
|
||||
current_idx = 1
|
||||
f_item.view_mode = "summary"
|
||||
imgui.set_next_item_width(120)
|
||||
changed_vm, new_idx = imgui.combo(f"##vm{i}", current_idx, view_modes)
|
||||
if changed_vm:
|
||||
f_item.view_mode = view_modes[new_idx]
|
||||
if hasattr(f_item, "custom_slices") and f_item.custom_slices:
|
||||
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.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.text_colored(imgui.ImVec4(1.0, 0.5, 0.0, 1.0), "[Slices Active]")
|
||||
imgui.tree_pop()
|
||||
imgui.end_table()
|
||||
# Context Composition collasping header
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import pytest
|
||||
from src.gui_2 import App
|
||||
from src.models import FileItem
|
||||
|
||||
def test_view_mode_initialization():
|
||||
app = App()
|
||||
# Mock imgui
|
||||
from imgui_bundle import imgui
|
||||
|
||||
app.context_files = [
|
||||
FileItem(path="test1.py"),
|
||||
FileItem(path="test2.py", view_mode="full")
|
||||
]
|
||||
|
||||
# We test the model defaults and the rendering assignment logic indirectly.
|
||||
assert app.context_files[0].view_mode == "full" # Default from FileItem Model
|
||||
assert app.context_files[1].view_mode == "full"
|
||||
|
||||
def test_batch_view_mode_change():
|
||||
app = App()
|
||||
|
||||
f1 = FileItem(path="test1.py", view_mode="full")
|
||||
f2 = FileItem(path="test2.py", view_mode="full")
|
||||
|
||||
app.context_files = [f1, f2]
|
||||
app.ui_selected_context_files = {"test1.py"}
|
||||
|
||||
# Simulate clicking "Skeleton" batch button
|
||||
for f in app.context_files:
|
||||
f_path = f.path if hasattr(f, "path") else str(f)
|
||||
if f_path in app.ui_selected_context_files:
|
||||
f.view_mode = "skeleton"
|
||||
|
||||
assert f1.view_mode == "skeleton"
|
||||
assert f2.view_mode == "full" # not selected
|
||||
Reference in New Issue
Block a user