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

[TUI] strata connect --write: a test with no keyboard, and an ended input counts as no

Niko122140d1a3e7d77d
diff --git a/strata_cli/launch/cmd.py b/strata_cli/launch/cmd.py
index a36b94b28..3eb551ebe 100644
--- a/strata_cli/launch/cmd.py
+++ b/strata_cli/launch/cmd.py
@@ -726,7 +726,10 @@ def run_connect(a: argparse.Namespace) -> int:
if not sys.stdin.isatty():
print("strata: --write asks first; run it in a terminal or add --yes.", file=sys.stderr)
return 2
- ans = input("\nWrite these files now? A file that exists is copied to a backup first. [y/N] ").strip().lower()
+ try:
+ ans = input("\nWrite these files now? A file that exists is copied to a backup first. [y/N] ").strip().lower()
+ except EOFError: # the input ended: that is a no
+ ans = ""
if ans not in ("y", "yes"):
_say("Nothing was written.")
return 0
diff --git a/tests/terminal/test_launch.py b/tests/terminal/test_launch.py
index 39e545290..e8376c3b8 100644
--- a/tests/terminal/test_launch.py
+++ b/tests/terminal/test_launch.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+import io
import json
import os
import shutil
@@ -917,10 +918,20 @@ class ConnectCommand(unittest.TestCase):
self.assertIn("backup", out)
def test_write_asks_first_without_yes(self):
- code, out, err = run_cli(["connect", "opencode", "--write"])
+ # no keyboard: stdin is a pipe whatever the shell that runs the tests is; input() must never be reached
+ pipe = io.StringIO("")
+ with mock.patch.object(sys, "stdin", pipe), mock.patch("builtins.input", side_effect=AssertionError("asked on a pipe")):
+ code, out, err = run_cli(["connect", "opencode", "--write"])
self.assertEqual(code, 2)
self.assertIn("asks first", err)
+ def test_write_answered_by_nobody_writes_nothing(self):
+ # a terminal whose input ends (Ctrl-D, a closed console) is "no", not a traceback
+ with mock.patch.object(sys.stdin, "isatty", return_value=True), mock.patch("builtins.input", side_effect=EOFError):
+ code, out, err = run_cli(["connect", "opencode", "--write"])
+ self.assertEqual(code, 0)
+ self.assertIn("Nothing was written", out)
+
def test_built_in_harness_has_nothing_to_write(self):
code, out, _ = run_cli(["connect", "deepseek-harness", "--write", "--yes"])
self.assertEqual(code, 0)