Skip to content

1008 renderer lib always points to page 1#1028

Merged
johbaxter merged 3 commits intodevfrom
1008-renderer-lib-always-points-to-page-1
May 14, 2025
Merged

1008 renderer lib always points to page 1#1028
johbaxter merged 3 commits intodevfrom
1008-renderer-lib-always-points-to-page-1

Conversation

@JaganSomannaKanini
Copy link
Copy Markdown
Contributor

Description

With multiple pages, routing is working.

Changes Made

Added a new wrapper method to validate the URL and render the same.

How to Test

Add multiple pages, give the names to the route and save the application. Then share it and you can navigate to other pages by adding the route name to the URL.

Notes

Scenarios, the route name should not start with "/". It should be like "page-2" or "page-2/testpage". It should not be like "/page-2" or "/page-2/testpage".

@JaganSomannaKanini JaganSomannaKanini requested a review from a team as a code owner May 2, 2025 14:56
@JaganSomannaKanini JaganSomannaKanini linked an issue May 2, 2025 that may be closed by this pull request
@github-actions
Copy link
Copy Markdown

github-actions bot commented May 2, 2025

@CodiumAI-Agent /describe

@QodoAI-Agent
Copy link
Copy Markdown

Title

1008 renderer lib always points to page 1


User description

Description

With multiple pages, routing is working.

Changes Made

Added a new wrapper method to validate the URL and render the same.

How to Test

Add multiple pages, give the names to the route and save the application. Then share it and you can navigate to other pages by adding the route name to the URL.

Notes

Scenarios, the route name should not start with "/". It should be like "page-2" or "page-2/testpage". It should not be like "/page-2" or "/page-2/testpage".


PR Type

Bug fix, Enhancement


Description

  • Add URLroute dependency to useEffect

  • Introduce wrapper to select home page ID

  • Replace getHomePage with new route logic

  • Default to page-1 when no route match


Changes walkthrough 📝

Relevant files
Enhancement
Renderer.tsx
Implement URL-based home page logic                                           

libs/renderer/src/Renderer.tsx

  • Added URLroute variable and effect dependency
  • Removed getHomePage import and usage
  • Created wrapper function for active page determination
  • Set default active page to "page-1" if unmatched
  • +107/-87

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

    github-actions bot commented May 2, 2025

    @CodiumAI-Agent /review

    @QodoAI-Agent
    Copy link
    Copy Markdown

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

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

    Incomplete return

    The wrapper function returns undefined when blocks is falsy due to a bare return. This can lead to activePageID being set to undefined. Ensure the function always returns a valid string.

    if(!blocks) {
        return}
    Object?.entries(blocks).forEach(([_, block]) => {
        if (block?.widget === "page") {
            if (currentRoute === block?.data.route) {
    Route change detection

    Relying on window.location.href and adding it to the effect dependencies may not reliably capture route updates. Consider using useLocation() from react-router-dom to detect path or hash changes.

    const URLroute = window.location.href;
    
    useEffect(() => {
        // if (isAuthorized) {
        // start the loading

    @github-actions
    Copy link
    Copy Markdown

    github-actions bot commented May 2, 2025

    @CodiumAI-Agent /improve

    @QodoAI-Agent
    Copy link
    Copy Markdown

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Reset loading on early exit

    Prevent the loading spinner from hanging by resetting isLoading to false before
    early returning when there's no pixel to run.

    libs/renderer/src/Renderer.tsx [84-86]

     if (!pixel) {
    +    setIsLoading(false);
         return;
     }
    Suggestion importance[1-10]: 8

    __

    Why: Adding setIsLoading(false) before the early return fixes a real bug where the spinner would hang indefinitely if pixel is empty, improving user experience.

    Medium
    Return default page on missing blocks

    Ensure the wrapper function always returns a valid page ID by returning a default
    "page-1" when blocks is missing instead of undefined.

    libs/renderer/src/Renderer.tsx [208-209]

    -if(!blocks) {
    -    return}
    +if (!blocks) {
    +    return "page-1";
    +}
    Suggestion importance[1-10]: 6

    __

    Why: Ensuring wrapper returns "page-1" instead of undefined prevents downstream errors when blocks is falsy and correctly provides a fallback.

    Low
    Use React Router location in effect

    Replace the manual window.location.href usage with React Router's useLocation return
    value to properly trigger the effect on route changes. Remove the unused URLroute
    constant and include location in your dependency array instead.

    libs/renderer/src/Renderer.tsx [58]

    -const URLroute = window.location.href;
    +const location = useLocation();
     ...
    Suggestion importance[1-10]: 5

    __

    Why: Replacing window.location.href with useLocation is correct to trigger the effect on route changes and avoids stale URL detection, but the snippet is minimal and requires updating the dependency array as well.

    Low

    @johbaxter johbaxter merged commit 7c61620 into dev May 14, 2025
    3 checks passed
    @johbaxter johbaxter deleted the 1008-renderer-lib-always-points-to-page-1 branch May 14, 2025 20:34
    @github-actions
    Copy link
    Copy Markdown

    @CodiumAI-Agent /update_changelog

    @QodoAI-Agent
    Copy link
    Copy Markdown

    Changelog updates: 🔄

    2025-05-14 #1028

    Changed

    • Renderer now validates and parses URL to render the correct page
    • Link blocks support relative route updates without full reload
    • Refactored routing logic to maintain navigation across shared links

    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.

    Renderer lib always points to page-1

    3 participants