Repository navigation
Description
Problem Statement
The page store is written with legacy MobX decorators on MobX 5, a version line that stopped two majors ago and that predates the React version the page runs on. Keeping the decorators alive costs the project in several places: a decorator compile step is configured in four build and test configurations; the main process carries a workaround because its build cannot compile the decorated store; the state-management packages declare peer ranges the page no longer satisfies; and the legacy decorator option the setup depends on has been removed from the next major of the compiler. A maintainer cannot upgrade MobX, and every contributor has to understand a decorator dialect that MobX itself has dropped.
The person using raxmlGUI should notice none of this, and must notice nothing when it is fixed.
Solution
The page store runs on the latest MobX 7 with the matching mobx-react-lite 5 and contains no decorators. Each store class declares its observable fields, computeds and actions in a plain annotation map. The decorator compile step is gone from every configuration, the main-process workaround is removed, and an unused MobX helper package is dropped. The app behaves exactly as before: every panel shows and updates the same state, and every analysis builds the same command and produces the same results.
The work lands in small steps on one feature branch, each step proven by tests that are written first and that pass on the current version before anything is converted.
User Stories
- As a researcher using raxmlGUI, I want loading an alignment to show its data type, sequence count and length as it does today, so that the upgrade costs me nothing.
- As a researcher, I want every option panel to show the same choices, defaults and availability as before, so that my analyses are set up the same way.
- As a researcher, I want changing an option to update the command preview immediately, so that I can still see what will run.
- As a researcher, I want the outgroup selection to keep its "none" behaviour (choosing a taxon clears "none", choosing "none" clears the taxa), so that I cannot build a contradictory outgroup.
- As a researcher, I want resetting an option to return it to its default, so that I can undo a change.
- As a researcher, I want invalid option values to show the same error messages as before, so that I know what to correct.
- As a researcher, I want the multistate number option to report an error for a missing or non-integer value, so that I do not start a run that will fail.
- As a researcher, I want adding a part in the partition editor to append it and prepare the next one with the next start position and a fresh name, so that I can define partitions quickly.
- As a researcher, I want the default partition to follow the alignment's length and data type, so that a single-partition analysis needs no manual setup.
- As a researcher, I want loading a partition file to show its path and content, so that I can review it before running.
- As a researcher, I want a run to start, stream its output, and finish or fail exactly as before, so that I can trust the results.
- As a researcher, I want model selection to run and apply the selected model as before, so that my raxml-ng analysis uses it.
- As a researcher, I want an ASTRAL run to show that it is running and to report its result, so that I know when it is done.
- As a researcher, I want cancelling a run or model selection to stay quiet, so that a cancel is not reported as an error.
- As a researcher, I want multiple runs in tabs to keep independent state, so that changing one does not disturb another.
- As a researcher, I want adding and removing runs to work as before, so that I can organise several analyses.
- As a researcher, I want the citation dialog to show and copy the same citations in each format, so that I can cite the tools I used.
- As a researcher, I want dark mode to switch and persist as before, so that my preference is kept.
- As a researcher, I want the app version to appear where it does today, so that I can report it in an issue.
- As a researcher, I want unhandled errors to be shown in the error dialog as before, so that failures are not silent.
- As a researcher, I want tree, backbone constraint and multifurcating constraint files to load and toggle as before, so that constrained searches still work.
- As a researcher, I want the modified-alignment notice and dialog to appear when an alignment was converted or changed, so that I know my input was altered.
- As a researcher on macOS, Ubuntu or Windows, I want identical behaviour after the upgrade, so that my platform is not the one that breaks.
- As a maintainer, I want the page store on the latest MobX 7, so that I receive fixes and can follow future releases.
- As a maintainer, I want
mobx-react-liteon the version that supports the React version the page uses, so that the pairing is inside its declared range. - As a maintainer, I want no decorators anywhere in the page store, so that no decorator compile step is needed.
- As a maintainer, I want the decorator plugin removed from every build and test configuration, so that the toolchain is simpler and the compiler can be upgraded later.
- As a maintainer, I want the decorator flag removed from the TypeScript configuration, so that the type checker matches what the code uses.
- As a maintainer, I want the main-process workaround for the decorated store removed, so that the main process can refer to the store's shape directly.
- As a maintainer, I want the unused MobX helper package removed, so that the dependency list reflects what the page imports.
- As a maintainer, I want the whole change to arrive upstream as one pull request from one feature branch, so that it is reviewed and merged as a unit.
- As a maintainer, I want each step on the feature branch to pass jest and the end-to-end suite on all three platforms, so that the branch is always in a working state.
- As a maintainer, I want the version bumps separated from the class rewrites, so that a failure points at one cause.
- As a contributor, I want every store class to declare its observable fields, computeds and actions in one visible map, so that I can see what is reactive without knowing a decorator dialect.
- As a contributor, I want one pattern used across the whole page store, so that I do not have to learn which classes use which style.
- As a contributor, I want a subclass that replaces a parent's action or computed to mark it as an override, so that the relationship is explicit and checked by MobX.
- As a contributor, I want jest to fail when a test changes observable state outside an action, so that I find out before review.
- As a contributor, I want the page store to raise no action warnings in normal use, so that a new warning stands out.
- As a contributor, I want every computed and action in the page store to have a test that asserts its result, so that I can change the store with confidence.
- As a contributor, I want every observable field to have a test proving that something depending on it updates, so that a field that stops being reactive is caught.
- As a reviewer, I want the coverage tests to land and pass on the current MobX version before any conversion, so that I know they pin today's behaviour.
- As a reviewer, I want a parity test that fails if any member that is observable, computed or an action today loses its annotation, so that I do not have to check 315 members by eye.
- As a reviewer, I want each class family converted in its own pull request, so that each review is small.
- As a reviewer, I want the behavioural rewrites (the option value initialisation, the outgroup override, the out-of-action writes) to land before the version bump, so that they are judged on their own.
- As an agent implementing a ticket, I want the replacement pattern stated once with an example, so that every conversion ticket produces the same shape.
- As an agent implementing a ticket, I want the order of steps and what each carries to be fixed, so that I do not have to decide scope.
- As an agent implementing a ticket, I want to know which details are left to my judgement, so that I do not reopen settled decisions.
- As a future maintainer, I want the temporary parity test and baseline removed at the end, so that no fixture is left to maintain.
- As a future maintainer, I want the later move past the current React plugin major to be unblocked by this work, so that the remaining compile step for JSX can be addressed separately.
Implementation Decisions
Target. The latest mobx 7 and mobx-react-lite 5. MobX 6 (mobx 6.16, mobx-react-lite 4.1) is an intermediate step only. Decorators are removed outright, not replaced by standard decorators. The unused mobx-utils package is removed, not upgraded.
Replacement pattern. Every class in the page store that has observable members calls makeObservable with an explicit annotation map in its constructor. makeAutoObservable is used nowhere; it throws for any class with a parent or a subclass.
- In the
Optionfamily, and in any class where a subclass replaces an action, actions are prototype methods. A subclass that replaces a parent action or computed annotates itoverride. - Elsewhere an action stays an arrow field where it is passed unbound. An annotated arrow action over an unannotated parent arrow field (the alignment's
dispose) is accepted as is. - A replaced computed is always annotated
override, never left unannotated. - A field that reads constructor-assigned state is assigned in the constructor body, not as a field initializer, because MobX 6 and 7 run initializers before the constructor body. In the page store this is the option's
value. - A subclass with no observable members of its own gets no
makeObservablecall. A class that needs one and has no constructor today gets a constructor.
From the prototype (trimmed):
class Option {
value;
constructor( run, defaultValue /* … */ ) {
this.defaultValue = defaultValue;
this.value = defaultValue; // was a field initializer reading this.defaultValue
makeObservable( this, {
value: observable,
setValue: action,
reset: action,
isDefault: computed,
error: computed,
} );
}
setValue( value ) { /* … */ }
}
class OutGroup extends Option {
constructor( run ) {
super( run, ['<none>'], 'Outgroup', '' );
makeObservable( this, {
options: computed,
setValue: override, // replaces the parent action
cmdValue: computed,
} );
}
setValue( value ) { /* … */ }
}Action enforcement. The page store runs under MobX's default setting ("observed") with no configure call. The eleven known writes to observable state outside an action are fixed, in five members: the alignment's parsed-alignment loader (two option values written after an await), the partition's add-part method, the run's ASTRAL start, the run's partition-file loader (two writes after an await), and the store base's version initialisation. Each is fixed by making the member an action or wrapping the writes that follow an await in runInAction. No temporary "never" setting is used at any step.
Order of steps. All on one feature branch, one pull request per ticket.
- Remove
mobx-utils. - Coverage push on MobX 5 (see Testing Decisions).
- Parity baseline and parity test.
- Rewrites that already work on MobX 5: the option's
valueassigned in the constructor;setValueas a prototype method with the outgroup option overriding it; the eleven out-of-action writes fixed; the three tests that assign observable state directly changed to set it insiderunInAction. - Bump to MobX 6 with decorators kept: both packages move in the same change; each decorated class gains a
makeObservable(this)call; each subclass override is marked with the override decorator; class fields flip to spec (define) semantics in the Babel configurations and the TypeScript configuration, for the page build and Jest together; the Jest setup fails a test on a MobX action warning. - Convert to annotation maps, one family per ticket, smallest first: the standalone classes (the final alignment, citation, part, partition, final partition, config); the app store with the run list; the input file with the alignment and the ASTRAL tree; the
Optionfamily (39 classes, one ticket); the run last. A family converts as a unit because decorators and annotation maps cannot be mixed within one inheritance chain. - Bump to MobX 7 and
mobx-react-lite5, with the one API rename the store needs (observable.refbecomesobservableRef) in the same change, since neither version accepts the other's name. - Cleanup: the decorator plugin leaves the three Babel configurations; the decorator flag is turned off in the TypeScript configuration; the main-process menu workaround for the decorated store is removed; the parity test and its baseline are deleted.
The Babel block stays. The page build keeps its Babel pass because it also compiles JSX in .js files. Only the decorator plugin leaves it. The React plugin stays on its current major.
Conversion method. The conversion is written directly, guided by the parity test. The official codemod is not used: it targets MobX 6 names, mishandles overrides in JavaScript, and does not know the method-versus-arrow rule above.
Call sites. Panels need no changes for the observer bumps. Option setValue is always called on its option, so making it a method is safe; the partition's reset is passed unbound and stays an arrow.
Branching. One feature branch for this spec; every ticket opens its pull request into it; the branch goes upstream as a single pull request. master is merged into the feature branch at step boundaries, not rebased, and the parity baseline is regenerated if master changed a decorated member.
Left to the implementer. How the coverage push is split into tickets (per store file is the default); the exact edit that removes the main-process workaround; whether the root Babel configuration file can be deleted outright (neither Jest nor the page build reads it; whether lint does is unverified); updates to the typecheck baseline.
Testing Decisions
A good test here asserts what a panel or a caller can observe from the page store: the value a computed returns, the state after an action, and that a dependent computed or reaction updates when an observable field changes. It does not assert how a member is annotated or how MobX is called. The one exception is the temporary parity test, which exists precisely to check annotations during the conversion and is deleted afterwards.
Seams, all existing.
- The page store's public members, under jest (primary). Tests construct store classes on the default test renderer bridge. Prior art: the existing store tests beside the store.
- Source scan, under jest (temporary). The parity test reads the store's source and compares annotated members against a baseline generated from today's decorators. Prior art: the existing source-scan tests for page imports and the typecheck baseline.
- Jest setup. One global check fails any test that triggers a MobX action warning, from the MobX 6 bump onward.
- Page paint, under jest. The existing render test is unchanged and proves the page still paints.
- The built shell, under Playwright. The existing end-to-end specs are unchanged and run on macOS, Ubuntu and Windows in CI on every pull request.
Coverage push (prerequisite of all conversion work).
- Scope: the page store only, not the panels.
- Bar: every computed and every action in the page store runs under jest and has its result asserted. Today 92 of 181 computeds and 54 of 93 actions run. Not a percentage.
- Reactivity: each observable field has at least one test proving that changing it updates a computed or reaction in the store. Panels are not rendered for this.
- The bar is measured once, by script, when the coverage work finishes. No coverage threshold is added to CI. The tests stay.
- The tests must pass on MobX 5 before any conversion ticket starts.
- Named so they are not skipped, because these members are rewritten and have no test today: the outgroup option's
setValue, the partition's add-part method, the multistate number option'serror.
Parity test. Fails if a member that is observable, computed or an action in the baseline is missing from its class's annotation map, or the reverse. It does not check that an annotation kind is right for a subclass; a wrong kind throws at construction, and jest constructs every class.
Gates. Jest and the end-to-end suite gate every pull request through CI. Steps 5, 7 and 8 change runtime behaviour globally and are where a platform-specific failure is most likely.
Out of Scope
- Upgrading the React plugin past its current major and removing the Babel block. The block also compiles JSX in
.jsfiles; that choice (rename to.jsx, a Babel plugin for the bundler, or a small pre-transform) is a separate effort after this one. - Redesigning the page store, or changing which state is observable.
- Converting the page store to TypeScript.
- New end-to-end flows, and tests that render panels to prove reactivity.
- A permanent coverage threshold in CI.
- Standard (TC39) decorators.
Further Notes
-
This spec is the handoff from the wayfinder map Map: page store on MobX 7 without decorators #105, which holds the decisions and links the evidence: MobX 6 rules (What MobX 6 changes for the page store #106), MobX 7 changes (What MobX 7 changes beyond MobX 6 for the page store #116), the React plugin findings (What @vitejs/plugin-react past 5 needs once decorators are gone #107), the override and write inventory (Inventory overrides and out-of-action writes in the page store #108), coverage (Measure how much of the page store the suites exercise #109), the prototype (Prototype the replacement pattern on Option and two subclasses #110), and the decisions on pattern (Choose the replacement pattern for decorators #111), action enforcement (Choose the action-enforcement setting #112), tests (Choose which page-store tests must exist before the conversion #117) and order (Choose the order of steps #113).
-
Research findings are on the branches
research/mobx-6-page-store,research/mobx-7-page-storeandresearch/plugin-react-after-decorators; the prototype is onprototype/mobx-7-option-pattern. None of these is merged. -
Inventory in brief: 52 classes; five overrides, of which only the outgroup option's redeclared arrow action is rejected by MobX 6 and 7; one initializer that reads constructor-assigned state; eleven out-of-action writes in five members; three tests that assign observable state directly.
-
Known gaps in the evidence: the write inventory matches by property name and can miss writes through an alias or into a nested plain object, and MobX 7.1 also checks Map and Set changes, so more warnings may surface on 7; they are fixed the same way. The transition assumptions for steps 4 and 5 were checked in a scratch build with this repo's compiler, not inside the app.
-
Feature branch:
spec/118-page-store-mobx-7, created fromorigin/masterbefore the first ticket is cut.
Activity
14 remaining items