mirror of
https://github.com/getpaseo/paseo.git
synced 2026-12-05 22:55:33 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c00034b57 | ||
|
|
ce6f7d16a9 | ||
|
|
4dde313d45 |
@@ -8,6 +8,10 @@ import {
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
import { waitForWorkspaceTabsVisible } from "../support/helpers/workspace-tabs";
|
||||
|
||||
function visibleTerminalTabs(page: Page) {
|
||||
return page.locator('[data-testid^="workspace-tab-terminal_"]').filter({ visible: true });
|
||||
}
|
||||
|
||||
// The browser owns Cmd+Shift+brackets for its own tabs, so web keeps
|
||||
// Alt+Shift+brackets on every OS. Desktop bindings live in the desktop suite.
|
||||
test("web switches to the previous and next tab with Alt+Shift+[ and ]", async ({ page }) => {
|
||||
@@ -15,9 +19,7 @@ test("web switches to the previous and next tab with Alt+Shift+[ and ]", async (
|
||||
try {
|
||||
await gotoWorkspace(page, workspace.workspaceId);
|
||||
await waitForWorkspaceTabsVisible(page);
|
||||
const terminalTabs = page
|
||||
.locator('[data-testid^="workspace-tab-terminal_"]')
|
||||
.filter({ visible: true });
|
||||
const terminalTabs = visibleTerminalTabs(page);
|
||||
await clickNewTerminal(page);
|
||||
await expect(terminalTabs).toHaveCount(1, { timeout: 30_000 });
|
||||
await clickNewTerminal(page);
|
||||
@@ -38,7 +40,8 @@ test("web switches to the previous and next tab with Alt+Shift+[ and ]", async (
|
||||
|
||||
async function openBlankTabAfterTerminal(page: Page) {
|
||||
await clickNewTerminal(page);
|
||||
await page.getByRole("button", { name: "Terminal 1", exact: true }).focus();
|
||||
// The shell can set its own tab title before the terminal is ready for input.
|
||||
await visibleTerminalTabs(page).and(page.locator('[aria-selected="true"]')).focus();
|
||||
await openNewTabMenuWithShortcut(page);
|
||||
return page
|
||||
.getByRole("button", { name: "New tab", exact: true })
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Start with Claude's provider details open on a connected Android device.
|
||||
# Open the app with agent-device --no-test-ime so the software keyboard is visible.
|
||||
SESSION="${AGENT_DEVICE_SESSION:-default}"
|
||||
SERIAL="${ANDROID_SERIAL:-$(adb devices | awk '/\tdevice$/ {print $1; exit}')}"
|
||||
device() {
|
||||
agent-device --session "$SESSION" "$@"
|
||||
}
|
||||
|
||||
MODEL_HINT="e.g. openai/gpt-5"
|
||||
MODEL_FIELD="label=\"$MODEL_HINT\" role=text-field"
|
||||
|
||||
open_sheet() {
|
||||
device press 'label="Add model" role=button' --settle
|
||||
device wait "$MODEL_FIELD" 15000
|
||||
}
|
||||
|
||||
keyboard_shown() {
|
||||
adb -s "$SERIAL" shell dumpsys input_method | grep 'mInputShown=true' >/dev/null
|
||||
}
|
||||
|
||||
focus_model_field() {
|
||||
device press "$MODEL_FIELD" --settle
|
||||
if ! keyboard_shown; then
|
||||
echo "The software keyboard did not open." >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
model_field_bounds() {
|
||||
device snapshot -i --json | jq -ce --arg hint "$MODEL_HINT" '
|
||||
.data.nodes[] | select(.label == $hint and .kind == "text-field" and .visibleToUser) | .rect
|
||||
'
|
||||
}
|
||||
|
||||
open_sheet
|
||||
focus_model_field
|
||||
|
||||
# This press fails if the keyboard covers the button.
|
||||
device press 'label="Cancel" role=button'
|
||||
device wait absent "$MODEL_FIELD" 15000
|
||||
|
||||
open_sheet
|
||||
resting_bounds=$(model_field_bounds)
|
||||
focus_model_field
|
||||
device back --system --settle
|
||||
if keyboard_shown; then
|
||||
echo "Android Back did not dismiss the keyboard." >&2
|
||||
exit 1
|
||||
fi
|
||||
restored_bounds=$(model_field_bounds)
|
||||
if [[ "$restored_bounds" != "$resting_bounds" ]]; then
|
||||
echo "Model ID did not return to its resting bounds: $restored_bounds instead of $resting_bounds." >&2
|
||||
exit 1
|
||||
fi
|
||||
device press 'label="Cancel" role=button'
|
||||
device wait absent "$MODEL_FIELD" 15000
|
||||
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } fr
|
||||
import type { ComponentProps, ReactNode } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Keyboard, Text, View } from "react-native";
|
||||
import { Keyboard, Platform, Text, View } from "react-native";
|
||||
import type { DimensionValue, StyleProp, ViewProps, ViewStyle } from "react-native";
|
||||
import { StyleSheet, useUnistyles, withUnistyles } from "react-native-unistyles";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
@@ -694,6 +694,11 @@ function CompactSheetBody({
|
||||
);
|
||||
}
|
||||
|
||||
function getCompactSheetKeyboardBehavior(snapPoints: readonly string[]) {
|
||||
// With one snap point, extending cannot lift the sheet above the Android keyboard.
|
||||
return Platform.OS === "android" && snapPoints.length === 1 ? "interactive" : "extend";
|
||||
}
|
||||
|
||||
export function AdaptiveModalSheet(props: AdaptiveModalSheetProps) {
|
||||
const panelActive = useRetainedPanelActive();
|
||||
const { visible, onClose, onDismiss } = props;
|
||||
@@ -863,7 +868,7 @@ function AdaptiveModalSheetPresentation({
|
||||
enablePanDownToClose
|
||||
backgroundComponent={SheetBackground}
|
||||
handleComponent={SheetHandle}
|
||||
keyboardBehavior="extend"
|
||||
keyboardBehavior={getCompactSheetKeyboardBehavior(resolvedSnapPoints)}
|
||||
keyboardBlurBehavior="restore"
|
||||
accessible={false}
|
||||
presentation={presentation}
|
||||
|
||||
@@ -3954,7 +3954,6 @@ export class CodexAppServerAgentSession implements AgentSession {
|
||||
|
||||
private readonly usageSessionKey = randomUUID();
|
||||
private readonly harnessEnvironment: Record<string, string>;
|
||||
private readImportedSettings: boolean;
|
||||
|
||||
usageSession() {
|
||||
if (this.closed) return null;
|
||||
@@ -3978,9 +3977,7 @@ 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,
|
||||
@@ -4101,7 +4098,7 @@ export class CodexAppServerAgentSession implements AgentSession {
|
||||
|
||||
this.speedModels =
|
||||
CodexModelListResponseSchema.parse(await client.request("model/list", {})).data ?? [];
|
||||
if (!this.readImportedSettings) this.normalizeSpeed();
|
||||
this.normalizeSpeed();
|
||||
await this.loadResolvedConfig();
|
||||
await this.loadCollaborationModes();
|
||||
await this.loadSkills();
|
||||
@@ -4109,10 +4106,6 @@ 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) {
|
||||
@@ -4361,7 +4354,7 @@ export class CodexAppServerAgentSession implements AgentSession {
|
||||
const runs = resolved ?? "default";
|
||||
this.providerOptions = { ...this.providerOptions, service_tier: runs };
|
||||
this.requestedServiceTier = runs;
|
||||
this.openOptionsPatch = { ...this.openOptionsPatch, service_tier: runs };
|
||||
this.openOptionsPatch = { service_tier: runs };
|
||||
}
|
||||
|
||||
private get serviceTier(): string | null {
|
||||
@@ -4649,7 +4642,6 @@ 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;
|
||||
@@ -4665,7 +4657,6 @@ 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");
|
||||
@@ -4695,26 +4686,6 @@ 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) {
|
||||
@@ -8639,22 +8610,6 @@ 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,
|
||||
@@ -8686,7 +8641,6 @@ export class CodexAppServerAgentClient implements AgentClient {
|
||||
autoReviewEnabled,
|
||||
launchContext?.agentId,
|
||||
options?.purpose ?? "interactive",
|
||||
{ readImportedSettings },
|
||||
);
|
||||
await session.connect();
|
||||
return session;
|
||||
@@ -8752,32 +8706,12 @@ export class CodexAppServerAgentClient implements AgentClient {
|
||||
}
|
||||
|
||||
async importSession(input: ImportProviderSessionInput, context: ImportProviderSessionContext) {
|
||||
const imported = await importSessionFromPersistence({
|
||||
return importSessionFromPersistence({
|
||||
provider: CODEX_PROVIDER,
|
||||
request: input,
|
||||
context,
|
||||
resumeSession: (handle, config, launchContext) =>
|
||||
this.openResumedSession({
|
||||
handle,
|
||||
overrides: config,
|
||||
launchContext,
|
||||
readImportedSettings: true,
|
||||
}),
|
||||
resumeSession: this.resumeSession.bind(this),
|
||||
});
|
||||
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> {
|
||||
|
||||
+2
-111
@@ -1,20 +1,14 @@
|
||||
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { mkdtempSync, rmSync } 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.
|
||||
@@ -57,13 +51,10 @@ async function startResponsesEndpoint(): Promise<{
|
||||
baseUrl: string;
|
||||
server: Server;
|
||||
requestCount: () => number;
|
||||
lastRequest: () => unknown;
|
||||
}> {
|
||||
let requests = 0;
|
||||
let lastRequest: unknown;
|
||||
const server = createServer((req, res) => {
|
||||
const chunks: Buffer[] = [];
|
||||
req.on("data", (chunk: Buffer) => chunks.push(chunk));
|
||||
req.resume();
|
||||
req.on("end", () => {
|
||||
if (req.method !== "POST" || req.url !== "/v1/responses") {
|
||||
res.statusCode = 404;
|
||||
@@ -71,7 +62,6 @@ async function startResponsesEndpoint(): Promise<{
|
||||
return;
|
||||
}
|
||||
requests += 1;
|
||||
lastRequest = JSON.parse(Buffer.concat(chunks).toString());
|
||||
res.setHeader("content-type", "text/event-stream");
|
||||
res.end(finalAnswer());
|
||||
});
|
||||
@@ -84,7 +74,6 @@ async function startResponsesEndpoint(): Promise<{
|
||||
baseUrl: `http://127.0.0.1:${address.port}/v1`,
|
||||
server,
|
||||
requestCount: () => requests,
|
||||
lastRequest: () => lastRequest,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -203,101 +192,3 @@ 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);
|
||||
|
||||
Reference in New Issue
Block a user