Skip to content

Dragged component position accuracy#3

Merged
ben-million merged 1 commit intomainfrom
cursor/dragged-component-position-accuracy-498b
Mar 9, 2026
Merged

Dragged component position accuracy#3
ben-million merged 1 commit intomainfrom
cursor/dragged-component-position-accuracy-498b

Conversation

@ben-million
Copy link
Collaborator

Enhance repositioning prompt accuracy by generating layout-aware, actionable instructions for ctrl+dragged components.

The previous prompt generation was less precise, relying on absolute Y coordinates and a verbose DOM dump. This PR introduces a new utility (nearby.ts) to intelligently analyze the DOM structure (flex, grid, block layouts, gaps, margins) around the dragged element. This allows prompt.ts to provide specific, incremental CSS suggestions (e.g., "add margin-top: 4px") and JSX reordering instructions, directly addressing the user's need for highly accurate agent positioning without CSS transforms.


Open in Web Open in Cursor 

- Create nearby.ts with layout detection (flex/grid/block), sibling
  gap measurement, insertion index computation, and React fiber
  component name resolution
- Rewrite prompt.ts reposition section to produce focused, actionable
  instructions: parent layout info, child index movement, neighbor
  gaps, and smart margin suggestions based on gap vs parent gap
- Support both vertical and horizontal flow axes

Co-authored-by: Ben MacLaurin <ben-million@users.noreply.github.com>
@cursor
Copy link

cursor bot commented Mar 8, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@ben-million ben-million marked this pull request as ready for review March 9, 2026 01:15
@ben-million ben-million merged commit a0f5cdc into main Mar 9, 2026
1 check passed
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.

2 participants