mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 20:09:33 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Onboarding asks users to connect a model before they can finish setting up their agent. > - Cloud users can start setup on a phone, where provider sign-in and key entry can be difficult. > - They need a way to find the same workspace on a computer. > - This pull request adds a copyable link on the mobile model step and defers agent creation while the handoff is offered. > - A user can open the link on desktop or continue on the phone. ## Linked Issues or Issue Description **Subsystem affected** React onboarding UI and its Cloud health metadata. **Problem or motivation** On a phone, the Cloud model step does not explain how to find the same onboarding page on a computer. The fresh agent draft is local to that browser and can leave a provisional agent behind. **Proposed solution** Offer Continue on desktop and Keep going here at the start of the mobile model step. Copy the workspace's HTTPS `/onboarding` link. Ask users to sign in to the same account on desktop and explain that they may need to enter their choices again. **Alternatives considered** The original invite URL would carry an invite token. Copying the workspace's onboarding URL lets Cloud handle sign-in through its existing entry flow. **Roadmap alignment** This is a focused improvement to the existing onboarding wizard. It uses the current Cloud workspace entry flow and keeps model selection available on mobile. **Additional context** Refs #23315 for naming-step setup drafts. Related prior work: #3594 covered a native iOS-to-web handoff token and is closed. ## What Changed - Add the Cloud mobile handoff panel and clipboard fallback. - Prefer the canonical tenant HTTPS origin and build a clean `/onboarding` URL. Older tenants can use the current HTTPS tenant origin. - Defer the provisional agent in the naming and model steps while the mobile handoff is available. Desktop and self-hosted sessions keep the early-draft behavior from #23315. - Render the step indicators as round dots inside the step buttons so the mobile touch-height rule does not stretch them. - Add browser coverage for the Cloud and self-hosted paths and unit coverage for URL handling. ## Verification - Passed 52 focused Vitest tests for the onboarding route, stepper, handoff URL, and shared clipboard policy. - Passed UI typecheck, the test-budget guard, and `git diff --check`. - Passed 23 tests in desktop Chrome with four workers, including the affected CI browser shard and the upstream early-draft regression. The handoff scenarios cover the mobile dots, clipboard success and manual fallback, same-workspace desktop re-entry via simulated sign-in, continuing on mobile, and the self-hosted flow. - Manual reproduction: use a fresh Cloud test workspace and a 390 × 844 viewport. Enter an agent name and proceed to Connect a model. Open Continue on desktop and copy the link. Open it on desktop and sign in with the same account if needed. A real Cloud sign-in was outside the local fixture. ## Risks - Setup choices from the phone may need to be entered again on desktop. - Real Cloud sign-in and in-app mobile browsers still need a live tenant check. No database migration is needed. ## Model Used - OpenAI Codex with GPT-6.2 Sol (`gpt-6.2-sol`) for branch preparation and verification. Used the terminal and Chromium. The context window size is not available in the session. ## 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>
89 lines
3.2 KiB
TypeScript
89 lines
3.2 KiB
TypeScript
import type { ServerInfoSnapshot } from "@paperclipai/shared";
|
|
import { tenantSessionRecovery } from "@/lib/tenant-session-recovery";
|
|
import { apiErrorFromResponse, apiFetch } from "./client";
|
|
import { ApiUnavailableError, readApiJson } from "./response";
|
|
|
|
export type DevServerHealthStatus = {
|
|
enabled: true;
|
|
restartRequired: boolean;
|
|
reason: "backend_changes" | "pending_migrations" | "backend_changes_and_pending_migrations" | null;
|
|
lastChangedAt: string | null;
|
|
changedPathCount: number;
|
|
changedPathsSample: string[];
|
|
pendingMigrations: string[];
|
|
autoRestartEnabled: boolean;
|
|
activeRunCount: number;
|
|
waitingForIdle: boolean;
|
|
lastRestartAt: string | null;
|
|
};
|
|
|
|
export type CloudInstanceHealthStatus = {
|
|
/** Operator-supplied harness IDs. Absent means unrestricted; [] allows none. */
|
|
availableHarnesses?: string[];
|
|
managed: true;
|
|
managedBy: "paperclip-cloud";
|
|
stackSlug: string | null;
|
|
stackDisplayName?: string;
|
|
cloudBaseUrl: string | null;
|
|
runtimeIdentity?: { canonicalOrigin: string; stackSlug: string };
|
|
};
|
|
|
|
export type HealthStatus = {
|
|
status: "ok" | "starting";
|
|
version?: string;
|
|
/** Commit of the running server; null when build metadata is unavailable. */
|
|
commit?: string | null;
|
|
deploymentMode?: "local_trusted" | "authenticated";
|
|
deploymentExposure?: "private" | "public";
|
|
localAiLoginSupported?: boolean;
|
|
hostedGoogleAiLoginSupported?: boolean;
|
|
authReady?: boolean;
|
|
bootstrapStatus?: "ready" | "bootstrap_pending";
|
|
bootstrapInviteActive?: boolean;
|
|
/** The unclaimed Cloud app is ready; this response did not probe SQL. */
|
|
warmStandby?: boolean;
|
|
features?: {
|
|
companyDeletionEnabled?: boolean;
|
|
};
|
|
serverInfo?: ServerInfoSnapshot;
|
|
devServer?: DevServerHealthStatus;
|
|
cloud?: CloudInstanceHealthStatus;
|
|
/**
|
|
* Settings surfaces hidden by the hosting operator (keys from the shared
|
|
* settings-visibility registry). Absent when nothing is hidden.
|
|
*/
|
|
hiddenSettings?: string[];
|
|
};
|
|
|
|
export const healthApi = {
|
|
get: async (): Promise<HealthStatus> => {
|
|
const res = await apiFetch("/api/health", {
|
|
credentials: "include",
|
|
headers: { Accept: "application/json" },
|
|
cache: "no-store",
|
|
});
|
|
const payload = await readApiJson<HealthStatus & { error?: string } | null>(res);
|
|
if (!res.ok) {
|
|
const recovery = tenantSessionRecovery.recoverIfNeeded(res.status, payload);
|
|
if (recovery) return recovery;
|
|
throw apiErrorFromResponse(res, payload);
|
|
}
|
|
// Startup recovery can still serve sign-in and deployment metadata.
|
|
if (payload?.status !== "ok" && payload?.status !== "starting") throw new ApiUnavailableError(res.status);
|
|
return payload;
|
|
},
|
|
requestDevServerRestart: async (): Promise<void> => {
|
|
const res = await fetch("/api/health/dev-server/restart", {
|
|
method: "POST",
|
|
credentials: "include",
|
|
headers: { Accept: "application/json" },
|
|
});
|
|
if (!res.ok) {
|
|
const payload = await res.json().catch(() => null) as { error?: string } | null;
|
|
const recovery = tenantSessionRecovery.recoverIfNeeded(res.status, payload);
|
|
if (recovery) return recovery;
|
|
throw new Error(payload?.error ?? `Failed to request restart (${res.status})`);
|
|
}
|
|
},
|
|
};
|