Preferences: lazy loading on connect, on by default

Off reads the whole app from app.sab when connecting. Read at each connect, so a
change takes effect on the next one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-11 14:13:41 +03:00
co-authored by Claude Opus 5.5
parent cb0196caa7
commit 7ff2479736
3 changed files with 32 additions and 9 deletions
+10 -3
View File
@@ -8,7 +8,7 @@ so later rebinding would only ever be seen by the module that did it.
import configparser
import os
VERSION = "0.0.0.170"
VERSION = "0.0.0.171"
PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties")
DEFAULT_GRID_SIZE = 10
DEFAULT_ADD_TIMESTAMP = True
@@ -118,6 +118,7 @@ def load_preferences():
left_pane_width = DEFAULT_LEFT_PANE_WIDTH
sedona_home = ""
trace_dasp = False
lazy_loading = True
if os.path.exists(PROPERTIES_FILE):
try:
@@ -130,6 +131,7 @@ def load_preferences():
)
sedona_home = config.get("Editor", "sedona.home", fallback="").strip()
trace_dasp = config.getboolean("Editor", "trace_dasp", fallback=False)
lazy_loading = config.getboolean("Editor", "lazy_loading", fallback=True)
except Exception:
pass
else:
@@ -150,7 +152,8 @@ def load_preferences():
left_pane_width = max(
MIN_ALLOWED_LEFT_PANE_WIDTH, min(MAX_ALLOWED_LEFT_PANE_WIDTH, left_pane_width)
)
return sedona_home, grid_size, add_timestamp, box_width, left_pane_width, trace_dasp
return (sedona_home, grid_size, add_timestamp, box_width, left_pane_width, trace_dasp,
lazy_loading)
def save_preferences():
@@ -170,6 +173,7 @@ def save_preferences():
"box_width": str(BOX_WIDTH),
"left_pane_width": str(LEFT_PANE_WIDTH),
"trace_dasp": str(TRACE_DASP),
"lazy_loading": str(LAZY_LOADING),
}
with open(PROPERTIES_FILE, "w") as configfile:
config.write(configfile)
@@ -259,5 +263,8 @@ def base_window_title_live():
return f"Sedona Live Editor [v{VERSION}] — {device_host}:{device_port}"
SEDONA_HOME, GRID_SIZE, ADD_TIMESTAMP, BOX_WIDTH, LEFT_PANE_WIDTH, TRACE_DASP = load_preferences()
# LAZY_LOADING: on connect, read components as folders are opened (True) or the whole
# app from app.sab first (False). Read at each connect, so a change takes effect on the next.
(SEDONA_HOME, GRID_SIZE, ADD_TIMESTAMP, BOX_WIDTH, LEFT_PANE_WIDTH, TRACE_DASP,
LAZY_LOADING) = load_preferences()
LAST_PALETTE_KIT = load_last_palette_kit()
+8 -5
View File
@@ -70,11 +70,14 @@ class DeviceSession:
self._load_slot_registry(parts)
self.sox_client.load(0)
try:
count = self.seed_from_sab()
self.seed_info = f"app read from app.sab: {count} components"
except Exception as e:
self.seed_info = f"app.sab not used: {e}"
if app_state.LAZY_LOADING:
self.seed_info = "lazy loading"
else:
try:
count = self.seed_from_sab()
self.seed_info = f"app read from app.sab: {count} components"
except Exception as e:
self.seed_info = f"app.sab not used: {e}"
root_comp = self.sox_client.cache_get(0)
if root_comp and root_comp.children:
+14 -1
View File
@@ -2699,6 +2699,18 @@ def open_preferences_dialog():
)
chk_trace_dasp.grid(row=5, column=1, sticky="w", pady=(0, 15))
lbl_lazy = ttk.Label(frame_padded, text="Lazy loading on connect?", anchor="w")
lbl_lazy.grid(row=6, column=0, sticky="w", pady=(0, 15), padx=(0, 10))
# Off: the whole app is read from app.sab when connecting. Takes effect on the next.
var_lazy_loading = tk.BooleanVar(value=app_state.LAZY_LOADING)
chk_lazy_loading = ttk.Checkbutton(
frame_padded,
text="Yes",
variable=var_lazy_loading
)
chk_lazy_loading.grid(row=6, column=1, sticky="w", pady=(0, 15))
def apply_preferences():
try:
val = int(entry_grid.get().strip())
@@ -2755,6 +2767,7 @@ def open_preferences_dialog():
app_state.GRID_SIZE = val
app_state.ADD_TIMESTAMP = var_timestamp.get()
app_state.TRACE_DASP = var_trace_dasp.get()
app_state.LAZY_LOADING = var_lazy_loading.get()
app_state.SEDONA_HOME = entry_home.get().strip()
app_state.save_preferences()
@@ -2773,7 +2786,7 @@ def open_preferences_dialog():
messagebox.showerror("Invalid Input", message, parent=dialog)
btn_save_pref = ttk.Button(frame_padded, text="Apply Changes", command=apply_preferences)
btn_save_pref.grid(row=6, column=1, sticky="e")
btn_save_pref.grid(row=7, column=1, sticky="e")
if not app_state.SEDONA_HOME:
entry_home.focus_set()