Scripts: check then's parameters and keep a failed startup script's message

script.startup.run checks then's parameters as script.run checks them,
before any startup script runs. In the app, the message of a startup
script that fails or is stopped, through the quit prompt too, stays in
the status bar's notes after the chosen script ends.
This commit is contained in:
dotCooCoo committed 2026-11-25 13:49:06 -08:00
1 parent f906a0f814
commit c0487189bd
7 files changed
+60 -8

No files matched your search

+10 -2
View File
@@ -95,7 +95,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Run Startup Scripts",
[],
None,
"{reason: launch|menu (launch: the app starting; menu: before a script chosen from File › Scripts), then?: script.run's parameters (the script to run once the startup scripts have run), maxFuel?: whole number from 1 to 100000000000 (each startup script's instructions; default 1000000000)} run the .jsx files of the Startup Scripts folder next to the settings, one at a time, as script.run runs a file, each with the same limits as any script and its own undo step; nothing runs, and the reply says why, when the runStartupScripts preference is off (the default), in Safe Mode, or in a session without the folder (the web, and a run with VECTORCRAFT_NO_PREFS); only the folder's own .jsx files run, sorted by name without regard to case, then by name; links, hidden files, names starting with a dot, subfolders and other files are left out, and so is a script the Safe Mode choice disabled; a missing folder runs nothing; a script that cannot be read, is larger than 8 MiB, fails or is stopped is named in failed and in the Script Console, and the next one runs, then the script of then; while a startup script runs, the launch marker names it, so a launch that stops there offers to disable it; script.* commands are refused inside a script, so a startup script does not start another startup run. VectorCraft's own rules: the folder, the order, the limits of a listing (2048 folder entries, 512 scripts, 250 ms) and what a failure does → {reason, skipped: true, why: off|safeMode|noFolder, then?: script.run's reply} | {reason, skipped: false, ran: [names], failed: [{name, error}], disabled: [names], truncated, unreadable, then?: script.run's reply}, or, in the app, {reason, skipped: false, running, queued: the runs queued, then's included, failed: [{name, error}] (the runs that could not start before the first one did), disabled, truncated, unreadable, then?: script.run's reply when it ran to its end at once}, each run then reporting as script.run's do, and a later run that cannot start is named in the status bar",
"{reason: launch|menu (launch: the app starting; menu: before a script chosen from File › Scripts), then?: script.run's parameters (the script to run once the startup scripts have run), maxFuel?: whole number from 1 to 100000000000 (each startup script's instructions; default 1000000000)} run the .jsx files of the Startup Scripts folder next to the settings, one at a time, as script.run runs a file, each with the same limits as any script and its own undo step; nothing runs, and the reply says why, when the runStartupScripts preference is off (the default), in Safe Mode, or in a session without the folder (the web, and a run with VECTORCRAFT_NO_PREFS); only the folder's own .jsx files run, sorted by name without regard to case, then by name; links, hidden files, names starting with a dot, subfolders and other files are left out, and so is a script the Safe Mode choice disabled; a missing folder runs nothing; a script that cannot be read, is larger than 8 MiB, fails or is stopped is named in failed and in the Script Console, and the next one runs, then the script of then; while a startup script runs, the launch marker names it, so a launch that stops there offers to disable it; script.* commands are refused inside a script, so a startup script does not start another startup run. VectorCraft's own rules: the folder, the order, the limits of a listing (2048 folder entries, 512 scripts, 250 ms) and what a failure does → {reason, skipped: true, why: off|safeMode|noFolder, then?: script.run's reply} | {reason, skipped: false, ran: [names], failed: [{name, error}], disabled: [names], truncated, unreadable, then?: script.run's reply}, or, in the app, {reason, skipped: false, running, queued: the runs queued, then's included, failed: [{name, error}] (the runs that could not start before the first one did), disabled, truncated, unreadable, then?: script.run's reply when it ran to its end at once}, each run then reporting as script.run's do, and a later run that cannot start is named in the status bar, where the message of a startup script that fails or is stopped also stays",
always,
startup_run
),
@@ -394,6 +394,12 @@ impl Session {
}
}
/// The running script is a startup script (`script.startup.run`), not the script queued after
/// them.
pub fn startup_script_running(&self) -> bool {
self.startup_loading.is_some()
}
/// Begins a run of the startup script at `path`, read now and checked as `script.run` checks a
/// file, with the launch marker naming it while it runs. → the run's name, or the error that kept
/// it from starting, which the Script Console also shows.
@@ -534,8 +540,10 @@ fn startup_run(s: &mut Session, p: &Value) -> Result<Value> {
if s.script_running() {
return Err(EngineError::Busy);
}
// A chosen script that cannot start ends the request before any startup script runs.
// A chosen script that cannot start ends the request before any startup script runs, and its
// parameters are checked as `script.run` checks them.
if let Some(then) = &then {
super::params::check_params("script.run", then)?;
prepare(s, then)?;
}
let root = match (s.startup_skip(), s.startup_scripts_dir()) {