# JBrowseDesktopRootModel

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. [View source](https://github.com/GMOD/jbrowse-components/blob/main/products/jbrowse-desktop/src/rootModel/rootModel.ts).

Holds JBrowse Desktop's top-level state: the loaded config, the session,
internet accounts, undo history, the app menus and the text-indexing jobs.

Many properties of the root model are available through the session, and
we generally prefer using the session model (via e.g. `getSession`) over the
root model (via e.g. `getRoot`) in plugin code.

Each section ends with the members a composed model contributes, linked to the page that documents them.

## Properties

| Member | Description |
| --- | --- |
| **jobsManager**<br><code>jobsManager: types.optional(JobsManager, {})</code> |  |

6 inherited properties from 3 models:

From [BaseRootModel](../baserootmodel): [`jbrowse`](../baserootmodel#property-jbrowse), [`session`](../baserootmodel#property-session), [`sessionPath`](../baserootmodel#property-sessionpath), [`assemblyManager`](../baserootmodel#property-assemblymanager)

From [InternetAccountsMixin](../internetaccountsmixin): [`internetAccounts`](../internetaccountsmixin#property-internetaccounts)

From [HistoryManagementMixin](../historymanagementmixin): [`history`](../historymanagementmixin#property-history)


## Volatiles

| Member | Description |
| --- | --- |
| **version**<br><code>string</code> |  |
| **adminMode**<br><code>boolean</code> |  |
| **detachDisposers**<br><code>(() =&gt; void)[]</code> | What has to stop the moment the Loader lets go of this root — here, the autosave autorun, which writes to disk over IPC.<br><br>Not `addDisposer`, which fires only on destroy, and the destroy is now a task later than the swap. An autosave left running in that gap writes the *outgoing* session to `sessionPath`, which the replacement has already been loaded from. See `detach`. |
| **openNewSessionCallback**<br><code>(_path: string) =&gt; Promise&lt;void&gt;</code> |  |
| **openLinkCallback**<br><code>(_link: string) =&gt; Promise&lt;void&gt;</code> |  |
| **returnToStartScreenCallback**<br><code>() =&gt; void</code> |  |

5 inherited volatiles from 2 models:

From [BaseRootModel](../baserootmodel): [`rpcManager`](../baserootmodel#volatile-rpcmanager), [`error`](../baserootmodel#volatile-error), [`textSearchManager`](../baserootmodel#volatile-textsearchmanager), [`pluginManager`](../baserootmodel#volatile-pluginmanager)

From [RootAppMenuMixin](../rootappmenumixin): [`mutableMenuActions`](../rootappmenumixin#volatile-mutablemenuactions)


## Methods

| Member | Description |
| --- | --- |
| **menus**<br><code>() =&gt; Menu[]</code> |  |

## Actions

| Member | Description |
| --- | --- |
| **addDetachDisposer**<br><code>(disposer: () =&gt; void) =&gt; void</code> | Register something that must stop when the Loader detaches this root. See the `detachDisposers` volatile for why this is not `addDisposer`. |
| **detach**<br><code>() =&gt; void</code> | Called when the Loader releases this root. Stops everything the root runs outside the tree (the worker pool and the autosave autorun) and leaves the tree itself alone.<br><br>The caller destroys the tree on a later task (`scheduleDetachedDestroy`), which runs the `beforeDestroy` hooks in it; plugins rely on those hooks, so the destroy cannot be skipped. This action stops the outside work immediately, so none of it runs between detach and destroy. ADR-069. |
| **setOpenNewSessionCallback**<br><code>(cb: (arg: string) =&gt; Promise&lt;void&gt;) =&gt; void</code> |  |
| **setOpenLinkCallback**<br><code>(cb: (arg: string) =&gt; Promise&lt;void&gt;) =&gt; void</code> | Wired by the Loader to open a JBrowse Web link as a new session (the Loader owns plugin-manager lifecycle, as with openNewSessionCallback). |
| **setReturnToStartScreenCallback**<br><code>(cb: () =&gt; void) =&gt; void</code> | Wired by the Loader to tear down this plugin manager and show the start screen (the Loader owns plugin-manager lifecycle). |
| **saveSession**<br><code>(val: SessionSnap) =&gt; Promise&lt;void&gt;</code> |  |
| **updateTrackBase**<br><code>(trackConf: { [key: string]: unknown; trackId: string; }) =&gt; void</code> | Replace a track's base config: its sessionTracks entry when the session owns the track, otherwise its jbrowse.tracks entry. |
| **setPluginsUpdated**<br><code>() =&gt; Promise&lt;void&gt;</code> | Persist the session, then rebuild the plugin manager from disk so the changed plugin set takes effect (Loader wires openNewSessionCallback to reload from the session path). |
| **flushSession**<br><code>() =&gt; Promise&lt;void&gt;</code> | Save now rather than waiting out the autosave's 1s debounce, so the last second of edits survives. Every path that tears the session down — quitting, returning to the start screen — has to call this first; Exit did not, and lost whatever was still inside the debounce window. |

14 inherited actions from 3 models:

From [BaseRootModel](../baserootmodel): [`setError`](../baserootmodel#action-seterror), [`setSession`](../baserootmodel#action-setsession), [`setDefaultSession`](../baserootmodel#action-setdefaultsession), [`setSessionPath`](../baserootmodel#action-setsessionpath), [`renameCurrentSession`](../baserootmodel#action-renamecurrentsession)

From [InternetAccountsMixin](../internetaccountsmixin): [`initializeInternetAccount`](../internetaccountsmixin#action-initializeinternetaccount), [`createEphemeralInternetAccount`](../internetaccountsmixin#action-createephemeralinternetaccount), [`findAppropriateInternetAccount`](../internetaccountsmixin#action-findappropriateinternetaccount)

From [RootAppMenuMixin](../rootappmenumixin): [`appendMenu`](../rootappmenumixin#action-appendmenu), [`insertMenu`](../rootappmenumixin#action-insertmenu), [`appendToMenu`](../rootappmenumixin#action-appendtomenu), [`insertInMenu`](../rootappmenumixin#action-insertinmenu), [`appendToSubMenu`](../rootappmenumixin#action-appendtosubmenu), [`insertInSubMenu`](../rootappmenumixin#action-insertinsubmenu)


