mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 00:18:27 +00:00
* feat(cli): share rendered videos through unified reviews (#7135) * feat(share): attach editable project sources to reviews (#7137) * feat(share): measure local sharing outcomes (#7138) * feat(cli): stage the sixty-day publish transition (#7136) * feat(studio): share review pages from local preview (#7140) Advertise the CLI sharing bridge before bootstrapping it so standalone Studio does not request unsupported routes. Preserve origin and session checks. Budget the intended sharing artifact: clean main packs at 8,060,519 bytes versus 8,162,979 with sharing (8,169,168 in CI). Required policy and Unicode tables, bundled sharing code, and Studio controls account for the growth. Set the packed-only budget to 8,577,627, following the 5% headroom convention; retain the unpacked cap and all package checks. * fix(share): persist refusals and improve CLI retry feedback * fix(ci): restore render diagnostics and include sharing workspace * fix(cli): keep sharing owner error codes stable * fix(share): clarify update feedback and align audience changes * fix(share): clarify updates and avoid scratch-file rerenders * fix(cli): report active shares and preserve update channels * fix(cli): resolve update channel when checking registry * fix(ci): refresh sharing package budgets after rebase * fix(share): require consent before uploading project files
108 lines
3.9 KiB
TypeScript
108 lines
3.9 KiB
TypeScript
/**
|
||
* Shared render-success sentinel + post-artifact-validated cleanup guards.
|
||
*
|
||
* Read by the top-level CLI process handlers (uncaughtException /
|
||
* unhandledRejection) to sanitize the exit code when a post-artifact-validated
|
||
* cleanup step throws.
|
||
*
|
||
* Set by the render command AFTER `executeRenderJob` (or the Docker child
|
||
* render) resolves cleanly — the point at which the artifact has been
|
||
* validated AND committed to disk. Any throw after this point (worker
|
||
* teardown, browser shutdown, telemetry flush, feedback prompt, stray
|
||
* promise rejection) must not turn a valid render into an exit-1
|
||
* "no final error message" failure.
|
||
*
|
||
* Field signal (all win32/x64, CLI 0.7.58, ffmpeg=no, 1080x1920 renders):
|
||
* - ts=1784169760 — 6-worker capture retried down after Runtime.evaluate
|
||
* timeout, completed all 1260 frames, printed 'artifact validated',
|
||
* exited 1 with no final error message. Output MP4 valid on disk.
|
||
* - ts=1784171150 — full REPRO command provided; identical shape.
|
||
* - ts=1784172467 — `--workers 2`, identical shape.
|
||
* All three: ffprobe + visual QA confirmed the output was valid; the CLI
|
||
* still exited 1 after the terminal "artifact validated" checkpoint.
|
||
*/
|
||
|
||
import { sanitizeSuccessfulExitCode } from "./commandResult.js";
|
||
|
||
let renderSucceeded = false;
|
||
let commandDelivered = false;
|
||
|
||
/**
|
||
* Called by the render command after the producer's `executeRenderJob` (or
|
||
* the Docker child) resolves cleanly. From this point on, any thrown
|
||
* teardown error must not be allowed to override the exit code.
|
||
*/
|
||
export function markRenderSucceeded(): void {
|
||
renderSucceeded = true;
|
||
}
|
||
|
||
/**
|
||
* Read by cli.ts process handlers to decide whether a late throw is fatal.
|
||
* When true, the handlers log the throw at warn level (so it's still visible
|
||
* for diagnosis) but do not surface it as an exit-1 failure.
|
||
*/
|
||
export function isRenderSucceeded(): boolean {
|
||
return renderSucceeded;
|
||
}
|
||
|
||
/** Called by the root CLI once any command's result is out with exit 0. */
|
||
export function markCommandDelivered(): void {
|
||
commandDelivered = true;
|
||
}
|
||
|
||
/** True once the run has delivered its result, so a late teardown error must not change the exit code. */
|
||
export function isRunDelivered(): boolean {
|
||
return renderSucceeded || commandDelivered;
|
||
}
|
||
|
||
/** Test-only reset. Not exported from the package. */
|
||
export function _resetRenderSuccessForTests(): void {
|
||
renderSucceeded = false;
|
||
commandDelivered = false;
|
||
}
|
||
|
||
type PostRenderErrorSink = (message: string) => void;
|
||
|
||
const defaultErrorSink: PostRenderErrorSink = (message) => {
|
||
process.stderr.write(`${message}\n`);
|
||
};
|
||
|
||
/**
|
||
* Run a post-artifact-validated cleanup step so a throw cannot flip the CLI
|
||
* exit code. Use only after the artifact is committed to disk. Logs a compact
|
||
* warning and swallows the error. Only a top-level render that called
|
||
* `markRenderSucceeded()` may ask the root CLI to clear a stray exit code;
|
||
* an embedded render does not own the surrounding command’s outcome.
|
||
*/
|
||
export function runPostRenderStep(
|
||
label: string,
|
||
fn: () => void,
|
||
sink: PostRenderErrorSink = defaultErrorSink,
|
||
): void {
|
||
try {
|
||
fn();
|
||
} catch (err) {
|
||
reportPostRenderStepFailure(label, err, sink);
|
||
}
|
||
}
|
||
|
||
export async function runPostRenderStepAsync(
|
||
label: string,
|
||
fn: () => Promise<void>,
|
||
sink: PostRenderErrorSink = defaultErrorSink,
|
||
): Promise<void> {
|
||
try {
|
||
await fn();
|
||
} catch (err) {
|
||
reportPostRenderStepFailure(label, err, sink);
|
||
}
|
||
}
|
||
|
||
function reportPostRenderStepFailure(label: string, err: unknown, sink: PostRenderErrorSink): void {
|
||
const message = err instanceof Error ? err.message : String(err);
|
||
sink(` [hyperframes] Post-render step '${label}' failed (render already succeeded): ${message}`);
|
||
// The failing step (or something it triggered) may have set a non-zero
|
||
// exitCode. The render succeeded, so ask the root CLI owner to clear it.
|
||
if (isRenderSucceeded()) sanitizeSuccessfulExitCode();
|
||
}
|