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++

Terminal: no engine for this computer is a warning, not a refusal: ask (default yes, --yes skips), download the model, end with the engine problem and the next step, exit 0

Niko1221c4345a7c031d
diff --git a/setup.py b/setup.py
index 0c7ab554f..7578d88dd 100644
--- a/setup.py
+++ b/setup.py
@@ -5938,7 +5938,7 @@ def control_engine_step(gpu, vision):
ok(f"engine component: {found.version} ({found.platform}-{found.backend}) in {eng}")
except EC.EngineMissing as e:
plain = getattr(e, "plain_notice", None) or getattr(e, "driver_notice", None)
- if plain or os.environ.get("STRATA_NEED_ENGINE") == "1":
+ if (plain or os.environ.get("STRATA_NEED_ENGINE") == "1") and os.environ.get("STRATA_ALLOW_NO_ENGINE") != "1":
# The model is tens of GB: when the engine is a dead end for this PC (a build for another card family, a driver that is too
# old) or the caller (strata launch) needs one now, stop before step 5 instead of after the download.
fail(plain or "no engine is installed for this PC",
diff --git a/strata_cli/launch/app.py b/strata_cli/launch/app.py
index bb84e876b..8f0a0dc25 100644
--- a/strata_cli/launch/app.py
+++ b/strata_cli/launch/app.py
@@ -259,7 +259,7 @@ class LaunchApp(App):
def run_launch(self, confirmed: bool = False) -> None:
s = self.ctx.settings
self.cancel = threading.Event()
- self.runner = Runner(s, catalog=self.ctx.catalog, emit=self._emit, cancel=self.cancel, feed=self.ctx.feed)
+ self.runner = Runner(s, catalog=self.ctx.catalog, emit=self._emit, cancel=self.cancel, feed=self.ctx.feed, confirm=self._ask_from_run)
gb = getattr(self.runner, "download_gb", lambda: 0.0)() if not confirmed else 0.0
if gb >= 1.0:
free = self.ctx.catalog.disk_free(s.data_dir or self.ctx.catalog.data_dir())
@@ -283,6 +283,27 @@ class LaunchApp(App):
self.running = True
threading.Thread(target=self._work, daemon=True).start()
+ def _ask_from_run(self, title: str, text: str) -> bool:
+ """A question from the run (a worker thread): show it on the screen and wait for the answer. Enter means yes."""
+ box: dict[str, bool] = {"go": True}
+ answered = threading.Event()
+
+ def done(choice: str | None) -> None:
+ box["go"] = choice == "go"
+ answered.set()
+
+ def show() -> None:
+ self.push_screen(ConfirmScreen(title, text, [("go", "Download anyway"), ("no", "Not now")]), done)
+
+ try:
+ self.call_from_thread(show)
+ except Exception: # noqa: BLE001 - the app is closing
+ return False
+ while not answered.wait(0.2):
+ if self.cancel.is_set():
+ return False
+ return box["go"]
+
def _emit(self, ev: Event) -> None:
screen = self.run_screen
if screen is not None:
@@ -407,4 +428,7 @@ def run_tui(settings: S.LaunchSettings | None, *, catalog: Catalog | None = None
return 0
if result is None:
return 0
+ if not result.serving:
+ print(result.final_text)
+ return 0
return run_monitor(_info_for(result, ctx.settings))
diff --git a/strata_cli/launch/cmd.py b/strata_cli/launch/cmd.py
index b43670035..29c6dd1d6 100644
--- a/strata_cli/launch/cmd.py
+++ b/strata_cli/launch/cmd.py
@@ -102,6 +102,7 @@ def add_parsers(sp: argparse._SubParsersAction) -> list[argparse.ArgumentParser]
o = p.add_argument_group("running")
o.add_argument("--save-preset", metavar="NAME", help="save these choices under this name")
o.add_argument("--no-tui", action="store_true", help="no screens: serve, print the address and return")
+ o.add_argument("--yes", action="store_true", help="do not ask questions (for one: whether to download the model on a computer with no engine yet)")
o.add_argument("--plan", action="store_true", help="show what would happen and exit; nothing is changed")
o.add_argument("--feed", metavar="URL|DIR", help="where the signed update feed (engine downloads) is; default: STRATA_UPDATE_FEED or the project's")
o.add_argument("--output", choices=("human", "json"), default="human")
@@ -307,6 +308,20 @@ def _stop_all(name: str | None) -> int:
return 0
+def _ask_yes(title: str, text: str) -> bool:
+ """Ask a yes/no question on the terminal. Enter means yes. When nobody can answer (no keyboard), the answer is yes: the person already
+ named the model on the command line."""
+ if not (sys.stdin.isatty() and sys.stdout.isatty()):
+ return True
+ _say("")
+ _say(f"[!] {text}")
+ try:
+ answer = input("Go on? [Y/n] ").strip().lower()
+ except EOFError:
+ return True
+ return answer in ("", "y", "yes")
+
+
def _tui(run, *args, **kw) -> int:
"""Open the screens. An error of the screens themselves ends with a plain sentence and a non-zero exit code, never a traceback and exit 0
(tester report T02)."""
@@ -460,7 +475,7 @@ def run_launch(a: argparse.Namespace) -> int:
s.api_key = access.new_key()
if not s.name:
s.name = f"{s.model or 'model'} {S.context_label(s.context)}"
- runner = Runner(s, catalog=catalog, emit=_printer(machine), feed=a.feed)
+ runner = Runner(s, catalog=catalog, emit=_printer(machine), feed=a.feed, assume_yes=bool(a.yes or machine), confirm=_ask_yes)
if a.plan:
plan = runner.plan()
plan["warnings"] = [n.line() for n in notes]
@@ -496,6 +511,14 @@ def run_launch(a: argparse.Namespace) -> int:
store.touch_used(saved.name)
elif a.preset:
store.touch_used(a.preset) # flags next to --preset change this start only
+ if not result.serving:
+ if machine:
+ print(json.dumps({"schema_version": 1, "ok": True, "serving": False, "name": s.name, "profile": result.profile,
+ "engine_problem": result.engine_problem, "message": result.final_text}))
+ else:
+ _say("")
+ _say(result.final_text)
+ return 0
if machine:
print(json.dumps({"schema_version": 1, "ok": True, "name": s.name, "profile": result.profile, "urls": result.urls,
"api_key": "set" if result.key else None, "tuned": result.tune_word,
diff --git a/strata_cli/launch/runner.py b/strata_cli/launch/runner.py
index df8afa4c9..0394cc9ab 100644
--- a/strata_cli/launch/runner.py
+++ b/strata_cli/launch/runner.py
@@ -64,6 +64,9 @@ class Result:
notices: list[str]
config: str
tunnel: str | None = None
+ serving: bool = True # False: the model is ready but nothing was started (no engine yet)
+ engine_problem: str | None = None # the plain reason there is no engine, when serving is False
+ final_text: str = "" # what to tell the person when serving is False
NO_ENGINE_NEXT = ("Get the engine that matches this computer's graphics card (from whoever sent you Strata, or with `strata update --feed <address>`), "
@@ -71,6 +74,22 @@ NO_ENGINE_NEXT = ("Get the engine that matches this computer's graphics card (fr
STAGES = ("engine", "model", "config", "tune", "start", "access")
+NO_ENGINE_STEP = ("run `strata update --feed <address>` with the update source you were given, or ask whoever sent you Strata for the engine "
+ "that matches this computer's graphics card, then run `strata launch` again")
+
+
+def no_engine_warning(reason: str) -> str:
+ """The plain warning shown before a model is downloaded on a computer with no engine to run it."""
+ reason = reason.strip().rstrip(".")
+ return (f"Strata couldn't find an engine for this computer ({reason}). The model will download, but it may not run until you install "
+ f"the right engine (next step: {NO_ENGINE_STEP}).")
+
+
+def no_engine_final(reason: str, name: str = "") -> str:
+ reason = reason.strip().rstrip(".")
+ return (f"The model is ready, but Strata can't start it yet: it couldn't find an engine for this computer ({reason}). "
+ f"Next step: {NO_ENGINE_STEP}. The model files stay on this computer.")
+
def tune_words(result: dict | None, code: int | None = None) -> tuple[str, str]:
"""(short word, plain sentence) for a tuner result: faster / already fastest / busy PC / failed / stopped."""
@@ -216,8 +235,12 @@ def launch_dir() -> Path:
class Runner:
def __init__(self, s: S.LaunchSettings, *, catalog: Catalog | None = None, emit: Callable[[Event], None] | None = None,
cancel: threading.Event | None = None, feed: str | None = None, python: str | None = None,
- components_dir: str | None = None, hardware: dict | None = None):
+ components_dir: str | None = None, hardware: dict | None = None,
+ confirm: Callable[[str, str], bool] | None = None, assume_yes: bool = False):
self.s = s
+ self.confirm = confirm # asked (title, text) before a model is downloaded with no engine; True = go on
+ self.assume_yes = assume_yes # --yes: no questions
+ self.engine_problem: str | None = None
self._catalog = catalog
self.emit_cb = emit or (lambda e: None)
self.cancel = cancel or threading.Event()
@@ -330,7 +353,8 @@ class Runner:
# engine: refuse here, before the model (tens of GB) is touched.
after = ec.status(root)
if not after.get("usable"):
- raise LaunchError(self._no_engine_words(last, after), NO_ENGINE_NEXT, 5)
+ self.no_engine(self._no_engine_words(last, after))
+ return
if code != 0:
why = ""
if isinstance(last, dict):
@@ -345,6 +369,24 @@ class Runner:
"Check your internet connection, or point Strata at an update source with --feed, then try again.", 6)
self.emit("engine", "The engine is installed.", 100)
+ def no_engine(self, reason: str) -> None:
+ """There is no engine for this computer and none to get. This is a warning, not a refusal: the model may still be downloaded, because
+ the engine can be installed afterwards. Ask first (the answer is yes unless the person says no; --yes skips the question) when a
+ download is about to happen; otherwise just remember the problem for the final message."""
+ self.engine_problem = reason
+ warning = no_engine_warning(reason)
+ self.emit("engine", warning, 100, level="warn")
+ if self.assume_yes or self.confirm is None:
+ return
+ try:
+ gb = self.download_gb()
+ except Exception: # noqa: BLE001
+ gb = 0.0
+ if gb < 0.05:
+ return # nothing would be downloaded: no question, only the final message
+ if not self.confirm("No engine for this computer yet", warning + f" Download the model now (about {gb:.0f} GB)?"):
+ raise LaunchError("Stopped. Nothing was downloaded.", "Install the engine first, or run this again and answer yes.", 130)
+
@staticmethod
def _no_engine_words(last: object, report: dict) -> str:
"""The one plain sentence for "no usable engine for this PC": the update's own note (the wrong-card-family line, or "the feed has no
@@ -495,7 +537,12 @@ class Runner:
self.emit("model", f"Getting {title} ready (a download may be large; it continues where it stopped if interrupted)…", 0)
argv = [self.python, str(cat.src / "setup.py"), *self.setup_args()]
env = self._env()
- env.update(STRATA_CONTROL_INSTALL="1", STRATA_NEED_ENGINE="1", STRATA_INSTALL_DIR=str(cat.root), PYTHONNOUSERSITE="1")
+ env.update(STRATA_CONTROL_INSTALL="1", STRATA_INSTALL_DIR=str(cat.root), PYTHONNOUSERSITE="1")
+ env.pop("STRATA_NEED_ENGINE", None)
+ if self.engine_problem:
+ env["STRATA_ALLOW_NO_ENGINE"] = "1" # the person said go on: setup warns about the engine instead of stopping
+ else:
+ env["STRATA_NEED_ENGINE"] = "1"
for k in ("PYTHONHOME", "PYTHONPATH", "VIRTUAL_ENV"):
env.pop(k, None)
env["PYTHONPATH"] = str(cat.src)
@@ -772,6 +819,11 @@ class Runner:
cfg = self.build_config(base)
self.ensure_profile(cfg)
self.emit("config", "Settings are saved.", 100)
+ if self.engine_problem:
+ text = no_engine_final(self.engine_problem, self.s.name or self.name)
+ self.emit("done", text, 100, level="warn")
+ return Result(self.profile, [], self.s.api_key, None, self.notices + [text], str(cfg), serving=False,
+ engine_problem=self.engine_problem, final_text=text)
self.tune()
self.check_cancel()
if not start:
diff --git a/tests/terminal/test_launch_engine_first.py b/tests/terminal/test_launch_engine_first.py
index 4cf158e13..8ce209203 100644
--- a/tests/terminal/test_launch_engine_first.py
+++ b/tests/terminal/test_launch_engine_first.py
@@ -1,19 +1,19 @@
-"""`strata launch` settles the engine before it touches the model: with no usable engine and none to get, it refuses at once, with the
-plain sentence `strata update` gives and one next step, and no model byte is downloaded (the 0.1.45.x tester round downloaded 19 of
-37.6 GB first and then failed with the generic line)."""
+"""`strata launch` settles the engine before it touches the model. With no usable engine and none to get it does NOT refuse (owner decision,
+2026-10-18): it warns in plain words (the reason from `strata update`, and the next step), asks whether to download the model anyway (the
+answer is yes unless the person says no; --yes skips the question), downloads, and ends with a message that names the engine problem and the
+next step, exit code 0. Nothing is started without an engine."""
from __future__ import annotations
import io
import json
import os
-import sys
import unittest
from pathlib import Path
from unittest import mock
from strata_cli.launch import settings as S
-from strata_cli.launch.runner import LaunchError, NO_ENGINE_NEXT, Runner
+from strata_cli.launch.runner import LaunchError, NO_ENGINE_STEP, Runner, no_engine_final, no_engine_warning
from strata_control import engine_component as ec
ROOT = Path(__file__).resolve().parents[2]
@@ -50,20 +50,27 @@ def runner(spawned: list) -> Runner:
class EngineBeforeModel(unittest.TestCase):
def run_ensure(self, statuses: list[dict], events: list[dict], code: int = 0):
"""ensure_engine() with a fake `strata update` and a sequence of engine reports. Returns (spawn count, the error or None)."""
- spawns: list = []
- r = runner(spawns)
-
- def spawn(argv, **kw):
- spawns.append(argv)
- return FakeProc(events, code)
+ spawns, err, _r = self.run_ensure_runner(statuses, events, code)
+ return spawns, err
+ def run_ensure_runner(self, statuses: list[dict], events: list[dict], code: int = 0, confirm=None, gb: float = 0.0,
+ assume_yes: bool = False):
+ """ensure_engine() like run_ensure, returning (spawns, error or None, the runner with .events)."""
+ spawns: list = []
+ seen: list = []
+ r = Runner(S.LaunchSettings(family="qwen", model="Q2_0", context=32768), catalog=mock.Mock(), emit=seen.append,
+ confirm=confirm, assume_yes=assume_yes)
+ r.events = seen
+ r.check_cancel = lambda: None
err = None
- with mock.patch.object(ec, "status", side_effect=statuses), mock.patch.object(Runner, "_spawn", side_effect=lambda argv, **kw: spawn(argv, **kw)):
+ with mock.patch.object(ec, "status", side_effect=statuses), \
+ mock.patch.object(Runner, "_spawn", side_effect=lambda argv, **kw: spawns.append(argv) or FakeProc(events, code)), \
+ mock.patch.object(Runner, "download_gb", return_value=gb):
try:
r.ensure_engine()
except LaunchError as e:
err = e
- return spawns, err
+ return spawns, err, r
def test_engine_present_runs_nothing(self):
spawns, err = self.run_ensure([USABLE], [])
@@ -76,38 +83,105 @@ class EngineBeforeModel(unittest.TestCase):
self.assertEqual(len(spawns), 1)
self.assertIn("update", spawns[0])
- def test_no_engine_and_the_feed_has_none(self):
+ def test_no_engine_and_the_feed_has_none_is_a_warning_not_a_refusal(self):
note = "The feed has no engine package for this PC."
- spawns, err = self.run_ensure([UNUSABLE, UNUSABLE], update_events("none-for-this-pc", note))
- self.assertIsNotNone(err)
- self.assertEqual(err.code, 5)
- self.assertEqual(err.text, note)
- self.assertEqual(err.next, NO_ENGINE_NEXT)
- self.assertNotIn("The app never downloads", str(err)) # not the generic line
-
- def test_wrong_family_says_the_plain_line(self):
- spawns, err = self.run_ensure([UNUSABLE, UNUSABLE], update_events("none-for-this-pc", WRONG_FAMILY))
- self.assertIsNotNone(err)
- self.assertEqual(err.code, 5)
- self.assertEqual(err.text, WRONG_FAMILY)
- self.assertIn("This build of Strata is for AMD RX 7000 cards. This computer has an AMD RX 9000 card (gfx1201).", err.text)
- self.assertIn("Ask for the RX 9000 build.", err.text)
- self.assertIn("Nothing was downloaded", err.next)
+ spawns, err, r = self.run_ensure_runner([UNUSABLE, UNUSABLE], update_events("none-for-this-pc", note))
+ self.assertIsNone(err)
+ self.assertEqual(r.engine_problem, note)
+ warning = no_engine_warning(note)
+ self.assertEqual(r.events[-1].text, warning)
+ self.assertEqual(r.events[-1].level, "warn")
+ self.assertIn("Strata couldn't find an engine for this computer (The feed has no engine package for this PC)", warning)
+ self.assertIn("The model will download, but it may not run until you install the right engine (next step:", warning)
+ self.assertIn(NO_ENGINE_STEP, warning)
+ self.assertNotIn("The app never downloads", warning) # not the generic line
+
+ def test_wrong_family_names_the_plain_reason_in_the_warning(self):
+ spawns, err, r = self.run_ensure_runner([UNUSABLE, UNUSABLE], update_events("none-for-this-pc", WRONG_FAMILY))
+ self.assertIsNone(err)
+ self.assertEqual(r.engine_problem, WRONG_FAMILY)
+ text = r.events[-1].text
+ self.assertIn("This build of Strata is for AMD RX 7000 cards. This computer has an AMD RX 9000 card (gfx1201).", text)
+ self.assertIn("Ask for the RX 9000 build)", text)
def test_installed_wrong_family_package_uses_its_plain_notice(self):
report = {"usable": False, "engine": None, "notice": WRONG_FAMILY}
- spawns, err = self.run_ensure([report, report], update_events("none-for-this-pc"))
- self.assertEqual(err.text, WRONG_FAMILY)
+ spawns, err, r = self.run_ensure_runner([report, report], update_events("none-for-this-pc"))
+ self.assertEqual(r.engine_problem, WRONG_FAMILY)
+
+ def test_the_question_is_asked_with_the_warning_and_no_stops_before_the_download(self):
+ asked = []
+ spawns, err, r = self.run_ensure_runner([UNUSABLE, UNUSABLE], update_events("none-for-this-pc", "No engine here."),
+ confirm=lambda title, text: asked.append((title, text)) or False, gb=66.0)
+ self.assertEqual(len(asked), 1)
+ self.assertIn("Strata couldn't find an engine for this computer (No engine here)", asked[0][1])
+ self.assertIn("Download the model now (about 66 GB)?", asked[0][1])
+ self.assertIsInstance(err, LaunchError)
+ self.assertEqual(err.code, 130)
+ self.assertIn("Nothing was downloaded", err.text)
+
+ def test_yes_goes_on_and_the_yes_flag_asks_nothing(self):
+ asked = []
+ spawns, err, r = self.run_ensure_runner([UNUSABLE, UNUSABLE], update_events("none-for-this-pc", "No engine here."),
+ confirm=lambda t, x: asked.append(1) or True, gb=66.0)
+ self.assertIsNone(err)
+ self.assertEqual(len(asked), 1)
+ asked.clear()
+ spawns, err, r = self.run_ensure_runner([UNUSABLE, UNUSABLE], update_events("none-for-this-pc", "No engine here."),
+ confirm=lambda t, x: asked.append(1) or False, gb=66.0, assume_yes=True)
+ self.assertIsNone(err)
+ self.assertEqual(asked, [])
+ self.assertEqual(r.engine_problem, "No engine here.")
+
+ def test_nothing_to_download_asks_nothing(self):
+ asked = []
+ spawns, err, r = self.run_ensure_runner([UNUSABLE, UNUSABLE], update_events("none-for-this-pc", "No engine here."),
+ confirm=lambda t, x: asked.append(1) or False, gb=0.0)
+ self.assertIsNone(err)
+ self.assertEqual(asked, [])
- def test_the_model_is_never_touched_when_the_engine_is_refused(self):
+ def test_the_model_is_downloaded_and_nothing_is_started_without_an_engine(self):
r = runner([])
+ started = []
with mock.patch.object(ec, "status", return_value=UNUSABLE), \
mock.patch.object(Runner, "_spawn", return_value=FakeProc(update_events("none-for-this-pc", WRONG_FAMILY))), \
- mock.patch.object(Runner, "ensure_model", side_effect=AssertionError("model step reached")) as model:
- with self.assertRaises(LaunchError) as ctx:
- r.run()
- self.assertEqual(ctx.exception.text, WRONG_FAMILY)
- model.assert_not_called()
+ mock.patch.object(Runner, "ensure_model", return_value=Path("/x/strata-q.json")) as model, \
+ mock.patch.object(Runner, "build_config", return_value=Path("/x/launch.json")), \
+ mock.patch.object(Runner, "ensure_profile"), mock.patch.object(Runner, "tune") as tune, \
+ mock.patch.object(Runner, "start", side_effect=lambda: started.append(1)):
+ result = r.run()
+ model.assert_called_once()
+ tune.assert_not_called()
+ self.assertEqual(started, [])
+ self.assertFalse(result.serving)
+ self.assertEqual(result.urls, [])
+ self.assertEqual(result.engine_problem, WRONG_FAMILY)
+ self.assertEqual(result.final_text, no_engine_final(WRONG_FAMILY))
+ self.assertIn("The model is ready, but Strata can't start it yet", result.final_text)
+ self.assertIn("Ask for the RX 9000 build)", result.final_text)
+ self.assertIn(NO_ENGINE_STEP, result.final_text)
+
+ def test_the_setup_child_is_told_to_go_on_without_an_engine(self):
+ r = runner([])
+ r.engine_problem = "No engine here."
+ seen = {}
+
+ class Boom(Exception):
+ pass
+
+ def spawn(self, argv, env=None, cwd=None):
+ seen["env"] = env
+ raise Boom()
+
+ cat = mock.MagicMock()
+ cat.src = ROOT
+ r._catalog = cat
+ r.s = S.LaunchSettings(family="qwen", model="Q2_0", context=32768)
+ with mock.patch.object(Runner, "installed_state", return_value=(None, None)), mock.patch.object(Runner, "_spawn", spawn):
+ with self.assertRaises(Boom):
+ r.ensure_model()
+ self.assertEqual(seen["env"].get("STRATA_ALLOW_NO_ENGINE"), "1")
+ self.assertNotIn("STRATA_NEED_ENGINE", seen["env"])
def test_a_failed_update_still_reports_the_old_message(self):
spawns, err = self.run_ensure([UNUSABLE], [{"event": "error", "error": {"message": "cannot reach the feed"}}], code=6)
@@ -140,14 +214,21 @@ class SetupControlStep(unittest.TestCase):
except SystemExit as e:
return e, out.getvalue()
- def test_wrong_family_stops_before_the_download(self):
+ def test_wrong_family_stops_before_the_download_when_nobody_said_go_on(self):
exc = ec.EngineMissing("nothing matched", Path("/c"), notice=WRONG_FAMILY)
res, out = self.step(exc, {})
self.assertIsInstance(res, SystemExit)
self.assertIn("Ask for the RX 9000 build.", out)
self.assertIn("nothing was downloaded", out)
- def test_no_engine_stops_before_the_download_for_launch(self):
+ def test_wrong_family_goes_on_with_a_warning_when_launch_said_go_on(self):
+ exc = ec.EngineMissing("nothing matched", Path("/c"), notice=WRONG_FAMILY)
+ res, out = self.step(exc, {"STRATA_ALLOW_NO_ENGINE": "1"})
+ self.assertNotIsInstance(res, SystemExit)
+ self.assertIn("no engine is installed for this PC yet", out)
+ self.assertIn("The model is downloaded and prepared now", out)
+
+ def test_no_engine_for_launch_still_stops_setup_when_run_on_its_own(self):
res, out = self.step(ec.EngineMissing("the component folder holds no engine package", Path("/c")), {"STRATA_NEED_ENGINE": "1"})
self.assertIsInstance(res, SystemExit)
diff --git a/tests/terminal/test_tuiqa_launch.py b/tests/terminal/test_tuiqa_launch.py
index db635808d..fa456f395 100644
--- a/tests/terminal/test_tuiqa_launch.py
+++ b/tests/terminal/test_tuiqa_launch.py
@@ -5,6 +5,7 @@ from __future__ import annotations
import asyncio
import contextlib
+import json
import io
import unittest
from unittest import mock
@@ -107,3 +108,111 @@ class FlagsOpenTheRun(unittest.TestCase):
if __name__ == "__main__":
unittest.main()
+
+
+class NoEngineFlow(unittest.TestCase):
+ """Owner decision 2026-10-18: no usable engine is a warning, not a refusal; the model downloads and the end message names the problem."""
+
+ def setUp(self):
+ self.home = Home().__enter__()
+ self.addCleanup(self.home.__exit__, None, None, None)
+
+ def served_nothing(self):
+ from strata_cli.launch.runner import Result, no_engine_final
+ text = no_engine_final("The feed has no engine package for this PC.")
+ return Result("launch-x", [], None, None, [text], "/x", serving=False, engine_problem="The feed has no engine package for this PC.",
+ final_text=text)
+
+ def test_the_command_ends_with_exit_zero_and_the_engine_message(self):
+ from strata_cli.launch.runner import Runner
+ from tests.terminal.launch_support import run_cli
+ with mock.patch.object(Runner, "run", return_value=self.served_nothing()):
+ code, out, err = run_cli(["launch", "--no-tui", "--model", "q2_0", "--yes"])
+ self.assertEqual(code, 0, err)
+ self.assertIn("The model is ready, but Strata can't start it yet", out)
+ self.assertIn("The feed has no engine package for this PC", out)
+ self.assertIn("Next step:", out)
+ self.assertNotIn("Strata is serving", out)
+
+ def test_json_says_not_serving(self):
+ from strata_cli.launch.runner import Runner
+ from tests.terminal.launch_support import run_cli
+ with mock.patch.object(Runner, "run", return_value=self.served_nothing()):
+ code, out, err = run_cli(["launch", "--no-tui", "--model", "q2_0", "--output", "json"])
+ data = json.loads(out)
+ self.assertEqual(code, 0)
+ self.assertTrue(data["ok"])
+ self.assertFalse(data["serving"])
+ self.assertIn("engine", data["engine_problem"])
+
+ def test_yes_is_passed_to_the_runner_and_json_never_asks(self):
+ from strata_cli.launch.runner import Runner
+ from tests.terminal.launch_support import run_cli
+ seen = []
+ real = Runner.__init__
+
+ def spy(self, *a, **kw):
+ seen.append(kw.get("assume_yes"))
+ real(self, *a, **kw)
+
+ with mock.patch.object(Runner, "__init__", spy), mock.patch.object(Runner, "run", return_value=self.served_nothing()):
+ run_cli(["launch", "--no-tui", "--model", "q2_0", "--yes"])
+ run_cli(["launch", "--no-tui", "--model", "q2_0", "--output", "json"])
+ run_cli(["launch", "--no-tui", "--model", "q2_0"])
+ self.assertEqual(seen, [True, True, False])
+
+ def test_the_question_default_is_yes(self):
+ from strata_cli.launch import cmd
+ with mock.patch("builtins.input", return_value=""), mock.patch.object(cmd.sys, "stdin") as sin, \
+ mock.patch.object(cmd.sys, "stdout") as sout:
+ sin.isatty.return_value = True
+ sout.isatty.return_value = True
+ self.assertTrue(cmd._ask_yes("t", "text"))
+ with mock.patch("builtins.input", return_value="n"), mock.patch.object(cmd.sys, "stdin") as sin, \
+ mock.patch.object(cmd.sys, "stdout") as sout:
+ sin.isatty.return_value = True
+ sout.isatty.return_value = True
+ self.assertFalse(cmd._ask_yes("t", "text"))
+ self.assertTrue(cmd._ask_yes("t", "text")) # no keyboard: the person already named the model
+
+ def test_the_screens_ask_with_a_dialog_and_enter_means_yes(self):
+ FakeRunner.instances.clear()
+ FakeRunner.behaviour = "ok"
+ FakeRunner.download = 0.0
+ answers = []
+
+ class Asking(FakeRunner):
+ def run(self, start=True):
+ answers.append(self.confirm("No engine", "Strata couldn't find an engine for this computer (x). Download?"))
+ return super().run(start)
+
+ def __init__(self, *a, confirm=None, **kw):
+ super().__init__(*a, **kw)
+ self.confirm = confirm
+
+ app = LaunchApp(make_ctx(settings=flags_settings()), auto_run=True)
+
+ async def go():
+ with mock.patch("strata_cli.launch.app.Runner", Asking):
+ async with app.run_test(size=SIZE) as pilot:
+ await pilot.pause(0.4)
+ self.assertIn("Strata couldn't find an engine for this computer", text_of(app))
+ await pilot.press("enter") # Download anyway
+ for _ in range(60):
+ await pilot.pause(0.05)
+ if app.result is not None:
+ break
+ return app.result
+
+ self.assertIsNotNone(asyncio.run(go()))
+ self.assertEqual(answers, [True])
+
+ def test_the_screens_show_the_end_message_and_exit_zero(self):
+ from strata_cli.launch.app import LaunchApp as LA
+ res = self.served_nothing()
+ with mock.patch.object(LA, "run", lambda self, **kw: res), mock.patch.object(launch_app, "run_monitor", side_effect=AssertionError("no monitor")):
+ out = io.StringIO()
+ with contextlib.redirect_stdout(out):
+ code = launch_app.run_tui(flags_settings(), catalog=catalog(HW_12), auto_run=True)
+ self.assertEqual(code, 0)
+ self.assertIn("The model is ready, but Strata can't start it yet", out.getvalue())