mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-25 16:14:26 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Operators use projects to organize and review related tasks. > - The Coordinator sidebar provides quick access to pinned items. > - Project pins were available from Recents after a project visit. > - This PR makes each project pinnable directly from More → Projects. > - Pinned project rows expand in place so operators can open a recent task from the sidebar. ## Linked Issues or Issue Description **What existing behavior does this improve?** Project navigation in the Coordinator workspace. **Subsystem affected** The board UI, specifically the Projects list and the left sidebar. **Current behavior** Users who review work by project must visit a project before they can pin it from Recents. Project rows use a separate expand control. Hidden sidebar controls also reserve space that can truncate project and task names. **Proposed behavior** Give each Coordinator project row a pin action. Let users click the sidebar project row to open or close its recent tasks, and give labels the full available width while row controls are hidden. **Reason and benefit** Users can set up several project shortcuts from one page and reach the tasks they review regularly from the sidebar. ## What Changed - Add pin and unpin actions to Coordinator Projects rows using the existing per-user browser preference. - Make pinned and recent project rows expand and collapse their tasks. Show closed and open folder icons for the two states. - Match nested task spacing to adjacent navigation items and give nested tasks a small indent. - Reserve sidebar label space for controls when they are visible. Keep the project icon and text centered in the Projects list. - Scope project star and join or leave controls to Classic mode. ## Verification - Run `pnpm --filter @paperclipai/ui typecheck`. - Run the focused workspace preference, project query, and pinned navigation Vitest files. - Run `tests/e2e/project-pinning.spec.ts` in Chromium to verify pinning, persistence, label width, expansion, and task navigation. - In Chromium, open More → Projects and pin a project. Reload and confirm the shortcut persists. Expand it using the mouse or keyboard, open a nested task, reorder pins, and unpin from either the list or the sidebar. - Check label widths at rest and with hover, keyboard focus, and touch controls. Check that Classic mode shows the star and membership controls. - GitHub Actions passed on `e96959bffe`, including build, typecheck, and all eight browser shards. Two server shards passed on retry. [CI run](https://github.com/paperclipai/paperclip/actions/runs/45466386598) - Greptile gave the same commit 5/5 with no open review threads. [Review](https://github.com/paperclipai/paperclip/pull/22805#issuecomment-7141648518) ## Risks - Clicking a project row in the Coordinator sidebar now opens its task list in place. Users can still open the full project from the Projects page. - This UI change reuses the existing browser preference and project task query. It requires no database migration. ## Model Used OpenAI Codex with GPT-6.2-Sol. Used local code execution, Chromium, and GitHub CLI. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Scott Tong <scott@scotts-mbp-m5-max.local> Co-authored-by: Paperclip <noreply@paperclip.ing>
83 lines
5.1 KiB
TypeScript
83 lines
5.1 KiB
TypeScript
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors, type DragEndEvent } from "@dnd-kit/core";
|
|
import { SortableContext, arrayMove, sortableKeyboardCoordinates, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
import { CSS } from "@dnd-kit/utilities";
|
|
import { GripVertical, PinOff } from "lucide-react";
|
|
import { RecentTaskNavItem } from "./RecentTaskNavItem";
|
|
import { SidebarNavItem } from "./SidebarNavItem";
|
|
import { cn } from "@/lib/utils";
|
|
import type { Project } from "@paperclipai/shared";
|
|
import { SidebarProjectTasks } from "./SidebarProjectTasks";
|
|
|
|
export type PinnedNavigationItem = { key: string; label: string } & (
|
|
| { project: Pick<Project, "id" | "companyId" | "name"> }
|
|
| { project?: never; to: string; icon: ReactNode; task?: { id: string; identifier: string | null; isUnreadForMe?: boolean } }
|
|
);
|
|
|
|
/** Keep this row mounted when a pin is toggled so its controls retain focus. */
|
|
export function SortablePinnedRow({ id, label, disabled = false, className, handleClassName, handleIconClassName, children, ...props }: Omit<ComponentPropsWithoutRef<"div">, "id" | "children"> & {
|
|
id: string; label: string; disabled?: boolean; handleClassName: string; handleIconClassName: string;
|
|
children: ReactNode | ((handle: ReactNode) => ReactNode);
|
|
}) {
|
|
const sortable = useSortable({ id, disabled, transition: null });
|
|
const handle = !disabled && <button ref={sortable.setActivatorNodeRef} type="button" {...sortable.attributes} {...sortable.listeners}
|
|
aria-label={`Reorder pinned ${label}`} title={`Drag to reorder ${label}`}
|
|
className={cn("absolute top-1/2 flex -translate-y-1/2 touch-none cursor-grab items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity active:cursor-grabbing hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring pointer-coarse:opacity-100", handleClassName)}>
|
|
<GripVertical aria-hidden className={handleIconClassName} />
|
|
</button>;
|
|
return <div {...props} ref={sortable.setNodeRef} style={{ transform: CSS.Transform.toString(sortable.transform) }}
|
|
className={cn(className, !disabled && "select-none", !sortable.isDragging && "motion-safe:transition-transform", sortable.isDragging && "z-10 opacity-80")}
|
|
onDragStart={disabled ? undefined : event => event.preventDefault()}>
|
|
{typeof children === "function" ? children(handle) : <>{children}{handle}</>}
|
|
</div>;
|
|
}
|
|
|
|
function PinnedItem({ item, userId, onUnpin }: { item: PinnedNavigationItem; userId?: string | null; onUnpin: (key: string) => void }) {
|
|
const rowClassName = "design-sidebar-item design-sidebar-pinned-item";
|
|
const row = (primary: ReactNode, handle: ReactNode) => <div className="design-sidebar-pinned-row relative">
|
|
{primary}
|
|
<button type="button" aria-label={`Unpin ${item.label}`} title={`Unpin ${item.label}`}
|
|
onMouseDown={event => event.stopPropagation()} onClick={() => onUnpin(item.key)}
|
|
className="absolute right-10 top-1/2 flex size-7 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:bg-sidebar-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring pointer-coarse:opacity-100"><PinOff className="size-3.5" /></button>
|
|
{handle}
|
|
</div>;
|
|
return <SortablePinnedRow id={item.key} label={item.label} className="relative"
|
|
handleClassName="right-3 size-7" handleIconClassName="size-3.5">
|
|
{handle => {
|
|
if (item.project) {
|
|
return <SidebarProjectTasks project={item.project} userId={userId} className={rowClassName}
|
|
renderRow={toggle => row(toggle, handle)} />;
|
|
}
|
|
const link = { to: item.to, label: item.label, iconNode: item.icon, className: rowClassName };
|
|
return row(item.task ? <RecentTaskNavItem {...link} task={item.task} /> : <SidebarNavItem {...link} />, handle);
|
|
}}
|
|
</SortablePinnedRow>;
|
|
}
|
|
|
|
export function SortablePinnedList({ keys, onReorder, children }: {
|
|
keys: string[]; onReorder?: (keys: string[]) => void; children: ReactNode;
|
|
}) {
|
|
const sensors = useSensors(
|
|
useSensor(PointerSensor, { activationConstraint: { distance: 8 } }),
|
|
useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),
|
|
);
|
|
function move({ active, over }: DragEndEvent) {
|
|
if (!over || active.id === over.id) return;
|
|
const from = keys.indexOf(String(active.id)), to = keys.indexOf(String(over.id));
|
|
if (from >= 0 && to >= 0) onReorder?.(arrayMove(keys, from, to));
|
|
}
|
|
return <DndContext sensors={sensors} collisionDetection={closestCenter} onDragEnd={move}>
|
|
<SortableContext items={keys} strategy={verticalListSortingStrategy}>
|
|
{children}
|
|
</SortableContext>
|
|
</DndContext>;
|
|
}
|
|
|
|
export function PinnedNavigationList({ items, userId, onReorder, onUnpin }: {
|
|
items: PinnedNavigationItem[]; userId?: string | null; onReorder: (keys: string[]) => void; onUnpin: (key: string) => void;
|
|
}) {
|
|
return <SortablePinnedList keys={items.map(item => item.key)} onReorder={onReorder}>
|
|
{items.map(item => <PinnedItem key={item.key} item={item} userId={userId} onUnpin={onUnpin} />)}
|
|
</SortablePinnedList>;
|
|
}
|