Skip to content

Fix style mode bugs found in deep review#470

Merged
aidenybai merged 6 commits into
mainfrom
cursor/fix-style-mode-bugs-a358
Jun 13, 2026
Merged

Fix style mode bugs found in deep review#470
aidenybai merged 6 commits into
mainfrom
cursor/fix-style-mode-bugs-a358

Conversation

@aidenybai

@aidenybai aidenybai commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the confirmed bugs from a deep review of style mode (edit panel):

  • Prompt/preview desync on overlapping tweaks (tweak-store.ts): tweaks are now kept in commit-recency order (key re-inserted on commit), tweaks fully covered by a new wider commit are dropped, and a longhand stepped back to its original under a changed aggregate is still emitted in the prompt. Previously pt-8p-6pt-1 copied CSS that contradicted the on-screen preview.
  • Tailwind hint chip named the wrong class for aggregate rows (edit-panel/index.tsx, find-tailwind-class.ts): the chip was keyed off cssProperties[0], so the uniform padding row showed pt-4 instead of p-4. Now keyed off property.key, with the comma-joined aggregate spellings (py, px, my, mx, size, inset, inset-x, inset-y) added to the lookup tables.
  • oklch() percentage chroma parsed 100× too small (parse-any-color.ts): parsePercentOrNumber divides by 100 and multiplied by a per-percent scale of 0.004; the scale is now 0.4 (CSS Color 4: 100% chroma = 0.4). Typing/pasting oklch(70% 60% 25) no longer applies a near-gray.
  • Out-of-range originals teleported to the clamp bound (step-property.ts): stepping now widens the range to include the original value, so a 128px heading no longer snaps to 96px when pressing the increase arrow.
  • rounded-full infinite radius (css-property-builders.ts): Chromium computes calc(infinity * 1px) to ~3.36e7px; values past CSS_LENGTH_INFINITY_THRESHOLD_PX are capped to the row's max bound instead of displaying 33554400px.
  • Inset aggregate rows ranked last (sort-properties-by-recommendation.ts): "top,right,bottom,left", "left,right", "top,bottom" were missing from the rank map, so inset: 0 overlays sorted their canonical row below z-index.
  • Canonical negative Tailwind classes ignored (tailwind-autoapply.ts): -m-4 and -mt-[8px] now apply negative values; previously only the non-Tailwind spelling m--4 worked.
  • Baseline default-detection broken for display/width/height (css-baseline-measurement.ts): the baseline clone is forced to display: none, so those keys compared as "author-modified" on every element; they now fall back to the heuristic (and the width,height size row is covered by it).
  • Enum pointer stepping bypassed the commit pipeline (cycle-control.tsx): arrows/label clicks now route through onStepcommitTweak like keyboard arrows, so they get the same flash/discard-prompt behavior.

Tests

Added e2e regression coverage:

  • Copied prompt CSS content is asserted for the overlap scenarios (first prompt-content assertions in the suite).
  • Shift-held Tailwind chip text is asserted (p-2 on a uniform-padding row).
  • Out-of-range stepping (inline 128px font) and rounded-full clamped display.
  • Negative Tailwind classes (-m-4, -mt-[8px]).

Verification

  • Full Playwright e2e suite: 662 passed, 1 flaky (pre-existing touch-mode test, passed on retry).
  • CLI vitest suite: passed.
  • pnpm build, pnpm typecheck, pnpm lint: clean.
  • pnpm format: clean except a pre-existing issue in skills/react-grab/SKILL.md (untouched by this PR).
Open in Web Open in Cursor 

Summary by cubic

Fixes style mode bugs so the preview and copied prompt stay in sync, Tailwind inputs (including negatives) apply correctly, and numeric/color handling is more robust. Also stabilizes opening the panel in tests.

  • Bug Fixes

    • Prompt/preview sync: keep edits in commit order and drop covered edits; emit a longhand returned to original when an earlier aggregate changed; re-committing a wider aggregate over a prior longhand fans out and stays in sync.
    • Tailwind: hint chip keys off the row and names aggregate classes (py, px, size, inset, inset-x, inset-y); support canonical and arbitrary negatives (-m-4, -mt-[8px]); block negative-enum leaks (-font-700); derive POSITION_KEYS from the registry.
    • Stepping/clamp: widen range to include the original to avoid jumps against arrow direction; clamp infinite border-radius from rounded-full to the row max for px units only (large z-index values are preserved).
    • Color: fix oklch() percent chroma scale to 0.4 so inputs like oklch(70% 60% 25) render correctly.
    • Ranking/baseline: rank inset aggregates correctly; for display, width, height, and width,height, fall back to the heuristic instead of the display:none baseline.
    • Controls: enum arrows/label clicks now route through onStep → commit for consistent flash/discard behavior.
    • Tests: add e2e coverage for prompt content (including 3-way overlap p-6pt-8px-2 and aggregate re-commit over a longhand), aggregate hint labels, out-of-range stepping, rounded-full clamping, and negative Tailwind classes; stabilize with a shared hoverUntilSelected helper for opening the panel.
  • Refactors

    • Rename the edit-panel "tweak store" to "style store" (createStyleStore, applyStyle, hasPendingStyles, hasChangedStyleFor); rename commitTweak to stepActiveProperty; complete cssKeypropertyKey naming.
    • Inline edit-panel pass-through aliases (call styleStore.filteredProperties() and discardConfirmation.isPending() directly; inline the pointer step forwarder).
    • Inline single-use toolbar layout helpers and remove utils/toolbar-layout.ts.

Written for commit 0541152. Summary will update on new commits.

Review in cubic

…ailwind fixes

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
react-grab-storybook Ready Ready Preview, Comment Jun 13, 2026 8:18am
react-grab-website Ready Ready Preview, Comment Jun 13, 2026 8:18am

@pkg-pr-new

pkg-pr-new Bot commented Jun 13, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@react-grab/cli@470
npm i https://pkg.pr.new/grab@470
npm i https://pkg.pr.new/react-grab@470

commit: 0541152

@aidenybai aidenybai marked this pull request as ready for review June 13, 2026 02:32

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 14 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/react-grab/src/utils/css-property-builders.ts Outdated
Comment thread packages/react-grab/src/components/edit-panel/tailwind-autoapply.ts
Addresses the two cubic P2 reports plus thermo review findings:

- Unit-gate the infinity clamp so a real large z-index keeps its value
  instead of being rewritten to the bound (css-property-builders.ts).
- Skip the numeric->enum fallback for negative-prefixed classes so
  `-font-700` is a no-op instead of applying font-weight 700.
- Extract splitNegativePrefix util to de-duplicate the sign handling.
- Derive the tailwind chip table (single source of truth) and
  POSITION_KEYS from the registry so parallel lists can't drift.
- Drop the redundant lastCommittedTweakKey shadow state (derive the
  last-committed key from insertion order).
- Finish the cssKey->propertyKey rename for aggregate-capable keys.
- Make the new e2e tests deterministic (poll + setSearchInputValue;
  non-reflowing border-radius for the out-of-range stepping case).
- Rename the edit-panel "tweak store" to "style store" to match the
  product's style mode: tweak-store.ts -> style-store.ts and all symbols
  (createStyleStore, applyStyle, hasPendingStyles, hasChangedStyleFor,
  stylesByKey, PropertyStyle). Behavior-preserving.
- Rename commitTweak -> stepActiveProperty (it steps the active property
  and delegates to commit) and isUntweakedColor -> isUnchangedColor.
- Add an e2e regression for a 3-way overlap (p-6 -> pt-8 -> px-2) that
  locks the prompt-matches-preview ordering across a full aggregate, a
  longhand, and an axis aggregate.
- De-flake panel opening: share a hoverUntilSelected retry primitive
  (re-hover, moving the pointer away first) between openEditPanel and
  enterPromptMode, replacing their divergent ad-hoc hover waits.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4c7bda4. Configure here.

Comment thread packages/react-grab/src/components/edit-panel/style-store.ts
Locks the (correct) last-write-wins behavior flagged by Bugbot: re-
committing a wider aggregate over a prior per-side override fans out to
every side in both the preview and the copied prompt, so they never
desync. Dropping the covered longhand in applyStyle is what guarantees
this — keeping it would show top=28 in the preview but emit top=8.
Collapse thin indirection in the style panel: drop the filteredProperties
and isPendingDismiss rename-aliases (use styleStore.filteredProperties()
and discardConfirmation.isPending() directly) and inline the stepFromPointer
forwarder at its two call sites. Behavior-identical.
getButtonSpacingClass/getMinDimensionClass were one-line ternaries used
once each, and both call sites already named the result locally. Inline
them and delete the file.
@aidenybai aidenybai merged commit 4532a10 into main Jun 13, 2026
18 checks passed
@aidenybai aidenybai deleted the cursor/fix-style-mode-bugs-a358 branch June 13, 2026 09:38
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