Skip to content

Independent Auditing of AI Agents. Run by human or the agent itself, to answer the most crucial question in the AI Agent Economy. Is the agent doing what is supposed to do? With iFixAi you can have this answer in less than 120 seconds.

fix: fall back to noninteractive UI when input streams are detached (#248)

Rudy Mizrahi Celekli424a8c4587ba
diff --git a/ifixai/cli/ui.py b/ifixai/cli/ui.py
index f94878d..a8fa451 100644
--- a/ifixai/cli/ui.py
+++ b/ifixai/cli/ui.py
@@ -49,6 +49,8 @@ def is_interactive() -> bool:
return (
supports_color()
and _questionary_available()
+ and sys.stdin is not None
+ and sys.stdout is not None
and sys.stdin.isatty()
and sys.stdout.isatty()
)
diff --git a/ifixai/tests/test_ui_detached_stdin.py b/ifixai/tests/test_ui_detached_stdin.py
new file mode 100644
index 0000000..f84f32d
--- /dev/null
+++ b/ifixai/tests/test_ui_detached_stdin.py
@@ -0,0 +1,9 @@
+from ifixai.cli import ui
+
+
+def test_missing_input_stream_uses_noninteractive_fallback(monkeypatch):
+ monkeypatch.setattr(ui, 'supports_color', lambda: True)
+ monkeypatch.setattr(ui, '_questionary_available', lambda: True)
+ monkeypatch.setattr(ui.sys, 'stdin', None)
+ assert ui.is_interactive() is False
+ assert ui.select('Pick', ['one', 'two'], default='two') == 'two'