mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-23 00:53:38 +02:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The board UI has been graduating experimental conference-room task experiences into the default issue and onboarding flows > - Several task UI improvements were still coupled to the Conference Room Chat experimental flag even though they are useful outside chat itself > - That coupling meant disabling chat also reverted unrelated defaults such as work-mode labels, task status colors, team creation copy, and the graduated issue thread > - This pull request keeps chat-specific gating scoped to chat while making the graduated task UI the default experience > - The benefit is that operators can use the newer task workflows without needing to enable the separate chat experiment ## Linked Issues or Issue Description No public GitHub issue exists for this exact change. ### Problem or motivation The Conference Room Chat experimental flag was controlling unrelated task UI defaults, which made non-chat workflows regress when chat was disabled. ### Proposed solution Remove that flag from task-thread, work-mode, onboarding, status, and team-creation presentation paths while leaving chat-specific behavior separately gated. ### Alternatives considered Keeping the flag as a broad umbrella until chat graduates would avoid a behavior change, but it keeps unrelated UI improvements hidden behind the wrong capability switch. ### Roadmap alignment Checked `ROADMAP.md`; this is focused graduation/polish for existing UI surfaces rather than a new roadmap-level core feature. Related search: - Searched open PRs and issues for `conference room chat experimental flag`: no matches. - Searched open PRs and issues for `graduated issue thread`: no matches. ## What Changed - Removes Conference Room Chat flag branching from task-thread rendering, work-mode labels, task status colors, and team creation copy. - Makes the onboarding completion path create/reuse an onboarding project, create the first assigned task, and send the user to the dashboard instead of chat. - Deletes the legacy onboarding wizard and classic task-thread files now that the graduated flow is the default. - Updates focused UI tests and affected E2E specs for the default task experience. - Adds a user-visible onboarding error if restored state is missing the company or agent required for launch. ## Verification - `pnpm run preflight:workspace-links && pnpm exec vitest run ui/src/components/NewIssueDialog.test.tsx ui/src/components/OnboardingWizardVariant.test.tsx ui/src/components/RunChatSurface.test.tsx ui/src/components/SidebarCompanyMenu.test.tsx ui/src/components/StatusBadge.test.tsx ui/src/lib/agent-order.test.ts ui/src/lib/onboarding-launch.test.ts ui/src/lib/work-mode-meta.test.ts ui/src/pages/IssueDetail.test.tsx` - `pnpm --filter @paperclipai/ui typecheck` - `npx playwright test --config tests/e2e/playwright.config.ts --list tests/e2e/conference-room-typing-intro.spec.ts tests/e2e/planning-mode-visual-verification.spec.ts` - Attempted targeted Playwright execution locally, but this host is missing Chromium system libraries (`libatk1.0-0t64`, `libatspi2.0-0t64`, `libxcomposite1`, `libxdamage1`, `libxfixes3`, `libxrandr2`, `libgbm1`, `libasound2t64`). CI runs the specs in the proper Actions environment. ## Risks - Medium UI behavior risk: this intentionally changes the default experience for users who have not enabled Conference Room Chat. - Medium onboarding risk: completion now creates/reuses a project and creates the first task instead of only navigating. - Low migration risk: no database schema or migration changes are included. - The PR avoids `pnpm-lock.yaml` and `.github/workflows` changes. ## Model Used OpenAI Codex, GPT-5-class coding model, tool-enabled local repository workflow with shell, git, and test execution. ## 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: Paperclip <noreply@paperclip.ing>
346 lines
11 KiB
TypeScript
346 lines
11 KiB
TypeScript
import { useCallback, useMemo, useState } from "react";
|
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
import {
|
|
Check,
|
|
ChevronsUpDown,
|
|
GripVertical,
|
|
LogOut,
|
|
Plus,
|
|
Settings,
|
|
UserPlus,
|
|
} from "lucide-react";
|
|
import {
|
|
DndContext,
|
|
MouseSensor,
|
|
TouchSensor,
|
|
closestCenter,
|
|
type DragEndEvent,
|
|
useSensor,
|
|
useSensors,
|
|
} from "@dnd-kit/core";
|
|
import { SortableContext, arrayMove, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
import { CSS } from "@dnd-kit/utilities";
|
|
import type { Company } from "@paperclipai/shared";
|
|
import { Link, useLocation, useNavigate } from "@/lib/router";
|
|
import { authApi } from "@/api/auth";
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuLabel,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import { useCompany } from "@/context/CompanyContext";
|
|
import { useDialogActions } from "@/context/DialogContext";
|
|
import { useCompanyOrder } from "@/hooks/useCompanyOrder";
|
|
import { queryKeys } from "@/lib/queryKeys";
|
|
import { cn, SIDEBAR_RAIL_HIDDEN_LABEL } from "@/lib/utils";
|
|
import { useSidebar } from "../context/SidebarContext";
|
|
import { CompanyPatternIcon } from "./CompanyPatternIcon";
|
|
|
|
interface SidebarCompanyMenuProps {
|
|
open?: boolean;
|
|
onOpenChange?: (open: boolean) => void;
|
|
}
|
|
|
|
function WorkspaceIcon({ company }: { company: Company }) {
|
|
return (
|
|
<CompanyPatternIcon
|
|
companyName={company.name}
|
|
logoUrl={company.logoUrl}
|
|
brandColor={company.brandColor}
|
|
className="size-5 shrink-0 rounded-md text-[11px]"
|
|
/>
|
|
);
|
|
}
|
|
|
|
function SortableCompanyItem({
|
|
company,
|
|
isEditing,
|
|
isSelected,
|
|
onSelect,
|
|
}: {
|
|
company: Company;
|
|
isEditing: boolean;
|
|
isSelected: boolean;
|
|
onSelect: (company: Company) => void;
|
|
}) {
|
|
const {
|
|
attributes,
|
|
listeners,
|
|
setActivatorNodeRef,
|
|
setNodeRef,
|
|
transform,
|
|
transition,
|
|
isDragging,
|
|
} = useSortable({ id: company.id, disabled: !isEditing });
|
|
|
|
return (
|
|
<DropdownMenuItem
|
|
ref={setNodeRef}
|
|
style={{
|
|
transform: CSS.Transform.toString(transform),
|
|
transition,
|
|
zIndex: isDragging ? 10 : undefined,
|
|
}}
|
|
onSelect={(event) => {
|
|
if (isEditing) {
|
|
event.preventDefault();
|
|
return;
|
|
}
|
|
onSelect(company);
|
|
}}
|
|
className={cn(
|
|
"min-w-0 gap-2 py-2",
|
|
isEditing && "cursor-grab",
|
|
isDragging && "opacity-80",
|
|
isSelected && "bg-accent text-accent-foreground",
|
|
)}
|
|
>
|
|
<WorkspaceIcon company={company} />
|
|
<span className="min-w-0 flex-1 truncate">{company.name}</span>
|
|
{isEditing ? (
|
|
<button
|
|
type="button"
|
|
ref={setActivatorNodeRef}
|
|
aria-label={`Reorder ${company.name}`}
|
|
className="inline-flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-[2px] focus-visible:ring-ring"
|
|
onClick={(event) => {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
}}
|
|
{...attributes}
|
|
{...listeners}
|
|
>
|
|
<GripVertical className="size-4" aria-hidden="true" />
|
|
</button>
|
|
) : (
|
|
<>
|
|
<span className="shrink-0 rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground">
|
|
{company.issuePrefix}
|
|
</span>
|
|
{isSelected ? <Check className="size-4 text-muted-foreground" /> : null}
|
|
</>
|
|
)}
|
|
</DropdownMenuItem>
|
|
);
|
|
}
|
|
|
|
export function SidebarCompanyMenu({ open: controlledOpen, onOpenChange }: SidebarCompanyMenuProps = {}) {
|
|
const [internalOpen, setInternalOpen] = useState(false);
|
|
const [isEditingOrder, setIsEditingOrder] = useState(false);
|
|
const queryClient = useQueryClient();
|
|
const { companies, selectedCompany, setSelectedCompanyId } = useCompany();
|
|
const { openOnboarding } = useDialogActions();
|
|
const { isMobile, setSidebarOpen, collapsed, peeking } = useSidebar();
|
|
const rail = collapsed && !peeking;
|
|
const location = useLocation();
|
|
const navigate = useNavigate();
|
|
const open = controlledOpen ?? internalOpen;
|
|
const setOpen = onOpenChange ?? setInternalOpen;
|
|
const sensors = useSensors(
|
|
useSensor(MouseSensor, {
|
|
activationConstraint: { distance: 8 },
|
|
}),
|
|
useSensor(TouchSensor, {
|
|
activationConstraint: { delay: 180, tolerance: 6 },
|
|
}),
|
|
);
|
|
const sidebarCompanies = useMemo(
|
|
() => companies.filter((company) => company.status !== "archived"),
|
|
[companies],
|
|
);
|
|
const { data: session } = useQuery({
|
|
queryKey: queryKeys.auth.session,
|
|
queryFn: () => authApi.getSession(),
|
|
retry: false,
|
|
});
|
|
const currentUserId = session?.user?.id ?? session?.session?.userId ?? null;
|
|
const { orderedCompanies, persistOrder } = useCompanyOrder({
|
|
companies: sidebarCompanies,
|
|
userId: currentUserId,
|
|
});
|
|
|
|
const signOutMutation = useMutation({
|
|
mutationFn: () => authApi.signOut(),
|
|
onSuccess: async () => {
|
|
setOpen(false);
|
|
if (isMobile) setSidebarOpen(false);
|
|
await queryClient.invalidateQueries({ queryKey: queryKeys.auth.session });
|
|
},
|
|
});
|
|
|
|
function handleOpenChange(nextOpen: boolean) {
|
|
if (!nextOpen) setIsEditingOrder(false);
|
|
setOpen(nextOpen);
|
|
}
|
|
|
|
function closeNavigationChrome() {
|
|
setOpen(false);
|
|
setIsEditingOrder(false);
|
|
if (isMobile) setSidebarOpen(false);
|
|
}
|
|
|
|
function selectCompany(company: Company) {
|
|
const pathPrefix = location.pathname.split("/")[1]?.toUpperCase();
|
|
const isCompanyRoute = sidebarCompanies.some((sidebarCompany) => (
|
|
sidebarCompany.issuePrefix.toUpperCase() === pathPrefix
|
|
));
|
|
const shouldLeaveCurrentRoute = company.id !== selectedCompany?.id
|
|
&& (location.pathname.startsWith("/instance/") || isCompanyRoute);
|
|
|
|
setSelectedCompanyId(company.id);
|
|
setOpen(false);
|
|
if (isMobile) setSidebarOpen(false);
|
|
if (shouldLeaveCurrentRoute) {
|
|
navigate(`/${company.issuePrefix}/dashboard`);
|
|
}
|
|
}
|
|
|
|
function addCompany() {
|
|
setOpen(false);
|
|
if (isMobile) setSidebarOpen(false);
|
|
openOnboarding();
|
|
}
|
|
|
|
const handleDragEnd = useCallback(
|
|
(event: DragEndEvent) => {
|
|
const { active, over } = event;
|
|
if (!over || active.id === over.id) return;
|
|
|
|
const ids = orderedCompanies.map((company) => company.id);
|
|
const oldIndex = ids.indexOf(active.id as string);
|
|
const newIndex = ids.indexOf(over.id as string);
|
|
if (oldIndex === -1 || newIndex === -1) return;
|
|
|
|
persistOrder(arrayMove(ids, oldIndex, newIndex));
|
|
},
|
|
[orderedCompanies, persistOrder],
|
|
);
|
|
|
|
return (
|
|
<DropdownMenu open={open} onOpenChange={handleOpenChange}>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
variant="ghost"
|
|
// `px-3` (not px-2) so the logo's left edge lines up with the nav icon
|
|
// column (nav px-3 + item px-3) and, crucially, stays put between states:
|
|
// the Button's default size adds `has-[>svg]:px-3`, so with the chevron
|
|
// svg present (expanded) it was already 12px but without it (rail) it fell
|
|
// back to 8px — a 4px horizontal jump on collapse (PAP-10676).
|
|
className="h-9 flex-1 justify-start gap-2 px-3 text-left"
|
|
aria-label={selectedCompany ? `Open ${selectedCompany.name} workspace switcher` : "Open workspace switcher"}
|
|
>
|
|
<span className="flex min-w-0 flex-1 items-center gap-2">
|
|
{selectedCompany ? <WorkspaceIcon company={selectedCompany} /> : null}
|
|
<span className={cn("truncate text-sm font-bold text-foreground", rail && SIDEBAR_RAIL_HIDDEN_LABEL)}>
|
|
{selectedCompany?.name ?? "Select workspace"}
|
|
</span>
|
|
</span>
|
|
{!rail && <ChevronsUpDown className="size-3.5 shrink-0 text-muted-foreground" />}
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="start" sideOffset={8} className="w-64 p-1">
|
|
<div className="flex items-center justify-between gap-2 px-2 py-1.5">
|
|
<DropdownMenuLabel className="p-0 text-[11px] font-semibold uppercase text-muted-foreground">
|
|
Switch workspace
|
|
</DropdownMenuLabel>
|
|
<button
|
|
type="button"
|
|
onClick={(event) => {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
setIsEditingOrder((current) => !current);
|
|
}}
|
|
className="rounded px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
|
|
>
|
|
{isEditingOrder ? "Done" : "Edit"}
|
|
</button>
|
|
</div>
|
|
<div className="max-h-96 overflow-y-auto">
|
|
<DndContext
|
|
sensors={sensors}
|
|
collisionDetection={closestCenter}
|
|
onDragEnd={handleDragEnd}
|
|
>
|
|
<SortableContext
|
|
items={orderedCompanies.map((company) => company.id)}
|
|
strategy={verticalListSortingStrategy}
|
|
>
|
|
{orderedCompanies.map((company) => (
|
|
<SortableCompanyItem
|
|
key={company.id}
|
|
company={company}
|
|
isEditing={isEditingOrder}
|
|
isSelected={company.id === selectedCompany?.id}
|
|
onSelect={selectCompany}
|
|
/>
|
|
))}
|
|
</SortableContext>
|
|
</DndContext>
|
|
{orderedCompanies.length === 0 ? (
|
|
<DropdownMenuItem disabled>No workspaces</DropdownMenuItem>
|
|
) : null}
|
|
</div>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem
|
|
onClick={addCompany}
|
|
className="gap-2 py-2 text-muted-foreground"
|
|
disabled={isEditingOrder}
|
|
>
|
|
<Plus className="size-4" />
|
|
<span>Create new team...</span>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem asChild disabled={isEditingOrder}>
|
|
<Link
|
|
to="/company/settings/invites"
|
|
onClick={(event) => {
|
|
if (isEditingOrder) {
|
|
event.preventDefault();
|
|
return;
|
|
}
|
|
closeNavigationChrome();
|
|
}}
|
|
>
|
|
<UserPlus className="size-4" />
|
|
<span className="truncate">
|
|
{selectedCompany ? `Invite people to ${selectedCompany.name}` : "Invite people"}
|
|
</span>
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem asChild disabled={isEditingOrder}>
|
|
<Link
|
|
to="/company/settings"
|
|
onClick={(event) => {
|
|
if (isEditingOrder) {
|
|
event.preventDefault();
|
|
return;
|
|
}
|
|
closeNavigationChrome();
|
|
}}
|
|
>
|
|
<Settings className="size-4" />
|
|
<span>Company settings</span>
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
{session?.session ? (
|
|
<>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem
|
|
variant="destructive"
|
|
onClick={() => signOutMutation.mutate()}
|
|
disabled={isEditingOrder || signOutMutation.isPending}
|
|
>
|
|
<LogOut className="size-4" />
|
|
<span>{signOutMutation.isPending ? "Signing out..." : "Sign out"}</span>
|
|
</DropdownMenuItem>
|
|
</>
|
|
) : null}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
);
|
|
}
|