High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
chore: wait --not-text
Mariocc196a349cc4
diff --git a/cmd/pinchtab/cmd_cli_register.go b/cmd/pinchtab/cmd_cli_register.goindex a1c1bd22..f8a52a73 100644--- a/cmd/pinchtab/cmd_cli_register.go+++ b/cmd/pinchtab/cmd_cli_register.go@@ -256,6 +256,7 @@ func configureBrowserFlags() {networkCmd.Flags().Bool("stream", false, "Stream network entries in real-time (like tail -f)")waitCmd.Flags().String("text", "", "Wait for text on page")+ waitCmd.Flags().String("not-text", "", "Wait for text to disappear from page")waitCmd.Flags().String("url", "", "Wait for URL glob match")waitCmd.Flags().String("load", "", "Wait for load state (networkidle)")waitCmd.Flags().String("fn", "", "Wait for JS expression to be truthy")diff --git a/internal/cli/actions/actions_wait.go b/internal/cli/actions/actions_wait.goindex 0eec0e41..f2ec6a27 100644--- a/internal/cli/actions/actions_wait.go+++ b/internal/cli/actions/actions_wait.go@@ -14,6 +14,7 @@ func Wait(client *http.Client, base, token string, args []string, cmd *cobra.Combody := map[string]any{}textFlag, _ := cmd.Flags().GetString("text")+ notTextFlag, _ := cmd.Flags().GetString("not-text")urlFlag, _ := cmd.Flags().GetString("url")loadFlag, _ := cmd.Flags().GetString("load")fnFlag, _ := cmd.Flags().GetString("fn")@@ -24,6 +25,8 @@ func Wait(client *http.Client, base, token string, args []string, cmd *cobra.Comswitch {case textFlag != "":body["text"] = textFlag+ case notTextFlag != "":+ body["notText"] = notTextFlagcase urlFlag != "":body["url"] = urlFlagcase loadFlag != "":@@ -41,7 +44,7 @@ func Wait(client *http.Client, base, token string, args []string, cmd *cobra.Com}}default:- fmt.Println("Usage: pinchtab wait <selector|ms> [--text|--url|--load|--fn] [--timeout ms] [--tab id]")+ fmt.Println("Usage: pinchtab wait <selector|ms> [--text|--not-text|--url|--load|--fn] [--timeout ms] [--tab id]")return}diff --git a/internal/handlers/wait.go b/internal/handlers/wait.goindex bbd3d5d1..66666cd9 100644--- a/internal/handlers/wait.go+++ b/internal/handlers/wait.go@@ -28,6 +28,7 @@ type waitRequest struct {Selector string `json:"selector,omitempty"` // CSS/XPath/text selectorState string `json:"state,omitempty"` // "visible" (default) or "hidden"Text string `json:"text,omitempty"` // wait for text on page+ NotText string `json:"notText,omitempty"` // wait for text to disappear from pageURL string `json:"url,omitempty"` // wait for URL glob matchLoad string `json:"load,omitempty"` // "networkidle"Fn string `json:"fn,omitempty"` // JS expression to poll for truthy@@ -51,6 +52,8 @@ func (wr *waitRequest) mode() string {return "selector"case wr.Text != "":return "text"+ case wr.NotText != "":+ return "notText"case wr.URL != "":return "url"case wr.Load != "":@@ -199,6 +202,9 @@ func (h *Handlers) handleWaitCore(w http.ResponseWriter, r *http.Request, req wacase "text":js = fmt.Sprintf(`document.body && document.body.innerText.includes(%s)`, jsonStr(req.Text))matchLabel = req.Text+ case "notText":+ js = fmt.Sprintf(`!document.body || !document.body.innerText.includes(%s)`, jsonStr(req.NotText))+ matchLabel = "!" + req.NotTextcase "url":js = buildURLMatchJS(req.URL)matchLabel = req.URLdiff --git a/internal/handlers/wait_test.go b/internal/handlers/wait_test.goindex c1be2185..7c37cfc9 100644--- a/internal/handlers/wait_test.go+++ b/internal/handlers/wait_test.go@@ -140,6 +140,7 @@ func TestWaitRequest_Mode(t *testing.T) {{"empty", waitRequest{}, ""},{"selector", waitRequest{Selector: "#foo"}, "selector"},{"text", waitRequest{Text: "hello"}, "text"},+ {"notText", waitRequest{NotText: "Loading..."}, "notText"},{"url", waitRequest{URL: "**/dash"}, "url"},{"load", waitRequest{Load: "networkidle"}, "load"},{"fn", waitRequest{Fn: "true"}, "fn"},@@ -176,6 +177,16 @@ func TestHandleWait_TextNoTab(t *testing.T) {}}+func TestHandleWait_NotTextNoTab(t *testing.T) {+ h := New(&mockBridge{failTab: true}, &config.RuntimeConfig{}, nil, nil, nil)+ req := httptest.NewRequest("POST", "/wait", bytes.NewReader([]byte(`{"notText":"Loading..."}`)))+ w := httptest.NewRecorder()+ h.HandleWait(w, req)+ if w.Code != 404 {+ t.Errorf("expected 404, got %d: %s", w.Code, w.Body.String())+ }+}+func TestHandleWait_URLNoTab(t *testing.T) {h := New(&mockBridge{failTab: true}, &config.RuntimeConfig{}, nil, nil, nil)req := httptest.NewRequest("POST", "/wait", bytes.NewReader([]byte(`{"url":"**/dashboard"}`)))diff --git a/skills/pinchtab/SKILL.md b/skills/pinchtab/SKILL.mdindex e983231e..9e789120 100644--- a/skills/pinchtab/SKILL.md+++ b/skills/pinchtab/SKILL.md@@ -197,6 +197,22 @@ Rules:- For the `scroll` action via HTTP, use `"scrollX"` / `"scrollY"` for pixel deltas, or `"selector"` to scroll an element into view. Example: `{"kind":"scroll","scrollY":1500}` or `{"kind":"scroll","selector":"#footer"}`. The `x`/`y` fields are target viewport coordinates, not scroll deltas.- The download HTTP endpoint (`GET /download?url=...` or `GET /tabs/TAB_ID/download?url=...`) returns JSON `{contentType, data (base64), size, url}`, not raw bytes. Decode `data` with base64 to get the file. Only `http`/`https` URLs are allowed. Private/internal hosts are blocked unless listed in `security.downloadAllowedDomains`.+### Waiting++Use `wait` when the DOM settles asynchronously — spinners, toasts, XHR-driven content.++```bash+pinchtab wait <selector> # Element to appear (default visible)+pinchtab wait <selector> --state hidden # Element to disappear+pinchtab wait --text "Order confirmed" # Text to appear+pinchtab wait --not-text "Loading..." # Text to disappear (spinner/toast dismiss)+pinchtab wait --url "**/dashboard" # URL glob match+pinchtab wait --load networkidle # Network idle+pinchtab wait 500 # Fixed delay in ms (last resort)+```++Default timeout 10s, max 30s via `--timeout <ms>`. Prefer `--not-text` / `--state hidden` over polling.+### Export, debug, and verification```bashdiff --git a/tests/benchmark/benchmark-coverage-plan.md b/tests/benchmark/benchmark-coverage-plan.mdindex 85c044b7..5aed32ad 100644--- a/tests/benchmark/benchmark-coverage-plan.md+++ b/tests/benchmark/benchmark-coverage-plan.md@@ -13,8 +13,6 @@ it to the bottom of the file with the loop number that closed it.| ID | Weakness | Severity | Effort | Current status ||----|----------|:--------:|:------:|----------------|-| A1 | ~~**Missing CSS selector hangs for 30 s**~~ — **resolved Loop #30**. `firstNodeBySelector` now uses `chromedp.AtLeast(0)` so missing selectors return `element not found` in <100 ms. Agents that need to wait should use `pinchtab wait --selector` first. Verified via Group 8.2: 87 ms wall-clock. | 🔴 high | 🟡 medium | **closed** |-| A2 | ~~**`text:<value>` selector intermittently fails**~~ — **resolved Loop #30**. Two underlying bugs: (1) the CLI was stripping the `text:` prefix before sending, so `click "text:Submit"` was falling through to CSS lookup for `Submit`; (2) the text resolver used `el.innerText` (O(N²) layout-forcing) instead of `el.textContent`. Fixed both; agent used `text:` aggressively in Loop #30 across 10+ cases with zero failures. | 🔴 high | 🔴 hard | **closed** || A3 | **First `fill` after `nav` race** — the first `fill` action after a navigation occasionally times out; the retry works. Suggests the readiness wait in `action_pointer.go` isn't quite aligned with when the DOM is actually interactive. | 🟡 mid | 🟡 medium | open || A4 | **Ref recovery picks wrong target on repeated-label siblings** — a row of `✕` delete buttons causes the recovery path to silently bind to the wrong row. **Data-loss risk.** Loop #6 caught it deleting the wrong SPA task. | 🔴 high | 🟡 medium | open || A5 | **`scroll into view` fails on overlay/sticky elements** — returns `-32000 no layout object` even when the element is visible. Forces `eval`-based click workaround. | 🟡 mid | 🟡 medium | open |@@ -25,11 +23,11 @@ it to the bottom of the file with the loop number that closed it.| ID | Missing | Impact | Effort | Status ||----|---------|:------:|:------:|--------|-| B1 | **`pinchtab download --output <path>`** — `download` currently returns base64 inline; agent has to post-process. Asked every run. | 🟡 mid | 🟢 easy | open |+| B1 | ~~**`pinchtab download --output <path>`**~~ — **Already implemented.** `-o` flag exists. | 🟡 mid | 🟢 easy | **closed** || B2 | **Screenshot / PDF `-o` paths write inside container, not host.** Benchmark-wrapper issue; production installs are fine. Needs wrapper `docker cp` or `--host-path` flag. | 🟡 mid | 🟢 easy | open || B3 | **`<select multiple>` not supported.** `SelectByNodeID` sets `this.value = v` which is single-select only. Real bug. | 🟡 mid | 🟡 medium | open || B4 | **No viewport resize / mobile emulation.** Can't test responsive layouts or mobile-only UI. | 🟡 mid | 🟡 medium | open |-| B5 | **No `wait --not-text` / `wait --element-gone`** — `wait` only waits for appearance. Disappearance patterns (spinner removal, toast dismiss) force polling. | 🟢 low | 🟢 easy | open |+| B5 | ~~**No `wait --not-text`**~~ — **implemented.** `wait --not-text "Loading..."` waits for text to disappear. `wait <selector> --state hidden` already handled element disappearance. | 🟢 low | 🟢 easy | **closed** || B6 | **No request interception** — `--block-images` / `--block-ads` work but no arbitrary URL pattern blocking or response mocking. | 🟡 mid | 🔴 hard | open || B7 | **No mobile-gesture primitives** — pinch, long-press, two-finger scroll. Niche but will matter. | 🟢 low | 🟡 medium | open |@@ -111,18 +109,16 @@ Not bugs — friction that wrapper / docs could eliminate.When picking the next continuous-loop target, sort by `(agent pain × value) / effort`. Current order:-1. **A1 — fast-fail on missing CSS selectors** — biggest single agent friction-2. **B1 — `download --output <path>`** — tiny, asked every run-3. **C2 — cookies fixture + tasks** — critical untested capability (auth flows)-4. **B3 — multi-select support** — real bug, fixture-driven validation already designed-5. **A4 — ref recovery confidence tuning** — data-loss risk-6. **D1 — shadow DOM fixture + `>>>` piercing** — biggest real-world pattern absence-7. **A5 — scroll-into-view fallback for layout-less elements**-8. **C1 — clipboard fixture + tasks**-9. **C6 — file upload fixture + sandbox-path integration**-10. **D4 — infinite-scroll fixture**-11. **C3–C5** — storage / network / console coverage-12. **D5–D15** — remaining real-world patterns+1. **C2 — cookies fixture + tasks** — critical untested capability (auth flows)+2. **B3 — multi-select support** — real bug, fixture-driven validation already designed+3. **A4 — ref recovery confidence tuning** — data-loss risk 🔴+4. **D1 — shadow DOM fixture + `>>>` piercing** — biggest real-world pattern absence+5. **A5 — scroll-into-view fallback for layout-less elements**+6. **C1 — clipboard fixture + tasks**+7. **C6 — file upload fixture + sandbox-path integration**+8. **D4 — infinite-scroll fixture**+9. **C3–C5** — storage / network / console coverage+10. **D5–D15** — remaining real-world patternsBelow that threshold: everything is incremental coverage / doc polish.@@ -195,5 +191,7 @@ functionality roadmap see the user's earlier survey (§1–11).Populated as loops close items. Each entry: `- [Loop #N] <id> — <one-linedescription>`.-*(none yet — continuous-loop session paused at Loop #16; this plan seeds the-next batch.)*+- [Loop #30] A1 — Missing CSS selector hangs (now fast-fail <100ms via `chromedp.AtLeast(0)`)+- [Loop #30] A2 — `text:<value>` selector reliability (fixed prefix stripping + `textContent`)+- B1 — `download --output <path>` already implemented (`-o` flag exists)+- B5 — `wait --not-text "..."` added; `--state hidden` already handled elements