mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-05 16:04:43 +00:00
* feat(app): add first-run setup modal New users landed on an empty "Add a project" screen and never found providers, Paseo tools or phone pairing, which all live in Settings. A one-time setup modal now walks them through Appearance, Providers, Projects, Orchestration and Phone. Every step renders the same component Settings uses, so changing something in setup changes it in Settings too. The modal opens only when the setup host is connected, its workspaces have loaded and it has no projects. Existing users already have projects, so they never see it after upgrading and no migration is needed. Finishing or skipping writes `@paseo:onboarding` on this client. It uses its own key because it records feature state, and e2e specs replace app settings wholesale. Settings > General > "Show setup again" reopens the modal on step 1. Native phones skip the modal for now. Shared pieces moved out so setup and Settings render the same thing: - ThemePicker is a tile grid and replaces the Settings theme dropdown. - PaseoToolsCard is extracted from the host page. - The skeleton pulse moves to components/ui. Provider rows show it while the first snapshot loads instead of "Loading…". - The pair-device direct-connection hint links to the Tailscale docs. The e2e fixture marks setup completed by default so existing specs keep their starting state. The desktop smoke and lifecycle scripts, which start from a fresh daemon, mark it before they continue. * feat(onboarding): suggest projects from agent history The setup's Projects step lists the repos the user already ran agents in, with busy recent ones preselected, so a new user adds their projects in one click instead of browsing for folders. With rows checked, the footer's main button adds them and only moves on once every one was added; a checked row always means "this will be added". The daemon resolves each session folder to its project root (main checkout for worktrees, repo root for subfolders) because only it can read the git state; the app asks once per provider so a slow or broken provider never holds up the others and can be retried on its own. Hosts without the projectSuggestions feature show only the Add project button. Onboarding e2e hosts read an empty Claude history with other providers off, so suggestions never depend on the machine running the tests. * fix(onboarding): keep late project adds on their step and show Retry early - A finished add only advances setup while the Projects step is still open. - A failed provider shows its Retry as soon as any provider answers. - The desktop lifecycle check no longer reloads the window: setup never opens there because no host is connected. * fix(onboarding): bind late project adds to their step visit and freeze rows while adding - Each step visit has an id; a finished add only advances the visit that started it, so leaving and returning to Projects, or reopening setup, ignores it. - Suggestion rows are disabled while their batch is being added. * test(app): drive theme selection through the tile picker Settings → Appearance no longer has a theme dropdown. The Escape test opens the syntax theme dropdown instead, and the Android system-bars check taps theme tiles. * fix(server): return project suggestion roots in the form project.add stores Git reports Windows repo roots with forward slashes, so an added suggestion kept showing because its path never matched the new project's root. * feat(app): two control sizes, orchestration switches and mobile connect choices in setup Controls had four sizes picked per call site, so a button in a dialog, a settings row and a setup step came out at different heights. Controls now have two: md (default; 32px with a pointer, 44px in the compact layout so phone controls are full touch targets) and sm (28px, for tight chrome and nested settings rows). The breakpoint picks md's height, not the caller. Setup: - Orchestration is three switches (Paseo tools, agent skills, CLI), all on, applied on Continue. Turning one off undoes it; the desktop CLI uninstall removes only the file this app installed. - The Mobile step has store buttons and a "Choose how to connect" section: Relay opens the existing pairing modal, Tailscale opens the docs. Settings section docs links are one pattern, SettingsSection's `link` prop, and modals sit on surface0 like a screen. The vitest unistyles stub now resolves breakpoint values by window width, as Unistyles does at runtime; without it md controls had no height in browser tests. * fix(app): finish setup on its last step and confirm undoing orchestration In the compact layout Orchestration is the last step, and Finish closed setup without applying its switches. The last step's work now runs before Finish, the same as Continue. Turning off skills now asks first, as Settings does. Removing the CLI keeps a paseo command this app didn't install and says so. A failed Paseo tools update shows a toast. Adding suggested projects no longer advances when a row was checked while the add ran. Chat sender attribution and the message preview toggle go back to the sm button: md padding is a breakpoint value, and on web its media-query rule beat the zero right padding that aligns the sender with its bubble. * fix(app): ignore a late Finish once the user left the last setup step Finish called complete(), which ignored the step visit, so pressing Back while Orchestration applied its choices still closed setup and recorded it as done. next(visit) now finishes setup from the last step, so a late Finish is dropped the same way a late Continue already was. * fix(app): hold the skills switch while setup applies its choices The Paseo tools and CLI switches were disabled while Continue or Finish applied them, but the skills switch only locked while a skills operation ran. With skills needing no change, it stayed editable during a pending tools update and the new value was silently dropped. * fix(app): read setup's skills choice as off when no skill is picked Saving an empty selection in the skills picker left setup's skills switch on. Continue then asked the host to install nothing, the host reported skills as not installed, and the step stayed put with no error. Setup now reads skills as off with nothing picked, as Settings does.
231 lines
9.1 KiB
TypeScript
231 lines
9.1 KiB
TypeScript
import { randomUUID } from "node:crypto";
|
|
import { mkdir, mkdtemp, rm, utimes, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
import { expect, type Locator, type Page } from "@playwright/test";
|
|
import type { DaemonClient as InternalDaemonClient } from "@getpaseo/client/internal/daemon-client";
|
|
import { addProjectFlow, addProjectFlowInput, chooseAddProjectMethod } from "./add-project-flow";
|
|
import { connectDaemonClient } from "./daemon-client-loader";
|
|
import { buildCreateAgentPreferences, buildSeededHost } from "./daemon-registry";
|
|
import { startIsolatedHostDaemon, type IsolatedHostDaemonOptions } from "./isolated-host-daemon";
|
|
|
|
/** Points a fresh browser profile at one host, with no first-run record and no app settings. */
|
|
export async function openAppAsNewUser(
|
|
page: Page,
|
|
host: { serverId: string; port: number },
|
|
): Promise<void> {
|
|
const seededHost = buildSeededHost({
|
|
serverId: host.serverId,
|
|
endpoint: `127.0.0.1:${host.port}`,
|
|
nowIso: new Date().toISOString(),
|
|
});
|
|
await page.route(/:6767\b/, (route) => route.abort());
|
|
await page.routeWebSocket(/:6767\b/, async (webSocket) => {
|
|
await webSocket.close({ code: 1008, reason: "Blocked developer daemon during e2e." });
|
|
});
|
|
await page.addInitScript(
|
|
({ registryHost, preferences }) => {
|
|
localStorage.setItem("@paseo:e2e", "1");
|
|
localStorage.setItem("@paseo:daemon-registry", JSON.stringify([registryHost]));
|
|
localStorage.setItem("@paseo:create-agent-preferences", JSON.stringify(preferences));
|
|
},
|
|
{ registryHost: seededHost, preferences: buildCreateAgentPreferences() },
|
|
);
|
|
await page.goto("/");
|
|
}
|
|
|
|
export function setupModal(page: Page): Locator {
|
|
return page.getByTestId("onboarding-modal").getByRole("dialog");
|
|
}
|
|
|
|
export async function expectSetupStep(page: Page, title: string): Promise<void> {
|
|
await expect(setupModal(page).getByRole("heading", { name: title, exact: true })).toBeVisible({
|
|
timeout: 60_000,
|
|
});
|
|
}
|
|
|
|
export async function pickTheme(page: Page, name: string): Promise<void> {
|
|
const tile = setupModal(page).getByRole("radio", { name, exact: true });
|
|
await tile.click();
|
|
await expect(tile).toBeChecked();
|
|
}
|
|
|
|
export async function continueSetup(page: Page): Promise<void> {
|
|
await setupModal(page).getByRole("button", { name: "Continue", exact: true }).click();
|
|
}
|
|
|
|
export async function skipSetup(page: Page): Promise<void> {
|
|
await setupModal(page).getByRole("button", { name: "Skip setup", exact: true }).click();
|
|
await expect(setupModal(page)).toHaveCount(0);
|
|
}
|
|
|
|
/** Adds a folder through the regular Add project flow, opened from the setup's Projects step. */
|
|
export async function addProjectFromSetup(page: Page, projectPath: string): Promise<void> {
|
|
await setupModal(page).getByRole("button", { name: "Add project", exact: true }).click();
|
|
await expect(addProjectFlow(page)).toBeVisible({ timeout: 30_000 });
|
|
await chooseAddProjectMethod(page, "directory-search");
|
|
await addProjectFlowInput(page).fill(projectPath);
|
|
await page.keyboard.press("Enter");
|
|
await expect(addProjectFlow(page)).toHaveCount(0, { timeout: 30_000 });
|
|
}
|
|
|
|
export async function showSetupAgainFromSettings(page: Page): Promise<void> {
|
|
await page.locator('[data-testid="sidebar-settings"]:visible').first().click();
|
|
await page.getByRole("button", { name: "Show setup again", exact: true }).click();
|
|
}
|
|
|
|
export async function goToSetupStep(page: Page, label: string): Promise<void> {
|
|
await setupModal(page).getByRole("tab", { name: label, exact: true }).click();
|
|
}
|
|
|
|
export function paseoToolsSwitch(scope: Page | Locator): Locator {
|
|
return scope.getByRole("switch", { name: "Inject Paseo tools", exact: true });
|
|
}
|
|
|
|
/** Whether the host gives its agents Paseo tools, read from the host itself. */
|
|
export async function hostGivesAgentsPaseoTools(host: { port: number }): Promise<boolean> {
|
|
const client = await connectDaemonClient<
|
|
Pick<InternalDaemonClient, "connect" | "close" | "getDaemonConfig">
|
|
>({ clientIdPrefix: "app-e2e-onboarding", port: host.port });
|
|
try {
|
|
return (await client.getDaemonConfig()).config.mcp.injectIntoAgents !== false;
|
|
} finally {
|
|
await client.close();
|
|
}
|
|
}
|
|
|
|
export async function finishSetup(page: Page): Promise<void> {
|
|
await setupModal(page).getByRole("button", { name: "Finish", exact: true }).click();
|
|
await expect(setupModal(page)).toHaveCount(0);
|
|
}
|
|
|
|
/** Opens the Phone step's Relay row: the pair device modal, over setup. */
|
|
export async function openRelayPairingFromSetup(page: Page): Promise<Locator> {
|
|
await setupModal(page).getByRole("button", { name: "Relay", exact: true }).click();
|
|
const pairing = page.getByTestId("onboarding-pair-device-card");
|
|
await expect(pairing).toBeVisible();
|
|
return pairing;
|
|
}
|
|
|
|
export async function closeRelayPairing(pairing: Locator): Promise<void> {
|
|
await pairing.getByRole("button", { name: "Close", exact: true }).click();
|
|
await expect(pairing).toHaveCount(0);
|
|
}
|
|
|
|
/** Clicks the Phone step's Tailscale row and returns the docs page it opened. */
|
|
export async function openTailscaleDocsFromSetup(page: Page): Promise<string> {
|
|
await page
|
|
.context()
|
|
.route("https://paseo.sh/**", (route) =>
|
|
route.fulfill({ contentType: "text/html", body: "<title>Paseo docs</title>" }),
|
|
);
|
|
const popup = page.waitForEvent("popup");
|
|
await setupModal(page).getByRole("link", { name: "Tailscale, Docs", exact: true }).click();
|
|
const docs = await popup;
|
|
await docs.waitForLoadState("domcontentloaded");
|
|
const url = docs.url();
|
|
await docs.close();
|
|
return url;
|
|
}
|
|
|
|
export interface SetupHost {
|
|
serverId: string;
|
|
port: number;
|
|
close(): Promise<void>;
|
|
}
|
|
|
|
/**
|
|
* An isolated host whose only agent history is the Claude sessions given here, so suggestions
|
|
* never depend on the machine running the test. Its HOME is a scratch folder, so the skills setup
|
|
* installs never land in the real ~/.agents, ~/.claude or ~/.codex. `withBrokenProvider` adds a
|
|
* provider that cannot start.
|
|
*/
|
|
export async function startSetupHost(
|
|
label: string,
|
|
options: {
|
|
claudeSessionsIn?: readonly string[];
|
|
withBrokenProvider?: boolean;
|
|
mutableRelay?: IsolatedHostDaemonOptions["mutableRelay"];
|
|
} = {},
|
|
): Promise<SetupHost> {
|
|
const serverId = `srv_onboarding_${label}_${randomUUID().replaceAll("-", "").slice(0, 8)}`;
|
|
const claudeConfigDir = await seedClaudeHistory(options.claudeSessionsIn ?? []);
|
|
const home = await mkdtemp(path.join(tmpdir(), "paseo-onboarding-home-"));
|
|
const daemon = await startIsolatedHostDaemon(serverId, {
|
|
config: claudeOnlyConfig({ withBrokenProvider: options.withBrokenProvider ?? false }),
|
|
environment: { ...process.env, HOME: home, CLAUDE_CONFIG_DIR: claudeConfigDir },
|
|
mutableRelay: options.mutableRelay,
|
|
});
|
|
return {
|
|
serverId,
|
|
port: daemon.port,
|
|
close: async () => {
|
|
await daemon.close();
|
|
await rm(claudeConfigDir, { recursive: true, force: true });
|
|
await rm(home, { recursive: true, force: true });
|
|
},
|
|
};
|
|
}
|
|
|
|
/** Writes one recent Claude session per folder into a fresh CLAUDE_CONFIG_DIR. */
|
|
async function seedClaudeHistory(cwds: readonly string[]): Promise<string> {
|
|
const configDir = await mkdtemp(path.join(tmpdir(), "paseo-onboarding-claude-"));
|
|
const newest = Date.now() - 60_000;
|
|
for (const [index, cwd] of cwds.entries()) {
|
|
const sessionId = `onboarding-session-${index + 1}`;
|
|
const projectDir = path.join(configDir, "projects", cwd.replace(/[^a-zA-Z0-9]/g, "-"));
|
|
await mkdir(projectDir, { recursive: true });
|
|
const sessionPath = path.join(projectDir, `${sessionId}.jsonl`);
|
|
const record = {
|
|
type: "user",
|
|
uuid: `${sessionId}-user`,
|
|
message: { role: "user", content: `Work on session ${index + 1}` },
|
|
cwd,
|
|
sessionId,
|
|
};
|
|
await writeFile(sessionPath, `${JSON.stringify(record)}\n`);
|
|
const timestamp = new Date(newest - index * 60_000);
|
|
await utimes(sessionPath, timestamp, timestamp);
|
|
}
|
|
return configDir;
|
|
}
|
|
|
|
function claudeOnlyConfig(options: { withBrokenProvider: boolean }) {
|
|
const brokenProvider = {
|
|
"broken-acp": {
|
|
extends: "acp",
|
|
label: "Broken ACP",
|
|
command: ["missing-agent-command", "acp"],
|
|
},
|
|
};
|
|
return {
|
|
agents: {
|
|
providers: {
|
|
codex: { enabled: false },
|
|
copilot: { enabled: false },
|
|
omp: { enabled: false },
|
|
opencode: { enabled: false },
|
|
pi: { enabled: false },
|
|
...(options.withBrokenProvider ? brokenProvider : {}),
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
/** The switch that picks a suggested project for adding. */
|
|
export function projectSuggestion(page: Page, name: string): Locator {
|
|
return setupModal(page).getByRole("switch", { name, exact: true });
|
|
}
|
|
|
|
/** The whole suggestion row, with its path, last use and any add error beside the switch. */
|
|
export function projectSuggestionRow(page: Page, name: string): Locator {
|
|
return setupModal(page)
|
|
.getByTestId("project-suggestion")
|
|
.filter({ has: page.getByRole("switch", { name, exact: true }) });
|
|
}
|
|
|
|
/** The footer's main button, which adds the checked suggestions when there are any. */
|
|
export function setupPrimaryButton(page: Page, label: string): Locator {
|
|
return setupModal(page).getByRole("button", { name: label, exact: true });
|
|
}
|