mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-25 16:14:26 +01:00
feat(ui): show the Cloud Slack invitation in the workspace sidebar (#22702)
## Thinking Path > - Teams use Paperclip to manage agents and their work. > - Hosted teams can have a private Slack channel with the Paperclip team. > - A workspace member needs to know whether they can open the channel or still need the owner's invitation. > - Cloud supplies that information for the selected organization. > - This change puts a Slack button in the sidebar footer. It opens a dialog with the next action. ## Linked Issues or Issue Description **Subsystem affected** Workspace sidebar and the Cloud onboarding browser journey. **Problem or motivation** After setup, a user can lose track of the invitation to their organization's private feedback channel. **Proposed solution** Show the invitation status in a dialog. Offer a channel link when Cloud confirms the connection. **Roadmap alignment** This extends the existing hosted workspace navigation. The roadmap has no separate item for this shortcut. ## What Changed - Both sidebar variants use the existing portfolio request to show the Slack shortcut when Cloud supplies invitation details. - The icon uses grayscale at rest and brand colors on hover or keyboard focus. The button has an accessible name and a tooltip. - The Cloud onboarding journey selects Codex and confirms feedback intent when the first-account welcome appears. - Storybook covers pending and connected channels. ## Verification - The sidebar suite passed 36 tests. The Cloud onboarding journey suite passed 10 tests covering both the current and previous gateway layouts. - The Storybook catalog regenerated successfully. - In a local browser run, a fresh user completed signup, connected a test model, hired an agent, opened its chat, and opened and dismissed the Slack invitation. The test used a local Slack fixture. - The incremental verifier selected broad CI coverage for the runner journey change. All applicable checks passed on `ea9779abda`. A GitHub runner shut down during a server test shard. The shard and final verification gate passed on retry. [CI run](https://github.com/paperclipai/paperclip/actions/runs/45276376121/attempts/2) · [Greptile review (5/5)](https://github.com/paperclipai/paperclip/pull/22702#issuecomment-7115303606) ## Risks An older Cloud service can omit the optional feedback field. In that case, the sidebar keeps the existing layout. Cloud controls the channel destination and the invitation state. ## Model Used OpenAI GPT-6 in Codex, with repository tools and browser verification. ## 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 <1504818+scotttong@users.noreply.github.com> Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
11 files changed
+190
-57
No files matched your search
@@ -12,7 +12,8 @@ import { Link } from "@/lib/router";
|
||||
import { authApi } from "@/api/auth";
|
||||
import { queryKeys } from "@/lib/queryKeys";
|
||||
import { useCloudInstance } from "@/hooks/useCloudInstance";
|
||||
import { useCloudInviteUrl } from "@/hooks/useCloudInviteUrl";
|
||||
import { useCloudSidebarLinks } from "@/hooks/useCloudSidebarLinks";
|
||||
import { SidebarSlackFeedback } from "./SidebarSlackFeedback";
|
||||
import { useCanInviteCompanyMembers } from "@/hooks/useCompanyInviteAccess";
|
||||
import { useHiddenSettings } from "@/hooks/useHiddenSettings";
|
||||
import { useSignOut } from "@/hooks/useSignOut";
|
||||
@@ -129,7 +130,7 @@ export function SidebarAccountMenu({
|
||||
// On Cloud the shortcut exists only for the current stack's owner/admin and
|
||||
// only once the stack metadata is known; the in-app Invites tab is never a
|
||||
// fallback there because it drives a different invitation flow.
|
||||
const cloudInviteUrl = useCloudInviteUrl();
|
||||
const { inviteUrl: cloudInviteUrl, slackFeedback } = useCloudSidebarLinks(cloud);
|
||||
// Self-hosted invites need the `users:invite` grant. Offer the shortcut only
|
||||
// to boards with role-default access (company owner/admin/operator,
|
||||
// instance admins, local boards). The server checks the actual grants.
|
||||
@@ -275,6 +276,7 @@ export function SidebarAccountMenu({
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
{slackFeedback && <SidebarSlackFeedback feedback={slackFeedback} className="hover:bg-accent/50" />}
|
||||
{!isCloud ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
|
||||
@@ -128,6 +128,7 @@ describe("SidebarAccountMenu", () => {
|
||||
let container: HTMLDivElement;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal("ResizeObserver", class { observe() {} unobserve() {} disconnect() {} });
|
||||
container = document.createElement("div");
|
||||
document.body.appendChild(container);
|
||||
mockAuthApi.getSession.mockResolvedValue({
|
||||
@@ -472,7 +473,7 @@ describe("SidebarAccountMenu", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it.each([SidebarAccountMenu, ProductionSidebarAccountMenu])("hides cloud feedback and signs out through the harness (%#)", async (AccountMenu) => {
|
||||
it.each([SidebarAccountMenu, ProductionSidebarAccountMenu])("opens the current Cloud Slack channel and signs out through the harness (%#)", async (AccountMenu) => {
|
||||
const root = createRoot(container);
|
||||
const onOpenChange = vi.fn();
|
||||
const queryClient = new QueryClient({
|
||||
@@ -488,7 +489,8 @@ describe("SidebarAccountMenu", () => {
|
||||
cloudBaseUrl: "https://cloud.example.test",
|
||||
},
|
||||
});
|
||||
queryClient.setQueryData(queryKeys.cloud.stacks, cloudStacksPortfolio("owner"));
|
||||
const channelUrl = "https://slack.com/app_redirect?channel=CTEST";
|
||||
queryClient.setQueryData(queryKeys.cloud.stacks, { ...cloudStacksPortfolio("owner"), slackFeedback: { href: channelUrl } });
|
||||
|
||||
await act(async () => {
|
||||
root.render(
|
||||
@@ -506,6 +508,9 @@ describe("SidebarAccountMenu", () => {
|
||||
await flushReact();
|
||||
|
||||
expect(container.querySelector('a[aria-label="Share feedback"]')).toBeNull();
|
||||
const slack = container.querySelector<HTMLButtonElement>('button[aria-label="Slack the Paperclip team"]');
|
||||
expect(slack?.getAttribute("aria-haspopup")).toBe("dialog");
|
||||
expect(slack?.querySelector("img")?.getAttribute("src")).toBe("/brands/apps/slack.svg");
|
||||
|
||||
// Cloud manages invitations in the stack's People settings, reached with a
|
||||
// same-tab top-level navigation rather than the in-app router.
|
||||
@@ -534,6 +539,13 @@ describe("SidebarAccountMenu", () => {
|
||||
expect(mockNavigateTopLevel).toHaveBeenCalledWith("/cloud/logout");
|
||||
expect(onOpenChange).toHaveBeenCalledWith(false);
|
||||
|
||||
await act(() => slack!.click());
|
||||
const dialog = document.body.querySelector('[data-slot="dialog-content"]');
|
||||
expect(dialog?.textContent).toContain("inbox for the Slack invitation");
|
||||
const channel = dialog?.querySelector("a");
|
||||
expect(channel?.getAttribute("href")).toBe(channelUrl);
|
||||
expect(channel?.target).toBe("_blank");
|
||||
|
||||
await act(async () => {
|
||||
root.unmount();
|
||||
});
|
||||
@@ -557,7 +569,8 @@ describe("SidebarAccountMenu", () => {
|
||||
// Company roles can differ from Cloud roles; the Members page only offers
|
||||
// the Cloud invite link to the current stack's owner/admin, so the menu
|
||||
// must match rather than send a plain member to People settings.
|
||||
queryClient.setQueryData(queryKeys.cloud.stacks, cloudStacksPortfolio("member"));
|
||||
const message = "Open the invitation emailed to your organization’s owner.";
|
||||
queryClient.setQueryData(queryKeys.cloud.stacks, { ...cloudStacksPortfolio("member"), slackFeedback: { message } });
|
||||
|
||||
await act(async () => {
|
||||
root.render(
|
||||
@@ -576,6 +589,17 @@ describe("SidebarAccountMenu", () => {
|
||||
expect(popover?.querySelector('a[href="/company/settings/members?tab=invites"]')).toBeNull();
|
||||
expect(popover?.querySelector('a[aria-label="View profile"]')).not.toBeNull();
|
||||
|
||||
const slack = container.querySelector<HTMLButtonElement>('button[aria-label="Slack the Paperclip team"]');
|
||||
expect(slack).not.toBeNull();
|
||||
await act(() => slack!.click());
|
||||
await flushReact();
|
||||
const dialog = document.body.querySelector('[data-slot="dialog-content"]');
|
||||
expect(dialog?.querySelector('[data-slot="dialog-description"]')?.textContent).toBe(message);
|
||||
expect(dialog?.querySelector("a")).toBeNull();
|
||||
const done = Array.from(dialog!.querySelectorAll("button")).find((button) => button.textContent === "Got it");
|
||||
await act(() => done!.click());
|
||||
expect(document.body.querySelector('[data-slot="dialog-content"]')).toBeNull();
|
||||
|
||||
await act(async () => {
|
||||
root.unmount();
|
||||
});
|
||||
|
||||
@@ -13,7 +13,8 @@ import { Link } from "@/lib/router";
|
||||
import { authApi } from "@/api/auth";
|
||||
import { queryKeys } from "@/lib/queryKeys";
|
||||
import { useCloudInstance } from "@/hooks/useCloudInstance";
|
||||
import { useCloudInviteUrl } from "@/hooks/useCloudInviteUrl";
|
||||
import { useCloudSidebarLinks } from "@/hooks/useCloudSidebarLinks";
|
||||
import { SidebarSlackFeedback } from "./SidebarSlackFeedback";
|
||||
import { useCanInviteCompanyMembers } from "@/hooks/useCompanyInviteAccess";
|
||||
import { useHiddenSettings } from "@/hooks/useHiddenSettings";
|
||||
import { useSignOut } from "@/hooks/useSignOut";
|
||||
@@ -129,7 +130,7 @@ export function SidebarAccountMenu({
|
||||
// On Cloud the shortcut exists only for the current stack's owner/admin and
|
||||
// only once the stack metadata is known; the in-app Invites tab is never a
|
||||
// fallback there because it drives a different invitation flow.
|
||||
const cloudInviteUrl = useCloudInviteUrl();
|
||||
const { inviteUrl: cloudInviteUrl, slackFeedback } = useCloudSidebarLinks(cloud);
|
||||
// Self-hosted invites need the `users:invite` grant. Offer the shortcut only
|
||||
// to boards with role-default access (company owner/admin/operator,
|
||||
// instance admins, local boards). The server checks the actual grants.
|
||||
@@ -275,6 +276,7 @@ export function SidebarAccountMenu({
|
||||
</FlyoutOptions>
|
||||
</FlyoutContent>
|
||||
</Popover>
|
||||
{slackFeedback && <SidebarSlackFeedback feedback={slackFeedback} className="hover:bg-sidebar-accent" />}
|
||||
{!isCloud ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import type { CloudStackPortfolio } from "@/api/cloud";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Button } from "./ui/button";
|
||||
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "./ui/dialog";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
|
||||
|
||||
const label = "Slack the Paperclip team";
|
||||
|
||||
export function SidebarSlackFeedback({ feedback, className }: {
|
||||
feedback: NonNullable<CloudStackPortfolio["slackFeedback"]>;
|
||||
className: string;
|
||||
}) {
|
||||
const triggerClass = cn("group flex size-8 shrink-0 items-center justify-center rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", className);
|
||||
const logo = <img src="/brands/apps/slack.svg" alt="" className="size-4 grayscale group-hover:grayscale-0 group-focus-visible:grayscale-0" />;
|
||||
return (
|
||||
<Dialog>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<DialogTrigger asChild>
|
||||
<button type="button" aria-label={label} className={triggerClass}>{logo}</button>
|
||||
</DialogTrigger>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top">{label}</TooltipContent>
|
||||
</Tooltip>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Your private Slack channel</DialogTitle>
|
||||
<DialogDescription>
|
||||
{"message" in feedback ? feedback.message : "Open your shared channel to talk with the Paperclip team. If you still need to join, check your organization owner’s inbox for the Slack invitation."}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
{"href" in feedback ? (
|
||||
<Button asChild><a href={feedback.href} target="_blank" rel="noreferrer">Open Slack channel</a></Button>
|
||||
) : (
|
||||
<DialogClose asChild><Button>Got it</Button></DialogClose>
|
||||
)}
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user