mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-23 01:32:40 +00:00
* feat(app): reveal streaming text as one continuous fade front Streaming assistant text is released by word and every character fades in over the same 150 ms envelope from a start time owned by the message. Start times never decrease in reading order, so a line paints as a single front moving left to right, however the text is chunked. Per-word envelopes with an internal stagger let the next word's first letter overtake the previous word's last letter, which read as holes and flashing words at the real frame rate; 100 ms frame strips hid it. Native renderers receive the fade ranges as a prop on a host view wrapping the root Text, so ranges and text land in the same Fabric mount transaction. The earlier binding sent ranges through a separate async module call keyed by view tag and had to reconcile them against the view's text; on a fast phone the UI thread lags JS by several commits, mounts and calls interleave, and every reconciliation heuristic guessed wrong. Native code no longer infers newness or creates start times. The mock load-test provider now separates cycles with a blank line so a cycle heading is not appended to the previous paragraph. * fix(ci): refresh streaming dependencies and isolate E2E setup * test(app): distinguish fade cleanup from Markdown replacement * test(app): detect restarted fades during Markdown updates * docs(app): keep streaming guidance focused on constraints and QA * test(app): control animation time in Android fade assertions Fixed wall-clock sleeps let emulator scheduling select the sampled animation frame. Inject the animator time source and drive paint at exact timestamps within one UI-thread operation; production keeps the system clock. Verify the mid-fade sample and the exact cleanup boundary without sleeps, polling, or retries. * fix(test): compile the desktop renderer before lifecycle checks The lifecycle fixture treated Metro /status as app readiness. Its first Settings click therefore spent its 90-second UI budget compiling the cold bundle. An isolated cold-cache run restricted to one CPU reproduced the click timeout before the app runtime had loaded. Reuse the browser suite's existing bundle warmup before launching Electron, and preserve Metro output in the lifecycle artifacts. The UI timeout, build-request timeout, lifecycle assertions and product behavior are unchanged. CI did not preserve Metro output, so its precise startup timing is not recoverable from the failed run. The retained log makes subsequent startup failures diagnosable without relying only on an empty renderer text dump. Validation: three complete lifecycle E2E runs under private Xvfb displays; existing Metro readiness tests; app typecheck; targeted lint; root format. * test(file-observer): await burst delivery through native recovery The deletion phase required every event within 10 seconds, but native coalescing recovery uses a 30-second safety audit followed by the existing reconciliation debounce. An idle diagnostic excludes that delayed audit and therefore cannot act as a completion barrier. Await the required delivered events instead, preserving every deletion assertion and the existing overall test watchdog. A real-filesystem test with controlled native notifications reproduces 95 outstanding paths at the old deadline and verifies completion when the safety audit delivers them. No production observer behavior changes. * test(file-observer): verify burst recovery through public events The controlled-clock regression constructed a private native backend, bypassing the interface used by consumers. Consolidate recovery coverage into the public observer integration test instead: drive real writes, deletes and directory renames, then await every required public event, including the 450 surviving files at their renamed paths. No public capability was added: subscribe callbacks already express completion. No production behavior or test timeout changes. * test(app): drive Android fade tests through the native host The instrumentation suite constructed TailFadeInAnimator directly, advanced its private clock, and counted FadeInSpan instances. It now mounts the WordFadeHost that React mounts, feeds it the ranges prop the bridge sends, and asserts rendered pixels: hidden before a start time, a monotone front inside and across words, settled frames equal to the baseline, and no frame callbacks left after settling. Span counts and internal timing state are no longer asserted. Choreographer cannot be advanced deterministically from a test and the fade epoch is the message's wall-clock start time, so the host takes a WordFadeFrameClock (time plus frame callbacks) as its smallest public seam; production keeps the Choreographer-backed default. Fixture text is sized in pixels so every sample stays on one line at any density; at 420 dpi the 32sp fixture wrapped and the column helper summed glyphs from the first line.
193 lines
6.2 KiB
TypeScript
193 lines
6.2 KiB
TypeScript
import { warmMetro } from "./metro-warmup.mjs";
|
|
export { warmMetro } from "./metro-warmup.mjs";
|
|
import { spawn, type ChildProcess } from "node:child_process";
|
|
import { killProcessTree } from "./helpers/spawn-node";
|
|
import { existsSync } from "node:fs";
|
|
import path from "node:path";
|
|
import net from "node:net";
|
|
import dotenv from "dotenv";
|
|
|
|
export interface WaitForServerOptions {
|
|
host?: string;
|
|
timeoutMs?: number;
|
|
label: string;
|
|
childProcess?: ChildProcess | null;
|
|
getRecentOutput?: () => string;
|
|
}
|
|
|
|
type ServerProbe = (host: string, port: number) => Promise<void>;
|
|
|
|
const RESERVED_LOCAL_PORTS = new Set([
|
|
6767, // Installed daemon.
|
|
6768, // Developer daemon.
|
|
61680, // OpenCode's default local server.
|
|
]);
|
|
|
|
function createLineBuffer(maxLines = 120): { add: (line: string) => void; dump: () => string } {
|
|
const lines: string[] = [];
|
|
return {
|
|
add(line) {
|
|
lines.push(line);
|
|
if (lines.length > maxLines) lines.shift();
|
|
},
|
|
dump: () => lines.join("\n"),
|
|
};
|
|
}
|
|
|
|
function formatRecentOutput(getRecentOutput?: () => string): string {
|
|
const output = getRecentOutput?.().trim();
|
|
return output ? `\nRecent output:\n${output}` : "";
|
|
}
|
|
|
|
async function getAvailablePort(): Promise<number> {
|
|
return new Promise((resolve, reject) => {
|
|
const server = net.createServer();
|
|
server.once("error", reject);
|
|
server.listen(0, "127.0.0.1", () => {
|
|
const address = server.address();
|
|
if (!address || typeof address === "string") {
|
|
server.close(() => reject(new Error("Failed to acquire port")));
|
|
return;
|
|
}
|
|
server.close(() => resolve(address.port));
|
|
});
|
|
});
|
|
}
|
|
|
|
async function getAvailableE2EPort(): Promise<number> {
|
|
for (;;) {
|
|
const port = await getAvailablePort();
|
|
if (!RESERVED_LOCAL_PORTS.has(port)) return port;
|
|
}
|
|
}
|
|
|
|
async function connectToServer(host: string, port: number): Promise<void> {
|
|
await new Promise<void>((resolve, reject) => {
|
|
const socket = net.connect(port, host, () => {
|
|
socket.end();
|
|
resolve();
|
|
});
|
|
socket.setTimeout(1_000, () => {
|
|
socket.destroy();
|
|
reject(new Error(`Connection timed out to ${host}:${port}`));
|
|
});
|
|
socket.on("error", reject);
|
|
});
|
|
}
|
|
|
|
async function waitForServer(
|
|
port: number,
|
|
options: WaitForServerOptions,
|
|
probe: ServerProbe = connectToServer,
|
|
): Promise<void> {
|
|
const { host = "127.0.0.1", timeoutMs = 15_000, label, childProcess, getRecentOutput } = options;
|
|
const deadline = Date.now() + timeoutMs;
|
|
let lastConnectionError: unknown = null;
|
|
|
|
while (Date.now() < deadline) {
|
|
if (childProcess?.exitCode !== null && childProcess?.exitCode !== undefined) {
|
|
const signal = childProcess.signalCode ? `, signal ${childProcess.signalCode}` : "";
|
|
throw new Error(
|
|
`${label} exited before listening on ${host}:${port} (exit code ${childProcess.exitCode}${signal}).${formatRecentOutput(getRecentOutput)}`,
|
|
);
|
|
}
|
|
try {
|
|
await probe(host, port);
|
|
return;
|
|
} catch (error) {
|
|
lastConnectionError = error;
|
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
}
|
|
}
|
|
|
|
const reason =
|
|
lastConnectionError instanceof Error
|
|
? ` Last connection error: ${lastConnectionError.message}`
|
|
: "";
|
|
throw new Error(
|
|
`${label} did not start on ${host}:${port} within ${timeoutMs}ms.${reason}${formatRecentOutput(getRecentOutput)}`,
|
|
);
|
|
}
|
|
|
|
async function probeMetro(host: string, port: number): Promise<void> {
|
|
const response = await fetch(`http://${host}:${port}/status`, {
|
|
signal: AbortSignal.timeout(1_000),
|
|
});
|
|
const body = (await response.text()).trim();
|
|
if (response.status !== 200 || body !== "packager-status:running") {
|
|
throw new Error(
|
|
`Expected Metro status on ${host}:${port}, received HTTP ${response.status}: ${JSON.stringify(body.slice(0, 200))}`,
|
|
);
|
|
}
|
|
}
|
|
|
|
export async function waitForMetro(port: number, options: WaitForServerOptions): Promise<void> {
|
|
await waitForServer(port, options, probeMetro);
|
|
}
|
|
|
|
function startMetro(port: number, buffer: ReturnType<typeof createLineBuffer>): ChildProcess {
|
|
const appDir = path.resolve(__dirname, "../..");
|
|
const expoCli = require.resolve("expo/bin/cli");
|
|
// Spawns Node directly to bypass Windows .cmd shim execution restrictions without shell: true.
|
|
const child = spawn(process.execPath, [expoCli, "start", "--web", "--port", String(port)], {
|
|
cwd: appDir,
|
|
env: {
|
|
...process.env,
|
|
BROWSER: "none",
|
|
...(process.env.E2E_DESKTOP_RUNTIME === "1" ? { PASEO_WEB_PLATFORM: "electron" } : {}),
|
|
},
|
|
stdio: ["ignore", "pipe", "pipe"],
|
|
detached: false,
|
|
});
|
|
const log = (chunk: Buffer, stream: "stdout" | "stderr") => {
|
|
for (const line of chunk.toString().split("\n").filter(Boolean)) {
|
|
buffer.add(`[${stream}] ${line}`);
|
|
console[stream === "stdout" ? "log" : "error"](`[metro] ${line}`);
|
|
}
|
|
};
|
|
child.stdout?.on("data", (chunk: Buffer) => log(chunk, "stdout"));
|
|
child.stderr?.on("data", (chunk: Buffer) => log(chunk, "stderr"));
|
|
return child;
|
|
}
|
|
|
|
async function loadHarnessEnvironment(repoRoot: string): Promise<void> {
|
|
const envTestPath = path.join(repoRoot, ".env.test");
|
|
if (existsSync(envTestPath)) dotenv.config({ path: envTestPath });
|
|
}
|
|
|
|
export default async function globalSetup() {
|
|
if (process.env.PASEO_REPLICA_CACHE_MEASUREMENT === "1") {
|
|
if (!process.env.PASEO_REPLICA_CACHE_MEASUREMENT_URL) {
|
|
throw new Error("PASEO_REPLICA_CACHE_MEASUREMENT_URL must be set for live measurement");
|
|
}
|
|
return;
|
|
}
|
|
const repoRoot = path.resolve(__dirname, "../../../..");
|
|
await loadHarnessEnvironment(repoRoot);
|
|
|
|
const metroPort = await getAvailableE2EPort();
|
|
const metroOutput = createLineBuffer();
|
|
let metroProcess: ChildProcess | null = null;
|
|
|
|
try {
|
|
metroProcess = startMetro(metroPort, metroOutput);
|
|
await waitForMetro(metroPort, {
|
|
label: "Metro web server",
|
|
timeoutMs: 120_000,
|
|
childProcess: metroProcess,
|
|
getRecentOutput: metroOutput.dump,
|
|
});
|
|
await warmMetro(metroPort);
|
|
process.env.E2E_METRO_PORT = String(metroPort);
|
|
console.log(`[e2e] Metro warmed on port ${metroPort}`);
|
|
|
|
return async () => {
|
|
await killProcessTree(metroProcess);
|
|
console.log("[e2e] Metro stopped");
|
|
};
|
|
} catch (error) {
|
|
await killProcessTree(metroProcess);
|
|
throw error;
|
|
}
|
|
}
|