From 7ff24797365f0783640030f504dbaf62a4355a65 Mon Sep 17 00:00:00 2001 From: Arda Aydin Date: Sun, 11 Oct 2026 14:13:41 +0300 Subject: [PATCH] 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 --- app_state.py | 13 ++++++++++--- device_session.py | 13 ++++++++----- main.py | 15 ++++++++++++++- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/app_state.py b/app_state.py index a72c646..b1efef1 100644 --- a/app_state.py +++ b/app_state.py @@ -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() diff --git a/device_session.py b/device_session.py index ec5982e..8065c00 100644 --- a/device_session.py +++ b/device_session.py @@ -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: diff --git a/main.py b/main.py index c06e7d8..76fc0f5 100644 --- a/main.py +++ b/main.py @@ -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()