Skip to content

changed store paths#571

Merged
TheJeran merged 2 commits intomainfrom
jp/direct-stores
Mar 2, 2026
Merged

changed store paths#571
TheJeran merged 2 commits intomainfrom
jp/direct-stores

Conversation

@TheJeran
Copy link
Collaborator

@TheJeran TheJeran commented Mar 2, 2026

In the most recent builds, Next split the codes into chunks causing multiple copies of stores. So one function was writing information to a store while the other never got it.

This happened because @GlobalStates folder has an index and exports each store from one path. These "barrel files" are not treated as a single code chunk and so Next decided to split them up and share them in different chunks—Causing the issue we had before.

To solve this, all files now reference directly to each store to prevent multiple references that could justify splitting them into different chunks. I built it locally and it appears to work. Lets see if it works here.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on optimizing how global state stores are imported across the application. By eliminating a central 'barrel file' and transitioning to direct imports for each store, the aim is to prevent Next.js from creating multiple instances of the same store. This ensures consistent state access and modification throughout the application, resolving a critical issue related to state synchronization.

Highlights

  • Refactored Global Store Imports: The 'barrel file' (src/GlobalStates/index.ts) that re-exported all global stores has been removed. All components now directly import individual store hooks (e.g., useGlobalStore) from their specific file paths (e.g., src/GlobalStates/GlobalStore).
  • Addressed Next.js Chunking Issue: This change resolves an issue where Next.js was splitting global store code into multiple chunks, leading to inconsistent state management across different parts of the application.
  • Removed Redundant State Property: The fetchNC property was removed from the useZarrStore state in LocalNetCDF.tsx as it was no longer necessary.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/GlobalStates/index.ts
    • Removed the barrel file that re-exported all global store hooks.
  • src/components/LandingHome.tsx
    • Updated imports to directly reference useGlobalStore and useZarrStore from their respective files.
  • src/components/plots/AnalysisInfo.tsx
    • Added the 'use client' directive.
    • Updated imports to directly reference useAnalysisStore and useGlobalStore from their respective files.
  • src/components/plots/AnalysisWG.tsx
    • Updated imports to directly reference useAnalysisStore, useGlobalStore, and usePlotStore from their respective files.
  • src/components/plots/AxisLines.tsx
    • Updated imports to directly reference useAnalysisStore, useGlobalStore, useImageExportStore, usePlotStore, and useZarrStore from their respective files.
  • src/components/plots/CountryBorders.tsx
    • Updated imports to directly reference useAnalysisStore, useGlobalStore, and usePlotStore from their respective files.
  • src/components/plots/DataCube.tsx
    • Updated imports to directly reference useGlobalStore and usePlotStore from their respective files.
  • src/components/plots/FlatBlocks.tsx
    • Updated imports to directly reference useAnalysisStore, useErrorStore, useGlobalStore, and usePlotStore from their respective files.
  • src/components/plots/FlatMap.tsx
    • Updated imports to directly reference useAnalysisStore, useGlobalStore, usePlotStore, and useZarrStore from their respective files.
  • src/components/plots/KeyFramePreviewer.tsx
    • Updated imports to directly reference useGlobalStore, useImageExportStore, and usePlotStore from their respective files.
  • src/components/plots/MorphingPoints.tsx
    • Updated imports to directly reference useGlobalStore and usePlotStore from their respective files.
  • src/components/plots/Plot.tsx
    • Updated imports to directly reference useAnalysisStore, useGlobalStore, useImageExportStore, and usePlotStore from their respective files.
  • src/components/plots/PointCloud.tsx
    • Updated imports to directly reference useAnalysisStore, useGlobalStore, and usePlotStore from their respective files.
  • src/components/plots/Sphere.tsx
    • Updated imports to directly reference useAnalysisStore, useGlobalStore, and usePlotStore from their respective files.
  • src/components/plots/SphereBlocks.tsx
    • Updated imports to directly reference useErrorStore, useGlobalStore, and usePlotStore from their respective files.
  • src/components/plots/UVCube.tsx
    • Updated imports to directly reference useAnalysisStore, useGlobalStore, and usePlotStore from their respective files.
  • src/components/plots/plotarea/FixedTicks.tsx
    • Updated imports to directly reference useGlobalStore and usePlotStore from their respective files.
  • src/components/plots/plotarea/LinePlot.tsx
    • Updated imports to directly reference useGlobalStore from its respective file.
  • src/components/plots/plotarea/PlotPoints.tsx
    • Updated imports to directly reference useGlobalStore and usePlotStore from their respective files.
  • src/components/plots/plotarea/ThickLine.tsx
    • Updated imports to directly reference usePlotStore and useGlobalStore from their respective files.
  • src/components/textures/TextureMakers.tsx
    • Updated imports to directly reference useGlobalStore from its respective file.
  • src/components/ui/Colorbar.tsx
    • Updated imports to directly reference useGlobalStore, usePlotStore, and useAnalysisStore from their respective files.
  • src/components/ui/Elements/AxisBars.tsx
    • Updated imports to directly reference usePlotStore from its respective file.
  • src/components/ui/Elements/Error.tsx
    • Updated imports to directly reference useErrorStore from its respective file.
  • src/components/ui/Elements/Loading.tsx
    • Updated imports to directly reference useGlobalStore from its respective file.
  • src/components/ui/ExportExtent.tsx
    • Updated imports to directly reference useGlobalStore and useImageExportStore from their respective files.
  • src/components/ui/Footer.tsx
    • Updated imports to directly reference useImageExportStore from its respective file.
  • src/components/ui/KeyFrames.tsx
    • Updated imports to directly reference useImageExportStore and usePlotStore from their respective files.
  • src/components/ui/LinePlotArea/PlotLineOptions.tsx
    • Updated imports to directly reference usePlotStore from its respective file.
  • src/components/ui/MainPanel/AdjustPlot.tsx
    • Updated imports to directly reference useAnalysisStore, useGlobalStore, and usePlotStore from their respective files.
  • src/components/ui/MainPanel/AnalysisOptions.tsx
    • Updated imports to directly reference useAnalysisStore, useGlobalStore, and useZarrStore from their respective files.
  • src/components/ui/MainPanel/Colormaps.tsx
    • Updated imports to directly reference useGlobalStore from its respective file.
  • src/components/ui/MainPanel/Dataset.tsx
    • Updated imports to directly reference useGlobalStore and useZarrStore from their respective files.
  • src/components/ui/MainPanel/LocalNetCDF.tsx
    • Updated imports to directly reference useGlobalStore and useZarrStore from their respective files.
    • Removed the fetchNC:true property from the useZarrStore.setState call.
  • src/components/ui/MainPanel/LocalZarr.tsx
    • Updated imports to directly reference useZarrStore and useGlobalStore from their respective files.
  • src/components/ui/MainPanel/MetaDataInfo.tsx
    • Updated imports to directly reference useCacheStore, useGlobalStore, usePlotStore, and useZarrStore from their respective files.
  • src/components/ui/MainPanel/PlayButton.tsx
    • Updated imports to directly reference useCacheStore, useGlobalStore, usePlotStore, and useZarrStore from their respective files.
  • src/components/ui/MainPanel/PlotType.tsx
    • Updated imports to directly reference useGlobalStore and usePlotStore from their respective files.
  • src/components/ui/MainPanel/Variables.tsx
    • Updated imports to directly reference useGlobalStore from its respective file.
  • src/components/ui/NavBar/ExportImageSettings.tsx
    • Updated imports to directly reference useGlobalStore, useImageExportStore, and usePlotStore from their respective files.
  • src/components/ui/NavBar/Navbar.tsx
    • Updated imports to directly reference useGlobalStore and usePlotStore from their respective files.
  • src/components/ui/NavBar/PerformanceMode.tsx
    • Updated imports to directly reference useGlobalStore from its respective file.
  • src/components/ui/NavBar/PlotLineButton.tsx
    • Updated imports to directly reference useErrorStore and usePlotStore from their respective files.
  • src/components/ui/ShaderEditor.tsx
    • Updated imports to directly reference useAnalysisStore and useGlobalStore from their respective files.
  • src/components/zarr/GetMetadata.tsx
    • Updated imports to directly reference useGlobalStore from its respective file.
  • src/components/zarr/MetadataText.tsx
    • Updated imports to directly reference useGlobalStore from its respective file.
  • src/components/zarr/NCGetters.ts
    • Updated imports to directly reference useZarrStore, useCacheStore, useGlobalStore, and useErrorStore from their respective files.
  • src/components/zarr/ZarrGetters.ts
    • Updated imports to directly reference useZarrStore, useGlobalStore, useCacheStore, and useErrorStore from their respective files.
  • src/components/zarr/ZarrLoaderLRU.ts
    • Updated imports to directly reference useGlobalStore, useZarrStore, useErrorStore, and useCacheStore from their respective files.
  • src/hooks/useCoordBounds.tsx
    • Updated imports to directly reference usePlotStore from its respective file.
  • src/hooks/useDataFetcher.tsx
    • Updated imports to directly reference useGlobalStore, usePlotStore, and useZarrStore from their respective files.
  • src/utils/ExportCanvas.tsx
    • Updated imports to directly reference useGlobalStore, useImageExportStore, and usePlotStore from their respective files.
  • src/utils/HelperFuncs.ts
    • Updated imports to directly reference useCacheStore, useGlobalStore, usePlotStore, and useZarrStore from their respective files.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses an issue with Zustand store instantiation in Next.js by removing the barrel file and updating all imports to be direct. This is a solid fix for the described problem. My review includes a few suggestions to improve code consistency by sorting the new import statements alphabetically, which will enhance maintainability.

Comment on lines +3 to +7
import { useAnalysisStore } from '@/GlobalStates/AnalysisStore';
import { useGlobalStore } from '@/GlobalStates/GlobalStore';
import { usePlotStore } from '@/GlobalStates/PlotStore';
import { useZarrStore } from '@/GlobalStates/ZarrStore';
import { useImageExportStore } from '@/GlobalStates/ImageExportStore';

Choose a reason for hiding this comment

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

medium

For better maintainability and consistency, it's a good practice to keep imports sorted alphabetically. This applies to the new import statements for the stores. This suggestion applies to other files in this pull request as well where multiple stores are being imported.

Suggested change
import { useAnalysisStore } from '@/GlobalStates/AnalysisStore';
import { useGlobalStore } from '@/GlobalStates/GlobalStore';
import { usePlotStore } from '@/GlobalStates/PlotStore';
import { useZarrStore } from '@/GlobalStates/ZarrStore';
import { useImageExportStore } from '@/GlobalStates/ImageExportStore';
import { useAnalysisStore } from '@/GlobalStates/AnalysisStore';
import { useGlobalStore } from '@/GlobalStates/GlobalStore';
import { useImageExportStore } from '@/GlobalStates/ImageExportStore';
import { usePlotStore } from '@/GlobalStates/PlotStore';
import { useZarrStore } from '@/GlobalStates/ZarrStore';
References
  1. Imports should be sorted alphabetically to improve readability and maintainability. This is a common convention enforced by tools like ESLint's sort-imports rule. (link)

Comment on lines +1 to +4
import { useZarrStore } from "@/GlobalStates/ZarrStore";
import { useCacheStore } from "@/GlobalStates/CacheStore";
import { useGlobalStore } from "@/GlobalStates/GlobalStore";
import { useErrorStore } from "@/GlobalStates/ErrorStore";

Choose a reason for hiding this comment

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

medium

To improve code readability and consistency, please sort the import statements alphabetically.

Suggested change
import { useZarrStore } from "@/GlobalStates/ZarrStore";
import { useCacheStore } from "@/GlobalStates/CacheStore";
import { useGlobalStore } from "@/GlobalStates/GlobalStore";
import { useErrorStore } from "@/GlobalStates/ErrorStore";
import { useCacheStore } from "@/GlobalStates/CacheStore";
import { useErrorStore } from "@/GlobalStates/ErrorStore";
import { useGlobalStore } from "@/GlobalStates/GlobalStore";
import { useZarrStore } from "@/GlobalStates/ZarrStore";
References
  1. Imports should be sorted alphabetically to improve readability and maintainability. This is a common convention enforced by tools like ESLint's sort-imports rule. (link)

Comment on lines +1 to +4
import { useZarrStore } from '@/GlobalStates/ZarrStore';
import { useGlobalStore } from '@/GlobalStates/GlobalStore';
import { useCacheStore } from '@/GlobalStates/CacheStore';
import { useErrorStore } from '@/GlobalStates/ErrorStore';

Choose a reason for hiding this comment

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

medium

To improve code readability and consistency, please sort the import statements alphabetically.

Suggested change
import { useZarrStore } from '@/GlobalStates/ZarrStore';
import { useGlobalStore } from '@/GlobalStates/GlobalStore';
import { useCacheStore } from '@/GlobalStates/CacheStore';
import { useErrorStore } from '@/GlobalStates/ErrorStore';
import { useCacheStore } from '@/GlobalStates/CacheStore';
import { useErrorStore } from '@/GlobalStates/ErrorStore';
import { useGlobalStore } from '@/GlobalStates/GlobalStore';
import { useZarrStore } from '@/GlobalStates/ZarrStore';
References
  1. Imports should be sorted alphabetically to improve readability and maintainability. This is a common convention enforced by tools like ESLint's sort-imports rule. (link)

Comment on lines +3 to +6
import { useGlobalStore } from "@/GlobalStates/GlobalStore";
import { useZarrStore } from "@/GlobalStates/ZarrStore";
import { useErrorStore } from "@/GlobalStates/ErrorStore";
import { useCacheStore } from "@/GlobalStates/CacheStore";

Choose a reason for hiding this comment

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

medium

To improve code readability and consistency, please sort the import statements alphabetically.

Suggested change
import { useGlobalStore } from "@/GlobalStates/GlobalStore";
import { useZarrStore } from "@/GlobalStates/ZarrStore";
import { useErrorStore } from "@/GlobalStates/ErrorStore";
import { useCacheStore } from "@/GlobalStates/CacheStore";
import { useCacheStore } from "@/GlobalStates/CacheStore";
import { useErrorStore } from "@/GlobalStates/ErrorStore";
import { useGlobalStore } from "@/GlobalStates/GlobalStore";
import { useZarrStore } from "@/GlobalStates/ZarrStore";
References
  1. Imports should be sorted alphabetically to improve readability and maintainability. This is a common convention enforced by tools like ESLint's sort-imports rule. (link)

@TheJeran TheJeran merged commit bdd42f8 into main Mar 2, 2026
6 checks passed
@TheJeran
Copy link
Collaborator Author

TheJeran commented Mar 2, 2026

closes #568

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