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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix([brain-bucket-chip-reorder]): address codex + claude review
[._.]/ Adam Eivy46cb76efa98f
diff --git a/client/src/components/brain/links/BucketCard.jsx b/client/src/components/brain/links/BucketCard.jsxindex c228a81eb4..0eda4add04 100644--- a/client/src/components/brain/links/BucketCard.jsx+++ b/client/src/components/brain/links/BucketCard.jsx@@ -4,6 +4,7 @@ import BrailleSpinner from '../../BrailleSpinner';import InlineConfirmRow from '../../ui/InlineConfirmRow';import LinkChip from './LinkChip';import { bucketColor, BUCKET_COLORS, BUCKET_COLOR_KEYS, LINK_DND_TYPE, BUCKET_DND_TYPE } from './bucketColors';+import { chipInsertIndex } from './bucketReorder';/*** A single bucket (bookmark group): colored header with inline edit/delete,@@ -37,10 +38,7 @@ export default function BucketCard({// Insert a chip before or after the chip at index `i` based on which half of// it the pointer is over (chips flow left-to-right within a wrapping row).- const dropIndexFor = (e, i) => {- const rect = e.currentTarget.getBoundingClientRect();- return e.clientX > rect.left + rect.width / 2 ? i + 1 : i;- };+ const dropIndexFor = (e, i) => chipInsertIndex(e.currentTarget.getBoundingClientRect(), e.clientX, i);// While dragging a link over a chip: show a precise insertion bar instead of// the whole-card drop ring. Bucket-reorder drags (no link payload) fall@@ -91,7 +89,7 @@ export default function BucketCard({className={`flex flex-col bg-port-card border rounded-lg overflow-hidden transition-colors ${dropActive ? 'border-port-accent ring-1 ring-port-accent' : 'border-port-border'}`}- onDragOver={(e) => { e.preventDefault(); setDropActive(true); }}+ onDragOver={(e) => { e.preventDefault(); if (dropIndex === null) setDropActive(true); }}onDragLeave={() => { setDropActive(false); setDropIndex(null); }}onDrop={(e) => {e.preventDefault();@@ -213,7 +211,7 @@ export default function BucketCard({{links.map((link, i) => (<Fragment key={link.id}>{dropIndex === i && <ChipInsertionBar />}- <div onDragOver={(e) => handleChipDragOver(e, i)} onDrop={(e) => handleChipDrop(e, i)}>+ <div className="max-w-full min-w-0" onDragOver={(e) => handleChipDragOver(e, i)} onDrop={(e) => handleChipDrop(e, i)}><LinkChip link={link} onRemove={onRemoveLink} draggable /></div></Fragment>diff --git a/client/src/components/brain/links/bucketReorder.js b/client/src/components/brain/links/bucketReorder.jsindex e232ec2f79..45b1df9ab6 100644--- a/client/src/components/brain/links/bucketReorder.js+++ b/client/src/components/brain/links/bucketReorder.js@@ -8,6 +8,16 @@* links whose `{ bucketId, bucketOrder }` actually changed (so the caller only* PATCHes what moved).*/+/**+ * Map a pointer position over a chip to an insertion index: before the chip+ * (its own index) when the pointer is in its left half, after it (index + 1)+ * when in the right half. Pure so the before/after boundary is unit-testable+ * (jsdom can't supply a real rect or clientX to a drag event).+ */+export function chipInsertIndex(rect, clientX, i) {+ return clientX > rect.left + rect.width / 2 ? i + 1 : i;+}+export function reorderLinksInBucket(links, link, bucketId, targetIndex) {const ordered = links.filter(l => l.bucketId === bucketId)diff --git a/client/src/components/brain/links/bucketReorder.test.js b/client/src/components/brain/links/bucketReorder.test.jsindex 4adeeadd8f..3fdbd8c00f 100644--- a/client/src/components/brain/links/bucketReorder.test.js+++ b/client/src/components/brain/links/bucketReorder.test.js@@ -1,8 +1,24 @@import { describe, it, expect } from 'vitest';-import { reorderLinksInBucket } from './bucketReorder';+import { reorderLinksInBucket, chipInsertIndex } from './bucketReorder';const mk = (id, bucketId, bucketOrder) => ({ id, bucketId, bucketOrder });+describe('chipInsertIndex', () => {+ const rect = { left: 100, width: 40 }; // midpoint at 120++ it('inserts before the chip when the pointer is in its left half', () => {+ expect(chipInsertIndex(rect, 110, 3)).toBe(3);+ });++ it('inserts after the chip when the pointer is in its right half', () => {+ expect(chipInsertIndex(rect, 130, 3)).toBe(4);+ });++ it('treats the exact midpoint as "before" (not strictly greater)', () => {+ expect(chipInsertIndex(rect, 120, 3)).toBe(3);+ });+});+describe('reorderLinksInBucket', () => {it('moves a chip later within its bucket, accounting for its own removal', () => {const links = [mk('a', 'b1', 0), mk('b', 'b1', 1), mk('c', 'b1', 2), mk('d', 'b1', 3)];