From 53eb79c7600a0fc8a26419e7c4b5a25a417db70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Wed, 3 Jun 2026 19:06:18 +0200 Subject: [PATCH] source: abort guard compares to the originating screen, not 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A script opened from the dashboard (screen_idx 4) aborted after its first line: the guard treated any non-console screen as 'an interactive command opened a screen'. Record the screen the source started from and abort only when a sourced line navigates away from it (what a bare interactive command does). Now 'o' from the dashboard runs the whole script in place — the dashboard populates live behind the global Computing overlay — while a bare connect/explore inside a script still aborts. Batch unaffected (BootDispatch pins screen 0, so origin 0). Co-Authored-By: Claude Opus 4.8 --- src/tui/shell.cpp | 5 +++-- src/tui/tui.hpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tui/shell.cpp b/src/tui/shell.cpp index 8601da4..e3e3fb8 100644 --- a/src/tui/shell.cpp +++ b/src/tui/shell.cpp @@ -296,6 +296,7 @@ void Tui::Source(const std::string &filename) { loading_executed = 0; loading_lineno = 0; loading_prev_in_source = in_source; + source_origin_screen = screen_idx; // a sourced line that leaves this screen aborts in_source = true; loading = true; @@ -346,10 +347,10 @@ void Tui::ProcessNextSourceLine() { Submit(); ++loading_executed; - if (screen_idx != 0) { + if (screen_idx != source_origin_screen) { Print("source: line " + std::to_string(loading_lineno) + " is interactive (would open a screen) — aborting."); - screen_idx = 0; + screen_idx = source_origin_screen; loading.store(false); tick_in_flight.store(false); in_source = loading_prev_in_source; diff --git a/src/tui/tui.hpp b/src/tui/tui.hpp index 63861a8..ff01484 100644 --- a/src/tui/tui.hpp +++ b/src/tui/tui.hpp @@ -103,6 +103,7 @@ class Tui { int loading_executed; int loading_lineno; bool loading_prev_in_source; + int source_origin_screen = 0; ///< screen a `source` started from; a sourced line that navigates away (opens an interactive screen) aborts it. ftxui::ScreenInteractive *screen_ptr; ///< set in Run() so Source() can post events. // ---- Dashboard scroll state (0 = top; grows as the user scrolls down) ----