Optionalerror: unknownThe error that triggered the report, if any.
Optionalcontext: ReportContextOptional page URL, action label, and extra payload.
The user's choice.
await showReportDialog(err, { action: "render-crash" });
export async function showReportDialog(
error?: unknown,
context?: ReportContext,
): Promise<ReportChoice> {
const diagnostics = await collectDiagnostics(error, context);
if (typeof document === 'undefined') {
openTab(buildGithubUrl(diagnostics));
return 'github';
}
return new Promise<ReportChoice>((resolve) => {
const container = document.createElement('div');
document.body.append(container);
const root = createRoot(container);
let settled = false;
const finish = (choice: ReportChoice) => {
if (settled) return;
settled = true;
resolve(choice);
// Defer teardown so the dialog's close transition can finish.
globalThis.setTimeout(() => {
root.unmount();
container.remove();
}, 300);
};
root.render(<ReportDialogHost diagnostics={diagnostics} onDone={finish} />);
});
}
Collects diagnostics and shows the review dialog, resolving once the user picks a report path or dismisses. Mounts the dialog into a throwaway React root appended to
document.body, so it works from any context — including the class-basedErrorBoundaryafter a render crash. When no DOM is available it opens the GitHub path directly.