Add project pinning to the Coordinator sidebar (#22805)

## 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>
This commit is contained in:
authored and GitHub committed 2026-11-24 11:31:38 -08:00
1 parent cffd17e78a
commit 096060598d
12 files changed
+236 -121

No files matched your search

+6 -3
View File
@@ -114,13 +114,16 @@ marker. Tasks archived from the viewer’s inbox leave Recents. Canceled and
completed tasks remain eligible. Opening a recent task moves its row to the top
of Recents.
Standard Recents also shows recent chats and projects as individual links.
Standard Recents also shows recent chats and projects.
Coordinator Recents lets you pin tasks, agent chats, and projects above More.
The pin button appears on the current row or when a row is hovered or focused
with the keyboard. Shortcuts share the saved order with pinned pages and stay
available as Recents changes.
Project links in Recents and pinned navigation open the project's Tasks tab.
Both locations have a chevron that shows up to 12 recently updated project tasks.
In **More → Projects**, each project row also lets you pin or unpin its sidebar
shortcut without opening the project. Project star and join/leave controls appear
only in the Classic workspace.
In Recents and pinned navigation, clicking a project row opens or closes its
folder to show up to 12 recently updated tasks. Each task links to its detail page.
The task list loads when expanded and keeps the task status and unread markers.
Agent-owned tasks show **In Progress** only while a task-linked run is queued
+45
View File
@@ -0,0 +1,45 @@
import { expect, test } from "@playwright/test";
test("pin a project from the Projects list and open a task from its sidebar row", async ({ page, request }) => {
const createdCompany = await request.post("/api/companies", { data: { name: "Project pinning" } });
expect(createdCompany.ok()).toBe(true);
const company = await createdCompany.json();
const projectName = "Customer onboarding";
const taskTitle = "Review the welcome email";
const createdProject = await request.post(`/api/companies/${company.id}/projects`, {
data: { name: projectName },
});
expect(createdProject.ok()).toBe(true);
const project = await createdProject.json();
const createdTask = await request.post(`/api/companies/${company.id}/issues`, {
data: { title: taskTitle, projectId: project.id, status: "todo" },
});
expect(createdTask.ok()).toBe(true);
const task = await createdTask.json();
const projectsPath = `/${company.issuePrefix}/projects`;
await page.goto(projectsPath);
const main = page.getByRole("main");
const nav = page.getByRole("navigation", { name: "Workspace navigation" });
const folder = nav.getByRole("button", { name: projectName, exact: true });
await main.getByRole("button", { name: `Pin ${projectName}`, exact: true }).click();
await expect(page).toHaveURL((url) => url.pathname === projectsPath);
await expect(folder).toHaveAttribute("aria-expanded", "false");
await page.reload();
await expect(folder).toHaveAttribute("aria-expanded", "false");
const label = folder.locator("[data-cell-marquee]");
const idleWidth = await label.evaluate((element) => element.getBoundingClientRect().width);
await folder.hover();
await expect.poll(() => label.evaluate((element) => element.getBoundingClientRect().width)).toBeLessThan(idleWidth);
await folder.press("Space");
await expect(folder).toHaveAttribute("aria-expanded", "true");
await expect(page).toHaveURL((url) => url.pathname === projectsPath);
await nav.getByRole("link", { name: taskTitle }).click();
await expect(page).toHaveURL((url) => url.pathname.includes(`/issues/${task.identifier}`));
await page.goto(projectsPath);
await main.getByRole("button", { name: `Unpin ${projectName}`, exact: true }).click();
await expect(folder).toHaveCount(0);
});
+1 -3
View File
@@ -1,6 +1,5 @@
import { Pin, PinOff } from "lucide-react";
import { useQuery } from "@tanstack/react-query";
import { useMemo } from "react";
import { authApi } from "@/api/auth";
import { usePinnedNavigation } from "@/hooks/usePinnedNavigation";
import { queryKeys } from "@/lib/queryKeys";
@@ -12,8 +11,7 @@ export function useAgentChatPins() {
const session = useQuery({ queryKey: queryKeys.auth.session, queryFn: () => authApi.getSession() });
const userId = session.data?.user?.id ?? session.data?.session?.userId;
const navigation = usePinnedNavigation(userId);
const keys = useMemo(() => new Set(navigation.pins), [navigation.pins]);
return { keys, orderedKeys: navigation.pins, toggle: navigation.toggle, reorder: navigation.reorder, canPin: navigation.canPin, error: navigation.error };
return { ...navigation, orderedKeys: navigation.pins };
}
export function AgentChatPin({ agent, pins, className }: {
+14 -28
View File
@@ -1,6 +1,6 @@
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react";
import { useQuery } from "@tanstack/react-query";
import { Inbox, Boxes, CircleCheck, Compass, FolderOpen, History, LayoutDashboard, MessageCircle, MoreHorizontal, Network, Pin, PinOff, Plus, Repeat, Search, Settings, SquarePen, Unplug, type LucideIcon } from "lucide-react";
import { Inbox, Boxes, CircleCheck, Compass, Folder, History, LayoutDashboard, MessageCircle, MoreHorizontal, Network, Plus, Repeat, Search, Settings, SquarePen, Unplug, type LucideIcon } from "lucide-react";
import type { Agent, IssueSummary, Project } from "@paperclipai/shared";
import { useCoordinatorAttentionCount } from "@/hooks/useCoordinatorAttentionCount";
import { instanceSettingsApi } from "@/api/instanceSettings";
@@ -8,13 +8,13 @@ import { useAgentChatNavigation } from "@/hooks/useAgentChatNavigation";
import { useResponsibilitiesEnabled } from "@/hooks/useResponsibilitiesEnabled";
import { useRecentTasks } from "@/hooks/useRecentTasks";
import { useRecentTaskOpenWarmup } from "@/hooks/useRecentTaskOpenWarmup";
import { usePinnedNavigation } from "@/hooks/usePinnedNavigation";
import { projectPinKey, usePinnedNavigation } from "@/hooks/usePinnedNavigation";
import { useDialogActions } from "@/context/DialogContext";
import { useSidebar } from "@/context/SidebarContext";
import { queryKeys } from "@/lib/queryKeys";
import type { RecentTaskEntry } from "@/lib/recent-tasks";
import { Link, useLocation } from "@/lib/router";
import { agentRouteRef, cn, projectRouteRef } from "@/lib/utils";
import { agentRouteRef, projectRouteRef } from "@/lib/utils";
import { SidebarCompanyMenu } from "./SidebarCompanyMenu";
import { SidebarNavItem } from "./SidebarNavItem";
import { RecentTaskNavItem, recentTaskPathRef } from "./RecentTaskNavItem";
@@ -30,17 +30,17 @@ import { AgentAvatar } from "./AgentAvatar";
import { agentChatPinKey } from "./AgentChatPin";
import { PinnedNavigationList, type PinnedNavigationItem } from "./PinnedNavigationList";
import { companyProjectsQuery } from "@/lib/company-projects-query";
import { NavigationPinButton, type PinControls } from "./NavigationPinButton";
import { SidebarProjectTasks } from "./SidebarProjectTasks";
const NO_RECENT_TASKS: never[] = [];
const TASK_PIN_ID_PATTERN = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
const taskPinKey = (companyId: string, id: string) => `task:${companyId}:${id}`;
const projectPinKey = (project: Project) => `project:${project.companyId}:${project.id}`;
const moreDestinations = [
{ label: "Search", to: "/search", icon: Search },
{ label: "Dashboard", to: "/dashboard", icon: LayoutDashboard },
{ label: "Projects", to: "/projects", icon: FolderOpen },
{ label: "Projects", to: "/projects", icon: Folder },
{ label: "Routines", to: "/routines", icon: Repeat },
{ label: "Artifacts", to: "/artifacts", icon: Boxes },
{ label: "Agents", to: "/agents/all", icon: Network },
@@ -70,7 +70,7 @@ export function buildPinnedNavigationItems(
}
for (const project of projects) {
const key = projectPinKey(project);
if (keys.has(key)) items.set(key, { key, to: `/projects/${projectRouteRef(project)}/issues`, label: project.name, icon: <FolderOpen className="size-4" />, project });
if (keys.has(key)) items.set(key, { key, label: project.name, project });
}
return pins.flatMap(key => {
const item = items.get(key);
@@ -78,24 +78,13 @@ export function buildPinnedNavigationItems(
});
}
type PinControls = { keys: ReadonlySet<string>; canPin: boolean; toggle: (key: string) => void };
type RecentTaskLink = Omit<RecentTaskEntry, "recordedAt">;
function NavigationPinButton({ pinKey, label, pins, className }: { pinKey: string; label: string; pins: PinControls; className: string }) {
const pinned = pins.keys.has(pinKey);
const Icon = pinned ? PinOff : Pin;
const actionLabel = `${pinned ? "Unpin" : "Pin"} ${label}`;
return <button type="button" aria-label={actionLabel} title={actionLabel} aria-pressed={pinned} disabled={!pins.canPin}
onClick={() => pins.toggle(pinKey)} className={cn("absolute top-1/2 flex -translate-y-1/2 items-center justify-center rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground", pinned ? "text-foreground" : "text-muted-foreground", className)}>
<Icon aria-hidden className="size-3.5" />
</button>;
}
function RecentPinRow({ pinKey, label, pins, children }: { pinKey: string; label: string; pins: PinControls; children: ReactNode }) {
if (!pins.canPin) return <>{children}</>;
return <div className="design-sidebar-pin-target relative min-w-0">
{children}
<NavigationPinButton pinKey={pinKey} label={label} pins={pins} className="right-3 size-7" />
<NavigationPinButton pinKey={pinKey} label={label} pins={pins} className="absolute right-3 top-1/2 size-7 -translate-y-1/2" />
</div>;
}
@@ -134,8 +123,6 @@ export function CoordinatorSidebar({ children }: { children?: ReactNode }) {
const { companyId, userId, agents, chats, session } = useAgentChatNavigation();
const unreadChatCount = chats.data?.filter(chat => chat.isUnreadForMe).length ?? 0;
const pinnedNavigation = usePinnedNavigation(userId);
const pinKeys = useMemo(() => new Set(pinnedNavigation.pins), [pinnedNavigation.pins]);
const pins = { keys: pinKeys, canPin: pinnedNavigation.canPin, toggle: pinnedNavigation.toggle };
const pinnedTaskIds = useMemo(() => {
if (!companyId || !session.isSuccess) return [];
const prefix = taskPinKey(companyId, "");
@@ -224,7 +211,7 @@ export function CoordinatorSidebar({ children }: { children?: ReactNode }) {
<Link to={to} onClick={() => { setMoreOpen(false); if (isMobile) setSidebarOpen(false); }} className="flex min-w-0 flex-1 items-center gap-2 rounded-sm px-2 py-1.5 pr-10 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring">
<Icon className="size-4 shrink-0 text-muted-foreground" />{label}
</Link>
<NavigationPinButton pinKey={to} label={label} pins={pins} className="right-0.5 size-8 rounded-sm opacity-0 transition-opacity group-hover/navigation-pin:opacity-100 group-focus-within/navigation-pin:opacity-100 pointer-coarse:opacity-100" />
<NavigationPinButton pinKey={to} label={label} pins={pinnedNavigation} className="absolute right-0.5 top-1/2 size-8 -translate-y-1/2 rounded-sm opacity-0 transition-opacity group-hover/navigation-pin:opacity-100 group-focus-within/navigation-pin:opacity-100 pointer-coarse:opacity-100" />
</div>
</div>)}
</FlyoutContent>
@@ -234,17 +221,16 @@ export function CoordinatorSidebar({ children }: { children?: ReactNode }) {
{session.isSuccess && recents.length > 0 && <div className="design-sidebar-recents"><SidebarSection label="Recents" collapsible={{ open: recentsOpen, onOpenChange: setRecentsOpen }}>
<RecentNavigationList>
{recents.map(item => item.kind === "task"
? <RecentTaskPinRow key={`${scope}:${item.id}`} task={item.task} pins={pins} />
? <RecentTaskPinRow key={`${scope}:${item.id}`} task={item.task} pins={pinnedNavigation} />
: item.kind === "chat"
? <RecentPinRow key={item.id} pinKey={agentChatPinKey(item.agent.companyId, item.agent.id)} label={item.agent.name} pins={pins}>
? <RecentPinRow key={item.id} pinKey={agentChatPinKey(item.agent.companyId, item.agent.id)} label={item.agent.name} pins={pinnedNavigation}>
<SidebarNavItem className="design-sidebar-item" to={`/chats/${encodeURIComponent(agentRouteRef(item.agent))}`} label={item.agent.name} iconNode={<AgentAvatar agent={item.agent} size={16} />} />
</RecentPinRow>
: <SidebarProjectTasks key={`${scope}:${item.id}`} project={item.project} userId={userId}
renderTask={task => <RecentTaskPinRow task={task} pins={pins} />}>
<RecentPinRow pinKey={projectPinKey(item.project)} label={item.project.name} pins={pins}>
<SidebarNavItem className="design-sidebar-item" to={`/projects/${projectRouteRef(item.project)}/issues`} label={item.project.name} icon={FolderOpen} />
</RecentPinRow>
</SidebarProjectTasks>)}
renderTask={task => <RecentTaskPinRow task={task} pins={pinnedNavigation} />}
renderRow={toggle => <RecentPinRow pinKey={projectPinKey(item.project)} label={item.project.name} pins={pinnedNavigation}>
{toggle}
</RecentPinRow>} />)}
</RecentNavigationList>
</SidebarSection></div>}
{children}
+1 -5
View File
@@ -23,7 +23,6 @@ interface EntityRowProps {
titleClassName?: string;
titleTextClassName?: string;
subtitleClassName?: string;
reserveSubtitleSpace?: boolean;
/**
* Make the title (the row's primary identifier) win the flex fight: it keeps a
* usable min-width floor and ellipsizes, while the `meta` cluster is the item
@@ -59,7 +58,6 @@ export function EntityRow({
titleClassName,
titleTextClassName,
subtitleClassName,
reserveSubtitleSpace,
titlePriority,
secondaryRow,
secondaryRowClassName,
@@ -98,15 +96,13 @@ export function EntityRow({
</span>
{titleAccessory}
</div>
{(subtitle || reserveSubtitleSpace) && (
{Boolean(subtitle) && (
<p
className={cn(
"text-xs text-muted-foreground mt-0.5 min-h-4",
!subtitleClassName && "truncate",
subtitleClassName,
!subtitle && "invisible",
)}
aria-hidden={!subtitle}
>
{subtitle}
</p>
+40
View File
@@ -0,0 +1,40 @@
import { Pin, PinOff } from "lucide-react";
import { cn } from "@/lib/utils";
import type { usePinnedNavigation } from "@/hooks/usePinnedNavigation";
export type PinControls = Pick<ReturnType<typeof usePinnedNavigation>, "keys" | "canPin" | "toggle">;
interface NavigationPinButtonProps {
pinKey: string;
label: string;
pins: PinControls;
className: string;
}
export function NavigationPinButton({ pinKey, label, pins, className }: NavigationPinButtonProps) {
const pinned = pins.keys.has(pinKey);
const Icon = pinned ? PinOff : Pin;
const action = `${pinned ? "Unpin" : "Pin"} ${label}`;
return (
<button
type="button"
aria-label={action}
title={`${action} ${pinned ? "from" : "to"} sidebar`}
aria-pressed={pinned}
disabled={!pins.canPin}
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
pins.toggle(pinKey);
}}
className={cn(
"flex items-center justify-center rounded-md outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
pinned ? "text-foreground" : "text-muted-foreground",
className,
)}
>
<Icon aria-hidden className="size-3.5" />
</button>
);
}
+19 -16
View File
@@ -9,14 +9,10 @@ import { cn } from "@/lib/utils";
import type { Project } from "@paperclipai/shared";
import { SidebarProjectTasks } from "./SidebarProjectTasks";
export interface PinnedNavigationItem {
key: string;
to: string;
label: string;
icon: ReactNode;
task?: { id: string; identifier: string | null; isUnreadForMe?: boolean };
project?: Pick<Project, "id" | "companyId" | "name">;
}
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"> & {
@@ -37,17 +33,24 @@ export function SortablePinnedRow({ id, label, disabled = false, className, hand
}
function PinnedItem({ item, userId, onUnpin }: { item: PinnedNavigationItem; userId?: string | null; onUnpin: (key: string) => void }) {
const link = { to: item.to, label: item.label, iconNode: item.icon, className: "design-sidebar-item design-sidebar-pinned-item group-hover/coordinator-pin:bg-sidebar-accent" };
const row = (handle: ReactNode) => <>
{item.task ? <RecentTaskNavItem {...link} task={item.task} /> : <SidebarNavItem {...link} />}
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 group-hover/coordinator-pin:opacity-100 group-focus-within/coordinator-pin:opacity-100 pointer-coarse:opacity-100"><PinOff className="size-3.5" /></button>
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}
</>;
return <SortablePinnedRow id={item.key} label={item.label} className="group/coordinator-pin relative"
handleClassName="right-3 size-7 group-hover/coordinator-pin:opacity-100 group-focus-within/coordinator-pin:opacity-100" handleIconClassName="size-3.5">
{handle => item.project ? <SidebarProjectTasks project={item.project} userId={userId}>{row(handle)}</SidebarProjectTasks> : row(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>;
}
+19 -12
View File
@@ -1,18 +1,20 @@
import { useId, useState, type ReactNode } from "react";
import { useQuery } from "@tanstack/react-query";
import { ChevronRight } from "lucide-react";
import { Folder, FolderOpen } from "lucide-react";
import type { Issue, Project } from "@paperclipai/shared";
import { issuesApi } from "@/api/issues";
import { queryKeys } from "@/lib/queryKeys";
import { cn } from "@/lib/utils";
import { taskStatusIconProps } from "@/lib/task-status-presentation";
import { RecentTaskNavItem } from "./RecentTaskNavItem";
import { TruncatedText } from "./TruncatedText";
import { StatusIcon } from "./StatusIcon";
export function SidebarProjectTasks({ project, userId, children, renderTask }: {
export function SidebarProjectTasks({ project, userId, renderRow, className, renderTask }: {
project: Pick<Project, "id" | "companyId" | "name">;
userId?: string | null;
children: ReactNode;
renderRow: (toggle: ReactNode) => ReactNode;
className?: string;
renderTask?: (task: Issue) => ReactNode;
}) {
const [expanded, setExpanded] = useState(false);
@@ -24,16 +26,21 @@ export function SidebarProjectTasks({ project, userId, children, renderTask }: {
}, { signal }),
enabled: expanded,
});
return <div>
<div className="flex min-w-0 items-center">
<div className="relative min-w-0 flex-1">{children}</div>
<button type="button" aria-label={`${expanded ? "Collapse" : "Expand"} ${project.name}`} aria-expanded={expanded} aria-controls={contentId}
className="mr-2 flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-ring"
onClick={() => setExpanded(previous => !previous)}>
<ChevronRight aria-hidden className={cn("size-3.5 transition-transform", expanded && "rotate-90")} />
const FolderIcon = expanded ? FolderOpen : Folder;
return <div className="design-sidebar-primary">
{renderRow(
<button
type="button"
aria-expanded={expanded}
aria-controls={expanded ? contentId : undefined}
onClick={() => setExpanded(previous => !previous)}
className={cn("design-sidebar-item design-sidebar-project-toggle flex items-center gap-2.5 rounded-lg py-1.5 text-left font-medium focus-visible:outline-ring", className)}
>
<FolderIcon aria-hidden className="size-4 shrink-0" />
<TruncatedText className="min-w-0 flex-1 truncate">{project.name}</TruncatedText>
</button>
</div>
{expanded && <div id={contentId} className="ml-5 border-l border-border pl-1">
)}
{expanded && <div id={contentId} className="design-sidebar-primary ms-2">
{isPending ? <p className="px-3 py-2 text-xs text-muted-foreground" role="status">Loading tasks…</p>
: error ? <p className="px-3 py-2 text-xs text-muted-foreground" role="alert">Couldn’t load tasks.</p>
: tasks?.length ? tasks.map(task => <div key={task.id}>{renderTask ? renderTask(task)
+7 -1
View File
@@ -1,5 +1,9 @@
import { useCallback, useMemo, useState, useSyncExternalStore } from "react";
export function projectPinKey(project: { companyId: string; id: string }) {
return `project:${project.companyId}:${project.id}`;
}
const UPDATED = "paperclip:pinned-navigation-updated";
const EMPTY = "[]";
@@ -29,6 +33,8 @@ export function usePinnedNavigation(userId: string | null | undefined) {
const snapshot = useSyncExternalStore(subscribe, () => read(key), () => EMPTY);
const pins = useMemo(() => parse(snapshot), [snapshot]);
const keys = useMemo(() => new Set(pins), [pins]);
function save(next: string[]) {
if (!key) return;
try {
@@ -56,5 +62,5 @@ export function usePinnedNavigation(userId: string | null | undefined) {
save(current.map(entry => visible.has(entry) ? ordered[index++] : entry));
}
return { pins, toggle, reorder, canPin: !!key, error: failure?.key === key ? failure.message : null };
return { pins, keys, toggle, reorder, canPin: !!key, error: failure?.key === key ? failure.message : null };
}
+13 -5
View File
@@ -4832,13 +4832,21 @@ html:has(.design-proposal-theme) .design-navigation-group-label {
color: color-mix(in oklab, var(--muted-foreground) 60%, transparent);
}
.design-sidebar .design-sidebar-item { min-height: var(--design-sidebar-item-height); margin-inline: var(--design-sidebar-item-inset); padding-inline: var(--design-sidebar-item-inset); color: var(--design-sidebar-item-foreground); font-size: var(--design-sidebar-label-size); line-height: var(--design-sidebar-label-leading); }
.design-sidebar-pin-target > .design-sidebar-item { padding-inline-end: calc(var(--spacing) * 10); }
.design-sidebar .design-sidebar-pinned-item { padding-inline-end: calc(var(--spacing) * 16); }
.design-sidebar-project-toggle { width: calc(100% - var(--design-sidebar-item-inset) * 2); }
.design-sidebar .design-sidebar-item:is(:hover, [aria-current="page"]) { background: var(--design-sidebar-item-highlight); color: var(--design-sidebar-item-active-foreground); }
.design-sidebar-pin-target > button { opacity: 0; pointer-events: none; }
.design-sidebar-pin-target > [aria-pressed] { opacity: 0; pointer-events: none; }
.design-sidebar-pin-target:is(:hover, :has(> [aria-current="page"], > :focus-visible)) {
> .design-sidebar-item { background: var(--design-sidebar-item-highlight); color: var(--design-sidebar-item-active-foreground); }
> button { opacity: 1; pointer-events: auto; }
> .design-sidebar-item { padding-inline-end: calc(var(--spacing) * 10); background: var(--design-sidebar-item-highlight); color: var(--design-sidebar-item-active-foreground); }
> [aria-pressed] { opacity: 1; pointer-events: auto; }
}
.design-sidebar-pinned-row > button:not(.design-sidebar-item) { pointer-events: none; }
.design-sidebar-pinned-row:is(:hover, :focus-within) {
> .design-sidebar-pinned-item { padding-inline-end: calc(var(--spacing) * 16); background: var(--design-sidebar-item-highlight); }
> button:not(.design-sidebar-item) { opacity: 1; pointer-events: auto; }
}
@media (pointer: coarse) {
.design-sidebar-pinned-row > .design-sidebar-pinned-item { padding-inline-end: calc(var(--spacing) * 16); }
.design-sidebar-pinned-row > button:not(.design-sidebar-item) { pointer-events: auto; }
}
.design-sidebar-new-task { display: flex; justify-content: flex-start; width: calc(100% - var(--design-sidebar-item-inset) * 2); height: var(--design-sidebar-item-height); margin-inline: var(--design-sidebar-item-inset); padding-inline: var(--design-sidebar-item-inset); gap: calc(var(--spacing) * 2.5); font-size: var(--design-sidebar-label-size); line-height: var(--design-sidebar-label-leading); font-weight: var(--font-weight-medium); color: var(--design-sidebar-item-foreground); }
.design-sidebar-new-task svg { width: var(--design-page-icon-size); height: var(--design-page-icon-size); }
+20 -15
View File
@@ -29,6 +29,7 @@ import { PageTabBar } from "../components/PageTabBar";
import { ProjectWorkspacesContent } from "../components/ProjectWorkspacesContent";
import { SummarySlotCard } from "../components/SummarySlotCard";
import { MembershipAction } from "../components/MembershipAction";
import { useCoordinatorWorkspaceEnabled } from "../hooks/useCoordinatorWorkspaceEnabled";
import { StarToggle } from "../components/StarToggle";
import { buildProjectWorkspaceSummaries } from "../lib/project-workspaces-tab";
import { collectLiveIssueIds } from "../lib/liveIssueIds";
@@ -334,6 +335,8 @@ export function ProjectDetail() {
filter?: string;
}>();
const { companies, selectedCompanyId, setSelectedCompanyId } = useCompany();
const workspace = useCoordinatorWorkspaceEnabled();
const classicWorkspace = workspace.loaded && !workspace.enabled;
const { closePanel } = usePanel();
const { setBreadcrumbs } = useBreadcrumbs();
const { pushToast } = useToastActions();
@@ -714,7 +717,7 @@ export function ProjectDetail() {
}
if (!project) return null;
const showLeftProjectNotice =
projectMembershipState === "left" && !dismissedLeftProjectIds.has(project.id);
classicWorkspace && projectMembershipState === "left" && !dismissedLeftProjectIds.has(project.id);
const projectMembershipPending =
membershipMutation.isPending &&
membershipMutation.variables?.resourceType === "project" &&
@@ -810,20 +813,22 @@ export function ProjectDetail() {
</div>
) : null}
</div>
<div className="ml-auto flex items-center gap-2">
<StarToggle
size="button"
starred={projectStarred}
pending={projectStarPending}
resourceName={project.name}
onToggle={(next) => membershipMutation.mutate({
resourceType: "project",
resourceId: project.id,
resourceName: project.name,
starred: next,
})}
/>
</div>
{classicWorkspace && (
<div className="ml-auto flex items-center gap-2">
<StarToggle
size="button"
starred={projectStarred}
pending={projectStarPending}
resourceName={project.name}
onToggle={(next) => membershipMutation.mutate({
resourceType: "project",
resourceId: project.id,
resourceName: project.name,
starred: next,
})}
/>
</div>
)}
</div>
<SummarySlotCard
+51 -33
View File
@@ -5,6 +5,9 @@ import { useCompany } from "../context/CompanyContext";
import { useDialogActions } from "../context/DialogContext";
import { useBreadcrumbs } from "../context/BreadcrumbContext";
import { EntityRow } from "../components/EntityRow";
import { NavigationPinButton } from "../components/NavigationPinButton";
import { useCoordinatorWorkspaceEnabled } from "../hooks/useCoordinatorWorkspaceEnabled";
import { projectPinKey, usePinnedNavigation } from "../hooks/usePinnedNavigation";
import { ProjectTile } from "../components/ProjectTile";
import { StatusBadge } from "../components/StatusBadge";
import { MembershipAction } from "../components/MembershipAction";
@@ -69,6 +72,8 @@ function sortProjects(projects: Project[], sortField: ProjectSortField, sortDir:
export function Projects() {
const { selectedCompanyId } = useCompany();
const workspace = useCoordinatorWorkspaceEnabled();
const pins = usePinnedNavigation(workspace.enabled && workspace.loaded ? workspace.userId : null);
const { openNewProject } = useDialogActions();
const { setBreadcrumbs } = useBreadcrumbs();
const [query, setQuery] = useState("");
@@ -143,6 +148,8 @@ export function Projects() {
<ProjectsToolbar query={query} onQueryChange={setQuery} sortField={sortField} sortDir={sortDir}
onSortChange={(field, direction) => { setSortField(field); setSortDir(direction); }} onNewProject={openNewProject} />
{pins.error && <p role="alert" className="text-sm text-destructive">{pins.error}</p>}
{!isLoading && projects.length === 0 && (
<EmptyState
icon={Hexagon}
@@ -186,10 +193,9 @@ export function Projects() {
key={project.id}
leading={<ProjectTile color={project.color ?? null} icon={project.icon ?? null} size="sm" />}
title={project.name}
subtitle={project.description ?? undefined}
reserveSubtitleSpace
subtitle={project.description?.trim() || undefined}
to={projectUrl(project)}
className={state === "left" ? "group text-foreground/55" : "group"}
className={state === "left" ? "group min-h-14 text-foreground/55" : "group min-h-14"}
trailing={
<div className="flex items-center gap-3">
{project.visibility === "private" ? <Lock className="size-4 shrink-0 text-muted-foreground" aria-label="Private project" /> : null}
@@ -210,36 +216,48 @@ export function Projects() {
</span>
)}
<StatusBadge status={project.status} />
<MembershipAction
state={state}
pending={joinLeavePending}
pendingState={joinLeavePending ? membershipMutation.variables?.state : null}
resourceName={project.name}
onJoin={() => membershipMutation.mutate({
resourceType: "project",
resourceId: project.id,
resourceName: project.name,
state: "joined",
})}
onLeave={() => membershipMutation.mutate({
resourceType: "project",
resourceId: project.id,
resourceName: project.name,
state: "left",
})}
/>
<StarToggle
size="row"
starred={starred}
pending={starPending}
resourceName={project.name}
onToggle={(next) => membershipMutation.mutate({
resourceType: "project",
resourceId: project.id,
resourceName: project.name,
starred: next,
})}
/>
{pins.canPin && (
<NavigationPinButton
pinKey={projectPinKey(project)}
label={project.name}
pins={pins}
className="size-6 shrink-0 hover:bg-accent"
/>
)}
{workspace.loaded && !workspace.enabled && (
<>
<MembershipAction
state={state}
pending={joinLeavePending}
pendingState={joinLeavePending ? membershipMutation.variables?.state : null}
resourceName={project.name}
onJoin={() => membershipMutation.mutate({
resourceType: "project",
resourceId: project.id,
resourceName: project.name,
state: "joined",
})}
onLeave={() => membershipMutation.mutate({
resourceType: "project",
resourceId: project.id,
resourceName: project.name,
state: "left",
})}
/>
<StarToggle
size="row"
starred={starred}
pending={starPending}
resourceName={project.name}
onToggle={(next) => membershipMutation.mutate({
resourceType: "project",
resourceId: project.id,
resourceName: project.name,
starred: next,
})}
/>
</>
)}
</div>
}
/>