Skip to content

feat(structure): host the ReactiveScript map as a Map mode - #58

Open
devagrawal09 wants to merge 1 commit into
solidjs:mainfrom
devagrawal09:feat/structure-rx-map
Open

devagrawal09 wants to merge 1 commit into
solidjs:mainfrom
devagrawal09:feat/structure-rx-map

Conversation

@devagrawal09

Copy link
Copy Markdown

What and why

Add a Map mode to Structure so ReactiveScript apps can show their live map alongside Owners and Reactivity. Map is offered only when globalThis.__RX__ provides mount(element). The pane disposes the map when you leave it or close the dock; a remembered Map selection falls back to Owners when no map is available. Arrow keys move between the available modes and focus follows the selection.

Tests

Added unit and browser coverage for Map mode. pnpm format:check, pnpm build, pnpm typecheck, pnpm test (347 passed), pnpm check, and pnpm test:e2e (31 passed) all passed.

When the app sets `globalThis.__RX__` with a `mount(element)` function, as
`@reactivescript/map/live` does in development, the Structure view offers
a third chip, Map. It mounts the map into the pane once it is on the page
and calls the returned dispose when you leave Map, close the dock or the
view unmounts. The view reads `__RX__` again each time it opens, and a
remembered Map falls back to Owners on a page without a map.

The arrow keys step through the chips the view offers, and focus moves to
the selected chip of the pane that takes over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@lxsmnsyc lxsmnsyc left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. It is not ready to approve yet, mainly because I cannot find the integration it hosts anywhere to check it against.

Open question

  • No linked issue covers this. The base has no mention of __RX__ or ReactiveScript. The PR adds a public contract (globalThis.__RX__.mount(element)) and a README section for one third-party tool.
  • Please link the @reactivescript/map/live source or release that sets __RX__ and calls it with an element. Say who owns the contract and whether it can change. The e2e test uses a stand-in that also sets graphs: [], which the toolbar's RxMapHost type does not declare, so the real shape is not pinned.
  • I have not decided whether the toolbar should host a named third-party map, or whether this should go through the dev-server data channel. The direction so far is that the Vite plugin carries what the runtime cannot provide.

Should fix

  1. The changeset and README state things the PR does not verify. .changeset/structure-rx-map.md:5 says @reactivescript/map/live sets __RX__ "in development". README.md (new "ReactiveScript map" section) says the map "lights the nodes each update changed". Nothing in the diff or tests shows either. Cut both claims, or link where they are shown.
  2. A map that fails to mount leaves an empty pane. src/dev-toolbar/structure/rx-map.ts mountRxMap only calls console.warn. The pane (RxMapPane, structure/index.tsx) has no visible error or empty state, so the user sees blank space under the chips. Show a short message in the frame when mount throws or returns no dispose function.
  3. structure/styles.css, [data-solid-rx-map-frame] > iframe sizes only an iframe, but the contract says mount(el) takes any element and draws into it. A map that appends a div or a canvas gets no sizing. Either document that the map must append an iframe, or size [data-solid-rx-map-frame] > *.
  4. __RX__ is read when the view opens (createEffect on props.show), not afterwards. The app can register or replace it while the view stays open, such as on HMR. The Map chip is then missing or stale until the view closes and opens. Say so in the README, or re-read on focus of the dock.

Nits

  • rx-map.ts declares StructureMode and dev-toolbar/index.tsx:51 declares it again. Import one.
  • moveMode in structure/index.tsx now looks up the dock body with closest('[data-solid-dev-toolbar-body]'), which couples the chips to the dock markup. The comment explains why, which helps.

Checked

  • Local, in a review worktree: format:check pass, test pass. typecheck and build fail the same way on the base 3c58230, so this PR does not cause them. The errors are TS2883 in HeadersViewer.tsx and noop.ts, and the unbuilt @solidjs/start-devtools module. gh pr checks shows the test job passing. I did not run e2e or measure bundle size, because the build does not complete in my review worktree.
  • No new dependencies, no lockfile change.
  • UI rules: no left-border selection, no focus chip, Solid version untouched. The border-bottom on [data-solid-rx-map-nav] is on a square bar, not a rounded component. The Map chip is text like the other two chips. States covered except the mount failure above.
  • The gating, fallback to Owners, arrow keys and dispose-once look right. Unit tests cover the helpers, and e2e covers mount, dispose on leave and on close, and fallback.

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.

2 participants