Skip to content

Spec: page store on MobX 7 without decorators #118

Closed
42 of 42 issues completed
Closed

Description

@jtklein-agents

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

  1. 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.
  2. 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.
  3. As a researcher, I want changing an option to update the command preview immediately, so that I can still see what will run.
  4. 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.
  5. As a researcher, I want resetting an option to return it to its default, so that I can undo a change.
  6. As a researcher, I want invalid option values to show the same error messages as before, so that I know what to correct.
  7. 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.
  8. 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.
  9. 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.
  10. As a researcher, I want loading a partition file to show its path and content, so that I can review it before running.
  11. 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.
  12. As a researcher, I want model selection to run and apply the selected model as before, so that my raxml-ng analysis uses it.
  13. 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.
  14. As a researcher, I want cancelling a run or model selection to stay quiet, so that a cancel is not reported as an error.
  15. As a researcher, I want multiple runs in tabs to keep independent state, so that changing one does not disturb another.
  16. As a researcher, I want adding and removing runs to work as before, so that I can organise several analyses.
  17. 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.
  18. As a researcher, I want dark mode to switch and persist as before, so that my preference is kept.
  19. As a researcher, I want the app version to appear where it does today, so that I can report it in an issue.
  20. As a researcher, I want unhandled errors to be shown in the error dialog as before, so that failures are not silent.
  21. As a researcher, I want tree, backbone constraint and multifurcating constraint files to load and toggle as before, so that constrained searches still work.
  22. 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.
  23. 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.
  24. As a maintainer, I want the page store on the latest MobX 7, so that I receive fixes and can follow future releases.
  25. As a maintainer, I want mobx-react-lite on the version that supports the React version the page uses, so that the pairing is inside its declared range.
  26. As a maintainer, I want no decorators anywhere in the page store, so that no decorator compile step is needed.
  27. 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.
  28. As a maintainer, I want the decorator flag removed from the TypeScript configuration, so that the type checker matches what the code uses.
  29. 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.
  30. As a maintainer, I want the unused MobX helper package removed, so that the dependency list reflects what the page imports.
  31. 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.
  32. 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.
  33. As a maintainer, I want the version bumps separated from the class rewrites, so that a failure points at one cause.
  34. 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.
  35. 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.
  36. 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.
  37. As a contributor, I want jest to fail when a test changes observable state outside an action, so that I find out before review.
  38. As a contributor, I want the page store to raise no action warnings in normal use, so that a new warning stands out.
  39. 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.
  40. 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.
  41. 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.
  42. 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.
  43. As a reviewer, I want each class family converted in its own pull request, so that each review is small.
  44. 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.
  45. 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.
  46. 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.
  47. 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.
  48. As a future maintainer, I want the temporary parity test and baseline removed at the end, so that no fixture is left to maintain.
  49. 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 Option family, and in any class where a subclass replaces an action, actions are prototype methods. A subclass that replaces a parent action or computed annotates it override.
  • 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 makeObservable call. 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.

  1. Remove mobx-utils.
  2. Coverage push on MobX 5 (see Testing Decisions).
  3. Parity baseline and parity test.
  4. Rewrites that already work on MobX 5: the option's value assigned in the constructor; setValue as 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 inside runInAction.
  5. 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.
  6. 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 Option family (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.
  7. Bump to MobX 7 and mobx-react-lite 5, with the one API rename the store needs (observable.ref becomes observableRef) in the same change, since neither version accepts the other's name.
  8. 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.

  1. 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.
  2. 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.
  3. Jest setup. One global check fails any test that triggers a MobX action warning, from the MobX 6 bump onward.
  4. Page paint, under jest. The existing render test is unchanged and proves the page still paints.
  5. 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's error.

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 .js files; 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

Sub-issues

Sub-issues

42 of 42 Issues completed
Loading 42 sub-issues

Activity

  1. added
    ready-for-agent
    on Nov 14, 2026
  2. 14 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions