mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-28 04:41:52 +01:00
## 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>
50 lines
2.1 KiB
TypeScript
50 lines
2.1 KiB
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import { accessApi, type CurrentBoardAccess } from "@/api/access";
|
|
import { queryKeys } from "@/lib/queryKeys";
|
|
import { useOptionalCompany } from "@/context/CompanyContext";
|
|
|
|
/**
|
|
* Whether a board may invite people to `companyId` on a self-hosted instance,
|
|
* judged from the current board access snapshot.
|
|
*
|
|
* Mirrors the other client-side role gates (`ToolsAdminGate`, the run
|
|
* ledger): local implicit boards and instance admins always pass; otherwise
|
|
* the active company membership must be owner, admin, or operator, the roles
|
|
* that carry the default `users:invite` grant. Legacy members normalize to
|
|
* operator. Resolves to false while the snapshot is unknown.
|
|
* The server stays authoritative; this only decides whether to offer a
|
|
* shortcut that would otherwise end in a permission error.
|
|
*/
|
|
export function canInviteCompanyMembers(
|
|
companyId: string | null | undefined,
|
|
boardAccess: CurrentBoardAccess | undefined,
|
|
): boolean {
|
|
if (!boardAccess) return false;
|
|
if (boardAccess.source === "local_implicit" || boardAccess.isInstanceAdmin) return true;
|
|
if (!companyId) return false;
|
|
const membership = boardAccess.memberships?.find(
|
|
(item) => item.companyId === companyId && item.status === "active",
|
|
);
|
|
return membership?.membershipRole === "owner" ||
|
|
membership?.membershipRole === "admin" ||
|
|
membership?.membershipRole === "operator" ||
|
|
membership?.membershipRole === "member";
|
|
}
|
|
|
|
/**
|
|
* Whether the signed-in board may invite people to the selected company on a
|
|
* self-hosted instance. Pass `enabled: false` on Cloud, where invitations live
|
|
* in the stack's People settings and use a different rule
|
|
* (see `useCloudSidebarLinks`).
|
|
*/
|
|
export function useCanInviteCompanyMembers(enabled = true): boolean {
|
|
const company = useOptionalCompany();
|
|
const boardAccess = useQuery({
|
|
queryKey: queryKeys.access.currentBoardAccess,
|
|
queryFn: () => accessApi.getCurrentBoardAccess(),
|
|
enabled,
|
|
staleTime: 30_000,
|
|
});
|
|
return enabled && canInviteCompanyMembers(company?.selectedCompanyId, boardAccess.data);
|
|
}
|