Skip to content

Conversation

@Anchel123
Copy link
Contributor

@Anchel123 Anchel123 commented Mar 26, 2025

PR Type

Enhancement, Bug fix


Description

  • Added loading indicators for graph fetching and options loading.

    • Introduced isFetchingGraph state for graph loading.
    • Updated CodeGraph to display a spinner during graph fetching.
    • Enhanced Combobox to show a loading state when fetching options.
  • Improved Combobox behavior:

    • Disabled selection when no options are available and not fetching.
    • Added a spinner and message for fetching options.
  • Fixed minor issues and improved user experience:

    • Removed unnecessary debugger statement in GraphView.
    • Enhanced error handling for API fetch failures.

Changes walkthrough 📝

Relevant files
Enhancement
code-graph.tsx
Added loading state and spinner for graph fetching             

app/components/code-graph.tsx

  • Added isFetchingGraph state to manage graph loading.
  • Displayed a spinner when fetching the graph.
  • Updated UI to handle empty graph state more gracefully.
  • +16/-7   
    combobox.tsx
    Enhanced combobox with loading state and error handling   

    app/components/combobox.tsx

  • Added isFetchingOptions state for options loading.
  • Disabled combobox when no options are available.
  • Displayed spinner and messages during options fetching.
  • Improved API fetch error handling.
  • +44/-23 
    page.tsx
    Added graph loading state and improved error handling       

    app/page.tsx

  • Added isFetchingGraph state to manage graph loading.
  • Enhanced error handling for graph fetching API calls.
  • Updated CodeGraph component to use the new loading state.
  • +25/-18 
    Bug fix
    graphView.tsx
    Minor cleanup and zoom behavior improvement                           

    app/components/graphView.tsx

  • Removed unnecessary debugger statement.
  • Improved zoom behavior by resetting zoomed nodes.
  • +0/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • PR Summary by Typo

    Overview

    This PR addresses issue #426 by implementing loading states across the application, enhancing user experience during data fetching for graph visualizations and repository selection.

    Key Changes

    • Introduced isFetchingGraph state to display a loading spinner and message while fetching graph data in CodeGraph.tsx.
    • Added isFetchingOptions state and a loading spinner to the repository Combobox.tsx when fetching available repositories, along with a 30-second caching mechanism.
    • Disabled the combobox when options are being fetched or none are found.
    • Integrated the isFetchingGraph state into page.tsx to manage the loading status for graph data.
    • Removed an unnecessary debugger statement from graphView.tsx.

    Work Breakdown

    Category Lines Changed
    New Work 53 (52.0%)
    Churn 17 (16.7%)
    Refactor 32 (31.4%)
    Total Changes 102
    To turn off PR summary, please visit Notification settings.

    - Introduced `isFetchingGraph` state to manage loading state in the graph component.
    - Updated `CodeGraph` to display a loading spinner while fetching the graph.
    - Enhanced `Combobox` to show a loading state when fetching options.
    - Updated the Combobox component to disable the select input when there are no options and not fetching options, improving user experience.
    @vercel
    Copy link

    vercel bot commented Mar 26, 2025

    The latest updates on your projects. Learn more about Vercel for GitHub.

    Project Deployment Review Updated (UTC)
    code-graph Error Error Dec 22, 2025 2:36pm

    @coderabbitai
    Copy link
    Contributor

    coderabbitai bot commented Mar 26, 2025

    Important

    Review skipped

    Auto reviews are disabled on base/target branches other than the default branch.

    Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

    You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

    ✨ Finishing touches
    🧪 Generate unit tests (beta)
    • Create PR with unit tests
    • Post copyable unit tests in a comment
    • Commit unit tests in branch add-loading-states

    Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

    ❤️ Share

    Comment @coderabbitai help to get the list of available commands and usage tips.

    @Anchel123 Anchel123 requested a review from barakb March 26, 2025 12:48
    @Anchel123 Anchel123 linked an issue Mar 26, 2025 that may be closed by this pull request
    @qodo-code-review
    Copy link
    Contributor

    Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Prop Inconsistency

    The component signature has changed with options/setOptions being moved from props to internal state, but the component is still being called with these props in page.tsx.

    const [options, setOptions] = useState<string[]>([]);
    
    Error Handling

    The error handling in fetchOptions doesn't properly handle network errors (like connection failures) which could cause the loading state to remain indefinitely.

    try {
        const result = await fetch(`/api/repo`, {
            method: 'GET',
        })
    
        if (!result.ok) {
            toast({
                variant: "destructive",
                title: "Uh oh! Something went wrong.",
                description: await result.text(),
            })
            return 
        }
    
        const json = await result.json()
        setOptions(json.result)
    } finally {
        setIsFetchingOptions(false)
    }
    

    @qodo-code-review
    Copy link
    Contributor

    qodo-code-review bot commented Mar 26, 2025

    Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Fix parameter mismatch

    The function parameters don't match the Props interface. The options and
    setOptions parameters are missing in the function signature but are used later
    in the component. This mismatch could cause runtime errors.

    app/components/code-graph.tsx [48-58]

     export function CodeGraph({
         graph,
         data,
         setData,
         onFetchGraph,
         isFetchingGraph,
         onFetchNode,
    +    options,
    +    setOptions,
         isShowPath,
         setPath,
         chartRef,
         selectedValue,
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    __

    Why: The function signature is missing the options and setOptions parameters that are defined in the Props interface and used in the component. This mismatch would cause runtime errors when the component tries to access these undefined props.

    High
    Remove duplicate state definition

    This component is redefining options and setOptions as local state, but these
    are also passed as props. This creates a conflict where the local state shadows
    the props, making the component ignore the props values and potentially causing
    inconsistent behavior.

    app/components/code-graph.tsx [85]

    -const [options, setOptions] = useState<string[]>([]);
    +// Remove this line as options and setOptions should be used from props
    +// const [options, setOptions] = useState<string[]>([]);
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    __

    Why: The component defines local state for options and setOptions while also receiving them as props, creating a conflict where the local state shadows the props. This would cause the component to ignore the props values, breaking expected behavior.

    Medium
    Fix invalid select value

    The value prop is using string literals like "Fetching options..." and "No
    options found" which might not exist in the options array. This can cause React
    Select to have an invalid state where the selected value doesn't match any
    available option, potentially causing rendering issues or unexpected behavior.

    app/components/combobox.tsx [63]

    -<Select open={open} onOpenChange={setOpen} disabled={options.length === 0 && !isFetchingOptions} value={isFetchingOptions ? "Fetching options..." : options.length !== 0 ? selectedValue : "No options found"} onValueChange={onSelectedValue}>
    +<Select 
    +  open={open} 
    +  onOpenChange={setOpen} 
    +  disabled={options.length === 0 && !isFetchingOptions} 
    +  value={options.includes(selectedValue) ? selectedValue : ""} 
    +  onValueChange={onSelectedValue}
    +>
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    __

    Why: The current implementation uses string literals as values that don't exist in the options array, which can cause React Select to have an invalid state. The improved code ensures the value is always valid by checking if the selectedValue exists in options.

    Low
    • Update

    @typo-app
    Copy link

    typo-app bot commented Dec 22, 2025

    Static Code Review 📊

    ✅ All quality checks passed!

    Copy link

    @typo-app typo-app bot left a comment

    Choose a reason for hiding this comment

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

    AI Code Review 🤖

    Files Reviewed: 4
    Comments Added: 1
    Lines of Code Analyzed: 134
    Critical Issues: 0

    PR Health: Excellent 🔥

    Give 👍 or 👎 on each review comment to help us improve.

    const [commitIndex, setCommitIndex] = useState<number>(0);
    const [currentCommit, setCurrentCommit] = useState(0);
    const containerRef = useRef<HTMLDivElement>(null);
    const [options, setOptions] = useState<string[]>([]);
    Copy link

    Choose a reason for hiding this comment

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

    logic: Local options state shadows props, breaking parent updates. Remove this local state and use the options and setOptions props from the parent component.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    Add loading states

    3 participants