Skip to content

fix(renderer): fix open event and sync event on cells#1377

Merged
johbaxter merged 1 commit intodevfrom
page-bug-run-cell-sync-bug
Jun 24, 2025
Merged

fix(renderer): fix open event and sync event on cells#1377
johbaxter merged 1 commit intodevfrom
page-bug-run-cell-sync-bug

Conversation

@johbaxter
Copy link
Copy Markdown
Contributor

Description

Changes Made

How to Test

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

Notes

@johbaxter johbaxter requested a review from a team as a code owner June 24, 2025 20:42
@github-actions
Copy link
Copy Markdown

@CodiumAI-Agent /describe

@QodoAI-Agent
Copy link
Copy Markdown

Title

fix(renderer): fix open event and sync event on cells


User description

Description

Changes Made

How to Test

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

Notes


PR Type

Bug fix, Enhancement


Description

  • Fix page ID extraction and open event dispatch

  • Enhance internal link navigation in LinkBlock

  • Refactor sync/async query and cell execution

  • Remove deprecated notifications and clean code


Changes walkthrough 📝

Relevant files
Bug fix
Renderer.tsx
Correct page ID extraction and remove notifications           

libs/renderer/src/Renderer.tsx

  • Updated getCurrentPageId regex to capture last route segment
  • Added debug log for matched route
  • Removed unused stateFilter warning code
  • Cleared commented error notification stubs
  • +2/-14   
    Enhancement
    LinkBlock.tsx
    Enhance internal link navigation logic                                     

    libs/renderer/src/components/block-defaults/link-block/LinkBlock.tsx

  • Refactored navigate to handle internal/external links
  • Added regex for #/app/:id and #/s/:id base routes
  • Prevent default and rebuild window.location.hash
  • Cleaned formatting and added semicolons
  • +19/-15 
    state.store.ts
    Refactor sync/async execution and open event logic             

    libs/renderer/src/store/state/state.store.ts

  • Standardized promise handling in runQuery, runCell
  • Enhanced dispatchOpenEvent for internal hash routing
  • Cleaned up commented code and logging
  • Reformatted utility methods and deep parsing logic
  • +245/-155
    Formatting
    useBlock.tsx
    Improve dispatchAction typing and formatting                         

    libs/renderer/src/hooks/useBlock.tsx

  • Adjusted TypeScript object formatting for actions param
  • Standardized semicolons and whitespace
  • No functional changes to logic
  • +1/-3     

    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

    @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: 4 🔵🔵🔵🔵⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Debug Logging

    Remove or conditionally guard the leftover console.log("match", match) in getCurrentPageId to avoid cluttering production logs.

    if (block?.widget === "page") {
        console.log("match", match);
        if (currentRoute === block?.data.route) {
    Parameter Misuse

    The isFullUrl function ignores its href parameter and tests data.href instead, causing misleading logic. Update to use the function argument.

    const isFullUrl = (href: string) => {
        return /^(https?:)?\/\//.test(data.href);
    };
    Stray Statement

    There's an unexplained 4; in dispatchOpenEvent which seems unintended and could cause runtime issues. It should be removed.

        4;
    } else if (destinationType === "External") {

    @github-actions
    Copy link
    Copy Markdown

    @CodiumAI-Agent /improve

    @QodoAI-Agent
    Copy link
    Copy Markdown

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Fix URL detection parameter

    The URL detection function should use its href parameter instead of always checking
    data.href, ensuring it correctly identifies full URLs based on the passed argument.

    libs/renderer/src/components/block-defaults/link-block/LinkBlock.tsx [36-38]

     const isFullUrl = (href: string) => {
    -    return /^(https?:)?\/\//.test(data.href);
    +    return /^(https?:)?\/\//.test(href);
     };
    Suggestion importance[1-10]: 8

    __

    Why: Using data.href instead of the function parameter in isFullUrl is a bug that will break external link detection; switching to test href fixes this core logic error.

    Medium
    Remove stray literal

    Remove the stray numeric literal 4; in dispatchOpenEvent, which appears to be a
    leftover debug artifact and leads to unreachable or erroneous code paths.

    libs/renderer/src/store/state/state.store.ts [1810]

    -4;
     
    +
    Suggestion importance[1-10]: 7

    __

    Why: The stray 4; serves no purpose and can cause confusing or unreachable code paths, so removing it improves code cleanliness.

    Medium
    Use hash for route extraction

    Extract the current route from window.location.hash rather than the full href, and
    remove the debug console.log. Use a regex that targets the segment after the hash
    for accurate matching.

    libs/renderer/src/Renderer.tsx [186-197]

    -const match = URLroute.match(/([^/]+)$/);
    -console.log("match", match);
    +const hash = window.location.hash;
    +const match = hash.match(/#\/(?:app|s)\/[^/]+\/(.+)/);
    +const currentRoute = match ? match[1] : "";
    Suggestion importance[1-10]: 6

    __

    Why: Extracting the route from window.location.hash with a more precise regex and removing the debug console.log enhances route parsing accuracy and removes noisy output.

    Low

    @johbaxter johbaxter merged commit 60966fc into dev Jun 24, 2025
    4 checks passed
    @johbaxter johbaxter deleted the page-bug-run-cell-sync-bug branch June 24, 2025 21:02
    @github-actions
    Copy link
    Copy Markdown

    @CodiumAI-Agent /update_changelog

    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.

    2 participants