# DiagonalizeProgressMixin

Auto-generated from the @jbrowse/mobx-state-tree model in the source. See the [developer guide](https://jbrowse.org/jb2/docs/developer_guide/) for concepts. Built into JBrowse core. [View source](https://github.com/GMOD/jbrowse-components/blob/main/packages/synteny-core/src/DiagonalizeProgressMixin.ts).

The auto-diagonalize lifecycle state shared by the comparative views
(LinearSyntenyView, DotplotView, CircularView): the in-flight wait, its live RPC status and
signal, and the flag that gates `settled` so a screenshot or browser test
can't capture a pre-reorder hairball.

`withDiagonalizeProgress` drives the wait and the status/signal pair; the view's
init autorun raises and lowers the gate, because it is the only code that knows a
reorder was asked for. Composed rather than duplicated so both
views report progress, cancel, and gate identically.

## Volatiles

| Member | Description |
| --- | --- |
| **awaitingAutoDiagonalize**<br><code>boolean</code> | True while the init autorun is waiting on the diagonalize RPC. Gates the canvas off — otherwise the user watches an undiagonalized hairball flash before the reorder kicks in. |
| **pendingAutoDiagonalize**<br><code>boolean</code> | A reorder this init asked for that has not succeeded yet. Raised before any render can paint, and lowered only once the pass resolves — a skipped or thrown reorder leaves it up, so the view's `settled` gate never reports done on an undiagonalized view and the capture fails loudly (times out) instead of committing a hairball.<br><br>One flag rather than a requested/complete pair: the two only ever moved together, and every state a pair can drift into either wedges the gate shut or opens it on the wrong pass. |
| **diagonalizeStatus**<br><code>StatusChannel</code> | Live status from the auto-diagonalize RPC (download %, parse, algorithm phase) shown on the reordering spinner; blank outside that wait.<br><br>A `StatusChannel` rather than a status field plus a setter: there is one operation to narrate here, and the channel is that pair with the message/fraction split already done, so the spinner reads `{ message, fraction }` instead of calling `statusMessageText` / `statusFraction` at every render site. |
| **diagonalizeCancel**<br><code>(() =&gt; void) &#124; undefined</code> | Aborts the in-flight auto-diagonalize, so the spinner's Cancel can reach it; undefined when none is running. |
| **diagonalizeError**<br><code>unknown</code> | Why the last reorder failed, while its gate is still up; cleared by the next run, a finish or a cancel |

## Actions

| Member | Description |
| --- | --- |
| **setAwaitingAutoDiagonalize**<br><code>(arg: boolean) =&gt; void</code> |  |
| **beginAutoDiagonalize**<br><code>(requested: boolean) =&gt; void</code> | Declare the gate at the top of one init apply pass: a reorder is pending iff THIS init asked for one. Assigning rather than raising is what hands the gate over cleanly — a superseded init that asked for a reorder and then skipped it would otherwise leave the flag up with nothing coming, wedging `settled` forever. |
| **finishAutoDiagonalize**<br><code>() =&gt; void</code> | A reorder resolved, the init's or a manual one, so the view on screen is the diagonalized one — open the gate. |
| **setDiagonalizeError**<br><code>(error: unknown) =&gt; void</code> |  |
| **setDiagonalizeCancel**<br><code>(arg?: (() =&gt; void) &#124; undefined) =&gt; void</code> |  |
| **cancelAutoDiagonalize**<br><code>() =&gt; void</code> | Abort an in-flight auto-diagonalize; `withDiagonalizeProgress`'s finally clears the wait flag, revealing the (undiagonalized) view.<br><br>Lowers the gate too. The abort reaches the caller as a throw, and the throw skips `finishAutoDiagonalize()` — right for a reorder that failed (`settled` stays false and a capture times out loudly rather than committing a hairball), wrong for one the user stopped: cancelling is the user accepting this view as it is, and a gate nothing will lower again leaves `settled` false forever. |

