Uh oh!
There was an error while loading. Please reload this page.
feat(perps-controller): add pro-mode layout preferences and mode state - #9550
Merged
michalconsensys merged 5 commits intoJul 20, 2026
Merged
Conversation
Add core-package state preparation for Perps Pro mode v1: - Add `proLayoutPreferences` state field (orderBookExpanded, chartExpanded, orderBookPosition, orderFormPosition) with defaults, persisted metadata, getProLayoutPreferences()/setProLayoutPreferences(patch) methods, and a selectProLayoutPreferences selector. - Add `PerpsMode` enum (Lite/Pro) and persisted `mode` field defaulting to Lite, with a setPerpsMode(mode) method and selectPerpsMode selector. - Expose new methods as messenger actions and regenerate method-action-types.
michalconsensystemporarily deployed
to
default-branch
July 20, 2026 09:37 — with
GitHub Actions
Inactive
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit deee807. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
… them Move PerpsMode/ProLayoutPreferences and their defaults into the dependency-free perpsConfig module and export DEFAULT_PERPS_MODE / DEFAULT_PRO_LAYOUT_PREFERENCES. getProLayoutPreferences() and the selectProLayoutPreferences/selectPerpsMode selectors now merge over these defaults so callers always receive a fully-populated object and default to PerpsMode.Lite, matching the marketFilterPreferences pattern.
Uh oh!
There was an error while loading. Please reload this page.
aganglada
approved these changes
Jul 20, 2026
Uh oh!
There was an error while loading. Please reload this page.
michalconsensys
deleted the
feat/perps-controller-pro-mode-state-tat-3582
branch
July 20, 2026 16:33
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Explanation
Before Perps Pro mode v1 UI work can start,
@metamask/perps-controllerneeds two core-state additions. This PR is core-package preparation only — there are no mobile UI changes.proLayoutPreferencesfield toPerpsControllerState(orderBookExpanded,chartExpanded,orderBookPosition,orderFormPosition). It follows the existingmarketFilterPreferencespattern — a flat, network-independent, persisted object — rather than the per-markettradeConfigurations.orderBookGroupingpattern, because these preferences must survive across markets instead of resetting per symbol. All four fields get sensible defaults now (chartExpanded/positions are reserved for future container-position UI), so no state-shape migration is needed later. Access is viagetProLayoutPreferences()and a patch-stylesetProLayoutPreferences(patch)setter (so future fields don't require new setter signatures), plus aselectProLayoutPreferencesselector.PerpsModeenum (Lite/Pro) and amode: PerpsModefield defaulting toPerpsMode.Lite, with asetPerpsMode(mode)method (mirroring the existingtoggleTestnetwrite pattern) and aselectPerpsModeselector. This supersedes the "State:" bullet previously sketched in TAT-3551, which will consume this field/enum/setter instead of redefining them.Both fields are persisted (
persist: true) consistent with the controller's existing global-preference metadata (marketFilterPreferences/maxSlippageBps). The new methods are exposed as messenger actions via the existing method-action codegen (PerpsController-method-action-types.tsregenerated), and the enum, type, defaults, selectors, and action types are exported from the package entry point.To keep the API ergonomic and robust for consumers:
PerpsModeenum,ProLayoutPreferencestype, and theDEFAULT_PERPS_MODE/DEFAULT_PRO_LAYOUT_PREFERENCESconstants live in the dependency-freeconstants/perpsConfigmodule (alongsideSortOptionId/MARKET_SORTING_CONFIG) and are re-exported from the controller/package entry points. This preserves the one-wayPerpsController → perpsConfigdependency (no cycle) and keepsselectors.tsfree of heavy transitive imports.getProLayoutPreferences(),selectProLayoutPreferences, andselectPerpsModemerge over / fall back to those defaults, so callers always receive a fully-populated preferences object and always default toPerpsMode.Lite— matching the fallback behavior ofgetMarketFilterPreferences/selectMarketFilterPreferenceseven when persisted state predates the new fields.Bumping the
@metamask/perps-controllerdependency version in mobile is intentionally out of scope and tracked as a separate follow-up once this ships.References
Changelog
@metamask/perps-controllerproLayoutPreferencesstate field (orderBookExpanded,chartExpanded,orderBookPosition,orderFormPosition) with the exportedProLayoutPreferencestype andDEFAULT_PRO_LAYOUT_PREFERENCESconstant,getProLayoutPreferences()/setProLayoutPreferences(patch)methods (exposed as messenger actions), and aselectProLayoutPreferencesselector; the getter and selector merge over defaults so callers always receive a fully-populated object.PerpsModeenum (Lite/Pro) and a persistedmodefield (defaultPerpsMode.Lite) with the exportedDEFAULT_PERPS_MODEconstant, asetPerpsMode(mode)method (exposed as a messenger action), and aselectPerpsModeselector that falls back to the default mode.Manual testing steps
Screenshots/Recordings
N/A — no UI changes in this PR (core package only).
Checklist
Note
Low Risk
Additive persisted preferences and API surface only; no trading, auth, or provider logic changes.
Overview
Adds persisted, network-independent Perps UI preferences to
@metamask/perps-controllerso Pro-mode mobile work can read/write shared state without redefining it.Pro layout: New
proLayoutPreferenceson controller state (orderBookExpanded,chartExpanded,orderBookPosition,orderFormPosition), modeled likemarketFilterPreferences(global, not per-market).getProLayoutPreferences()and patch-stylesetProLayoutPreferences(patch)merge withDEFAULT_PRO_LAYOUT_PREFERENCES;selectProLayoutPreferencesdoes the same for reselect consumers.Lite vs Pro:
PerpsMode(lite/pro), defaultmodeof Lite,setPerpsMode, andselectPerpsModewith default fallback.Types, defaults, and the enum live in
constants/perpsConfigand are re-exported from the controller and package entry; messenger action types are wired inPerpsController-method-action-types.ts. Both fields usepersist: truein state metadata. Unit tests cover controller behavior and selectors.Reviewed by Cursor Bugbot for commit e232861. Bugbot is set up for automated code reviews on this repo. Configure here.