mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-28 04:41:52 +01:00
fix(onboarding): restore browser launch and gate canaries (#12667)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The onboarding command starts the local server and opens the first-run wizard. > - Interactive onboarding stopped opening the browser by default. > - Organization creation could also succeed in the API while the wizard stayed on the name step. > - The npm canary workflow did not prove that the published package could complete this path. > - This pull request repairs the startup and organization transitions and adds an exact-version canary smoke gate. > - The benefit is a quickstart that works for users and is tested after each canary publish. ## Linked Issues or Issue Description Related: #12557 covers a separate final-route onboarding handoff. **What happened?** Interactive `paperclipai onboard` runs did not open the onboarding page. The organization API request could succeed while a same-company context update caused the wizard to stay on the organization step. The canary release lane did not test the exact published npm package through this path. **Expected behavior** Interactive onboarding must open the browser once. A successful organization request must advance to the first-agent step when the surrounding context adopts the same organization. Each published canary must install in a clean environment and reach the model connection step. **Steps to reproduce** 1. Run `npx paperclipai@canary onboard --data-dir "$(mktemp -d /tmp/paperclip-canary.XXXXXX)"` in an interactive terminal. 2. Enter an organization name while the company context refreshes from the create response. 3. Observe that the browser does not open or that the wizard can remain on the organization step after the API creates it. 4. Inspect the canary release lane and observe that no post-publish onboarding test runs against the exact npm version. **Paperclip version or commit** The issue reproduced with `2026.901.0-canary.8` and the source state before this pull request. **Deployment mode** Local trusted quickstart with embedded PostgreSQL. The install source can be npm or a source checkout. ## What Changed - Open the browser once for interactive foreground onboarding. - Preserve explicit browser opt-outs and restore the prior environment value after startup. - Accept a same-company context update after organization creation and reject a different-company takeover with an explicit error. - Export the exact canary version from the publish job. - Install and test that exact npm version in a clean Playwright smoke job through the "Connect a model" step. - Upload server logs, traces, screenshots, and the Playwright report when the canary smoke fails. - Document the interactive default and headless opt-outs. ## Verification - `pnpm exec vitest run cli/src/__tests__/onboard.test.ts ui/src/components/OnboardingWizard.step.test.tsx --reporter=dot` passes with 37 tests. - `node --test scripts/__tests__/release-verify-workflow.test.mjs` passes with 9 tests. - `pnpm exec playwright test --config tests/e2e/playwright.config.ts tests/e2e/onboarding.spec.ts` passes with 2 tests. - `PAPERCLIPAI_VERSION=2026.901.0-canary.8 pnpm run test:canary-onboarding-smoke` passes against the published npm package. - `pnpm check:token-gates` passes. - `pnpm -r typecheck` passes. - `pnpm build` passes. - A fresh interactive source run opens the browser and reaches "Connect a model" after organization and agent naming. ## Risks - Low risk. Automatic browser opening only applies to interactive foreground onboarding. - `PAPERCLIP_NO_BROWSER=1` and `PAPERCLIP_OPEN_ON_LISTEN=false` keep headless runs silent. - A different organization context still blocks the pending create transition. - The canary package is immutable before the smoke runs. A smoke failure leaves the package published but makes the release workflow red. - This change does not modify REST APIs, database schemas, or shared data types. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - OpenAI Codex based on GPT-5. The runtime does not expose the exact deployment snapshot or context-window size. The model used reasoning, browser automation, repository tools, shell commands, code editing, 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>
This commit is contained in:
1 parent
14c7efa068
commit
dda4dff645
11 files changed
+422
-13
No files matched your search
@@ -736,6 +736,50 @@ describe("OnboardingWizard — which step it lands on", () => {
|
||||
// here rather than read as a pass.
|
||||
expect(currentStep()).toBe("agent");
|
||||
expect(companyState.setSelectedCompanyId).not.toHaveBeenCalled();
|
||||
expect(document.body.textContent).toContain(
|
||||
"Organization created, but onboarding switched to another organization.",
|
||||
);
|
||||
});
|
||||
|
||||
it("finishes advancing when the returned company was already adopted", async () => {
|
||||
// The company-created live update can make the surrounding app adopt the
|
||||
// returned company before the POST continuation runs. That is not a
|
||||
// different-company takeover: both signals name the same company, so
|
||||
// dropping the continuation leaves the customer on the name step even
|
||||
// though the organization now exists.
|
||||
let resolveCreate: (company: { id: string; issuePrefix: string }) => void = () => {};
|
||||
mockCompaniesApi.create.mockReturnValue(
|
||||
new Promise<{ id: string; issuePrefix: string }>((resolve) => {
|
||||
resolveCreate = resolve;
|
||||
}),
|
||||
);
|
||||
routerState.pathname = "/onboarding";
|
||||
await render();
|
||||
await settle();
|
||||
|
||||
const nameInput = document.body.querySelector("input")! as HTMLInputElement;
|
||||
setControlledValue(nameInput, "Initech");
|
||||
await settle();
|
||||
const next = [...document.body.querySelectorAll("button")].find(
|
||||
(button) => button.textContent?.trim() === "Continue",
|
||||
)!;
|
||||
await act(async () => {
|
||||
next.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
||||
});
|
||||
|
||||
// Model the surrounding app adopting exactly the company that the pending
|
||||
// request is about, without choosing a new step on the wizard's behalf.
|
||||
dialogState.onboardingOpen = true;
|
||||
dialogState.onboardingOptions = { companyId: "company-created" };
|
||||
await rerender();
|
||||
await settle();
|
||||
|
||||
await act(async () => resolveCreate({ id: "company-created", issuePrefix: "INI" }));
|
||||
await settle();
|
||||
|
||||
expect(currentStep()).toBe("agent");
|
||||
expect(companyState.setSelectedCompanyId).toHaveBeenCalledWith("company-created");
|
||||
expect(mockCompaniesApi.create).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("applies the step again when the wizard is re-opened", async () => {
|
||||
|
||||
@@ -1093,6 +1093,26 @@ function OnboardingWizardInner({
|
||||
return createdCompanyIdRef.current === companyIdAtStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a just-created company can still be committed to this wizard.
|
||||
*
|
||||
* Company-list refreshes can make the surrounding app adopt the POST result
|
||||
* before the continuation runs. That is the same successful transition, not
|
||||
* a takeover. A different id still means navigation moved the wizard to a
|
||||
* different organization while the request was in flight.
|
||||
*/
|
||||
function canCommitCreatedCompany(
|
||||
companyIdAtStart: string | null,
|
||||
returnedCompanyId: string,
|
||||
) {
|
||||
const companyIdNow = createdCompanyIdRef.current;
|
||||
if (companyIdNow === companyIdAtStart || companyIdNow === returnedCompanyId) {
|
||||
return true;
|
||||
}
|
||||
setError("Organization created, but onboarding switched to another organization.");
|
||||
return false;
|
||||
}
|
||||
|
||||
async function handleLaunchToDashboard() {
|
||||
if (!createdCompanyId || !createdAgentId) {
|
||||
setError(INCOMPLETE_ONBOARDING_STATE_MESSAGE);
|
||||
@@ -1365,6 +1385,7 @@ function OnboardingWizardInner({
|
||||
}
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
const companyIdAtStart = createdCompanyIdRef.current;
|
||||
try {
|
||||
const company = await companiesApi.create({ name: companyName.trim() });
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.companies.all });
|
||||
@@ -1373,7 +1394,7 @@ function OnboardingWizardInner({
|
||||
// a company while the request was open has taken over the wizard, and
|
||||
// adopting the company just created would fight it — and would leave the
|
||||
// customer on a company they never navigated to.
|
||||
if (!stillTheSameCompany(null)) return;
|
||||
if (!canCommitCreatedCompany(companyIdAtStart, company.id)) return;
|
||||
setCreatedCompanyId(company.id);
|
||||
// Keep the mirror current here rather than waiting for the next render.
|
||||
// The goal write below asks `stillTheSameCompany(company.id)`, and a ref
|
||||
@@ -1429,6 +1450,7 @@ function OnboardingWizardInner({
|
||||
creatingCompanyRef.current = true;
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
const companyIdAtStart = createdCompanyIdRef.current;
|
||||
try {
|
||||
const company = await companiesApi.create({ name: companyName.trim() });
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.companies.all });
|
||||
@@ -1437,7 +1459,7 @@ function OnboardingWizardInner({
|
||||
// taken over the wizard, and adopting the company just created would
|
||||
// fight it — and would leave the customer on a company they never
|
||||
// navigated to.
|
||||
if (!stillTheSameCompany(null)) return;
|
||||
if (!canCommitCreatedCompany(companyIdAtStart, company.id)) return;
|
||||
setCreatedCompanyId(company.id);
|
||||
// Keep the mirror current rather than waiting for the next render, for
|
||||
// the same reason the mission path does: anything downstream that asks
|
||||
|
||||
Reference in new issue
Block a user