Skip to content

Add browser extension to ruby_event_store-process_manager#1956

Open
pjurewicz wants to merge 1 commit into
RailsEventStore:masterfrom
pjurewicz:process_manager-ui
Open

Add browser extension to ruby_event_store-process_manager#1956
pjurewicz wants to merge 1 commit into
RailsEventStore:masterfrom
pjurewicz:process_manager-ui

Conversation

@pjurewicz

@pjurewicz pjurewicz commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

First consumer of the browser extension API from #1951: the process manager gem now ships a browser extension inspecting stateful processes.

Process manager streams follow the ClassName$id convention, so the browser can recognize them and offer a dedicated view:

  • a Process state link appears on process manager stream pages
  • /process_managers/:stream_name renders the current state and the state rebuilt step by step (newest step first) — each row shows the event, its timestamp and the state after applying it
  • the extension serves its own stylesheet, built with Tailwind from the gem's views only (make css), so the browser's asset pipeline stays untouched

Design notes:

  • Recognition via registry, not constant resolution: including ProcessManager.with_state registers the class; parse_stream_name is a hash lookup. No Object.const_get on URL-derived input, no autoloading side effects, and hand-rolled classes that skip with_state are deliberately not browsable.
  • Replay through a public API: ProcessMethods#replay(events) folds apply from initial_state and returns the successive states. Production build_state uses the same fold, so the view shows exactly what the process computed. act is never invoked — browsing is side-effect free.
  • StateReplay returns steps plus the current state; the route handler is plain plumbing.

Example wiring in a Rails app:

require "ruby_event_store/process_manager/browser_extension"

mount RubyEventStore::Browser::App.for(
  event_store_locator: -> { Rails.configuration.event_store },
  extensions: [RubyEventStore::ProcessManager::BrowserExtension.new],
) => "/res",
as: :ruby_event_store_browser_app

Process manager streams follow the ClassName$id convention, which the
browser can now recognize and inspect. The gem ships an extension for
the ruby_event_store-browser extension API:

- a "Process state" link on process manager stream pages
- a /process_managers/:stream_name view rendering the current state and
  the state rebuilt step by step, newest step first
- its own stylesheet, built with Tailwind from the gem's views and
  served by the extension itself

Recognition is backed by a registry filled when a class includes
ProcessManager.with_state - no constant resolution of URL input.
State is rebuilt through the new public ProcessMethods#replay(events),
the same fold build_state uses in production; act is never invoked, so
browsing is side-effect free.
@pjurewicz
pjurewicz marked this pull request as ready for review July 17, 2026 18:23
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.

1 participant