Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix([brain-bucket-chip-reorder]): stop card dragleave from wiping the armed marker

[._.]/ Adam Eivyb397d552e8dd
diff --git a/client/src/components/brain/links/BucketBoard.test.jsx b/client/src/components/brain/links/BucketBoard.test.jsx
index bfac447d61..3d13f48102 100644
--- a/client/src/components/brain/links/BucketBoard.test.jsx
+++ b/client/src/components/brain/links/BucketBoard.test.jsx
@@ -70,9 +70,9 @@ describe('BucketBoard', () => {
expect(onMoveLinkToIndex).toHaveBeenCalledWith(twoChip[0], 'b1', 1);
});
- it('routes a drop in the gap (bubbling to the card) to the shown insertion index', () => {
+ it('keeps the armed marker through a bubbled dragleave and routes a gap drop to it', () => {
const onMoveLinkToIndex = vi.fn();
- render(
+ const { container } = render(
<BucketBoard
links={twoChip}
buckets={buckets}
@@ -84,11 +84,19 @@ describe('BucketBoard', () => {
/>
);
const linkDt = { getData: () => 'l1', types: ['text/x-brain-link'] };
- // Dragging over Beta (index 1) arms the insertion marker at index 1.
+ const card = container.querySelector('.flex.flex-col.bg-port-card'); // b1's card root
+ const chipRow = container.querySelector('.flex.flex-wrap'); // b1's chip row
+ // Hovering Beta (index 1) arms the marker at index 1.
fireEvent.dragOver(screen.getByText('Beta'), { dataTransfer: linkDt });
- // Releasing on the bucket header (not a chip) bubbles to the card's drop
- // handler, which must honor the armed marker rather than appending.
- fireEvent.drop(screen.getByText('Bookmarks'), { dataTransfer: linkDt });
+ // A bubbled dragleave reaching the card (the chip→gap crossing fires one)
+ // must NOT clear the armed marker — the regression was the card-level
+ // onDragLeave wiping dropIndex unconditionally. (relatedTarget can't be
+ // simulated in jsdom, but the card's leave no longer reads the event, so
+ // this exercises the exact handler that held the bug.)
+ fireEvent.dragLeave(card);
+ // Releasing in the gap (the chip row, not a chip) bubbles to the card's
+ // drop handler, which must honor the still-armed marker rather than append.
+ fireEvent.drop(chipRow, { dataTransfer: linkDt });
expect(onMoveLinkToIndex).toHaveBeenCalledWith(twoChip[0], 'b1', 1);
});
diff --git a/client/src/components/brain/links/BucketCard.jsx b/client/src/components/brain/links/BucketCard.jsx
index 96231812ec..35bf875c81 100644
--- a/client/src/components/brain/links/BucketCard.jsx
+++ b/client/src/components/brain/links/BucketCard.jsx
@@ -90,7 +90,11 @@ export default function BucketCard({
dropActive ? 'border-port-accent ring-1 ring-port-accent' : 'border-port-border'
}`}
onDragOver={(e) => { e.preventDefault(); if (dropIndex === null) setDropActive(true); }}
- onDragLeave={() => { setDropActive(false); setDropIndex(null); }}
+ // Don't clear dropIndex here: native dragleave bubbles, so a chip→gap
+ // crossing would fire this and wipe the armed marker before a gap/bar
+ // release — defeating the guarded clear on the chips row below. The chips
+ // row's own dragleave (with a relatedTarget guard) owns clearing.
+ onDragLeave={() => setDropActive(false)}
onDrop={(e) => {
e.preventDefault();
const insertAt = dropIndex; // capture the visible insertion point before clearing
@@ -254,5 +258,7 @@ export default function BucketCard({
/** A thin vertical accent bar marking where a dragged chip will land. */
function ChipInsertionBar() {
- return <div className="w-0.5 self-stretch min-h-[1.75rem] rounded-full bg-port-accent" aria-hidden="true" />;
+ // pointer-events-none so the bar isn't itself a drag target — a release on it
+ // passes through to the chips row (and bubbles to the card drop handler).
+ return <div className="w-0.5 self-stretch min-h-[1.75rem] rounded-full bg-port-accent pointer-events-none" aria-hidden="true" />;
}