fix: auto-detect viewer mode from global_config in rerun bridge#1435
Merged
spomichter merged 3 commits intodevfrom Mar 6, 2026
Merged
fix: auto-detect viewer mode from global_config in rerun bridge#1435spomichter merged 3 commits intodevfrom
spomichter merged 3 commits intodevfrom
Conversation
the rerun bridge now reads global_config.viewer_backend and maps it to the correct viewer_mode automatically. blueprints no longer need to match on viewer_backend and pass viewer_mode explicitly. this fixes rerun-connect not working on the G1 blueprint (the match statement was missing the rerun-connect case) and prevents the same class of bug from happening when new viewer backends are added. mapping: rerun -> native, rerun-web -> web, rerun-connect -> connect simplified both GO2 basic and G1 primitive blueprints to just call rerun_bridge(**rerun_config) without viewer_mode.
Contributor
Greptile SummaryThis PR fixes the critical bug where Key changes:
The fix is targeted, removes duplication, and ensures every blueprint automatically gets the correct viewer mode regardless of backend. Verified that blueprint guards prevent hypothetical fallback issues. Confidence Score: 5/5
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["dimos --viewer-backend backend"] --> B["Blueprint loaded - G1 or GO2"]
B --> C{viewer_backend\n== foxglove?}
C -- Yes --> D["autoconnect(foxglove_bridge())"]
C -- No --> E{viewer_backend\nstarts with rerun?}
E -- No --> F["autoconnect() or _transports_base\nno visualization"]
E -- Yes --> G["autoconnect(rerun_bridge)\nviewer_mode=None"]
G --> H["RerunBridgeModule.start()"]
H --> I{config.viewer_mode\nis None?}
I -- No --> L["Use explicit viewer_mode"]
I -- Yes --> J["_BACKEND_TO_MODE.get\nglobal_config.viewer_backend\nfallback: native"]
J --> K["Set self.config.viewer_mode"]
K --> L
L --> M{viewer_mode?}
M -- native --> N["rr.spawn() - desktop viewer"]
M -- web --> O["rr.serve_grpc + serve_web_viewer"]
M -- connect --> P["rr.connect_grpc(connect_url)"]
M -- none --> Q["rr.init only - headless"]
Last reviewed commit: c8e30c6 |
…rocess the previous approach read global_config.viewer_backend inside start() which runs in a forkserver worker process. the forkserver is created before the CLI applies --viewer-backend, so workers always saw the default (rerun-web). now: Config.viewer_mode uses default_factory=_resolve_viewer_mode which reads global_config at blueprint construction time in the main process. the resolved value is baked into the Config before being serialized to the worker.
default_factory runs when Config is instantiated inside the worker process, not at blueprint creation time. the kwargs dict is what gets serialized to the worker, so viewer_mode must be in the kwargs. call _resolve_viewer_mode() at module-level (main process) and pass the result as viewer_mode= to rerun_bridge().
mustafab0
pushed a commit
that referenced
this pull request
Mar 6, 2026
* fix: auto-detect viewer mode from global_config in rerun bridge the rerun bridge now reads global_config.viewer_backend and maps it to the correct viewer_mode automatically. blueprints no longer need to match on viewer_backend and pass viewer_mode explicitly. this fixes rerun-connect not working on the G1 blueprint (the match statement was missing the rerun-connect case) and prevents the same class of bug from happening when new viewer backends are added. mapping: rerun -> native, rerun-web -> web, rerun-connect -> connect simplified both GO2 basic and G1 primitive blueprints to just call rerun_bridge(**rerun_config) without viewer_mode. * fix: resolve viewer_mode at config construction time, not in worker process the previous approach read global_config.viewer_backend inside start() which runs in a forkserver worker process. the forkserver is created before the CLI applies --viewer-backend, so workers always saw the default (rerun-web). now: Config.viewer_mode uses default_factory=_resolve_viewer_mode which reads global_config at blueprint construction time in the main process. the resolved value is baked into the Config before being serialized to the worker. * fix: pass viewer_mode explicitly in blueprint kwargs default_factory runs when Config is instantiated inside the worker process, not at blueprint creation time. the kwargs dict is what gets serialized to the worker, so viewer_mode must be in the kwargs. call _resolve_viewer_mode() at module-level (main process) and pass the result as viewer_mode= to rerun_bridge().
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 free
to 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.
fixes rerun-connect not working on G1 blueprints.
problem
each blueprint had a
match global_config.viewer_backendthat manually mapped backend names torerun_bridge(viewer_mode=...). the G1 primitive blueprint was missing thererun-connectcase, sodimos --viewer-backend rerun-connect run unitree-g1-simsilently created an empty autoconnect with no viewer.fix
moved the mapping into
RerunBridgeModule.start()— it now auto-detectsviewer_modefromglobal_config.viewer_backendwhen not explicitly set:rerun→nativererun-web→webrerun-connect→connectnone→nonesimplified both GO2 basic and G1 primitive blueprints to just:
no blueprint needs to know about viewer modes anymore. adding new backends only requires updating the bridge.