Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(sidebar): hide stale pinned items immediately on workspace switch (MUL-2985) (#3564)
xiaoyue2649c913a4fa70
diff --git a/packages/views/layout/app-sidebar.tsx b/packages/views/layout/app-sidebar.tsxindex aa44dedeeb..b83595ce70 100644--- a/packages/views/layout/app-sidebar.tsx+++ b/packages/views/layout/app-sidebar.tsx@@ -379,12 +379,17 @@ export function AppSidebar({ topSlot, searchSlot, headerClassName, headerStyle }// write (our own optimistic update, or a WS refetch) cannot reorder the// DOM under dnd-kit while its drop animation is still interpolating.const [localPinned, setLocalPinned] = useState<PinnedItem[]>(pinnedItems);+ const [localPinnedWsId, setLocalPinnedWsId] = useState<string | null>(wsId ?? null);const isDraggingRef = useRef(false);useEffect(() => {if (!isDraggingRef.current) {setLocalPinned(pinnedItems);}}, [pinnedItems]);+ useEffect(() => {+ setLocalPinnedWsId(wsId ?? null);+ }, [wsId]);+ const visiblePinned = localPinnedWsId === (wsId ?? null) ? localPinned : EMPTY_PINS;const handleDragStart = useCallback(() => {isDraggingRef.current = true;@@ -639,7 +644,7 @@ export function AppSidebar({ topSlot, searchSlot, headerClassName, headerStyle }</SidebarGroupContent></SidebarGroup>- {localPinned.length > 0 && (+ {visiblePinned.length > 0 && (<Collapsible defaultOpen><SidebarGroup className="group/pinned"><SidebarGroupLabel@@ -648,14 +653,14 @@ export function AppSidebar({ topSlot, searchSlot, headerClassName, headerStyle }><span>{t(($) => $.sidebar.pinned_label)}</span><ChevronRight className="!size-3 ml-1 stroke-[2.5] transition-transform duration-200 group-data-[panel-open]/trigger:rotate-90" />- <span className="ml-auto text-[10px] text-muted-foreground opacity-0 transition-opacity group-hover/pinned:opacity-100">{localPinned.length}</span>+ <span className="ml-auto text-[10px] text-muted-foreground opacity-0 transition-opacity group-hover/pinned:opacity-100">{visiblePinned.length}</span></SidebarGroupLabel><CollapsibleContent><SidebarGroupContent><DndContext sensors={sensors} collisionDetection={closestCenter} onDragStart={handleDragStart} onDragEnd={handleDragEnd}>- <SortableContext items={localPinned.map((p) => p.id)} strategy={verticalListSortingStrategy}>+ <SortableContext items={visiblePinned.map((p) => p.id)} strategy={verticalListSortingStrategy}><SidebarMenu className="gap-0.5">- {localPinned.map((pin: PinnedItem) => (+ {visiblePinned.map((pin: PinnedItem) => (<PinRowkey={pin.id}pin={pin}