Skip to content

fix(client): removed source page #1182

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

Merged
merged 1 commit into from
May 27, 2025
Merged

Conversation

SuryaNarayanan-Kgs
Copy link
Contributor

Description

Changes Made

How to Test

  1. Steps to reproduce/test the behavior
  2. Expected outcomes

Notes

@SuryaNarayanan-Kgs SuryaNarayanan-Kgs requested a review from a team as a code owner May 20, 2025 11:23
@SuryaNarayanan-Kgs SuryaNarayanan-Kgs linked an issue May 20, 2025 that may be closed by this pull request
Copy link

@CodiumAI-Agent /describe

@CodiumAI-Agent
Copy link

Title

fix(client): removed source page


User description

Description

Changes Made

How to Test

  1. Steps to reproduce/test the behavior
  2. Expected outcomes

Notes


PR Type

Bug fix


Description

  • Use history back in Import breadcrumb

  • Fallback redirect to home if no history


Changes walkthrough 📝

Relevant files
Bug fix
ImportPage.tsx
Dynamic breadcrumb navigation fix                                               

packages/client/src/pages/import/ImportPage.tsx

  • Replace fixed navigate('/import') call
  • Check window.history.length before navigation
  • Use navigate(-1) for back navigation
  • Fallback to navigate('/') if no history
  • +5/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • Copy link

    @CodiumAI-Agent /review

    @CodiumAI-Agent
    Copy link

    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

    History API use

    Reliance on window.history.length for SPA navigation may be unreliable across browsers or user flows; consider using React Router methods to detect navigation history or fallback conditions consistently.

    if (window.history.length > 1) {
        navigate(-1);
    } else {
        navigate('/');
    }
    Navigation fallback

    The fallback to '/' may not match the intended import landing page; confirm that navigating to root provides expected context for users.

    } else {
        navigate('/');
    }

    Copy link

    @CodiumAI-Agent /improve

    @CodiumAI-Agent
    Copy link

    CodiumAI-Agent commented May 20, 2025

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Check history index reliably

    Replace the unreliable window.history.length check with React Router's
    history.state.idx property to determine if a back navigation is possible. This
    ensures the fallback logic works correctly in an SPA.

    packages/client/src/pages/import/ImportPage.tsx [585-589]

    -if (window.history.length > 1) {
    +if (window.history.state?.idx > 0) {
         navigate(-1);
     } else {
         navigate('/');
     }
    Suggestion importance[1-10]: 7

    __

    Why: Using window.history.length can be unreliable in an SPA; checking window.history.state?.idx aligns with React Router’s internal indexing and improves back‐navigation accuracy.

    Medium
    General
    Use replace option for navigate

    Add the { replace: true } option to both navigate calls to avoid creating extra
    history entries when performing back or fallback navigation.

    packages/client/src/pages/import/ImportPage.tsx [586-588]

    -navigate(-1);
    -navigate('/');
    +navigate(-1, { replace: true });
    +navigate('/', { replace: true });
    Suggestion importance[1-10]: 4

    __

    Why: Adding { replace: true } on the fallback navigate('/') avoids an extra entry, but it's redundant on navigate(-1) since back navigation doesn’t push a new history entry.

    Low

    @johbaxter
    Copy link
    Contributor

    image

    @ppatel9703 We probably want the red arrow to say "View your models"

    @johbaxter johbaxter merged commit b4642b6 into dev May 27, 2025
    4 checks passed
    @johbaxter johbaxter deleted the 735-remove-the-add-source-page-in-ui branch May 27, 2025 16:12
    @CodiumAI-Agent
    Copy link

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Check history index reliably

    Replace the unreliable window.history.length check with React Router's
    history.state.idx property to determine if a back navigation is possible. This
    ensures the fallback logic works correctly in an SPA.

    packages/client/src/pages/import/ImportPage.tsx [585-589]

    -if (window.history.length > 1) {
    +if (window.history.state?.idx > 0) {
         navigate(-1);
     } else {
         navigate('/');
     }
    Suggestion importance[1-10]: 7

    __

    Why: Using window.history.length can be unreliable in an SPA; checking window.history.state?.idx aligns with React Router’s internal indexing and improves back‐navigation accuracy.

    Medium
    General
    Use replace option for navigate

    Add the { replace: true } option to both navigate calls to avoid creating extra
    history entries when performing back or fallback navigation.

    packages/client/src/pages/import/ImportPage.tsx [586-588]

    -navigate(-1);
    -navigate('/');
    +navigate(-1, { replace: true });
    +navigate('/', { replace: true });
    Suggestion importance[1-10]: 4

    __

    Why: Adding { replace: true } on the fallback navigate('/') avoids an extra entry, but it's redundant on navigate(-1) since back navigation doesn’t push a new history entry.

    Low

    Copy link

    @CodiumAI-Agent /update_changelog

    @CodiumAI-Agent
    Copy link

    Changelog updates: 🔄

    2025-05-27 *

    Fixed

    • Remove source page from client UI
    • Fallback to home when navigating back with no history

    to commit the new content to the CHANGELOG.md file, please type:
    '/update_changelog --pr_update_changelog.push_changelog_changes=true'

    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.

    Remove the "Add Source" page in UI
    3 participants