Managing thirdparty package: defer.

This commit is contained in:
2026-05-13 05:09:23 -04:00
parent 8d6c91d306
commit 9266add6a1
10 changed files with 388 additions and 112 deletions
+26 -34
View File
@@ -13,7 +13,7 @@ import subprocess
import sys
import threading
import time
# from defer import defer
from defer import defer
import tomli_w
# from contextlib import ExitStack, nullcontext
import traceback
@@ -657,16 +657,15 @@ class App:
"""
[C: tests/test_gui_window_controls.py:test_gui_window_controls_minimize_maximize_close]
"""
if imgui.begin_menu("manual slop"):
if imgui.menu_item("Quit", "Ctrl+Q", False)[0]:
with imscope.menu("manual slop") as (active):
if active and imgui.menu_item("Quit", "Ctrl+Q", False)[0]:
self.runner_params.app_shall_exit = True
imgui.end_menu()
if imgui.begin_menu("Windows"):
for w in self.show_windows.keys():
_, self.show_windows[w] = imgui.menu_item(w, "", self.show_windows[w])
imgui.end_menu()
if imgui.begin_menu("Project"):
if imgui.menu_item("Save All", "", False)[0]:
with imscope.menu("Windows") as (active):
if (active):
for w in self.show_windows.keys():
_, self.show_windows[w] = imgui.menu_item(w, "", self.show_windows[w])
with imscope.menu("Project") as (active):
if active and imgui.menu_item("Save All", "", False)[0]:
self._flush_to_project()
self._flush_to_config()
models.save_config(self.config)
@@ -686,9 +685,8 @@ class App:
self.ai_status = f"md written: {path.name}"
except Exception as e:
self.ai_status = f"error: {e}"
imgui.end_menu()
if imgui.begin_menu("Layout"):
if imgui.menu_item("Save Current...", "", False)[0]:
with imscope.menu("Layout") as (active):
if active and imgui.menu_item("Save Current...", "", False)[0]:
self._show_save_workspace_profile_modal = True
self._new_workspace_profile_name = ""
imgui.separator()
@@ -696,37 +694,32 @@ class App:
if imgui.menu_item(profile.name, "", False)[0]:
self.controller._cb_load_workspace_profile(profile_id)
imgui.separator()
if imgui.begin_menu("Delete Profile"):
for profile_id, profile in self.workspace_profiles.items():
if imgui.menu_item(profile.name, "", False)[0]:
self.controller._cb_delete_workspace_profile(profile_id, self._new_workspace_profile_scope)
imgui.end_menu()
imgui.end_menu()
with imscope.menu("Delete Profile") as (active):
if active:
for profile_id, profile in self.workspace_profiles.items():
if imgui.menu_item(profile.name, "", False)[0]:
self.controller._cb_delete_workspace_profile(profile_id, self._new_workspace_profile_scope)
# RAG status indicator
if self.controller.rag_config and self.controller.rag_config.enabled:
imgui.same_line()
status = self.controller.rag_status
if status == "indexing...":
color = vec4(100, 255, 100)
elif status == "error":
color = vec4(255, 100, 100)
else:
color = vec4(180, 180, 180)
if status == "indexing...": color = vec4(100, 255, 100)
elif status == "error": color = vec4(255, 100, 100)
else: color = vec4(180, 180, 180)
imgui.text_colored(color, f"[RAG: {status}]")
if imgui.is_item_hovered():
imgui.set_tooltip(f"RAG is enabled. Status: {status}. Click to rebuild index.")
if imgui.is_item_clicked():
self.controller.event_queue.put('click', 'btn_rebuild_rag_index')
if imgui.is_item_hovered(): imgui.set_tooltip(f"RAG is enabled. Status: {status}. Click to rebuild index.")
if imgui.is_item_clicked(): self.controller.event_queue.put('click', 'btn_rebuild_rag_index')
# Draw right-aligned window controls directly in the menu bar (Win32 only)
if sys.platform == "win32":
try:
import ctypes
ctypes.pythonapi.PyCapsule_GetPointer.restype = ctypes.c_void_p
ctypes.pythonapi.PyCapsule_GetPointer.restype = ctypes.c_void_p
ctypes.pythonapi.PyCapsule_GetPointer.argtypes = [ctypes.py_object, ctypes.c_char_p]
hwnd_capsule = imgui.get_main_viewport().platform_handle_raw
hwnd = ctypes.pythonapi.PyCapsule_GetPointer(hwnd_capsule, b"nb_handle")
hwnd = ctypes.pythonapi.PyCapsule_GetPointer(hwnd_capsule, b"nb_handle")
except Exception:
hwnd = 0
@@ -734,9 +727,8 @@ class App:
btn_w = 40
# Use window width (points) instead of display_size (pixels) for correct scaling
window_w = imgui.get_window_width()
bar_h = imgui.get_window_height()
right_x = window_w - (btn_w * 3)
bar_h = imgui.get_window_height()
right_x = window_w - (btn_w * 3)
# Drag area check using an explicit invisible button spanning the empty space
curr_x = imgui.get_cursor_pos_x()
drag_w = right_x - curr_x