mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-24 22:49:00 +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>
108 lines
7.0 KiB
TypeScript
108 lines
7.0 KiB
TypeScript
import { expect } from "@playwright/test";
|
|
import { createConnectionProof } from "../connection-evidence.js";
|
|
import { onboardingConnect } from "./onboarding-connect.js";
|
|
import { onboardingFirstTask } from "./onboarding-first-task.js";
|
|
import { JourneyError, type JourneyContext, type JourneyEvidence, type TargetSession } from "./types.js";
|
|
|
|
type Row = Record<string, any>;
|
|
export interface CloudOnboardingInput {
|
|
page: JourneyContext["page"];
|
|
campaignId: string;
|
|
deadlineAt: number;
|
|
gateway: { model: string; baseUrl: string; apiKey: string };
|
|
maxRuns: number;
|
|
evidence: JourneyEvidence;
|
|
own: TargetSession["own"];
|
|
beforeWorkspace(name: string): Promise<void>;
|
|
workspaceCreated(): Promise<JourneyContext>;
|
|
/** The saved route must pass a deny-only runtime probe before Connect can spend. */
|
|
qualify(context: JourneyContext, connectionId: string): Promise<void>;
|
|
verifyExecution(context: JourneyContext, runIds: string[]): Promise<void>;
|
|
phase(phase: "setup" | "agent"): Promise<void>;
|
|
observeRun(run: Row): Promise<void>;
|
|
}
|
|
/** Measured actions use normal Cloud and tenant controls; infrastructure stays in the provider. */
|
|
export async function cloudOnboarding(input: CloudOnboardingInput): Promise<JourneyContext> {
|
|
const { page, evidence, campaignId } = input;
|
|
const name = `Journey QA ${campaignId}`;
|
|
const firstRunName = page.getByLabel("Name", { exact: true });
|
|
const organizationName = page.getByLabel("Organization name", { exact: true });
|
|
const createLink = page.getByRole("link", { name: /^(Create (?:a new )?organization|\+ New organization)$/ }).first();
|
|
const betaConnection = page.getByRole("checkbox", { name: "OpenAI Codex", exact: true });
|
|
// The first organization uses the signup Name/Next form. Later organizations
|
|
// use Organization name/Create organization, reached from the managed portfolio.
|
|
await expect(betaConnection.or(firstRunName).or(organizationName).or(createLink).first()).toBeVisible();
|
|
if (await betaConnection.isVisible()) {
|
|
await betaConnection.check();
|
|
await page.getByRole("checkbox", { name: "I intend to provide feedback on the Paperclip closed beta.", exact: true }).check();
|
|
await page.getByRole("button", { name: "Continue", exact: true }).click();
|
|
await expect(firstRunName).toBeVisible();
|
|
}
|
|
if (!await firstRunName.isVisible() && !await organizationName.isVisible()) {
|
|
await createLink.click();
|
|
await expect(organizationName).toBeVisible();
|
|
}
|
|
const firstRun = await firstRunName.isVisible();
|
|
await (firstRun ? firstRunName : organizationName).fill(name);
|
|
await input.beforeWorkspace(name);
|
|
await page.getByRole("button", { name: firstRun ? "Next" : "Create organization", exact: true }).click();
|
|
const context = await input.workspaceCreated();
|
|
const { api, company } = context;
|
|
evidence.deployment = context.identity;
|
|
evidence.checks.push({ id: "fresh-workspace", passed: true });
|
|
await input.phase("setup");
|
|
await expect(page.getByRole("heading", { name: "Create your first agent", exact: true })).toBeVisible({ timeout: 180_000 });
|
|
await input.own({ kind: "agent", name });
|
|
await page.getByLabel("Agent name", { exact: true }).fill(name);
|
|
await page.getByRole("button", { name: "Next", exact: true }).click();
|
|
await page.getByRole("button", { name: "Use API key instead", exact: true }).click();
|
|
await page.getByRole("radio", { name: /OpenAI.*API/ }).click();
|
|
const gatewayButton = page.getByRole("button", { name: "Use a custom gateway", exact: true });
|
|
const advanced = page.locator("summary").filter({ hasText: "Advanced" });
|
|
await expect(gatewayButton.or(advanced).first()).toBeVisible();
|
|
// Older tenants show the gateway inline and keep the runner picker in Advanced.
|
|
const inlineGateway = await gatewayButton.isVisible();
|
|
if (!inlineGateway) await advanced.click();
|
|
await gatewayButton.click();
|
|
const dialog = page.getByRole("dialog", { name: "Custom gateway connection", exact: true });
|
|
await dialog.getByLabel("Provider URL", { exact: true }).fill(input.gateway.baseUrl);
|
|
await dialog.getByLabel("API key", { exact: true }).fill(input.gateway.apiKey);
|
|
await dialog.getByRole("button", { name: "Change", exact: true }).click();
|
|
await dialog.getByLabel("Model IDs", { exact: true }).fill(input.gateway.model);
|
|
const connectionName = `My ${new URL(input.gateway.baseUrl).hostname}`;
|
|
await input.own({ kind: "connection", name: connectionName });
|
|
await dialog.getByRole("button", { name: "Save connection", exact: true }).click();
|
|
await expect(dialog).not.toBeVisible();
|
|
const connections = (await api.get(`/api/companies/${company.id}/ai-connections`)).connections as Row[];
|
|
const connection = connections.find(c => c.name === connectionName && c.provider === "openai" && c.method === "api_key" && c.status === "connected");
|
|
if (!connection || connections.length !== 1) throw new JourneyError("failed", "onboarding_connection_not_saved");
|
|
await input.own({ kind: "connection", name: connectionName, id: connection.id });
|
|
await page.getByRole("combobox", { name: "Model", exact: true }).selectOption(input.gateway.model);
|
|
if (inlineGateway) {
|
|
await advanced.click();
|
|
await page.getByRole("button", { name: "Runner", exact: true }).click();
|
|
await page.getByRole("option", { name: /^Paperclip Runner/ }).click();
|
|
}
|
|
await input.qualify(context, connection.id);
|
|
// Connect performs the production probe and agent creation. Never press Retry.
|
|
const connect = await onboardingConnect({ page, origin: api.origin, companyId: company.id, deadlineAt: input.deadlineAt,
|
|
retain: value => { evidence.onboardingConnect = value; } });
|
|
const agents = await api.get<Row[]>(`/api/companies/${company.id}/agents`);
|
|
const agent = agents.find(a => a.name === name);
|
|
if (!agent || agents.length !== 1 || agent.adapterType !== "paperclip_runner" || agent.adapterConfig?.provider !== "codex" || agent.adapterConfig?.model !== input.gateway.model) throw new JourneyError("failed", "onboarding_agent_configuration_mismatch");
|
|
connect.checkpoint = "agent-verification";
|
|
await input.own({ kind: "agent", name, id: agent.id });
|
|
evidence.checks.push({ id: "ui-connection-and-native-agent", passed: true });
|
|
await input.own({ kind: "issue", name: "Paperclip onboarding" });
|
|
await page.getByRole("button", { name: "Get started", exact: true }).click();
|
|
await input.phase("agent");
|
|
const completed = await onboardingFirstTask({ context, agent: { id: agent.id }, connectionId: connection.id,
|
|
proof: createConnectionProof(), campaignId, maxRuns: input.maxRuns, deadlineAt: input.deadlineAt,
|
|
own: input.own, observeRun: input.observeRun, onArtifact: artifact => { evidence.artifact = artifact; },
|
|
onPreAcceptanceFailure: receipt => { evidence.onboardingPreAcceptance = receipt; } });
|
|
await input.verifyExecution(context, [completed.artifact.originatingRunId]);
|
|
evidence.checks.push({ id: "first-task-complete", passed: true },
|
|
{ id: "downloadable-artifact-verified", passed: true }, { id: "native-trace-verified", passed: true });
|
|
return { ...context, startingState: "onboarding" };
|
|
}
|