source: abort guard compares to the originating screen, not 0
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 <noreply@anthropic.com>
This commit is contained in:
@@ -296,6 +296,7 @@ void Tui::Source(const std::string &filename) {
|
|||||||
loading_executed = 0;
|
loading_executed = 0;
|
||||||
loading_lineno = 0;
|
loading_lineno = 0;
|
||||||
loading_prev_in_source = in_source;
|
loading_prev_in_source = in_source;
|
||||||
|
source_origin_screen = screen_idx; // a sourced line that leaves this screen aborts
|
||||||
in_source = true;
|
in_source = true;
|
||||||
loading = true;
|
loading = true;
|
||||||
|
|
||||||
@@ -346,10 +347,10 @@ void Tui::ProcessNextSourceLine() {
|
|||||||
Submit();
|
Submit();
|
||||||
++loading_executed;
|
++loading_executed;
|
||||||
|
|
||||||
if (screen_idx != 0) {
|
if (screen_idx != source_origin_screen) {
|
||||||
Print("source: line " + std::to_string(loading_lineno)
|
Print("source: line " + std::to_string(loading_lineno)
|
||||||
+ " is interactive (would open a screen) — aborting.");
|
+ " is interactive (would open a screen) — aborting.");
|
||||||
screen_idx = 0;
|
screen_idx = source_origin_screen;
|
||||||
loading.store(false);
|
loading.store(false);
|
||||||
tick_in_flight.store(false);
|
tick_in_flight.store(false);
|
||||||
in_source = loading_prev_in_source;
|
in_source = loading_prev_in_source;
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ class Tui {
|
|||||||
int loading_executed;
|
int loading_executed;
|
||||||
int loading_lineno;
|
int loading_lineno;
|
||||||
bool loading_prev_in_source;
|
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.
|
ftxui::ScreenInteractive *screen_ptr; ///< set in Run() so Source() can post events.
|
||||||
|
|
||||||
// ---- Dashboard scroll state (0 = top; grows as the user scrolls down) ----
|
// ---- Dashboard scroll state (0 = top; grows as the user scrolls down) ----
|
||||||
|
|||||||
Reference in New Issue
Block a user