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]): honor the insertion marker on gap/bar drops

[._.]/ Adam Eivyc278b5511a06
diff --git a/client/src/components/brain/links/BucketBoard.test.jsx b/client/src/components/brain/links/BucketBoard.test.jsx
index 0a75fe907f..bfac447d61 100644
--- a/client/src/components/brain/links/BucketBoard.test.jsx
+++ b/client/src/components/brain/links/BucketBoard.test.jsx
@@ -70,6 +70,28 @@ 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', () => {
+ const onMoveLinkToIndex = vi.fn();
+ render(
+ <BucketBoard
+ links={twoChip}
+ buckets={buckets}
+ setBuckets={vi.fn()}
+ onAssignLink={vi.fn()}
+ onAddLinkToBucket={vi.fn()}
+ onBucketDeleted={vi.fn()}
+ onMoveLinkToIndex={onMoveLinkToIndex}
+ />
+ );
+ const linkDt = { getData: () => 'l1', types: ['text/x-brain-link'] };
+ // Dragging over Beta (index 1) arms the insertion 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 });
+ expect(onMoveLinkToIndex).toHaveBeenCalledWith(twoChip[0], 'b1', 1);
+ });
+
it('ignores a chip-level drop that carries no link payload (e.g. a bucket reorder)', () => {
const onMoveLinkToIndex = vi.fn();
render(
diff --git a/client/src/components/brain/links/BucketCard.jsx b/client/src/components/brain/links/BucketCard.jsx
index 0eda4add04..96231812ec 100644
--- a/client/src/components/brain/links/BucketCard.jsx
+++ b/client/src/components/brain/links/BucketCard.jsx
@@ -93,10 +93,18 @@ export default function BucketCard({
onDragLeave={() => { setDropActive(false); setDropIndex(null); }}
onDrop={(e) => {
e.preventDefault();
+ const insertAt = dropIndex; // capture the visible insertion point before clearing
setDropActive(false);
setDropIndex(null);
const linkId = e.dataTransfer.getData(LINK_DND_TYPE);
- if (linkId) { onDropLink?.(linkId); return; }
+ if (linkId) {
+ // Releasing in a chip gap / on the insertion bar bubbles here rather
+ // than to a chip's own handler — honor the marker that was showing
+ // (land at that index) instead of silently appending.
+ if (insertAt !== null) onMoveLink?.(linkId, insertAt);
+ else onDropLink?.(linkId);
+ return;
+ }
const draggedBucketId = e.dataTransfer.getData(BUCKET_DND_TYPE);
if (draggedBucketId) onReorderBucket?.(draggedBucketId);
}}