ShardBrowser icon indicating copy to clipboard operation
ShardBrowser copied to clipboard

[Feature Request / Bug] wait step's seconds param can't take a variable, so var.random → wait doesn't work

Open Nelsonxu2022 opened this issue 2 months ago • 1 comments

Title

wait step's seconds param can't take a variable, so var.random → wait doesn't work

Body

Summary

The wait step's seconds param is defined as kind: "number" and is read at runtime with param_f64, which never resolves {{variable}} references. That makes it impossible to feed a var.random output into wait for a randomized delay — a combination the codebase itself seems to anticipate (see the comment quoted below), but never actually wires up.

Steps to reproduce

  1. Add a var.random step, e.g. min=1000, max=5000, into=delay.
  2. Add a wait step and try to put {{delay}} into "seconds".
  3. The field is a native <input type="number">, so you can't even type {{delay}} into it. If you hand-edit the saved project file to force "seconds": "{{delay}}", the run doesn't error — it just silently falls back to the 1-second default, because the value is never expanded before being parsed.

Root cause

  • wait's param is declared as kind: "number" (src/entities/automation/model/palette.ts, ~L429-433):
kind: "wait",
params: [{ name: "seconds", label: "palette.wait.seconds.label", kind: "number", default: 2 }],
  • It's consumed with param_f64 (src-tauri/src/runner.rs, ~L160-166), which parses a literal number or a numeric string but never calls expand():
fn param_f64(params: &Value, name: &str) -> Option<f64> {
    params.get(name).and_then(|v| match v {
        Value::Number(n) => n.as_f64(),
        Value::String(s) => s.parse().ok(),
        _ => None,
    })
}
  • Compare that with var.random's min/max and var.math's a/b, which are kind: "text" and are resolved with as_number() (~L576-582) — which does run expand() first:
fn as_number(vars: &HashMap<String, String>, raw: &str) -> Result<f64> {
    let expanded = expand(raw, vars);
    expanded.trim().parse::<f64>()
        .map_err(|_| anyhow!("\"{expanded}\" is not a number"))
}
  • Notably, the comment directly above var.random's range-picking logic (~L1512) reads:

    "16 bits of the uuid is plenty for a wait or an index and keeps this free of another dependency."

    which implies a random-seconds-into-wait workflow was in mind when var.random was written, but wait never got the kind: "text" + as_number() treatment that would actually let it consume that value.

  • The same gap applies to every other kind: "number" param in the palette — waitFor.timeout, waitGone.timeout, waitText.timeout, waitUrl.timeout, readAttribute.timeout — none of them accept a variable either, for the same reason.

Suggested fix

Change seconds/timeout params from kind: "number" to kind: "text" (keeping the existing numeric default), and read them on the Rust side with as_number() instead of param_f64, the same way var.random/var.math already do. That's a small, localized change that would let var.random → wait (and any variable → any timeout) work without any other UI change.

Why it matters

Randomized delays between actions are a pretty basic building block for humanlike automation, which is one of this project's core selling points, so not being able to wire var.random into wait is a real functional gap rather than a nice-to-have.

Environment

  • Repo: ProxyShard/ShardBrowser, main branch
  • Commit at time of writing: 4880c3fd1a6360bc205daa5bc5542b16277201c3
  • ⚠️ Fill in your own app version / OS before submitting (Settings → About, or your build output) — the above is just the source commit I read the code at.

Nelsonxu2022 avatar Sep 13 '26 15:09 Nelsonxu2022

in v2.1.1

Kr1tos avatar Oct 24 '26 15:10 Kr1tos