Skip to content

Add /grab command with AI Canvas for visual element selection#2936

Draft
youknowriad wants to merge 1 commit intotrunkfrom
visual-ai-site-editing
Draft

Add /grab command with AI Canvas for visual element selection#2936
youknowriad wants to merge 1 commit intotrunkfrom
visual-ai-site-editing

Conversation

@youknowriad
Copy link
Copy Markdown
Contributor

@youknowriad youknowriad commented Mar 27, 2026

Related issues

How AI was used in this PR

This feature was largely AI-assisted (vibe-coded). The architecture, component structure, and integration were designed collaboratively with Claude. All code has been reviewed by the author.

Proposed Changes

  • Add new apps/ai-canvas React app workspace that renders a WordPress site in an iframe with element picker UI (hover highlights, tooltips, confirmation modal)
  • Add /grab slash command to the CLI ai chat that opens a headed Playwright browser with the AI Canvas, letting users visually select DOM elements
  • Selections flow asynchronously back to the CLI via Playwright's exposeFunction bridge — the browser stays open while the user continues chatting
  • Selected element context (HTML, CSS, selector, WP block type, ancestors) is automatically attached to the next AI prompt
  • Show the current selection label in the TUI prompt editor's bottom border

Testing Instructions

  • Build the CLI: npm run cli:build
  • Run node apps/cli/dist/cli/main.js ai, select a running site
  • Type /grab — a browser window should open showing the site in an iframe
  • Hover over elements — blue highlight and tooltip should follow the cursor
  • Click an element — confirmation modal appears with a friendly summary
  • Return to the CLI — the selected element label appears in the prompt area
  • Type a prompt — the element context should be included and the AI should reference it
  • The browser stays open for additional selections between prompts

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

Introduces a new `apps/ai-canvas` React 19 app that renders the site in an
iframe and provides element picking UI (highlight, tooltip, confirmation modal).
The CLI serves it via Playwright's page.route() on the same origin as the site,
enabling full iframe DOM access. Selections flow asynchronously to the CLI via
exposeFunction — the browser stays open and the user can pick elements at any
time, even while a prompt is running. The latest selection is shown in the
prompt editor's bottom border and attached to the next prompt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant