Skip to content

Share link: modern tools write their entry and read it back on load - #643

Open
BhattaraiSijan wants to merge 2 commits into
developmentfrom
feat/tools-url-state
Open

BhattaraiSijan wants to merge 2 commits into
developmentfrom
feat/tools-url-state

Conversation

@BhattaraiSijan

@BhattaraiSijan BhattaraiSijan commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #613. Groundwork for #616. Carved from #618 at Sandesh's request.

Summary

The share link's tools= entry lets a tool save its state into the link so the link reopens the same way. It was assembled from a list only the classic layout's init fills, so in the modern layout no tool could write into a link, and nothing on the read side handed a tool its entry back. This PR gives the modern layout both halves.

  • Each controller reports its own tools. The modern controller gains getToolsUrl(), built over its own registry of loaded tool ids, with the same id$string contract the classic one has. The classic controller is untouched and does not learn modern tools exist. (This replaces the first cut on Share: exports and links show a comparison the way the screen does #618, which pushed modern tools into the classic controller's private list.)
  • QueryURL asks both and joins the answers. It cannot import the modern controller: that import reaches mmgisAPI, which reads Layers_ at module load, and Layers_ already reaches QueryURL through TimeUI and Map_, so the cycle closes and L_ is undefined at load. Instead the modern layout hands the controller to QueryURL at mount and clears it at teardown, the same handoff UserInterfaceModern_ already does for mmgisAPI_._pluginController for the same reason. In the classic layout the property stays null and nothing changes.
  • A tool can read its entry back. New tool:getUrlState bus request, registered at mission load next to tool:getVars, answers the text a tool's getUrlString() wrote under its module name, or null. The shared adapter gets a mmgisGetToolUrlState wrapper.
  • One bad tool can't break the link. The modern getToolsUrl() skips a tool whose getUrlString() throws or returns no string, with a warning naming it, instead of failing Copy link for the whole app.
  • A tool's text may hold any characters. Each modern entry's text is encodeURIComponent-ed before the entries are joined on , and the query gets its encodeURI pass. getSingleQueryVariable undoes the outer layer and L_.getToolUrlState the inner one, so , & # $ | in a tool's text come back whole. Classic entries are written and read raw as before; the decode falls through to the raw text when an entry isn't valid percent-encoding.

Semantics, stated

tool:getUrlState answers the opening link's text for the whole session. It does not expire. A tool that restores itself on every mount would reapply the link's state each time, so apply it once, on first mount. The push-model store that makes apply-once the default, and stops core calling into plugin code at all, is the follow-up under #613; this PR hardens the pull model until then.

Not in this PR

Test plan

  • npx vitest run: 222 files, 3808 tests pass; npx tsc --noEmit clean
  • Unit: a throwing tool and a tool returning undefined are left out; a tool text with , & # $ | stays one entry; the reader decodes it and passes a raw classic entry through; a full round trip through writeCoordinateURL and getSingleQueryVariable reads both a classic and an encoded modern entry back whole
  • Air4US modern layout: copy a link with no tool state, it opens as today
  • Classic layout: copy a link, tools= unchanged from development

🤖 Generated with Claude Code

…rn entry

A modern tool that throws or returns no string no longer breaks Copy link for the whole app. Each modern entry's text is percent-encoded before the entries are joined and the query's own encodeURI pass, and tool:getUrlState decodes it, so a tool's text may hold commas, ampersands and hashes. Classic entries are unchanged. The bus doc states that the answer lasts the whole session and is to be applied once.

This branch has not been deployed

No deployments
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.

Share: tools in the modern layout write their state into the link and read it back on load

1 participant