@nyx-intelligence/val-mcp 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/session.js +34 -2
  2. package/package.json +1 -1
package/dist/session.js CHANGED
@@ -153,9 +153,41 @@ class ValSession {
153
153
  const r = el.getBoundingClientRect();
154
154
  return r.width > 0 && r.height > 0;
155
155
  };
156
- const els = Array.from(document.querySelectorAll("button, [role=button]")).filter(isVisible);
156
+ // Skip buttons that are toggles / segmented-control items / already-active
157
+ // controls — clicking them is a legitimate no-op, not a dead control.
158
+ const TOGGLE_ROLES = ["tab", "switch", "radio", "option", "menuitemradio", "menuitemcheckbox"];
159
+ const CONTAINER_ROLES = ["tablist", "radiogroup", "listbox", "menu", "tabs"];
160
+ const ACTIVE_CLASS = /(^|\s|-)(active|selected|is-active|is-selected|current|is-current)(\s|$|-)/i;
161
+ const isToggleLike = (el) => {
162
+ if (el.hasAttribute("disabled") || el.getAttribute("aria-disabled") === "true")
163
+ return true;
164
+ if (el.hasAttribute("aria-pressed") || el.hasAttribute("aria-selected"))
165
+ return true;
166
+ const ac = el.getAttribute("aria-current");
167
+ if (ac && ac !== "false")
168
+ return true;
169
+ const role = el.getAttribute("role");
170
+ if (role && TOGGLE_ROLES.indexOf(role) >= 0)
171
+ return true;
172
+ if (ACTIVE_CLASS.test(el.getAttribute("class") || ""))
173
+ return true;
174
+ let p = el.parentElement;
175
+ while (p) {
176
+ const r = p.getAttribute("role");
177
+ if (r && CONTAINER_ROLES.indexOf(r) >= 0)
178
+ return true;
179
+ p = p.parentElement;
180
+ }
181
+ return false;
182
+ };
183
+ const els = Array.from(document.querySelectorAll("button, [role=button]"))
184
+ .filter(isVisible)
185
+ .filter((el) => !isToggleLike(el));
157
186
  els.forEach((el, i) => el.setAttribute("data-val-ex", `e${i}`));
158
- return els.map((el, i) => ({ ref: `e${i}`, text: (el.innerText || el.getAttribute("aria-label") || "").trim().slice(0, 40) }));
187
+ return els.map((el, i) => ({
188
+ ref: `e${i}`,
189
+ text: (el.innerText || el.getAttribute("aria-label") || "").trim().slice(0, 40),
190
+ }));
159
191
  });
160
192
  const buttons = await tag();
161
193
  const dead = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nyx-intelligence/val-mcp",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Val — a 100% MCP QA agent for vibecoders. Drives a real browser to catch UX bugs (broken links, 404s, console errors, broken images) so your coding agent can fix them.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",