ChemPal Documentation - v1.7.0
    Preparing search index...
    • 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-based ErrorBoundary after a render crash. When no DOM is available it opens the GitHub path directly.

      Parameters

      • Optionalerror: unknown

        The error that triggered the report, if any.

      • Optionalcontext: ReportContext

        Optional page URL, action label, and extra payload.

      Returns Promise<ReportChoice>

      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} />);
      });
      }