-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow loading the app even when plugins fails to load #4769
Conversation
WalkthroughThe changes involve modifications to several components and hooks within the application, focusing on enhancing state management and error handling. Key updates include restructuring control flows, improving loading indicators, and refining the handling of initialization states. The adjustments aim to provide clearer feedback on the operational status of various functionalities, including plugins and workspaces, while also simplifying some logic flows. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Workspaces
participant Hook
User->>Workspaces: Request to load workspaces
Workspaces->>Hook: Check if canInitialize
Hook-->>Workspaces: Return canInitialize status
alt canInitialize is true
Workspaces->>Hook: Execute listWorkspace
Hook-->>Workspaces: Return workspaces data
Workspaces-->>User: Display workspaces
else canInitialize is false
Workspaces-->>User: Render nothing
end
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
app/packages/plugins/src/index.ts (1)
116-116
: Nitpick: Standardize string delimiter.The string delimiter for the
cacheKey
variable has been updated from single quotes to double quotes. This change does not affect the functionality but standardizes the string formatting.
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (6)
- app/packages/app/src/Sync.tsx (2 hunks)
- app/packages/core/src/components/Starter/index.tsx (3 hunks)
- app/packages/operators/src/loader.tsx (3 hunks)
- app/packages/plugins/src/index.ts (3 hunks)
- app/packages/spaces/src/components/Workspaces/hooks.ts (4 hunks)
- app/packages/spaces/src/components/Workspaces/index.tsx (2 hunks)
Additional context used
Path-based instructions (6)
app/packages/operators/src/loader.tsx (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.app/packages/spaces/src/components/Workspaces/hooks.ts (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.app/packages/spaces/src/components/Workspaces/index.tsx (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.app/packages/app/src/Sync.tsx (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.app/packages/core/src/components/Starter/index.tsx (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.app/packages/plugins/src/index.ts (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.
Additional comments not posted (17)
app/packages/operators/src/loader.tsx (4)
30-31
: LGTM!The changes enhance the state management by introducing a more granular state representation using a string union type (
"loading" | "error" | "ready"
) and an error state. This provides clearer insights into the function's operational status and allows capturing and managing errors that may occur during the loading of operators.
41-51
: LGTM!The changes to the
loadOperators
function improve its robustness by:
- Handling errors using a
.catch
block, updating the state to"error"
, and storing the error object. This ensures that errors are properly tracked and can be communicated to the calling components.- Updating the state to
"ready"
, triggering a force refresh, and settingoperatorsInitialized
totrue
on successful loading of operators.
60-66
: LGTM!The modifications to the return value of the
useOperators
function provide a more comprehensive interface for consumers of the hook. By returning an object containing multiple properties (ready
,hasError
,isLoading
,error
, andstate
), it allows them to easily determine the current status of the operator loading process.
Line range hint
1-68
: Code conforms to best practices!The code follows best practices in the used technologies:
- React: It uses React hooks (
useEffect
,useState
) for state management and side effects, and follows the convention of using theuse
prefix for custom hooks.- Recoil: It uses Recoil hooks (
useRecoilValue
,useSetRecoilState
) for accessing and updating Recoil state.- TypeScript: It uses TypeScript for type safety, with proper type annotations for function parameters, state variables, and return values.
There are no deviations from best practices in the mentioned technologies.
app/packages/spaces/src/components/Workspaces/hooks.ts (6)
8-8
: LGTM!The code changes are approved.
15-15
: LGTM!The code changes are approved.
18-18
: LGTM!The code changes are approved.
29-29
: LGTM!The code changes are approved.
41-41
: LGTM!The code changes are approved.
64-64
: LGTM!The code changes are approved.
app/packages/spaces/src/components/Workspaces/index.tsx (2)
28-34
: LGTM!The destructuring of the new
canInitialize
variable from theuseWorkspaces
hook looks good. The variable name is descriptive and follows the camelCase convention, which is a best practice in Typescript.
53-58
: Great job with theuseEffect
hook changes!The updates to the
useEffect
hook are excellent:
- Checking both
initialized
andcanInitialize
before callinglistWorkspace
ensures that the workspace is only loaded if the component is both initialized and allowed to initialize, which is a best practice.- Returning
null
ifcanInitialize
is false prevents the component from rendering when initialization is not permitted, which is also a good practice and improves the component's responsiveness to its initialization state.- Adding
canInitialize
to theuseEffect
hook's dependency array ensures that the effect is re-run whencanInitialize
changes, avoiding potential stale state issues.These changes enhance the component's overall logic and performance. Well done!
app/packages/app/src/Sync.tsx (1)
32-32
: LGTM!The import statement for
IndexPageQuery
has been added back correctly.app/packages/core/src/components/Starter/index.tsx (3)
8-8
: LGTM!The change is a minor refactor that improves code organization.
33-33
: LGTM!The change improves the clarity of the component's state management by using a more descriptive variable name and focusing on the loading state.
38-38
: LGTM!The change is consistent with the previous change and improves the responsiveness of the component to loading conditions.
app/packages/plugins/src/index.ts (1)
160-175
: LGTM!The changes to the
usePlugins
function enhance the error handling and state management:
- The introduction of the
notify
function allows alerting users when the initialization of Python plugins fails.- The state management is updated to include
operatorHasError
andoperatorIsLoading
flags from theuseOperators
hook.- The return object is adjusted to incorporate the new loading and error states from the operators.
These changes improve the user experience by providing more granular feedback on the plugin loading process.
Also applies to: 184-185
Caveats
What changes are proposed in this pull request?
allow loading the app even when plugins fails to load
How is this patch tested? If it is not, please explain why.
By redirecting plugins/operators request to non-existent port in fetch function to prevent loading of python plugins
Release Notes
Is this a user-facing change that should be mentioned in the release notes?
notes for FiftyOne users.
allow loading the app even when plugins fails to load
What areas of FiftyOne does this PR affect?
fiftyone
Python library changesSummary by CodeRabbit
New Features
canInitialize
property in the workspace hook to control component rendering based on initialization status.Bug Fixes
Refactor