Skip to content

fix(macros): commands no longer disappear when reordering in the macro editor#1244

Merged
chhoumann merged 1 commit into
masterfrom
fix/macro-reorder-ghost-gap
May 29, 2026
Merged

fix(macros): commands no longer disappear when reordering in the macro editor#1244
chhoumann merged 1 commit into
masterfrom
fix/macro-reorder-ghost-gap

Conversation

@chhoumann
Copy link
Copy Markdown
Owner

@chhoumann chhoumann commented May 29, 2026

Bug

In the macro editor, dragging to reorder a command could make another command disappear (most visibly with 2 commands).

Cause

CommandList's handleConsider/handleSort assigned svelte-dnd-action's raw e.detail.items — including the library's internal shadow placeholder — directly to commands, and only filtered the placeholder out of the {#each}. With few items, a command could end up retained in state as the placeholder and then be filtered out of the render, so it vanished.

Fix

Strip SHADOW_PLACEHOLDER_ITEM_ID in both handlers before assigning to commands — the exact fix already applied to the Settings choice list in #883. CommandList was the only dndzone list still missing it (pre-existing; unrelated to the recent CI/type work).

Verification

Manually verified in the dev vault: reordering with 2+ commands no longer drops an item and the order persists. bun run build + bun run check (svelte-check 0/0) clean; unit tests pass.


Open in Devin Review

Summary by CodeRabbit

  • Bug Fixes
    • Resolved an issue where placeholder items would persist during command list reordering, improving the drag-and-drop user experience.

Review Change Stack

…o editor

The macro command list assigned svelte-dnd-action's raw consider/finalize items
(including the library's internal shadow placeholder) straight to `commands`, and
only filtered the placeholder out of the {#each}. With few items, a command could
linger in state as the placeholder and then get filtered out of the render — i.e.
disappear when reordering via drag.

Mirror the fix already applied to the Settings choice list in #883: strip the
SHADOW_PLACEHOLDER_ITEM_ID entry in handleConsider and handleSort before assigning
to `commands`. (CommandList was the only dndzone list missing this.)

Verified by hand in the dev vault: reordering with 2+ commands no longer drops an
item, and order persists. build + svelte-check clean; unit tests pass.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying quickadd with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7b87049
Status:⚡️  Build in progress...

View logs

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9349ad02-f0dc-4050-bccf-fa11ab92837e

📥 Commits

Reviewing files that changed from the base of the PR and between 0e6bfaa and 7b87049.

📒 Files selected for processing (1)
  • src/gui/MacroGUIs/CommandList.svelte

📝 Walkthrough

Walkthrough

CommandList.svelte now filters the dnd-action internal shadow placeholder item from the commands array in both the consider and sort event handlers. This prevents the placeholder identifier from persisting in component state during drag-and-drop reordering operations.

Changes

Drag-and-drop shadow placeholder filtering

Layer / File(s) Summary
Filter shadow placeholder in dnd event handlers
src/gui/MacroGUIs/CommandList.svelte
handleConsider and handleSort now filter out SHADOW_PLACEHOLDER_ITEM_ID from the items array received from the dnd action, preventing the internal placeholder from persisting in component state during drag operations.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Whiskers twitched with delight
A phantom shadow fades from sight,
Drag and drop now flows so clean,
No more placeholders in between!
The quickadd burrow shines so bright! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main fix: preventing commands from disappearing when reordering in the macro editor, which matches the primary change in CommandList.svelte.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/macro-reorder-ghost-gap

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7b87049637

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +66 to +68
commands = (newItems as ICommand[]).filter(
(c) => c.id !== SHADOW_PLACEHOLDER_ITEM_ID
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the dragged command during consider

In the pointer-drag path, svelte-dnd-action's first consider event replaces the dragged item with the shadow placeholder; filtering it here means commands (and the dndzone's next items config) temporarily no longer contains the dragged command at all. If the user releases before a later over-index event re-inserts a shadow item, such as a tiny drag or dropping outside immediately after drag starts, handleSort receives that shortened list and saveCommands(commands) persists the macro with the command removed. Keep the dragged command represented in state during consider (or restore it before finalize) rather than dropping the placeholder from the dndzone items.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@chhoumann chhoumann merged commit 539605d into master May 29, 2026
7 of 10 checks passed
@chhoumann chhoumann deleted the fix/macro-reorder-ghost-gap branch May 29, 2026 10:26
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