Files
PerishFire 0688faaec3 reland(sidecar): converge product clients on package boundary (#7636)
* reland(sidecar): converge product clients after weekly release

Restore the sidecar convergence from #7244 after the release-scheduling revert in #7634. This tree matches the previously reviewed and cross-platform QA-accepted implementation at d83d4e032f.

* fix(sidecar): clarify identity and cache witnesses

Generated-By: looper 0.11.2 (runner=fixer, agent=codex)

* fix(packaged): probe cross-source desktop owners

Generated-By: looper 0.11.2 (runner=fixer, agent=codex)

* fix(sidecar): preserve cross-source launch ownership

Generated-By: looper 0.11.2 (runner=fixer, agent=codex)

* test(pack): assert cross-source Windows launch ownership

Generated-By: looper 0.11.2 (runner=fixer, agent=codex)

* fix(sidecar): align HyperFrames with client boundary

Generated-By: looper 0.11.2 (runner=fixer, agent=codex)

* fix(e2e): keep HyperFrames fixture in helper lane

Generated-By: looper 0.11.2 (runner=fixer, agent=codex)

* docs(sidecar): restore review and handoff contracts

Generated-By: looper 0.11.2 (runner=fixer, agent=codex)

* fix(sidecar): restore cache and daemon boundaries

Generated-By: looper 0.11.2 (runner=fixer, agent=codex)

* fix(pack): restore sourcemaps and Linux smoke discovery

Generated-By: looper 0.11.2 (runner=fixer, agent=codex)

* fix(sidecar): make payload handoff generation-atomic

* fix(sidecar): preserve packaged action and mode parity

Generated-By: looper 0.11.2 (runner=fixer, agent=codex)

* test(pack): align Linux cleanup resource count

Generated-By: looper 0.11.2 (runner=fixer, agent=codex)

* fix(packaged): preserve headless sidecar mode

* test: normalize source line endings

* fix(daemon): launch Codex cmd shims on Windows

---------

Co-authored-by: Looper <looper@noreply.github.com>
2026-09-01 13:22:04 +00:00

91 lines
2.4 KiB
TypeScript

import { mkdir, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import {
bootstrapSidecarProcess,
isCurrentSidecarLauncher,
readCurrentSidecarStamp,
SidecarFactory,
} from '@open-design/sidecar';
import {
SIDECAR_MESSAGES,
type DesktopRenderFramesInput,
} from '@open-design/sidecar-proto';
import { PNG } from 'pngjs';
const capturePath = process.env.OD_TEST_CAPTURED_FRAME_DOCUMENT;
const dataRoot = process.env.OD_TEST_SIDECAR_DATA_ROOT;
const runtimeRoot = process.env.OD_TEST_SIDECAR_RUNTIME_ROOT;
if ([capturePath, dataRoot, runtimeRoot].some((value) => value == null || value.length === 0)) {
throw new Error('HyperFrames desktop fixture paths are required');
}
const stamp = readCurrentSidecarStamp();
const resources = {
dataRoot: dataRoot!,
ownerPid: null,
port: 0,
runtimeRoot: runtimeRoot!,
};
if (isCurrentSidecarLauncher() && await bootstrapSidecarProcess(stamp, resources)) {
process.exit(0);
}
const framePng = solidPng(320, 180);
const client = SidecarFactory.create({
handlers: {
async [SIDECAR_MESSAGES.RENDER_FRAMES](rawInput) {
const input = rawInput as DesktopRenderFramesInput;
await Promise.all([
mkdir(input.outputDir, { recursive: true }),
writeFile(capturePath!, input.html, 'utf8'),
]);
for (let frame = 0; frame < 3; frame += 1) {
await writeFile(
join(input.outputDir, `frame-${String(frame).padStart(8, '0')}.png`),
framePng,
);
}
return {
duration: 0.1,
fps: 30,
frameCount: 3,
framePattern: join(input.outputDir, 'frame-%08d.png'),
height: 180,
ok: true,
width: 320,
};
},
},
lifecycle: {
async start() {
return { pid: process.pid };
},
status(runtime) {
return {
capabilities: { frameRenderer: true },
pid: runtime.pid,
state: 'running',
updatedAt: new Date().toISOString(),
url: null,
windowVisible: false,
};
},
async stop() {},
},
});
await client.start();
await client.waitUntilStopped();
function solidPng(width: number, height: number): Buffer {
const image = new PNG({ width, height });
for (let offset = 0; offset < image.data.length; offset += 4) {
image.data[offset] = 16;
image.data[offset + 1] = 37;
image.data[offset + 2] = 63;
image.data[offset + 3] = 255;
}
return PNG.sync.write(image);
}