Skip to content

fix: correct typo preventing window_update and layout_update#1151

Open
nightcityblade wants to merge 3 commits intofossasia:masterfrom
nightcityblade:fix/issue-1126
Open

fix: correct typo preventing window_update and layout_update#1151
nightcityblade wants to merge 3 commits intofossasia:masterfrom
nightcityblade:fix/issue-1126

Conversation

@nightcityblade
Copy link
Copy Markdown

@nightcityblade nightcityblade commented Apr 1, 2026

Fixes #1126

The update flag in ApiProvider.js was computed using cmd.commmand (3 m's) instead of cmd.command, causing window_update and layout_update incremental updates to never be applied.

Changes:

  • Line 117: cmd.commmandcmd.command (window_update)
  • Line 130: cmd.commmandcmd.command (layout_update)

Summary by Sourcery

Fix incremental update handling for window and layout messages in the API provider.

Bug Fixes:

  • Correct the update flag computation for window_update messages so they are applied incrementally.
  • Correct the update flag computation for layout_update messages so they are applied incrementally.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Apr 1, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes a typo in ApiProvider’s update flag logic so that window and layout incremental updates are correctly detected and passed to the respective message handlers.

Sequence diagram for corrected window_update and layout_update handling

sequenceDiagram
  participant Client
  participant ApiProvider
  participant apiHandlers
  participant WindowHandler
  participant LayoutHandler

  Client->>ApiProvider: postMessage cmd (command = window_update)
  ApiProvider->>ApiProvider: switch on cmd.command
  ApiProvider->>apiHandlers: onWindowMessage({ cmd: cmd, update: cmd.command == window_update })
  apiHandlers->>WindowHandler: handleWindowMessage(cmd, update = true)

  Client->>ApiProvider: postMessage cmd (command = layout_update, data)
  ApiProvider->>ApiProvider: switch on cmd.command
  ApiProvider->>apiHandlers: onLayoutMessage({ cmd: cmd.data, update: cmd.command == layout_update })
  apiHandlers->>LayoutHandler: handleLayoutMessage(cmd.data, update = true)
Loading

File-Level Changes

Change Details Files
Correct the update flag condition so window_update messages are applied incrementally.
  • Replace the incorrect property access on the command object when determining whether a window message is an incremental update
  • Ensure the update flag is true when cmd.command equals 'window_update'
js/api/ApiProvider.js
Correct the update flag condition so layout_update messages are applied incrementally.
  • Replace the incorrect property access on the command object when determining whether a layout message is an incremental update
  • Ensure the update flag is true when cmd.command equals 'layout_update'
js/api/ApiProvider.js

Assessment against linked issues

Issue Objective Addressed Explanation
#1126 Fix the typo in js/api/ApiProvider.js so that the update flag for window_update messages uses cmd.command instead of cmd.commmand, enabling incremental window updates.
#1126 Fix the typo in js/api/ApiProvider.js so that the update flag for layout_update messages uses cmd.command instead of cmd.commmand, enabling incremental layout updates.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="js/api/ApiProvider.js" line_range="117" />
<code_context>
         apiHandlers.current.onWindowMessage({
           cmd: cmd,
-          update: cmd.commmand == 'window_update',
+          update: cmd.command == 'window_update',
         });
         break;
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Use strict equality (`===`) instead of loose equality (`==`) for the command comparison.

This avoids type-coercion edge cases if `cmd.command` is ever not a string, reducing the risk of subtle comparison bugs.
</issue_to_address>

### Comment 2
<location path="js/api/ApiProvider.js" line_range="130" />
<code_context>
         apiHandlers.current.onLayoutMessage({
           cmd: cmd.data,
-          update: cmd.commmand == 'layout_update',
+          update: cmd.command == 'layout_update',
         });
         break;
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Prefer strict equality (`===`) over loose equality (`==`) for the layout command check.

This will avoid type-coercion issues and align with common JavaScript style conventions.

Suggested implementation:

```javascript
          cmd: cmd,
          update: cmd.command === 'window_update',
        });
        break;

```

```javascript
      case 'reload':
      case 'layout_update':
        apiHandlers.current.onLayoutMessage({
          cmd: cmd.data,
          update: cmd.command === 'layout_update',
        });
        break;

```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread js/api/ApiProvider.js Outdated
Comment thread js/api/ApiProvider.js Outdated
@nightcityblade
Copy link
Copy Markdown
Author

Good point from Sourcery! Updated both comparisons to use strict equality (===) instead of loose equality (==). Thanks!

@mariobehling mariobehling requested a review from Copilot April 10, 2026 22:45
@mariobehling
Copy link
Copy Markdown
Member

Thanks for the contribution!

A process note.

We have automatic Copilot PR reviews enabled on this repository. These reviews are only triggered if the contributor has GitHub Copilot enabled and an active license on their own account.

Please enable Copilot in your GitHub settings if you have access. In many regions, free licenses are available through educational institutions or developer programs. Enabling Copilot helps us speed up the auto review process and reduces manual review overhead for the core team.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a typo in the WebSocket message handler so incremental updates (window_update, layout_update) can be detected and applied by the frontend, addressing #1126.

Changes:

  • Correct cmd.commmandcmd.command when computing the update flag for window_update.
  • Correct cmd.commmandcmd.command when computing the update flag for layout_update.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread js/api/ApiProvider.js
@@ -127,7 +127,7 @@ const ApiProvider = ({ children }) => {
case 'layout_update':
apiHandlers.current.onLayoutMessage({
cmd: cmd.data,
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

onLayoutMessage in js/main.js is defined as ({ data, update }) => { ... }, but this provider calls it with { cmd: cmd.data, update: ... }. With this PR, update becomes true for layout_update, so parseLayoutsFromServer(data) will receive undefined and crash when reading layoutJSON.length. Pass the payload under the data key (or align the handler signature) to avoid runtime errors and actually apply layout updates.

Suggested change
cmd: cmd.data,
data: cmd.data,

Copilot uses AI. Check for mistakes.
@nightcityblade
Copy link
Copy Markdown
Author

Thanks for the note. I understand the repository preference, but I do not have Copilot enabled on this account, so I cannot trigger the automatic Copilot review from my side. The code change itself is already updated to address the earlier review feedback, so if there is any additional manual feedback on the patch I’m happy to address it promptly.

@Manik-Khajuria-5
Copy link
Copy Markdown
Contributor

@nightcityblade
many test are failing and no screenshot or video is being provided can u please go through it once again

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.

Fix typo preventing window_update and layout_update incremental updates

4 participants