Skip to content

feat(playwright): human.clear() — humanized field clearing + human_clear MCP tool#48

Merged
totigm merged 1 commit into
mainfrom
feat/human-clear
Jun 2, 2026
Merged

feat(playwright): human.clear() — humanized field clearing + human_clear MCP tool#48
totigm merged 1 commit into
mainfrom
feat/human-clear

Conversation

@totigm

@totigm totigm commented Jun 2, 2026

Copy link
Copy Markdown
Owner

What & why

Step 2 of the form-interaction work. Real flows don't just fill empty fields — they edit existing values (settings pages, "change your email", correcting a typo'd form). Until now you'd have to drop to raw Playwright (locator.clear() / fill('')) for that. human.clear() closes it.

Behavior

A real keyboard gesture, not a silent value reset:

  1. Click to focus (humanized, same implicit-click as type/paste)
  2. Select-all — platform-aware Mod+A (Meta+A on macOS, Control+A elsewhere), via the same resolver human.press uses
  3. a short personality/speed-scaled beat (so the selection visibly registers)
  4. Delete

Fires the keydown/up + input events the page expects (validation, "dirty" state, etc.). Works for inputs, textareas, and contenteditable.

await human.clear('#email');
await human.type('#email', 'new@example.com');   // replace, don't append

In speed: 'instant', delegates to Playwright's native locator.clear() — no visible gesture, consistent with the rest of instant mode.

Surface (full parity)

  • @humanjs/playwright: human.clear(target) (executor in the keyboard module, beside type/paste).
  • @humanjs/mcp: human_clear tool.
  • Recorder codegen: exports via toPlaywright / toHumanJS.
  • @humanjs/core: new 'clear' KnownActionType.
  • Skill + CLAUDE.md API shape updated.

Tests

Colocated tests cover the humanized gesture (focus click → select-all chord → Delete, no native clear) and the instant path (native locator.clear(), no gesture/motion). Gate green: lint · typecheck 9/9 · tests 8/8 · check:exports (publint) 11/11.

Changeset

minor for @humanjs/playwright + @humanjs/mcp + @humanjs/core, patch for @humanjs/skill.

Clears a text field with a real humanized gesture — click to focus,
select-all (platform-aware Mod+A), a beat, then Delete — firing the input
events the page expects. Pairs with type() to replace an existing value.
Instant mode delegates to Playwright's native locator.clear().

Mirrored as the human_clear MCP tool, exported by the recorder codegen,
documented in the skill primitives table, and backed by a new 'clear'
KnownActionType in @humanjs/core. Colocated tests cover the humanized
gesture and the instant path.
@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
humanjs Ready Ready Preview, Comment Jun 2, 2026 1:15pm

@totigm totigm merged commit 910260f into main Jun 2, 2026
6 checks passed
@totigm totigm deleted the feat/human-clear branch June 2, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant