Skip to content

fix(cmdk): keep the first result focused and the top fog stable across re-ranks - #6635

Merged
j15z merged 1 commit into
stagingfrom
fix/cmdk-current-selection-bug
Aug 12, 2026
Merged

fix(cmdk): keep the first result focused and the top fog stable across re-ranks#6635
j15z merged 1 commit into
stagingfrom
fix/cmdk-current-selection-bug

Conversation

@j15z

@j15z j15z commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • CMD+K ranks against the deferred query, but cmdk re-anchors selection against the stale rows still in the DOM. When the re-ranked list lands, the old pick either stays selected mid-list or dangles on an unmounted row (cmdk only self-heals when the selected row is the last one removed), so the first visible result wasn't focused and Enter did nothing ("fun" → "func"). Now a re-anchor effect selects the first row once the re-ranked list commits.
  • The palette's top/bottom fog stops were percentages of the list's height, and the list shrinks to its content — so the fog band physically moved whenever the result count changed, flashing over the dark selected first row ("run" → "run wo"). Stops are now pixel-anchored, frozen at the tuned 448px max-height look, so the fog is identical at every list height. The canvas selector keeps percentage stops on purpose (fixed-height card).

Type of Change

  • Bug fix

Testing

  • New regression test reproduces the dangling-selection race deterministically (fails without the fix)
  • All 66 search-modal tests pass; command-chrome test pins the pixel-anchored mask
  • lint, check:audits (25/25), and type-check pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 12, 2026 6:39pm

Request Review

@cursor

cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
UI-only search modal and command chrome styling/selection behavior with targeted regression tests; no auth, data, or API changes.

Overview
Fixes CMD+K keyboard and visual glitches tied to deferred search ranking and a content-sized result list.

When results re-rank after the deferred query commits, cmdk can keep a stale selection (mid-list or on a removed row), so Enter may do nothing. A useEffect on deferredSearch dispatches Home on the search input to re-select the first visible row once the ranked list matches the query.

The palette list fade mask switches from percentage stops to pixel stops (36px / 58px / bottom exit), so the top fog no longer shifts when result count changes. Canvas search keeps percentage masks on the fixed-height card. Tests cover the new mask classes and the funfunc selection race.

Reviewed by Cursor Bugbot for commit a12d177. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR fixes command-palette selection after deferred search re-ranking and stabilizes the palette fade as result counts change.

  • Re-anchors selection to the first result after each deferred query commits.
  • Replaces percentage-based palette mask stops with pixel-anchored stops.
  • Adds regression coverage for re-ranked selection and the updated mask classes.

Confidence Score: 5/5

The PR appears safe to merge with no concrete blocking or non-blocking issues identified.

The deferred-query effect restores first-row selection after re-ranking, and the revised mask geometry remains valid for the palette’s minimum list sizes.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal/search-modal.tsx Adds a post-commit effect that sends Home to cmdk after deferred search results re-rank; no actionable defect was established.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal/search-modal.test.tsx Adds regression coverage confirming that a narrowed, re-ranked result list selects its first row.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal/components/command-chrome/command-chrome.tsx Anchors the palette fade to fixed pixel offsets while retaining percentage stops for the fixed-height canvas variant.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal/components/command-chrome/command-chrome.test.tsx Updates the command-chrome assertion to pin the new pixel-based mask configuration.

Reviews (1): Last reviewed commit: "fix(cmdk): keep the first result focused..." | Re-trigger Greptile

@j15z
j15z merged commit 7c2ba46 into staging Aug 12, 2026
30 checks passed
@j15z
j15z deleted the fix/cmdk-current-selection-bug branch August 12, 2026 18:50
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