Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Drop the cached update notice when Control, engine or app version changed

Niko1221968fcb70b0ee
diff --git a/strata_control/engine_component.py b/strata_control/engine_component.py
index 42834e684..715a571bc 100644
--- a/strata_control/engine_component.py
+++ b/strata_control/engine_component.py
@@ -189,14 +189,38 @@ def engine_dir(root: Path | None = None) -> Path:
return (root or components_dir()) / "engine"
+def newest_installed_version(root: Path | None = None) -> str | None:
+ """The highest engine version in the component folder, or None. A quick scan; nothing is hashed."""
+ try:
+ found, _ = scan(root)
+ except Exception: # noqa: BLE001 - informational only
+ return None
+ return max((item.version for item in found), key=_version_key, default=None)
+
+
def cached_notice(root: Path | None = None) -> str | None:
""""update available (x.y.z): run `strata update`" from the last explicit check, or None. Reads one small local file; it never
- touches the network, so showing it at a start does not break the rule that only an update step downloads."""
+ touches the network, so showing it at a start does not break the rule that only an update step downloads.
+
+ The notice belongs to the versions the check was made for: it is dropped when Control or the installed engine is not the one
+ recorded then (an app install, an update, a rollback), and an engine that is not newer than the installed one is never offered."""
+ base = root or components_dir()
try:
- last = (json.loads(((root or components_dir()) / UPDATE_STATE).read_text(encoding="utf-8-sig")).get("last_check") or {})
+ last = (json.loads((base / UPDATE_STATE).read_text(encoding="utf-8-sig")).get("last_check") or {})
except (OSError, ValueError, AttributeError):
return None
- parts = [f"engine {last['engine']}" for _ in [0] if last.get("engine")] + [f"app {last['app']}" for _ in [0] if last.get("app")]
+ if not isinstance(last, dict):
+ return None
+ control = runtime_version()
+ if "control" in last and last["control"] != control:
+ return None
+ engine, app = last.get("engine"), last.get("app")
+ installed = newest_installed_version(base)
+ if "engine_installed" in last and last["engine_installed"] != installed:
+ engine = None
+ if engine and installed and _version_key(str(engine)) <= _version_key(installed):
+ engine = None
+ parts = ([f"engine {engine}"] if engine else []) + ([f"app {app}"] if app else [])
return f"update available ({', '.join(parts)}): run `strata update`" if parts else None
diff --git a/strata_control/updater.py b/strata_control/updater.py
index 470f3d2e5..9c12445cb 100644
--- a/strata_control/updater.py
+++ b/strata_control/updater.py
@@ -490,7 +490,9 @@ def check(ctx: Context) -> dict:
state.data["last_check"] = {
"at": (ctx.now or dt.datetime.now(dt.timezone.utc)).isoformat(),
"engine": report["engine"]["offered"]["version"] if report["engine"]["status"] in ("available", "install") and report["engine"]["offered"] else None,
- "app": report["app"]["offered"] if report["app"]["status"] == "available" else None}
+ "app": report["app"]["offered"] if report["app"]["status"] == "available" else None,
+ # the versions this result is for, so a later Control, engine or app change drops the cached notice
+ "control": ec.runtime_version(), "engine_installed": ec.newest_installed_version(ctx.components)}
state.save()
return report
diff --git a/tests/terminal/test_updater.py b/tests/terminal/test_updater.py
index 5fa016baf..29f77922b 100644
--- a/tests/terminal/test_updater.py
+++ b/tests/terminal/test_updater.py
@@ -630,6 +630,29 @@ class Cli(UpdaterCase):
def common(self):
return ["--feed", str(self.release), "--components-dir", str(self.components), "--model-config", str(self.config)]
+ def test_cached_update_notice_is_dropped_when_versions_change(self):
+ self.install_current()
+ self.publish(("0.1.46", fx.GOOD_ENGINE))
+ self.assertEqual(self.cli("update", "--check", *self.common())[0], 0)
+ notice = "update available (engine 0.1.46): run `strata update`"
+ self.assertEqual(ec.cached_notice(self.components), notice)
+ state_file = self.components / ec.UPDATE_STATE
+ saved = json.loads(state_file.read_text(encoding="utf-8"))
+ self.assertEqual(saved["last_check"]["engine_installed"], "0.1.45")
+ # a new app brings a new Control: the old result is not shown again
+ with mock.patch.object(ec, "runtime_version", return_value="9.9.9"):
+ self.assertIsNone(ec.cached_notice(self.components))
+ # the installed engine changed since the check (an update from elsewhere, a rollback)
+ with mock.patch.object(ec, "newest_installed_version", return_value="0.1.44"):
+ self.assertIsNone(ec.cached_notice(self.components))
+ # an old file without the recorded versions: still never offers an engine that is not newer
+ saved["last_check"] = {"at": "x", "engine": "0.1.45", "app": None}
+ state_file.write_text(json.dumps(saved), encoding="utf-8")
+ self.assertIsNone(ec.cached_notice(self.components))
+ saved["last_check"] = {"at": "x", "engine": "0.1.46", "app": None}
+ state_file.write_text(json.dumps(saved), encoding="utf-8")
+ self.assertEqual(ec.cached_notice(self.components), notice)
+
def test_check_update_and_rollback_from_the_terminal(self):
self.install_current()
self.publish(("0.1.46", fx.GOOD_ENGINE))