Compare commits

...
Author SHA1 Message Date
paseo-bot[bot]and3ae3ae 6291549834 Keep Codex thread settings when importing a session (#12167)
* fix(codex): keep thread settings on import

Use the native resume settings for the first imported turn and save
them with the agent so import preserves the thread's choices.

Co-authored-by: 3ae3ae <83870598+3ae3ae@users.noreply.github.com>

* fix(codex): resolve imported Speed for the resumed model

---------

Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
Co-authored-by: 3ae3ae <83870598+3ae3ae@users.noreply.github.com>
2026-12-05 22:42:46 +00:00
paseo-bot[bot] 51f22b3d42 Share worktree setup for the first-terminal browser checks (#12171)
Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
2026-12-05 21:32:06 +00:00
paseo-bot[bot] d4b380f4e0 Keep Settings clickable after leaving a composer dialog (#12156)
* fix(app): keep Settings clickable after leaving a composer dialog

A retained web chat freezes before a modal exit can finish. Remove the modal presentation when its owning panel becomes inactive so the old backdrop cannot block the destination.

* fix(app): complete sheet dismissal when leaving a retained panel

---------

Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
2026-12-05 20:42:49 +00:00
8 changed files with 405 additions and 62 deletions
@@ -29,6 +29,8 @@ import {
expectWorkspaceAgentConfiguration,
openCommandCenterForAgent,
} from "../support/helpers/command-center-agent-controls";
import { openSettingsWithShortcut } from "../support/helpers/app";
import { clickSettingsBackToWorkspace } from "../support/helpers/settings";
import { expectComposerVisible } from "../support/helpers/composer";
import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent";
@@ -297,6 +299,34 @@ test.describe("Agent profiles in the model picker", () => {
}
});
test("the composer profile editor reopens after visiting Settings", async ({ page }) => {
const seed = await seedAgentProfiles([PROFILE]);
const workspace = await seedMockAgentWorkspace({
repoPrefix: "agent-profiles-settings-return-",
title: "Agent profiles Settings return",
model: "ten-second-stream",
modeId: "load-test",
});
const model = { provider: PROFILE.provider, modelId: PROFILE.model };
try {
await openAgentRoute(page, workspace);
await expectComposerVisible(page);
await openModelPicker(page);
await openEditProfileFromModelRow(page, model);
await openSettingsWithShortcut(page);
await clickSettingsBackToWorkspace(page);
await expectComposerVisible(page);
await openModelPicker(page);
await openEditProfileFromModelRow(page, model);
await expectAgentProfileNameDraft(page, PROFILE.name);
} finally {
await workspace.cleanup();
await seed.restore();
}
});
test("canceling Remove in the composer profile editor keeps the editor and draft open", async ({
page,
}) => {
@@ -7,6 +7,7 @@ import {
withPluginFocusingAnAgentWithContextUsage,
withPluginHoldingNewWorkspaceComposer,
withPluginWritingToAnotherWorkspace,
withPluginSettingsFromComposer,
} from "../support/helpers/plugin-composers-by-reference";
test("a panel in the Explorer inserts at the cursor of the focused agent's composer", async ({
@@ -221,3 +222,26 @@ test("focus reaches an agent kept in the Explorer on a compact screen", async ({
await author.expectParentReadyToType();
});
});
test("Settings accepts clicks after a composer plugin closes its dialog and navigates", async ({
page,
}) => {
test.setTimeout(120_000);
await withPluginSettingsFromComposer(page, { width: 1280, height: 800 }, async (flow) => {
await flow.openPluginDialog();
await flow.openSettingsFromPlugin();
await flow.changeSetting();
await flow.returnToChat();
});
});
test("Settings accepts clicks after navigation from the compact model sheet", async ({ page }) => {
test.setTimeout(120_000);
await withPluginSettingsFromComposer(page, { width: 430, height: 900 }, async (flow) => {
await flow.openModelSheet();
await flow.openPluginDialog();
await flow.openSettingsFromPlugin();
await flow.changeSetting();
await flow.returnToChat();
});
});
@@ -5,7 +5,6 @@ import { clickNewTerminal } from "../support/helpers/launcher";
import { expectTerminalSurfaceVisible } from "../support/helpers/terminal-perf";
import {
connectWorkspaceSetupClient,
createWorkspaceThroughDaemon,
findWorktreeWorkspaceForProject,
navigateToWorkspaceViaSidebar,
openHomeWithProject,
@@ -15,34 +14,7 @@ import {
test.describe("Workspace setup runtime authority", () => {
test.describe.configure({ retries: 1 });
test("worktree workspace is created in its own directory", async ({ page }) => {
test.setTimeout(90_000);
const client = await connectWorkspaceSetupClient();
const repo = await createTempGitRepo("workspace-setup-chat-");
try {
await seedProjectForWorkspaceSetup(client, repo.path);
const workspace = await createWorkspaceThroughDaemon(client, {
cwd: repo.path,
worktreeSlug: `setup-chat-${Date.now()}`,
});
const workspaceId = workspace.id;
const wsInfo = await findWorktreeWorkspaceForProject(client, repo.path);
expect(wsInfo.workspaceDirectory).not.toBe(repo.path);
expect(existsSync(wsInfo.workspaceDirectory)).toBe(true);
await openHomeWithProject(page, repo.path);
await navigateToWorkspaceViaSidebar(page, workspaceId);
await expect(page).toHaveURL(/\/workspace\//, { timeout: 30_000 });
} finally {
await client.close();
await repo.cleanup();
}
});
test("first terminal opens in the created workspace directory", async ({ page }) => {
test("opens a new worktree and starts its first terminal there", async ({ page }) => {
test.setTimeout(90_000);
const client = await connectWorkspaceSetupClient();
@@ -51,35 +23,37 @@ test.describe("Workspace setup runtime authority", () => {
try {
await seedProjectForWorkspaceSetup(client, repo.path);
// Create workspace via daemon API since the new workspace screen
// no longer has a standalone terminal button
const worktreeSlug = `setup-terminal-${Date.now()}`;
const result = await client.createPaseoWorktree({
cwd: repo.path,
worktreeSlug,
const workspace = await test.step("creates a worktree in its own directory", async () => {
const result = await client.createPaseoWorktree({
cwd: repo.path,
worktreeSlug: `setup-terminal-${Date.now()}`,
});
if (!result.workspace || result.error) {
throw new Error(result.error ?? "Failed to create workspace");
}
const listedWorkspace = await findWorktreeWorkspaceForProject(client, repo.path);
expect(listedWorkspace.workspaceDirectory).toBe(result.workspace.workspaceDirectory);
expect(listedWorkspace.workspaceDirectory).not.toBe(repo.path);
expect(existsSync(listedWorkspace.workspaceDirectory)).toBe(true);
return result.workspace;
});
if (!result.workspace || result.error) {
throw new Error(result.error ?? "Failed to create workspace");
}
const workspaceDir = result.workspace.workspaceDirectory;
const workspaceId = result.workspace.id;
// Navigate to the worktree workspace via sidebar click (direct URL
// navigation for freshly created worktree workspaces can race with
// Expo Router hydration, so we use the sidebar which is authoritative).
await openHomeWithProject(page, repo.path);
await navigateToWorkspaceViaSidebar(page, workspaceId);
await test.step("opens the worktree from the sidebar", async () => {
await openHomeWithProject(page, repo.path);
await navigateToWorkspaceViaSidebar(page, workspace.id);
await expect(page).toHaveURL(/\/workspace\//, { timeout: 30_000 });
});
await clickNewTerminal(page);
await expectTerminalSurfaceVisible(page);
const countWorktreeTerminals = async () =>
(await client.listTerminals(workspace.workspaceDirectory)).terminals.length;
await test.step("registers the first terminal under the worktree directory", async () => {
await clickNewTerminal(page);
await expectTerminalSurfaceVisible(page);
// Verify terminal is listed under the worktree directory, not the original repo
await expect
.poll(async () => (await client.listTerminals(workspaceDir)).terminals.length > 0, {
timeout: 30_000,
})
.toBe(true);
expect((await client.listTerminals(repo.path)).terminals.length).toBe(0);
await expect.poll(countWorktreeTerminals, { timeout: 30_000 }).toBeGreaterThan(0);
expect((await client.listTerminals(repo.path)).terminals.length).toBe(0);
});
} finally {
await client.close();
await repo.cleanup();
+5
View File
@@ -38,6 +38,11 @@ export const openSettings = async (page: Page) => {
await expect(page).toHaveURL(/\/settings\/general$/);
};
export async function openSettingsWithShortcut(page: Page): Promise<void> {
await page.keyboard.press("ControlOrMeta+,");
await expect(page).toHaveURL(/\/settings\/general$/);
}
export const setWorkingDirectory = async (page: Page, directory: string) => {
const workingDirectorySelect = page
.locator('[data-testid="working-directory-select"]:visible')
@@ -766,3 +766,108 @@ export async function withPluginFocusingAnAgentWithContextUsage(
await agent.cleanup();
}
}
export async function withPluginSettingsFromComposer(
page: Page,
viewport: typeof WIDE,
run: (flow: {
openModelSheet(): Promise<void>;
openPluginDialog(): Promise<void>;
openSettingsFromPlugin(): Promise<void>;
changeSetting(): Promise<void>;
returnToChat(): Promise<void>;
}) => Promise<void>,
) {
const workspace = await seedWorkspace({ repoPrefix: "composer-settings-" });
const agent = await createMockAgent(workspace, "Composer settings agent");
const directory = await mkdtemp(path.join(tmpdir(), "paseo-composer-settings-"));
await writeFile(
path.join(directory, "paseo-plugin.json"),
JSON.stringify({ id: "composer-settings", requirements: pluginRequirements }),
);
await writeFile(
path.join(directory, "index.client.tsx"),
`import { useState } from "react";
import { Pressable, Text } from "react-native";
import { Action, Modal } from "@getpaseo/plugin/client/ui";
function Button({ title, onPress }) {
return <Pressable accessibilityRole="button" onPress={onPress}><Text>{title}</Text></Pressable>;
}
export default function contribute(client) {
client.addSettingsScreen({
id: "preferences",
title: "Composer preferences",
icon: "SlidersHorizontal",
Component() {
const [saved, setSaved] = useState(false);
return <Button title={saved ? "Preference saved" : "Save preference"} onPress={() => setSaved(true)} />;
},
});
client.addComposerItem({
id: "preferences",
Component() {
const [open, setOpen] = useState(false);
return <>
<Action title="Composer preferences" icon="ListChecks" onPress={() => setOpen(true)} />
<Modal title="Composer preferences" open={open} onOpenChange={setOpen}>
<Modal.Content>
<Button title="Open plugin settings" onPress={() => {
setOpen(false);
client.openSettings("preferences");
}} />
</Modal.Content>
</Modal>
</>;
},
});
return () => {};
}`,
);
const client = await connectNewWorkspaceDaemonClient({ ownProjects: false });
const previous = await client.getDaemonConfig();
const settingsButton = page.getByRole("button", { name: "Open plugin settings", exact: true });
try {
await client.patchDaemonConfig({ pluginsEnabled: true });
await client.installDirectoryPlugin(directory);
await page.setViewportSize(viewport);
await gotoAppShell(page);
await approveClientPluginsInUi(page, ["composer-settings"]);
await openAgentRoute(page, { workspaceId: workspace.workspaceId, agentId: agent.id });
await run({
openModelSheet: () =>
test.step("open Agent settings from the model button", () =>
page.getByRole("button", { name: /^Select model/ }).click()),
openPluginDialog: () =>
test.step("open the composer plugin's preferences dialog", async () => {
await page.getByRole("button", { name: "Composer preferences", exact: true }).click();
await expect(settingsButton).toBeVisible();
}),
openSettingsFromPlugin: () =>
test.step("navigate to Settings from the plugin dialog", () => settingsButton.click()),
changeSetting: () =>
test.step("save a preference in Settings", async () => {
await page
.getByRole("button", { name: "Save preference", exact: true })
.click({ timeout: 10_000 });
await expect(
page.getByRole("button", { name: "Preference saved", exact: true }),
).toBeVisible();
}),
returnToChat: () =>
test.step("return to chat with the dialog and model sheet closed", async () => {
await page.goBack();
await expect(prompt(page)).toBeVisible();
await expect(settingsButton).toBeHidden();
await expect(page.getByText("Agent settings", { exact: true })).toBeHidden();
}),
});
} finally {
await client.removePlugin("composer-settings");
await client.patchDaemonConfig({ pluginsEnabled: previous.config.pluginsEnabled });
await client.close();
await rm(directory, { recursive: true, force: true });
await workspace.cleanup();
}
}
@@ -1,5 +1,5 @@
import { useOverlayRegistration, type KeyboardInputEvent } from "@/keyboard";
import { useCallback, useEffect, useMemo, useState } from "react";
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import type { ComponentProps, ReactNode } from "react";
import { createPortal } from "react-dom";
import { useTranslation } from "react-i18next";
@@ -23,6 +23,7 @@ import {
useBottomSheetSafeAreaPaddingStyle,
useIsolatedBottomSheetVisibility,
} from "@/components/ui/isolated-bottom-sheet-modal";
import { useRetainedPanelActive } from "@/components/retained-panel";
import { ScrollView } from "@/components/ui/scroll-view";
import { isWeb } from "@/constants/platform";
import { BottomSafeAreaInset } from "@/components/ui/bottom-safe-area-inset";
@@ -693,7 +694,36 @@ function CompactSheetBody({
);
}
export function AdaptiveModalSheet({
export function AdaptiveModalSheet(props: AdaptiveModalSheetProps) {
const panelActive = useRetainedPanelActive();
const { visible, onClose, onDismiss } = props;
const dismissalPending = useRef(false);
const finishDismissal = useCallback(() => {
if (!dismissalPending.current) return;
dismissalPending.current = false;
onDismiss?.();
}, [onDismiss]);
useLayoutEffect(() => {
if (!isWeb) return;
if (visible) dismissalPending.current = true;
if (panelActive) return;
// Complete dismissal when the inactive commit removes the portal, including when
// a close animation was already running. Compact portal cleanup can also report dismissal.
if (visible) onClose();
finishDismissal();
}, [panelActive, visible, onClose, finishDismissal]);
// A web portal escapes its hidden panel. Unmount its presentation in the inactive commit
// so a chat that freezes on the next commit cannot strand the overlay above another screen.
return !isWeb || panelActive ? (
<AdaptiveModalSheetPresentation {...props} onDismiss={isWeb ? finishDismissal : onDismiss} />
) : null;
}
function AdaptiveModalSheetPresentation({
header,
showCloseButton = true,
visible,
@@ -3954,6 +3954,7 @@ export class CodexAppServerAgentSession implements AgentSession {
private readonly usageSessionKey = randomUUID();
private readonly harnessEnvironment: Record<string, string>;
private readImportedSettings: boolean;
usageSession() {
if (this.closed) return null;
@@ -3977,7 +3978,9 @@ export class CodexAppServerAgentSession implements AgentSession {
private readonly autoReviewEnabled: boolean = false,
private readonly agentId?: string,
private readonly initialResumePurpose: "interactive" | "history" = "interactive",
importOptions?: { readImportedSettings: boolean },
) {
this.readImportedSettings = importOptions?.readImportedSettings ?? false;
this.logger = logger.child({
module: "agent",
provider: CODEX_PROVIDER,
@@ -4098,7 +4101,7 @@ export class CodexAppServerAgentSession implements AgentSession {
this.speedModels =
CodexModelListResponseSchema.parse(await client.request("model/list", {})).data ?? [];
this.normalizeSpeed();
if (!this.readImportedSettings) this.normalizeSpeed();
await this.loadResolvedConfig();
await this.loadCollaborationModes();
await this.loadSkills();
@@ -4106,6 +4109,10 @@ export class CodexAppServerAgentSession implements AgentSession {
if (this.currentThreadId) {
await this.ensureThreadLoaded();
await this.applyDefaultModelAndThinking();
if (this.readImportedSettings) {
this.normalizeSpeed();
this.readImportedSettings = false;
}
}
if (this.closed) {
@@ -4354,7 +4361,7 @@ export class CodexAppServerAgentSession implements AgentSession {
const runs = resolved ?? "default";
this.providerOptions = { ...this.providerOptions, service_tier: runs };
this.requestedServiceTier = runs;
this.openOptionsPatch = { service_tier: runs };
this.openOptionsPatch = { ...this.openOptionsPatch, service_tier: runs };
}
private get serviceTier(): string | null {
@@ -4642,6 +4649,7 @@ export class CodexAppServerAgentSession implements AgentSession {
const response = await this.client.request("thread/resume", params);
this.rememberResolvedSandboxPolicy(response);
this.rememberRestoredCollaborationMode(response);
this.applyImportedThreadSettings(response);
}
} catch (error) {
const threadId = this.currentThreadId;
@@ -4657,6 +4665,7 @@ export class CodexAppServerAgentSession implements AgentSession {
const response = await this.client.request("thread/resume", params);
this.rememberResolvedSandboxPolicy(response);
this.rememberRestoredCollaborationMode(response);
this.applyImportedThreadSettings(response);
this.logger.info({ threadId }, "Unarchived Codex thread to restore active Paseo agent");
} else {
this.logger.warn({ error, threadId }, "Failed to resume persisted Codex thread");
@@ -4686,6 +4695,26 @@ export class CodexAppServerAgentSession implements AgentSession {
this.refreshResolvedCollaborationMode();
}
private applyImportedThreadSettings(response: unknown): void {
if (!this.readImportedSettings) return;
const thread = toObjectRecord(response);
if (!this.config.model && typeof thread?.model === "string" && thread.model) {
this.config.model = thread.model;
}
if (typeof thread?.reasoningEffort === "string") {
this.config.thinkingOptionId ??= normalizeCodexThinkingOptionId(thread.reasoningEffort);
}
const mode = this.restoredCollaborationMode?.mode;
if (mode === "plan" || mode === "default") {
const planMode = mode === "plan";
this.providerOptions = { ...this.providerOptions, plan_mode: planMode };
this.openOptionsPatch = { ...this.openOptionsPatch, plan_mode: planMode };
this.setPlanMode(planMode);
}
}
private parseSlashCommandInput(text: string): { commandName: string; args?: string } | null {
const trimmed = text.trim();
if (!trimmed.startsWith("/") || trimmed.length <= 1) {
@@ -8610,6 +8639,22 @@ export class CodexAppServerAgentClient implements AgentClient {
launchContext?: AgentLaunchContext,
options?: AgentResumeSessionOptions,
): Promise<AgentSession> {
return this.openResumedSession({ handle, overrides, launchContext, options });
}
private async openResumedSession({
handle,
overrides,
launchContext,
options,
readImportedSettings = false,
}: {
handle: { sessionId: string; metadata?: Record<string, unknown> };
overrides?: Partial<AgentSessionConfig>;
launchContext?: AgentLaunchContext;
options?: AgentResumeSessionOptions;
readImportedSettings?: boolean;
}): Promise<AgentSession> {
const storedConfig = (handle.metadata ?? {}) as Partial<AgentSessionConfig>;
const merged: AgentSessionConfig = {
...storedConfig,
@@ -8641,6 +8686,7 @@ export class CodexAppServerAgentClient implements AgentClient {
autoReviewEnabled,
launchContext?.agentId,
options?.purpose ?? "interactive",
{ readImportedSettings },
);
await session.connect();
return session;
@@ -8706,12 +8752,32 @@ export class CodexAppServerAgentClient implements AgentClient {
}
async importSession(input: ImportProviderSessionInput, context: ImportProviderSessionContext) {
return importSessionFromPersistence({
const imported = await importSessionFromPersistence({
provider: CODEX_PROVIDER,
request: input,
context,
resumeSession: this.resumeSession.bind(this),
resumeSession: (handle, config, launchContext) =>
this.openResumedSession({
handle,
overrides: config,
launchContext,
readImportedSettings: true,
}),
});
try {
const runtime = await imported.session.getRuntimeInfo();
return {
...imported,
config: {
...imported.config,
model: runtime.model ?? imported.config.model,
thinkingOptionId: runtime.thinkingOptionId ?? imported.config.thinkingOptionId,
},
};
} catch (error) {
await imported.session.close();
throw error;
}
}
async getCatalogCacheKey(_options: FetchCatalogOptions): Promise<string> {
@@ -1,14 +1,20 @@
import { mkdtempSync, rmSync } from "node:fs";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { once } from "node:events";
import { createServer, type Server } from "node:http";
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { z } from "zod";
import { afterEach, describe, expect, test } from "vitest";
import { createTestLogger } from "../../../test-utils/test-logger.js";
import { spawnProcess } from "../../../utils/spawn.js";
import { withTimeout } from "../../../utils/promise-timeout.js";
import { CodexAppServerAgentClient, CodexAppServerAgentSession } from "./codex-app-server-agent.js";
import { CodexAppServerClient } from "./codex/app-server-transport.js";
import { DaemonClient } from "../../test-utils/daemon-client.js";
import { createTestPaseoDaemon } from "../../test-utils/paseo-daemon.js";
// Runs the real `codex` binary against a local Responses endpoint standing in
// for a custom provider's OPENAI_BASE_URL, so no login is needed.
@@ -51,10 +57,13 @@ async function startResponsesEndpoint(): Promise<{
baseUrl: string;
server: Server;
requestCount: () => number;
lastRequest: () => unknown;
}> {
let requests = 0;
let lastRequest: unknown;
const server = createServer((req, res) => {
req.resume();
const chunks: Buffer[] = [];
req.on("data", (chunk: Buffer) => chunks.push(chunk));
req.on("end", () => {
if (req.method !== "POST" || req.url !== "/v1/responses") {
res.statusCode = 404;
@@ -62,6 +71,7 @@ async function startResponsesEndpoint(): Promise<{
return;
}
requests += 1;
lastRequest = JSON.parse(Buffer.concat(chunks).toString());
res.setHeader("content-type", "text/event-stream");
res.end(finalAnswer());
});
@@ -74,6 +84,7 @@ async function startResponsesEndpoint(): Promise<{
baseUrl: `http://127.0.0.1:${address.port}/v1`,
server,
requestCount: () => requests,
lastRequest: () => lastRequest,
};
}
@@ -192,3 +203,101 @@ describe("Codex custom provider import list", () => {
120_000,
);
});
async function seedNativePlanThread(cwd: string, env: NodeJS.ProcessEnv): Promise<string> {
const child = await spawnProcess("codex", ["app-server"], { cwd, env, stdio: "pipe" });
const seed = new CodexAppServerClient(child, createTestLogger());
try {
await seed.request("initialize", {
clientInfo: { name: "import-test", version: "1" },
capabilities: { experimentalApi: true },
});
seed.notify("initialized");
const { thread } = z.object({ thread: z.object({ id: z.string() }) }).parse(
await seed.request("thread/start", {
cwd,
model: "gpt-5.4",
config: { model_reasoning_effort: "high" },
}),
);
const completed = Promise.withResolvers<unknown>();
seed.setNotificationHandler((method, params) => {
if (method === "turn/completed") completed.resolve(params);
});
await seed.request("turn/start", {
threadId: thread.id,
input: [{ type: "text", text: "Reply done." }],
collaborationMode: {
mode: "plan",
settings: { model: "gpt-5.4", reasoning_effort: "high", developer_instructions: null },
},
});
expect(
await withTimeout(completed.promise, 15_000, "Native Codex turn did not finish"),
).toMatchObject({ turn: { status: "completed" } });
return thread.id;
} finally {
await seed.dispose();
}
}
test("import preserves the Codex thread model, reasoning effort, and Plan mode", async () => {
const artifacts = fileURLToPath(new URL("../../../../../../.artifacts/", import.meta.url));
mkdirSync(artifacts, { recursive: true });
const cwd = mkdtempSync(path.join(artifacts, "codex-import-settings-"));
const endpoint = await startResponsesEndpoint();
try {
writeFileSync(
path.join(cwd, "config.toml"),
[
'model = "gpt-5.4-mini"',
'model_reasoning_effort = "low"',
'model_provider = "fixture"',
"[model_providers.fixture]",
'name = "Fixture"',
'wire_api = "responses"',
'base_url = "' + endpoint.baseUrl + '"',
].join("\n"),
);
const env = { ...process.env, CODEX_HOME: cwd };
const sessionId = await seedNativePlanThread(cwd, env);
const expectedRequest = { model: "gpt-5.4", reasoning: { effort: "high" } };
expect(endpoint.lastRequest()).toMatchObject(expectedRequest);
const daemon = await createTestPaseoDaemon({
agentClients: {},
providerOverrides: { codex: { env: { CODEX_HOME: cwd }, options: { service_tier: "fast" } } },
paseoHomeRoot: cwd,
});
const client = new DaemonClient({ url: `ws://127.0.0.1:${daemon.port}/ws` });
try {
await client.connect();
const agent = await client.importAgent({ provider: "codex", sessionId, cwd });
const previousRequests = endpoint.requestCount();
await client.sendAgentMessage(agent.id, "Reply done again.");
expect(await client.waitForFinish(agent.id, 30_000)).toMatchObject({ status: "idle" });
expect(endpoint.requestCount()).toBeGreaterThan(previousRequests);
expect(endpoint.lastRequest()).toMatchObject(expectedRequest);
expect(agent).toMatchObject({
model: "gpt-5.4",
thinkingOptionId: "high",
runtimeInfo: { extra: { collaborationMode: "Plan" } },
options: { plan_mode: true, service_tier: "default" },
});
await client.setAgentOptions(agent.id, { plan_mode: false });
expect(await client.fetchAgent(agent.id)).toMatchObject({
agent: {
model: "gpt-5.4",
thinkingOptionId: "high",
runtimeInfo: { extra: { collaborationMode: "Default" } },
options: { plan_mode: false, service_tier: "default" },
},
});
} finally {
await client.close();
await daemon.close();
}
} finally {
await closeServer(endpoint.server);
rmSync(cwd, { recursive: true, force: true });
}
}, 60_000);