* feat(schedules): per-run workspaces, isolation and archive controls Scheduled agents never appeared in the sidebar: each schedule reused one stamped workspace and archived the run's agent on completion. Now every run mints its own workspace — the entity the sidebar shows — with per-schedule controls for isolation (local or worktree) and whether to archive that workspace when the run finishes. The schedule form is rebuilt on a non-React form model (open/commands/close) to end the flicker, edit-into-create contamination, and multi-host hydration bugs that came from effect-choreographed shared state. That lands the reusable foundations it needed: a form kit over a single control-geometry owner, a data-access taxonomy (replica/snapshot/fetch) with real load-state semantics, and lint/boundary guardrails so new screens inherit the paved road. Also fixes desktop combobox popovers truncating options when the trigger is narrower than the content. New schedule protocol fields are optional on both create and update, so old and new clients/daemons stay compatible. * test(app): complete mock themes for control-geometry tokens switch and terminal-profile-edit-modal now style through createControlGeometry, which reads theme.borderWidth[1], theme.opacity[50], and theme.colors.borderAccent. The hand-rolled mock themes in these two suites lacked those tokens, so the eager StyleSheet.create mock threw at import (collection error), not on any assertion. Add the missing tokens. * fix(schedules): address review findings on run cleanup, edit isolation, load error, sheet dismiss, and preference hydration - Server: archive the run's workspace even when agent creation fails, so a misconfigured provider no longer orphans a sidebar workspace/worktree. - Edit form: keep a stored worktree isolation while worktree eligibility is still resolving, instead of silently downgrading a saved schedule to local. - Schedules screen: show the load error/retry UI when every host fails, rather than spinning forever behind the loading branch. - Form sheet: fire the parent onClose on native gesture/backdrop dismiss so the sheet closes instead of re-opening. - Form model: apply late-loading saved preferences to untouched create-mode fields (never to edited schedules or user-modified fields). * fix(schedules): review batch — reconnect resubscribe, worktree prune, Android dismiss, cadence and provider edit safety - Push-router: re-send terminal and checkout-diff subscriptions after a reconnect; the old per-hook effect resubscribed on isConnected and the extracted router did not, so daemon restarts silently stopped terminals_changed pushes (root cause of the terminal-activity e2e failures). - Server: pass the run's source repo root when archiving worktree runs so the worktree is unregistered (git worktree remove/prune), not just deleted; also archive the workspace when agent creation fails even with archive-off (an agentless workspace has nothing to inspect). - Sheet: RN Modal onDismiss is iOS-only — notify dismiss once-per-close on the Android native path too; replace the JSDOM component test with a real Playwright dismiss spec and inline the trivial dismiss decision. - Form model: editing an interval schedule no longer rewrites its cadence to cron unless the cadence UI is touched (90-minute intervals have no cron equivalent); switching projects clears stale provider/model state and gates submit until the new host's snapshot resolves. * chore(lint): drop custom lint wrapper and boundary script, plain oxlint The import bans stay in .oxlintrc.json (oxlint-native no-restricted-imports). The receiver-sensitive checks the custom script enforced are not worth a parallel lint pipeline; if they come back it will be as oxlint rules. * fix(schedules): crash-safe run cleanup, capability-gated run options, resilient mutations - Persist the run's workspace/agent ids on the running-run record so a daemon crash mid-run can be recovered: restart archives the interrupted run's workspace under the same policy as normal cleanup (agentless always archives, otherwise archiveOnFinish is respected). - Hide Archive on finish (and omit archiveOnFinish/isolation from payloads) on hosts without workspaceMultiplicity — an old daemon ignores the fields, so offering the switch there would lie. - Optimistic pause/resume/delete no longer throw when the schedules cache holds a still-connecting entry alongside loaded data. - Mode field is gated on provider mode options, not a selected model, so model-less providers can pick their advertised modes.
240 lines
7.8 KiB
TypeScript
240 lines
7.8 KiB
TypeScript
import { expect, test, type Page } from "./fixtures";
|
|
import { gotoAppShell } from "./helpers/app";
|
|
import { daemonWsRoutePattern } from "./helpers/daemon-port";
|
|
import { openAgentRoute } from "./helpers/mock-agent";
|
|
import {
|
|
openGlobalNewWorkspaceComposer,
|
|
selectNewWorkspaceProject,
|
|
submitNewWorkspacePrompt,
|
|
} from "./helpers/new-workspace";
|
|
import { expectNoTruncation } from "./helpers/no-truncation";
|
|
import { escapeRegex } from "./helpers/regex";
|
|
import { seedWorkspace } from "./helpers/seed-client";
|
|
import { getServerId } from "./helpers/server-id";
|
|
import { waitForSidebarHydration } from "./helpers/workspace-ui";
|
|
|
|
const CREATE_AGENT_PREFERENCES_KEY = "@paseo:create-agent-preferences";
|
|
|
|
type WebSocketMessage = string | Buffer;
|
|
|
|
interface CreateAgentRequestMessage {
|
|
type: "create_agent_request";
|
|
config?: {
|
|
provider?: unknown;
|
|
modeId?: unknown;
|
|
};
|
|
}
|
|
|
|
function parseWebSocketJson(message: WebSocketMessage): unknown {
|
|
const rawMessage = typeof message === "string" ? message : message.toString("utf8");
|
|
try {
|
|
return JSON.parse(rawMessage);
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
function getSessionMessage(message: WebSocketMessage): Record<string, unknown> | null {
|
|
const envelope = parseWebSocketJson(message);
|
|
if (!envelope || typeof envelope !== "object") {
|
|
return null;
|
|
}
|
|
const maybeEnvelope = envelope as { type?: unknown; message?: unknown };
|
|
if (maybeEnvelope.type !== "session" || !maybeEnvelope.message) {
|
|
return null;
|
|
}
|
|
if (typeof maybeEnvelope.message !== "object") {
|
|
return null;
|
|
}
|
|
return maybeEnvelope.message as Record<string, unknown>;
|
|
}
|
|
|
|
async function seedCodexDefaultPermissionPreferences(page: Page, serverId: string): Promise<void> {
|
|
await page.addInitScript(
|
|
({ preferencesKey, serverId: seededServerId }) => {
|
|
localStorage.setItem(
|
|
preferencesKey,
|
|
JSON.stringify({
|
|
serverId: seededServerId,
|
|
provider: "codex",
|
|
providerPreferences: {
|
|
codex: {
|
|
model: "gpt-5.4-mini",
|
|
mode: "auto",
|
|
thinkingByModel: {
|
|
"gpt-5.4-mini": "low",
|
|
},
|
|
},
|
|
mock: {
|
|
model: "ten-second-stream",
|
|
},
|
|
},
|
|
}),
|
|
);
|
|
},
|
|
{ preferencesKey: CREATE_AGENT_PREFERENCES_KEY, serverId },
|
|
);
|
|
}
|
|
|
|
async function readCodexModePreference(page: Page): Promise<unknown> {
|
|
return page.evaluate((preferencesKey) => {
|
|
const raw = localStorage.getItem(preferencesKey);
|
|
if (!raw) return null;
|
|
const parsed = JSON.parse(raw) as {
|
|
providerPreferences?: Record<string, { mode?: unknown }>;
|
|
};
|
|
return parsed.providerPreferences?.codex?.mode ?? null;
|
|
}, CREATE_AGENT_PREFERENCES_KEY);
|
|
}
|
|
|
|
async function selectMode(page: Page, label: string): Promise<void> {
|
|
const modeControl = page.getByTestId("mode-control").first();
|
|
await expect(modeControl).toBeVisible({ timeout: 30_000 });
|
|
await modeControl.click();
|
|
|
|
const popup = page.getByTestId("combobox-desktop-container").last();
|
|
await expect(popup).toBeVisible({ timeout: 10_000 });
|
|
await expectNoTruncation(popup);
|
|
|
|
const searchInput = page.getByRole("textbox", { name: /search mode/i });
|
|
await expect(searchInput).toBeVisible({ timeout: 10_000 });
|
|
await searchInput.fill(label);
|
|
|
|
const option = page
|
|
.getByRole("dialog")
|
|
.last()
|
|
.getByText(new RegExp(`^${escapeRegex(label)}$`, "i"))
|
|
.first();
|
|
await expect(option).toBeVisible({ timeout: 10_000 });
|
|
await option.click({ force: true });
|
|
await expect(searchInput).not.toBeVisible({ timeout: 5_000 });
|
|
}
|
|
|
|
async function expectThinkingOptionsFit(page: Page): Promise<void> {
|
|
const thinkingControl = page.getByTestId("agent-thinking-selector").first();
|
|
await expect(thinkingControl).toBeVisible({ timeout: 30_000 });
|
|
await thinkingControl.click();
|
|
|
|
const popup = page.getByTestId("combobox-desktop-container").last();
|
|
await expect(popup).toBeVisible({ timeout: 10_000 });
|
|
await expectNoTruncation(popup);
|
|
|
|
await page.keyboard.press("Escape");
|
|
await expect(page.getByTestId("combobox-desktop-container")).toHaveCount(0, { timeout: 5_000 });
|
|
}
|
|
|
|
async function recordAndBlockCreateAgentRequests(page: Page): Promise<{
|
|
waitForCreateAgentRequest(): Promise<CreateAgentRequestMessage>;
|
|
}> {
|
|
let resolveRequest: ((message: CreateAgentRequestMessage) => void) | null = null;
|
|
const createAgentSeen = new Promise<CreateAgentRequestMessage>((resolve) => {
|
|
resolveRequest = resolve;
|
|
});
|
|
|
|
await page.routeWebSocket(daemonWsRoutePattern(), (ws) => {
|
|
const server = ws.connectToServer();
|
|
|
|
ws.onMessage((message) => {
|
|
const sessionMessage = getSessionMessage(message);
|
|
if (sessionMessage?.type === "create_agent_request") {
|
|
resolveRequest?.(sessionMessage as unknown as CreateAgentRequestMessage);
|
|
return;
|
|
}
|
|
server.send(message);
|
|
});
|
|
|
|
server.onMessage((message) => {
|
|
ws.send(message);
|
|
});
|
|
});
|
|
|
|
return {
|
|
waitForCreateAgentRequest: () => createAgentSeen,
|
|
};
|
|
}
|
|
|
|
test.describe("New workspace Codex mode preferences", () => {
|
|
test.describe.configure({ timeout: 240_000 });
|
|
|
|
test("keeps Full Access as the global Codex mode after the workspace draft auto-submit handoff", async ({
|
|
page,
|
|
}) => {
|
|
const serverId = getServerId();
|
|
const seeded = await seedWorkspace({ repoPrefix: "codex-mode-preferences-" });
|
|
const createAgentRecorder = await recordAndBlockCreateAgentRequests(page);
|
|
await seedCodexDefaultPermissionPreferences(page, serverId);
|
|
|
|
try {
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
await openGlobalNewWorkspaceComposer(page);
|
|
await selectNewWorkspaceProject(page, {
|
|
projectKey: seeded.projectId,
|
|
projectDisplayName: seeded.projectDisplayName,
|
|
});
|
|
|
|
await expect(page.getByTestId("mode-control").first()).toContainText("Default permissions", {
|
|
timeout: 30_000,
|
|
});
|
|
await expectThinkingOptionsFit(page);
|
|
await selectMode(page, "Full access");
|
|
await expect(page.getByTestId("mode-control").first()).toContainText("Full access");
|
|
|
|
await submitNewWorkspacePrompt(page, "Keep Codex full access selected globally.");
|
|
const createAgentRequest = await createAgentRecorder.waitForCreateAgentRequest();
|
|
|
|
expect(createAgentRequest.config).toMatchObject({
|
|
provider: "codex",
|
|
modeId: "full-access",
|
|
});
|
|
await expect
|
|
.poll(() => readCodexModePreference(page), { timeout: 10_000 })
|
|
.toBe("full-access");
|
|
} finally {
|
|
await seeded.cleanup();
|
|
}
|
|
});
|
|
|
|
test("uses the live Codex agent mode as the next New Workspace default", async ({ page }) => {
|
|
const serverId = getServerId();
|
|
const seeded = await seedWorkspace({ repoPrefix: "codex-live-mode-preferences-" });
|
|
await seedCodexDefaultPermissionPreferences(page, serverId);
|
|
|
|
try {
|
|
const agent = await seeded.client.createAgent({
|
|
provider: "codex",
|
|
cwd: seeded.repoPath,
|
|
workspaceId: seeded.workspaceId,
|
|
title: "Codex live mode preference e2e",
|
|
modeId: "auto",
|
|
model: "gpt-5.4-mini",
|
|
});
|
|
|
|
await openAgentRoute(page, {
|
|
workspaceId: seeded.workspaceId,
|
|
agentId: agent.id,
|
|
});
|
|
await expect(page.getByTestId("mode-control").first()).toContainText("Default permissions", {
|
|
timeout: 30_000,
|
|
});
|
|
|
|
await selectMode(page, "Full access");
|
|
await expect(page.getByTestId("mode-control").first()).toContainText("Full access", {
|
|
timeout: 30_000,
|
|
});
|
|
|
|
await openGlobalNewWorkspaceComposer(page);
|
|
await selectNewWorkspaceProject(page, {
|
|
projectKey: seeded.projectId,
|
|
projectDisplayName: seeded.projectDisplayName,
|
|
});
|
|
|
|
await expect(page.getByTestId("mode-control").first()).toContainText("Full access", {
|
|
timeout: 30_000,
|
|
});
|
|
} finally {
|
|
await seeded.cleanup();
|
|
}
|
|
});
|
|
});
|