Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

Merge commit '559a1196177420af5332d7c03055e1b4fac13537' into HEAD

tt-a1ib7cbcbc0e1e0
diff --cc scripts/build-readme-showcase.mjs
index ff41315e,4ca966fd..8332eaf8
--- a/scripts/build-readme-showcase.mjs
+++ b/scripts/build-readme-showcase.mjs
@@@ -334,9 -375,24 +394,23 @@@ function buildGif(ffmpeg, framesRoot)
'-y', '-loglevel', 'error', '-framerate', String(fps),
'-i', path.join(framesRoot, 'frame-%04d.png'),
'-filter_complex', filter, '-loop', '0', outputPath,
- ], { encoding: 'utf8' });
- if (result.status !== 0) throw new Error(`ffmpeg failed:\n${result.stderr || result.stdout}`);
+ ]);
}
+ // The owner of the temporary root must honor Chrome shutdown failure too.
+ export async function withCaptureDirectory(capture) {
+ const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-readme-showcase-'));
+ let retainProfile = false;
+ try {
+ return await capture(tempRoot);
+ } catch (error) {
+ retainProfile = error.retainProfile === true;
+ throw error;
+ } finally {
+ if (!retainProfile) fs.rmSync(tempRoot, { recursive: true, force: true });
+ }
+ }
+
async function main() {
for (const scene of scenes) {
const artifact = path.join(repoRoot, scene.artifact);
diff --cc test/readme-showcase.test.mjs
index 4ff8cac9,618bac27..44bb1a99
--- a/test/readme-showcase.test.mjs
+++ b/test/readme-showcase.test.mjs
@@@ -188,29 -190,70 +190,93 @@@ test('README motion proof is compact, l
}
});
+test('Windows command lookup and ffmpeg launch keep their boundary diagnostics', async () => {
+ const showcase = await import(pathToFileURL(path.join(repoRoot, 'scripts', 'build-readme-showcase.mjs')).href);
+ const selected = String.raw`C:\Tools\ffmpeg.EXE`;
+ const lookup = showcase.commandPath('ffmpeg', () => ({
+ status: 0,
+ stdout: `\r\n${selected}\r\nC:\\Other\\ffmpeg.exe\r\n`,
+ }), 'win32');
+ assert.equal(lookup, selected);
+ assert.equal(showcase.commandPath('ffmpeg', () => ({
+ status: 1,
+ stdout: '',
+ error: new Error('where failed'),
+ }), 'win32'), null);
+ assert.throws(
+ () => showcase.launchFfmpeg(selected, ['-version'], () => ({
+ status: null,
+ stderr: '',
+ error: Object.assign(new Error('spawn ENOENT'), { code: 'ENOENT' }),
+ })),
+ /ffmpeg failed:\s*spawn ENOENT/,
+ );
+});
+
+ function fakeChrome({ exitBeforeStop = false, closeOn = null } = {}) {
+ const child = new EventEmitter();
+ child.exitCode = null;
+ child.signalCode = null;
+ child.stderr = new PassThrough();
+ child.stdout = new PassThrough();
+ child.stdio = [null, child.stdout, child.stderr, new PassThrough(), new PassThrough()];
+ child.kill = (signal) => {
+ child.signalCode = signal;
+ if (closeOn === signal) {
+ child.exitCode = null;
+ queueMicrotask(() => child.emit('close', null, signal));
+ }
+ return true;
+ };
+ if (exitBeforeStop) {
+ child.exitCode = 0;
+ child.emit('close', 0, null);
+ }
+ return child;
+ }
+
+ test('showcase shutdown clears its timer and bounds a forced stop', async () => {
+ const showcase = await import(pathToFileURL(path.join(repoRoot, 'scripts', 'build-readme-showcase.mjs')).href);
+ const profile = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-showcase-profile-'));
+ const started = Date.now();
+ await showcase.stopChrome(fakeChrome({ exitBeforeStop: true }), profile);
+ assert.ok(Date.now() - started < 1000, 'an already exited browser must not wait for the losing timer');
+ fs.rmSync(profile, { recursive: true, force: true });
+
+ const retained = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-showcase-profile-'));
+ const forced = fakeChrome();
+ await assert.rejects(
+ () => showcase.stopChrome(forced, retained, 20),
+ new RegExp(`Chrome did not exit; profile retained at ${retained.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`),
+ );
+ assert.equal(forced.signalCode, 'SIGKILL');
+ assert.equal(fs.existsSync(retained), true);
+ fs.rmSync(retained, { recursive: true, force: true });
+
+ const graceful = fakeChrome({ closeOn: 'SIGTERM' });
+ const gracefulStarted = Date.now();
+ await showcase.stopChrome(graceful, profile);
+ assert.equal(graceful.signalCode, 'SIGTERM');
+ assert.ok(Date.now() - gracefulStarted < 1000, 'a prompt close must cancel the shutdown timer');
+ });
+
+ test('showcase navigation failure cancels its unused load waiter', async () => {
+ const showcase = await import(pathToFileURL(path.join(repoRoot, 'scripts', 'build-readme-showcase.mjs')).href);
+ const child = fakeChrome();
+ const cdp = new showcase.PipeCdp(child);
+ const loaded = cdp.waitFor('Page.loadEventFired', 'session');
+ let rejected = false;
+ loaded.catch(() => { rejected = true; });
+ const originalWrite = child.stdio[3].write.bind(child.stdio[3]);
+ child.stdio[3].write = () => { throw new Error('navigation pipe closed'); };
+ await assert.rejects(() => cdp.send('Page.navigate', { url: 'about:blank' }, 'session'), /navigation pipe closed/);
+ loaded.cancel();
+ await new Promise(resolve => setImmediate(resolve));
+ assert.equal(rejected, false);
+ child.stdio[3].write = originalWrite;
+ cdp.failAll(new Error('test finished'));
+ });
+
test('every README header links to the other languages', () => {
const languageLinks = [];
for (const { href, label } of readmeLanguages) {