#VFB-233 - Refactor Neuroglass state management and viewer configuration#218
#VFB-233 - Refactor Neuroglass state management and viewer configuration#218ddelpiano merged 16 commits intodevelopmentfrom
Conversation
…ion; add layout handling and datasource parameters for external server configuration
There was a problem hiding this comment.
Pull request overview
Refactors the Virtual Fly Brain frontend’s Neuroglass integration to dynamically generate Neuroglancer viewer state from loaded instances, support layout selection via Redux + ?layout=..., and make the Neuroglass datasource configurable at build/deploy time.
Changes:
- Replaced static Neuroglass state mappings with a
buildNeuroglassStatebuilder + shared shader/datasource config. - Added
neuroglassViewto Redux, plus middleware to read/write thelayoutURL parameter. - Introduced Docker/CI build args intended to configure Neuroglass datasource protocol/base URL.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| deployment/codefresh-dev.yaml | Passes Neuroglass datasource build args into the image build step. |
| applications/virtual-fly-brain/Dockerfile | Adds build args and exports datasource config during the Vite build. |
| applications/virtual-fly-brain/frontend/src/utils/neuroglassStateConfig.js | Implements dynamic viewer state builder, datasource URL builder, shader, and layout resolver. |
| applications/virtual-fly-brain/frontend/src/utils/neuroglassActions.js | Removes legacy state lookup helpers tied to static mappings. |
| applications/virtual-fly-brain/frontend/src/utils/constants.js | Defines known layouts, defaults, and URL parameter name. |
| applications/virtual-fly-brain/frontend/src/reducers/middleware/urlUpdaterMiddleware.js | Syncs ?layout into Redux on first load and writes it back on state change. |
| applications/virtual-fly-brain/frontend/src/reducers/actions/types/GlobalTypes.js | Adds SET_NEUROGLASS_VIEW action type. |
| applications/virtual-fly-brain/frontend/src/reducers/actions/globals.js | Adds setNeuroglassView action creator. |
| applications/virtual-fly-brain/frontend/src/reducers/GlobalReducer.js | Stores neuroglassView in global reducer state. |
| applications/virtual-fly-brain/frontend/src/components/NeuroglassViewer.jsx | Switches viewer to builder-based state, responsive layout selection, and debounced iframe reload. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
applications/virtual-fly-brain/frontend/src/components/NeuroglassViewer.jsx
Outdated
Show resolved
Hide resolved
applications/virtual-fly-brain/frontend/src/utils/neuroglassStateConfig.js
Outdated
Show resolved
Hide resolved
applications/virtual-fly-brain/frontend/src/utils/neuroglassStateConfig.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6d19fcced
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
applications/virtual-fly-brain/frontend/src/utils/neuroglassStateConfig.js
Outdated
Show resolved
Hide resolved
…nt variables for datasource settings
There was a problem hiding this comment.
Pull request overview
Refactors the Neuroglass viewer integration to dynamically build Neuroglancer viewer state from loaded VFB instances, add Redux/URL-driven layout selection, and make the Neuroglass datasource configurable via build/deploy-time variables.
Changes:
- Replaced hardcoded Neuroglass state mappings with a dynamic
buildNeuroglassStatebuilder and shared datasource/shader config. - Added
neuroglassViewto global Redux state and synchronized it with the URL?layoutparameter via middleware. - Plumbed
NEUROGLASS_DATA_PROTOCOL/NEUROGLASS_DATA_BASE_URLthrough build/deploy config and Vite defines.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| deployment/codefresh-dev.yaml | Passes Neuroglass datasource variables into the build pipeline. |
| applications/virtual-fly-brain/frontend/vite.config.js | Injects Neuroglass datasource env into the frontend build (and logs build config). |
| applications/virtual-fly-brain/frontend/src/utils/neuroglassStateConfig.js | Implements dynamic Neuroglass state generation and layout resolution. |
| applications/virtual-fly-brain/frontend/src/utils/neuroglassActions.js | Removes legacy state lookup utilities tied to static state maps. |
| applications/virtual-fly-brain/frontend/src/utils/constants.js | Adds known layouts and layout URL param/defaults. |
| applications/virtual-fly-brain/frontend/src/reducers/middleware/urlUpdaterMiddleware.js | Reads/writes ?layout and syncs it with Redux state. |
| applications/virtual-fly-brain/frontend/src/reducers/actions/types/GlobalTypes.js | Adds SET_NEUROGLASS_VIEW action type. |
| applications/virtual-fly-brain/frontend/src/reducers/actions/globals.js | Adds setNeuroglassView action creator. |
| applications/virtual-fly-brain/frontend/src/reducers/GlobalReducer.js | Stores neuroglassView in global state. |
| applications/virtual-fly-brain/frontend/src/components/NeuroglassViewer.jsx | Rebuilds iframe state dynamically, supports layout switching, and debounces reloads. |
| applications/virtual-fly-brain/Dockerfile | Exposes Neuroglass datasource build args and exports them for the Vite build. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
applications/virtual-fly-brain/frontend/src/utils/neuroglassStateConfig.js
Outdated
Show resolved
Hide resolved
applications/virtual-fly-brain/frontend/src/components/NeuroglassViewer.jsx
Outdated
Show resolved
Hide resolved
…vironment variables and improve error handling
There was a problem hiding this comment.
Pull request overview
Refactors the Neuroglass viewer integration to dynamically build Neuroglancer state from the currently loaded VFB instances and adds configurable Neuroglass datasource settings (protocol/base URL), plus URL/Redux syncing for viewer layout selection.
Changes:
- Replaced static Neuroglass state presets with dynamic state generation (
buildNeuroglassState) and layout resolution (resolveNeuroglassLayout). - Added Neuroglass datasource configuration via environment variables and propagated them through Vite build configuration and the Docker build.
- Introduced
globalInfo.neuroglassViewin Redux and middleware syncing of?layout=between URL and store.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| deployment/codefresh-dev.yaml | Passes Neuroglass datasource env vars into Codefresh build context. |
| applications/virtual-fly-brain/frontend/vite.config.js | Inlines Neuroglass config into the frontend bundle via define and logs build config. |
| applications/virtual-fly-brain/frontend/src/utils/neuroglassStateConfig.js | Implements dynamic layer/state generation and configurable datasource URL building. |
| applications/virtual-fly-brain/frontend/src/utils/neuroglassActions.js | Removes legacy helpers tied to static Neuroglass state maps. |
| applications/virtual-fly-brain/frontend/src/utils/constants.js | Adds known Neuroglass layout constants and URL param key. |
| applications/virtual-fly-brain/frontend/src/reducers/middleware/urlUpdaterMiddleware.js | Syncs layout URL param into Redux and updates URL when view changes. |
| applications/virtual-fly-brain/frontend/src/reducers/actions/types/GlobalTypes.js | Adds a new global action type for Neuroglass view updates. |
| applications/virtual-fly-brain/frontend/src/reducers/actions/globals.js | Adds setNeuroglassView(view) action creator. |
| applications/virtual-fly-brain/frontend/src/reducers/GlobalReducer.js | Stores neuroglassView in global Redux state. |
| applications/virtual-fly-brain/frontend/src/components/queryBuilder/FullscreenSlider.jsx | Removes a file-level eslint disable comment. |
| applications/virtual-fly-brain/frontend/src/components/configuration/VFBToolbar/vfbtoolbarHTML.jsx | Removes a file-level eslint disable comment. |
| applications/virtual-fly-brain/frontend/src/components/NeuroglassViewer.jsx | Refactors viewer to use dynamic state/layout and debounced iframe src updates. |
| applications/virtual-fly-brain/Dockerfile | Wires Neuroglass datasource vars into the Vite build step. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
applications/virtual-fly-brain/frontend/src/components/NeuroglassViewer.jsx
Show resolved
Hide resolved
applications/virtual-fly-brain/frontend/src/components/NeuroglassViewer.jsx
Show resolved
Hide resolved
…g messages in NeuroglassViewer
There was a problem hiding this comment.
Pull request overview
This PR refactors the Neuroglass viewer integration to dynamically generate Neuroglancer state from currently loaded VFB instances, and makes the Neuroglass datasource/viewer endpoints configurable via build-time environment variables. It also introduces Redux + URL synchronization for selecting the Neuroglass layout.
Changes:
- Build Neuroglass viewer state dynamically from
allLoadedInstances(layers, colors, visibility) and resolve layout based on URL/Redux + mobile/desktop. - Add
NEUROGLASS_DATA_PROTOCOL,NEUROGLASS_DATA_BASE_URL, andNEUROGLASS_URLconfiguration plumbing through Codefresh, Docker build, and Vitedefine. - Add
globalInfo.neuroglassViewRedux state and middleware support to sync?layout=between URL and Redux.
Reviewed changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| deployment/codefresh-dev.yaml | Pass Neuroglass-related build args into the app image build step. |
| applications/virtual-fly-brain/frontend/vite.config.js | Load + inject Neuroglass env vars into import.meta.env.* via Vite define. |
| applications/virtual-fly-brain/frontend/src/utils/neuroglassStateConfig.js | Replace static state maps with datasource config, layout resolution, and dynamic state/layer builders. |
| applications/virtual-fly-brain/frontend/src/utils/neuroglassActions.js | Remove legacy helpers tied to static Neuroglass state maps. |
| applications/virtual-fly-brain/frontend/src/utils/constants.js | Add known Neuroglass layouts + URL param + defaults. |
| applications/virtual-fly-brain/frontend/src/reducers/middleware/urlUpdaterMiddleware.js | Read/write ?layout= and sync it to/from Redux. |
| applications/virtual-fly-brain/frontend/src/reducers/actions/types/GlobalTypes.js | Add SET_NEUROGLASS_VIEW action type. |
| applications/virtual-fly-brain/frontend/src/reducers/actions/globals.js | Add setNeuroglassView(view) action creator. |
| applications/virtual-fly-brain/frontend/src/reducers/GlobalReducer.js | Store neuroglassView in global reducer state. |
| applications/virtual-fly-brain/frontend/src/components/queryBuilder/FullscreenSlider.jsx | Remove file-level eslint disable comment. |
| applications/virtual-fly-brain/frontend/src/components/configuration/VFBToolbar/vfbtoolbarHTML.jsx | Remove file-level eslint disable comment. |
| applications/virtual-fly-brain/frontend/src/components/NeuroglassViewer.jsx | Rebuild iframe URL from dynamic state, add debounced updates, and handle mobile/desktop layout selection. |
| applications/virtual-fly-brain/Dockerfile | Export Neuroglass build-time env vars into the Vite build step. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
applications/virtual-fly-brain/frontend/src/utils/neuroglassStateConfig.js
Outdated
Show resolved
Hide resolved
applications/virtual-fly-brain/frontend/src/reducers/middleware/urlUpdaterMiddleware.js
Show resolved
Hide resolved
applications/virtual-fly-brain/frontend/src/reducers/middleware/urlUpdaterMiddleware.js
Outdated
Show resolved
Hide resolved
applications/virtual-fly-brain/frontend/src/components/NeuroglassViewer.jsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
… validation for layout parameters
…uroglass layer configuration
…ndling in layer builder
applications/virtual-fly-brain/frontend/src/utils/neuroglassStateConfig.js
Show resolved
Hide resolved
applications/virtual-fly-brain/frontend/src/utils/neuroglassStateConfig.js
Outdated
Show resolved
Hide resolved
applications/virtual-fly-brain/frontend/src/utils/neuroglassStateConfig.js
Outdated
Show resolved
Hide resolved
| export function buildNeuroglassState(allLoadedInstances, focusedInstanceId, layout) { | ||
| const instances = allLoadedInstances || []; | ||
| const layers = instances | ||
| .filter(inst => inst?.metadata?.Id) |
There was a problem hiding this comment.
this will determine what we pull through the datasource, do we log somewhere if an id does not have data on the fileserver? just a curiosity. Thanks
There was a problem hiding this comment.
Not at the moment, we are not checking if there's data for this instance on the file server. For current setup with gs://neuroglass/ instances, we would need credentials to check in the bucket from VFB code. As discussed though, this will be limiting since we would have to do same for other file servers to be able to check if data exists. This would only work if we had a standardized way to verify data existence across all file servers.
There was a problem hiding this comment.
@ddelpiano This PR is pending adding a fix for this issue here , were we display an error message if an instance is not able to be loaded in Neuroglass. The strategy to use a callback didn't work, since the iframe and neuroglass are not on the same origin https://metacell.atlassian.net/browse/NGLASS-1064?focusedCommentId=36291
applications/virtual-fly-brain/frontend/src/utils/neuroglassStateConfig.js
Outdated
Show resolved
Hide resolved
…g data from server
2c930e8 to
0af4068
Compare
1efacfe to
0af4068
Compare
Changes Neuroglassviewer component to match design described on VFB-232. The changes enable dynamic construction of Neuroglass viewer state based on loaded VFB instances selected from the Layers Component. The Neuroglassviewer will display in a layer each of the selected instances toggled from the Layers Component, as well as delete and show/hide instances as selected from Layers Component. Allows updating the VFB data server as a configuration instead of hardcoding location.
Variables added to the Codefresh for storing these configuration values:
