mirror of
https://github.com/paperclipai/paperclip
synced 2026-04-25 17:25:15 +02:00
## Thinking Path > - Paperclip is the control plane for autonomous AI companies. > - V1 needs to stay local-first while also supporting shared, authenticated deployments. > - Human operators need real identities, company membership, invite flows, profile surfaces, and company-scoped access controls. > - Agents and operators also need the existing issue, inbox, workspace, approval, and plugin flows to keep working under those authenticated boundaries. > - This branch accumulated the multi-user implementation, follow-up QA fixes, workspace/runtime refinements, invite UX improvements, release-branch conflict resolution, and review hardening. > - This pull request consolidates that branch onto the current `master` branch as a single reviewable PR. > - The benefit is a complete multi-user implementation path with tests and docs carried forward without dropping existing branch work. ## What Changed - Added authenticated human-user access surfaces: auth/session routes, company user directory, profile settings, company access/member management, join requests, and invite management. - Added invite creation, invite landing, onboarding, logo/branding, invite grants, deduped join requests, and authenticated multi-user E2E coverage. - Tightened company-scoped and instance-admin authorization across board, plugin, adapter, access, issue, and workspace routes. - Added profile-image URL validation hardening, avatar preservation on name-only profile updates, and join-request uniqueness migration cleanup for pending human requests. - Added an atomic member role/status/grants update path so Company Access saves no longer leave partially updated permissions. - Improved issue chat, inbox, assignee identity rendering, sidebar/account/company navigation, workspace routing, and execution workspace reuse behavior for multi-user operation. - Added and updated server/UI tests covering auth, invites, membership, issue workspace inheritance, plugin authz, inbox/chat behavior, and multi-user flows. - Merged current `public-gh/master` into this branch, resolved all conflicts, and verified no `pnpm-lock.yaml` change is included in this PR diff. ## Verification - `pnpm exec vitest run server/src/__tests__/issues-service.test.ts ui/src/components/IssueChatThread.test.tsx ui/src/pages/Inbox.test.tsx` - `pnpm run preflight:workspace-links && pnpm exec vitest run server/src/__tests__/plugin-routes-authz.test.ts` - `pnpm exec vitest run server/src/__tests__/plugin-routes-authz.test.ts server/src/__tests__/workspace-runtime-service-authz.test.ts server/src/__tests__/access-validators.test.ts` - `pnpm exec vitest run server/src/__tests__/authz-company-access.test.ts server/src/__tests__/routines-routes.test.ts server/src/__tests__/sidebar-preferences-routes.test.ts server/src/__tests__/approval-routes-idempotency.test.ts server/src/__tests__/openclaw-invite-prompt-route.test.ts server/src/__tests__/agent-cross-tenant-authz-routes.test.ts server/src/__tests__/routines-e2e.test.ts` - `pnpm exec vitest run server/src/__tests__/auth-routes.test.ts ui/src/pages/CompanyAccess.test.tsx` - `pnpm --filter @paperclipai/shared typecheck && pnpm --filter @paperclipai/db typecheck && pnpm --filter @paperclipai/server typecheck` - `pnpm --filter @paperclipai/shared typecheck && pnpm --filter @paperclipai/server typecheck` - `pnpm --filter @paperclipai/ui typecheck` - `pnpm db:generate` - `npx playwright test --config tests/e2e/playwright.config.ts --list` - Confirmed branch has no uncommitted changes and is `0` commits behind `public-gh/master` before PR creation. - Confirmed no `pnpm-lock.yaml` change is staged or present in the PR diff. ## Risks - High review surface area: this PR contains the accumulated multi-user branch plus follow-up fixes, so reviewers should focus especially on company-boundary enforcement and authenticated-vs-local deployment behavior. - UI behavior changed across invites, inbox, issue chat, access settings, and sidebar navigation; no browser screenshots are included in this branch-consolidation PR. - Plugin install, upgrade, and lifecycle/config mutations now require instance-admin access, which is intentional but may change expectations for non-admin board users. - A join-request dedupe migration rejects duplicate pending human requests before creating unique indexes; deployments with unusual historical duplicates should review the migration behavior. - Company member role/status/grant saves now use a new combined endpoint; older separate endpoints remain for compatibility. - Full production build was not run locally in this heartbeat; CI should cover the full matrix. ## Model Used - OpenAI Codex coding agent, GPT-5-based model, CLI/tool-use environment. Exact deployed model identifier and context window were not exposed by the runtime. ## 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 run tests locally and they pass - [x] I have added or updated tests where applicable - [x] If this change affects the UI, I have included before/after screenshots - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] I will address all Greptile and reviewer comments before requesting merge Note on screenshots: this is a branch-consolidation PR for an already-developed multi-user branch, and no browser screenshots were captured during this heartbeat. --------- Co-authored-by: dotta <dotta@example.com> Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
384 lines
12 KiB
TypeScript
384 lines
12 KiB
TypeScript
import type { ReactNode } from "react";
|
|
import type { Issue } from "@paperclipai/shared";
|
|
import { Columns3 } from "lucide-react";
|
|
import { pickTextColorForPillBg } from "@/lib/color-contrast";
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuCheckboxItem,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuLabel,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
|
import { formatAssigneeUserLabel } from "../lib/assignees";
|
|
import type { InboxIssueColumn } from "../lib/inbox";
|
|
import { cn } from "../lib/utils";
|
|
import { timeAgo } from "../lib/timeAgo";
|
|
import { Identity } from "./Identity";
|
|
import { StatusIcon } from "./StatusIcon";
|
|
|
|
export const issueTrailingColumns: InboxIssueColumn[] = ["assignee", "project", "workspace", "parent", "labels", "updated"];
|
|
|
|
const issueColumnLabels: Record<InboxIssueColumn, string> = {
|
|
status: "Status",
|
|
id: "ID",
|
|
assignee: "Assignee",
|
|
project: "Project",
|
|
workspace: "Workspace",
|
|
parent: "Parent issue",
|
|
labels: "Tags",
|
|
updated: "Last updated",
|
|
};
|
|
|
|
const issueColumnDescriptions: Record<InboxIssueColumn, string> = {
|
|
status: "Issue state chip on the left edge.",
|
|
id: "Ticket identifier like PAP-1009.",
|
|
assignee: "Assigned agent or board user.",
|
|
project: "Linked project pill with its color.",
|
|
workspace: "Execution or project workspace used for the issue.",
|
|
parent: "Parent issue identifier and title.",
|
|
labels: "Issue labels and tags.",
|
|
updated: "Latest visible activity time.",
|
|
};
|
|
|
|
export function issueActivityText(issue: Issue): string {
|
|
return `Updated ${timeAgo(issue.lastActivityAt ?? issue.lastExternalCommentAt ?? issue.updatedAt)}`;
|
|
}
|
|
|
|
function issueTrailingGridTemplate(columns: InboxIssueColumn[]): string {
|
|
return columns
|
|
.map((column) => {
|
|
if (column === "assignee") return "minmax(6rem, 8rem)";
|
|
if (column === "project") return "minmax(4.5rem, 7rem)";
|
|
if (column === "workspace") return "minmax(6rem, 9rem)";
|
|
if (column === "parent") return "minmax(3.5rem, 5.5rem)";
|
|
if (column === "labels") return "minmax(3rem, 6rem)";
|
|
return "minmax(3.5rem, 4.5rem)";
|
|
})
|
|
.join(" ");
|
|
}
|
|
|
|
export function IssueColumnPicker({
|
|
availableColumns,
|
|
visibleColumnSet,
|
|
onToggleColumn,
|
|
onResetColumns,
|
|
title,
|
|
iconOnly = false,
|
|
}: {
|
|
availableColumns: InboxIssueColumn[];
|
|
visibleColumnSet: ReadonlySet<InboxIssueColumn>;
|
|
onToggleColumn: (column: InboxIssueColumn, enabled: boolean) => void;
|
|
onResetColumns: () => void;
|
|
title: string;
|
|
iconOnly?: boolean;
|
|
}) {
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
type="button"
|
|
variant={iconOnly ? "outline" : "ghost"}
|
|
size={iconOnly ? "icon" : "sm"}
|
|
className={iconOnly ? "h-8 w-8 shrink-0" : "hidden h-8 shrink-0 px-2 text-xs sm:inline-flex"}
|
|
title="Columns"
|
|
>
|
|
<Columns3 className={iconOnly ? "h-3.5 w-3.5" : "mr-1 h-3.5 w-3.5"} />
|
|
{!iconOnly && "Columns"}
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-[300px] rounded-xl border-border/70 p-1.5 shadow-xl shadow-black/10">
|
|
<DropdownMenuLabel className="px-2 pb-1 pt-1.5">
|
|
<div className="space-y-1">
|
|
<div className="text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground">
|
|
Desktop issue rows
|
|
</div>
|
|
<div className="text-sm font-medium text-foreground">
|
|
{title}
|
|
</div>
|
|
</div>
|
|
</DropdownMenuLabel>
|
|
<DropdownMenuSeparator />
|
|
{availableColumns.map((column) => (
|
|
<DropdownMenuCheckboxItem
|
|
key={column}
|
|
checked={visibleColumnSet.has(column)}
|
|
onSelect={(event) => event.preventDefault()}
|
|
onCheckedChange={(checked) => onToggleColumn(column, checked === true)}
|
|
className="items-start rounded-lg px-3 py-2.5 pl-8"
|
|
>
|
|
<span className="flex flex-col gap-0.5">
|
|
<span className="text-sm font-medium text-foreground">
|
|
{issueColumnLabels[column]}
|
|
</span>
|
|
<span className="text-xs leading-relaxed text-muted-foreground">
|
|
{issueColumnDescriptions[column]}
|
|
</span>
|
|
</span>
|
|
</DropdownMenuCheckboxItem>
|
|
))}
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem
|
|
onSelect={onResetColumns}
|
|
className="rounded-lg px-3 py-2 text-sm"
|
|
>
|
|
Reset defaults
|
|
<span className="ml-auto text-xs text-muted-foreground">status, id, updated</span>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
);
|
|
}
|
|
|
|
export function InboxIssueMetaLeading({
|
|
issue,
|
|
isLive,
|
|
showStatus = true,
|
|
showIdentifier = true,
|
|
statusSlot,
|
|
}: {
|
|
issue: Issue;
|
|
isLive: boolean;
|
|
showStatus?: boolean;
|
|
showIdentifier?: boolean;
|
|
statusSlot?: ReactNode;
|
|
}) {
|
|
return (
|
|
<>
|
|
{showStatus ? (
|
|
<span className="hidden shrink-0 sm:inline-flex">
|
|
{statusSlot ?? <StatusIcon status={issue.status} />}
|
|
</span>
|
|
) : null}
|
|
{showIdentifier ? (
|
|
<span className="shrink-0 font-mono text-xs text-muted-foreground">
|
|
{issue.identifier ?? issue.id.slice(0, 8)}
|
|
</span>
|
|
) : null}
|
|
{isLive && (
|
|
<span
|
|
className={cn(
|
|
"inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 sm:gap-1.5 sm:px-2",
|
|
"bg-blue-500/10",
|
|
)}
|
|
>
|
|
<span className="relative flex h-2 w-2">
|
|
<span className="absolute inline-flex h-full w-full animate-pulse rounded-full bg-blue-400 opacity-75" />
|
|
<span
|
|
className={cn(
|
|
"relative inline-flex h-2 w-2 rounded-full",
|
|
"bg-blue-500",
|
|
)}
|
|
/>
|
|
</span>
|
|
<span
|
|
className={cn(
|
|
"hidden text-[11px] font-medium sm:inline",
|
|
"text-blue-600 dark:text-blue-400",
|
|
)}
|
|
>
|
|
Live
|
|
</span>
|
|
</span>
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
|
|
export function InboxIssueTrailingColumns({
|
|
issue,
|
|
columns,
|
|
projectName,
|
|
projectColor,
|
|
workspaceId,
|
|
workspaceName,
|
|
assigneeName,
|
|
assigneeUserName,
|
|
assigneeUserAvatarUrl,
|
|
currentUserId,
|
|
parentIdentifier,
|
|
parentTitle,
|
|
assigneeContent,
|
|
onFilterWorkspace,
|
|
}: {
|
|
issue: Issue;
|
|
columns: InboxIssueColumn[];
|
|
projectName: string | null;
|
|
projectColor: string | null;
|
|
workspaceId?: string | null;
|
|
workspaceName: string | null;
|
|
assigneeName: string | null;
|
|
assigneeUserName?: string | null;
|
|
assigneeUserAvatarUrl?: string | null;
|
|
currentUserId: string | null;
|
|
parentIdentifier: string | null;
|
|
parentTitle: string | null;
|
|
assigneeContent?: ReactNode;
|
|
onFilterWorkspace?: (workspaceId: string) => void;
|
|
}) {
|
|
const activityText = timeAgo(issue.lastActivityAt ?? issue.lastExternalCommentAt ?? issue.updatedAt);
|
|
const userLabel = assigneeUserName ?? formatAssigneeUserLabel(issue.assigneeUserId, currentUserId) ?? "User";
|
|
|
|
return (
|
|
<span
|
|
className="grid items-center gap-2"
|
|
style={{ gridTemplateColumns: issueTrailingGridTemplate(columns) }}
|
|
>
|
|
{columns.map((column) => {
|
|
if (column === "assignee") {
|
|
if (assigneeContent) {
|
|
return <span key={column} className="min-w-0">{assigneeContent}</span>;
|
|
}
|
|
|
|
if (issue.assigneeAgentId) {
|
|
return (
|
|
<span key={column} className="min-w-0 text-xs text-foreground">
|
|
<Identity
|
|
name={assigneeName ?? issue.assigneeAgentId.slice(0, 8)}
|
|
size="sm"
|
|
className="min-w-0"
|
|
/>
|
|
</span>
|
|
);
|
|
}
|
|
|
|
if (issue.assigneeUserId) {
|
|
return (
|
|
<span key={column} className="min-w-0 text-xs text-foreground">
|
|
<Identity
|
|
name={userLabel}
|
|
avatarUrl={assigneeUserAvatarUrl}
|
|
size="sm"
|
|
className="min-w-0"
|
|
/>
|
|
</span>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<span key={column} className="min-w-0 truncate text-xs text-muted-foreground">
|
|
Unassigned
|
|
</span>
|
|
);
|
|
}
|
|
|
|
if (column === "project") {
|
|
if (projectName) {
|
|
const accentColor = projectColor ?? "#64748b";
|
|
return (
|
|
<span
|
|
key={column}
|
|
className="inline-flex min-w-0 items-center gap-2 text-xs font-medium"
|
|
style={{ color: pickTextColorForPillBg(accentColor, 0.12) }}
|
|
>
|
|
<span
|
|
className="h-1.5 w-1.5 shrink-0 rounded-full"
|
|
style={{ backgroundColor: accentColor }}
|
|
/>
|
|
<span className="truncate">{projectName}</span>
|
|
</span>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<span key={column} className="min-w-0 truncate text-xs text-muted-foreground">
|
|
No project
|
|
</span>
|
|
);
|
|
}
|
|
|
|
if (column === "labels") {
|
|
if ((issue.labels ?? []).length > 0) {
|
|
return (
|
|
<span key={column} className="flex min-w-0 items-center gap-1 overflow-hidden">
|
|
{(issue.labels ?? []).slice(0, 2).map((label) => (
|
|
<span
|
|
key={label.id}
|
|
className="inline-flex min-w-0 max-w-full shrink-0 items-center rounded-full border px-1.5 py-0 text-[10px] font-medium"
|
|
style={{
|
|
borderColor: label.color,
|
|
color: pickTextColorForPillBg(label.color, 0.12),
|
|
backgroundColor: `${label.color}1f`,
|
|
}}
|
|
>
|
|
<span className="truncate">{label.name}</span>
|
|
</span>
|
|
))}
|
|
{(issue.labels ?? []).length > 2 ? (
|
|
<span className="shrink-0 text-[10px] font-medium text-muted-foreground">
|
|
+{(issue.labels ?? []).length - 2}
|
|
</span>
|
|
) : null}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
return <span key={column} className="min-w-0" aria-hidden="true" />;
|
|
}
|
|
|
|
if (column === "workspace") {
|
|
if (!workspaceName) {
|
|
return <span key={column} className="min-w-0" aria-hidden="true" />;
|
|
}
|
|
|
|
return (
|
|
<span key={column} className="min-w-0 truncate text-xs text-muted-foreground">
|
|
{workspaceId && onFilterWorkspace ? (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<button
|
|
type="button"
|
|
className="truncate rounded-sm text-left text-xs text-muted-foreground transition-colors hover:text-foreground hover:underline"
|
|
onClick={(event) => {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
onFilterWorkspace(workspaceId);
|
|
}}
|
|
>
|
|
{workspaceName}
|
|
</button>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="top" sideOffset={6}>
|
|
Filter by workspace
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
) : (
|
|
workspaceName
|
|
)}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
if (column === "parent") {
|
|
if (!issue.parentId) {
|
|
return <span key={column} className="min-w-0" aria-hidden="true" />;
|
|
}
|
|
|
|
return (
|
|
<span key={column} className="min-w-0 truncate text-xs text-muted-foreground" title={parentTitle ?? undefined}>
|
|
{parentIdentifier ? (
|
|
<span className="font-mono">{parentIdentifier}</span>
|
|
) : (
|
|
<span className="italic">Sub-issue</span>
|
|
)}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
if (column === "updated") {
|
|
return (
|
|
<span key={column} className="min-w-0 truncate text-right text-[11px] font-medium text-muted-foreground">
|
|
{activityText}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
return null;
|
|
})}
|
|
</span>
|
|
);
|
|
}
|