Skip to content

Conversation

sastaachar
Copy link
Contributor

No description provided.

@sastaachar sastaachar requested a review from a team as a code owner September 2, 2025 12:23
@mnk-blr
Copy link
Collaborator

mnk-blr commented Sep 2, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @sastaachar, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant optimization to the embedding mechanism by preventing unnecessary pre-rendering of content that is already displayed or initialized. It enhances performance and user experience by avoiding redundant operations and provides a new option to explicitly control when existing pre-rendered content should be replaced.

Highlights

  • Optimized Pre-rendering Logic: The core preRender method now intelligently checks if content is already rendered. If it is, and the replaceExistingPreRender flag is not set to true, the method will return early, preventing redundant pre-rendering and improving performance.
  • New replaceExistingPreRender Option: A new boolean parameter, replaceExistingPreRender, has been added to the preRender method. This allows callers to explicitly force a re-render even if content is already present, providing more control over the embedding process.
  • Initial Hidden State for Pre-rendered Components: React components that are pre-rendered will now initially have their display style set to none. This ensures a smoother visual experience by preventing incomplete or flickering content from being briefly visible before the full embed is ready.
  • Enhanced Test Coverage: New test cases have been added to liveboard.spec.ts to cover the new replaceExistingPreRender functionality and to properly mock session information and authentication events, ensuring the robustness of the changes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an optimization to avoid re-rendering components that are already pre-rendered, and adds a mechanism to explicitly replace them if needed. The core logic changes in ts-embed.ts are sound and well-implemented. The accompanying test updates in liveboard.spec.ts are thorough, including a new test case for the replacement functionality. I've added a couple of suggestions to improve the test suite's maintainability and reliability by reducing code duplication and replacing fixed timeouts with fake timers.

Comment on lines 604 to 611
// mock getSessionInfo
jest.spyOn(SessionInfoService, 'getSessionInfo').mockResolvedValue({
releaseVersion: '1.0.0',
userGUID: '1234567890',
currentOrgId: 1,
privileges: [],
mixpanelToken: '1234567890',
});

Choose a reason for hiding this comment

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

medium

This mock setup for SessionInfoService.getSessionInfo is duplicated in several tests within this file. To improve maintainability and reduce boilerplate code, consider extracting this mock into a reusable helper function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please take care of this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 628 to +631
executeAfterWait(() => {
liveboardEmbed.navigateToLiveboard('lb1', 'viz1');
expect(onSpy).toHaveBeenCalledWith(HostEvent.Navigate, 'embed/viz/lb1/viz1');
done();
});
}, 1002);

Choose a reason for hiding this comment

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

medium

Using a fixed timeout like 1002 can make tests slow and potentially flaky, as they depend on real-time execution. It's better to use fake timers. You can call jest.useFakeTimers() at the top of your describe block and then use jest.advanceTimersByTime() to control the passage of time deterministically. This makes tests faster and more reliable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this would require wider rework , i tried using faketimers at this point we are using the execute after wait

Copy link

pkg-pr-new bot commented Sep 2, 2025

Open in StackBlitz

npm i https://pkg.pr.new/thoughtspot/visual-embed-sdk/@thoughtspot/visual-embed-sdk@300

commit: 38aecc6

Copy link

sonar-prod-ts bot commented Sep 16, 2025

SonarQube Quality Gate

Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
1.1% 1.1% Duplication

@sastaachar sastaachar merged commit b02be46 into main Sep 16, 2025
9 checks passed
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.

3 participants