Skip to content

Fix navigation to code diff and diagram diff when visualizer panel is already active#2159

Open
VellummyilumVinoth wants to merge 1 commit into
wso2:release/ballerina-5.12.xfrom
VellummyilumVinoth:fix-navigation-issue
Open

Fix navigation to code diff and diagram diff when visualizer panel is already active#2159
VellummyilumVinoth wants to merge 1 commit into
wso2:release/ballerina-5.12.xfrom
VellummyilumVinoth:fix-navigation-issue

Conversation

@VellummyilumVinoth

@VellummyilumVinoth VellummyilumVinoth commented May 4, 2026

Copy link
Copy Markdown
Contributor

Description

It resolves: wso2/product-integrator#1375

Goals

Describe the solutions that this feature/fix will introduce to resolve the problems described above

Approach

Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here.

UI Component Development

Specify the reason if following are not followed.

  • Added reusable UI components to the ui-toolkit. Follow the intructions when adding the componenent.
  • Use ui-toolkit components wherever possible. Run npm run storybook from the root directory to view current components.
  • Matches with the native VSCode look and feel.

Manage Icons

Specify the reason if following are not followed.

  • Added Icons to the font-wso2-vscode. Follow the instructions.

User stories

Summary of user stories addressed by this change>

Release note

Brief description of the new feature or bug fix as it will appear in the release notes

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

Type “Sent” when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type “N/A” and explain why.

Marketing

Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

Summary by CodeRabbit

  • Bug Fixes
    • Improved behavior when reopening review and popup views so the currently open panel is brought to the front before navigation or state updates.
    • Review navigation now resumes more reliably when a review panel is already open, while still restoring the requested review state when needed.

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b8651d4f-654c-455e-9702-34126a4423ef

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The Visualizer now reveals its current webview before review navigation and before opening the popup view for EVENT_TYPE.OPEN_VIEW. Review navigation still reopens ReviewMode from cached data when it is not already open.

Changes

Visualizer Focus Management

Layer / File(s) Summary
Visibility and reveal handling
workspaces/ballerina/ballerina-extension/src/features/ai/state/ApprovalViewManager.ts, workspaces/ballerina/ballerina-extension/src/stateMachinePopup.ts
navigateReviewMode reveals the Visualizer webview before in-place review navigation, and openPopupView reveals it for EVENT_TYPE.OPEN_VIEW before sending the popup state-machine event.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

Hop hop, the panel gleams anew,
My whiskers twitch at things to view.
Review and popup, now you’ll see,
A bright focus for you and me.
🐇✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only links the issue and leaves the required Purpose, Goals, Approach, tests, and other sections unfilled. Fill in the required template sections with the problem, solution, implementation details, tests, and relevant links.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: revealing the visualizer panel before navigating diff views when it is already open.
Linked Issues check ✅ Passed The changes reveal the visualizer and popup panels before dispatching navigation events, addressing the focus and visibility issue in #1375.
Out of Scope Changes check ✅ Passed The diff only adds panel reveal behavior in the related navigation and popup flows, with no unrelated code changes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
workspaces/ballerina/ballerina-extension/src/stateMachine.ts (1)

887-888: 💤 Low value

Redundant reveal() in openWebView service can now be removed

VisualizerWebview.currentPanel?.getWebview()?.reveal() at line 887 is the intended early reveal. However, the openWebView service at line 569 also calls reveal() when currentPanel already exists, so the panel ends up being revealed twice on every openView call where the panel is already open. Both calls are harmless (idempotent), but the one inside openWebView is now redundant given this earlier unconditional call.

♻️ Optional cleanup: remove the second reveal from `openWebView`
 } else {
-    VisualizerWebview.currentPanel!.getWebview()?.reveal();
     resolve(true);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@workspaces/ballerina/ballerina-extension/src/stateMachine.ts` around lines
887 - 888, Remove the redundant reveal call inside the openWebView flow: since
VisualizerWebview.currentPanel?.getWebview()?.reveal() is already invoked
unconditionally before calling stateService.send, delete the additional
.reveal() that openWebView performs when VisualizerWebview.currentPanel exists
(refer to VisualizerWebview.currentPanel, getWebview, reveal and the openWebView
service) so the panel is only revealed once on openView calls.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@workspaces/ballerina/ballerina-extension/src/stateMachine.ts`:
- Around line 887-888: Remove the redundant reveal call inside the openWebView
flow: since VisualizerWebview.currentPanel?.getWebview()?.reveal() is already
invoked unconditionally before calling stateService.send, delete the additional
.reveal() that openWebView performs when VisualizerWebview.currentPanel exists
(refer to VisualizerWebview.currentPanel, getWebview, reveal and the openWebView
service) so the panel is only revealed once on openView calls.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b197e387-94fa-449f-9bbd-e58948c093ec

📥 Commits

Reviewing files that changed from the base of the PR and between 48994e2 and 2248fa6.

📒 Files selected for processing (3)
  • workspaces/ballerina/ballerina-extension/src/features/ai/state/ApprovalViewManager.ts
  • workspaces/ballerina/ballerina-extension/src/stateMachine.ts
  • workspaces/ballerina/ballerina-extension/src/stateMachinePopup.ts

@VellummyilumVinoth VellummyilumVinoth marked this pull request as draft May 8, 2026 04:16
@VellummyilumVinoth VellummyilumVinoth marked this pull request as ready for review May 19, 2026 06:33
@VellummyilumVinoth VellummyilumVinoth force-pushed the fix-navigation-issue branch 2 times, most recently from c8c9bdd to 0e019b8 Compare June 26, 2026 06:42

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@workspaces/ballerina/ballerina-extension/src/features/ai/state/ApprovalViewManager.ts`:
- Line 369: The Visualizer panel is being revealed without transferring keyboard
focus because navigateReviewMode uses
VisualizerWebview.currentPanel?.getWebview()?.reveal(undefined, true). Update
this call so it matches openPopupView and reveals the panel with focus allowed,
ensuring the Visualizer becomes the active target in Review Mode. Keep the
change localized to navigateReviewMode and the VisualizerWebview reveal
invocation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 91360c1b-c803-4f69-9561-75c5adcaf902

📥 Commits

Reviewing files that changed from the base of the PR and between c8c9bdd and 0e019b8.

📒 Files selected for processing (2)
  • workspaces/ballerina/ballerina-extension/src/features/ai/state/ApprovalViewManager.ts
  • workspaces/ballerina/ballerina-extension/src/stateMachinePopup.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • workspaces/ballerina/ballerina-extension/src/stateMachinePopup.ts

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.

1 participant