Skip to content

Lazy create runtime maps for multi-map flex layouts#1600

Draft
Copilot wants to merge 6 commits intomasterfrom
copilot/lazy-create-runtime-maps
Draft

Lazy create runtime maps for multi-map flex layouts#1600
Copilot wants to merge 6 commits intomasterfrom
copilot/lazy-create-runtime-maps

Conversation

Copy link
Contributor

Copilot AI commented Mar 11, 2026

Implements lazy creation of runtime maps for multi-map flex layouts (ApplicationDefinition), so that only the first/active map is created at startup. Additional maps are created on demand the first time the user switches to them.

Changes Made

Data Model

  • Added optional mapDef and metadata fields to the MapInfo type in defs.ts to carry deferred map info
  • Added pendingMaps dictionary to IConfigurationReducerState in common.ts to track maps that have not yet been created

Init Flow (init-mapguide.ts, init-command.ts)

  • createRuntimeMapsAsync now only eagerly creates the first MapGuide map in a multi-map flex layout (when not reusing a session and not in stateless mode); remaining maps are deferred
  • setupMaps updated to add MapInfo entries (with map: undefined) for deferred maps so they still appear in availableMaps
  • Abstract setupMaps and initFromAppDefCoreAsync signatures updated to propagate pending map definitions
  • Added parseSwipePairs() to parse map swipe pair declarations from the application definition's MapSet

Redux State (reducers/config.ts, constants/actions.ts)

  • INIT_APP handler populates pendingMaps from MapInfo entries that have mapDef set, and stores mapSwipePairs
  • MAP_REFRESH handler clears a map from pendingMaps once its runtime map has been loaded
  • Added MAP_SET_SWIPE_MODE and MAP_UPDATE_SWIPE_POSITION action types and handlers for map swipe support

Runtime Lazy Loading (actions/map.ts, containers/map-menu.tsx)

  • New activateMap thunk checks if the target map is in pendingMaps; if so, it creates the runtime map on demand using the current session before dispatching MAP_SET_ACTIVE_MAP
  • MapMenuContainer now uses activateMap instead of setActiveMap so all map switches go through the lazy-load path

Map Swipe Feature (integrated from master)

  • Added IMapSwipePair interface to common.ts describing primary/secondary map pairs for side-by-side swipe comparison
  • Added setMapSwipeMode() and updateMapSwipePosition() action creators
  • Added MapSwipe command to DefaultCommands with registration in default-commands.ts and widget mapping in command-spec.ts
  • Added swipeActive and swipePosition state fields to IConfigurationReducerState
  • Added MapViewerSwipe component (map-viewer-swipe.tsx) for the swipe UI
  • Added swipe-aware layer management in add-manage-layers.tsx, layer-set-group-base.ts, and map provider classes
  • Added i18n strings for swipe UI labels

Testing

  • Added tests to reducers/config.spec.ts for pendingMaps population and clearing behaviour, and for MAP_SET_SWIPE_MODE / MAP_UPDATE_SWIPE_POSITION handlers
  • Added tests to actions/map.spec.ts for the activateMap thunk (non-pending case and pending-with-no-session case)
  • Added tests to actions/init-command.spec.ts for parseSwipePairs()
  • Added tests for swipe-mode layer management (test/api/layer-set-group-swipe.spec.ts) and swipe-aware layer manager UI (test/containers/add-manage-layers.spec.tsx)
  • All 653 tests pass across 92 test files
  • TypeScript compilation passes with no errors
  • CodeQL scan shows 0 alerts
Original prompt

This section details on the original issue you should resolve

<issue_title>Try to lazy create runtime maps for multi-map flex layouts</issue_title>
<issue_description>Right now it will eagerly load all runtime maps, which is wasteful if the other switchable maps aren't actually switched to</issue_description>

Comments on the Issue (you are @copilot in this section)

@jumpinjackie Switch back to 0.15 milestone

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@coveralls
Copy link

coveralls commented Mar 11, 2026

Coverage Status

coverage: 37.828% (+0.07%) from 37.763%
when pulling 20ca748 on copilot/lazy-create-runtime-maps
into 7cb3116 on master.

Copilot AI and others added 2 commits March 11, 2026 14:45
Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
@jumpinjackie
Copy link
Owner

@copilot Please try again if the rate limit has subsided

…improve error messages

Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 11, 2026

@copilot Please try again if the rate limit has subsided

Completed the remaining work in e2c8a2d. Here's a summary of all changes made:

Core implementation (48dbe77):

  • MapInfo type now has optional mapDef/metadata fields for lazy tracking
  • IConfigurationReducerState has a new pendingMaps dictionary
  • createRuntimeMapsAsync only eagerly creates the first MapGuide map in multi-map flex layouts; remaining maps are deferred
  • Config reducer populates pendingMaps on INIT_APP and clears entries on MAP_REFRESH
  • New activateMap thunk creates the runtime map on-demand when switching to an unloaded map
  • MapMenuContainer now uses activateMap instead of setActiveMap

Code review cleanup (e2c8a2d):

  • Fixed duplicate/misplaced imports in test file
  • Simplified isFirstMapDef = false flag (removed redundant if check)
  • Improved error/warning messages in activateMap to clarify the map switch still proceeds when lazy creation fails

All 561 tests pass, code review clean, CodeQL shows 0 alerts.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • storybook.js.org
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node /home/REDACTED/work/mapguide-react-layout/mapguide-react-layout/node_modules/.bin/storybook build -c .storybook (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Try to lazy create runtime maps for multi-map flex layouts Lazy create runtime maps for multi-map flex layouts Mar 11, 2026
@jumpinjackie
Copy link
Owner

@copilot Integrate latest changes from master and revalidate your work

…create-runtime-maps branch

Co-authored-by: jumpinjackie <563860+jumpinjackie@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 13, 2026

@copilot Integrate latest changes from master and revalidate your work

Integrated all latest master changes in 83131e3. The branch now includes:

  • Map swipe feature from master (IMapSwipePair, setMapSwipeMode, updateMapSwipePosition, parseSwipePairs, MapSwipe command, swipe component, swipe state in config reducer)
  • All new/modified source files: layer-set-group-base.ts, map-providers/base.ts, context.tsx, add-manage-layers.tsx, generic.tsx, and all related swipe components
  • All new test files from master: layer-set-group-swipe.spec.ts, add-manage-layers.spec.tsx, new command.spec.ts tests, and parseSwipePairs tests added to init-command.spec.ts
  • Updated translations (de.json, he.json) and viewer data (appdef.split.json)

All 653 tests pass (up from 561), TypeScript compiles clean, and CodeQL shows 0 alerts.

@jumpinjackie
Copy link
Owner

@copilot Manually resolved conflicts. Pls revalidate your current work.

Copy link
Contributor Author

Copilot AI commented Mar 13, 2026

@copilot Manually resolved conflicts. Pls revalidate your current work.

Revalidated after manual conflict resolution. All 653 tests pass across 92 test files, TypeScript compilation is clean with no errors.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • storybook.js.org
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node /home/REDACTED/work/mapguide-react-layout/mapguide-react-layout/node_modules/.bin/storybook build -c .storybook (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Try to lazy create runtime maps for multi-map flex layouts

3 participants