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 review mode navigation by detecting whether the review UI is actually visible, not just opened, before switching to the requested index.
    • Enhanced webview and popup navigation to reveal the active Visualizer UI when moving to the corresponding view, improving consistency in what users see.

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 812118ce-3844-4e62-a5d4-1d2d655fbd4b

📥 Commits

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

📒 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
🚧 Files skipped from review as they are similar to previous changes (2)
  • workspaces/ballerina/ballerina-extension/src/stateMachinePopup.ts
  • workspaces/ballerina/ballerina-extension/src/features/ai/state/ApprovalViewManager.ts

📝 Walkthrough

Walkthrough

The changes add webview reveal calls in two opening paths and update review navigation to check visibility before deciding whether to navigate directly or reopen the review mode.

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/stateMachine.ts, workspaces/ballerina/ballerina-extension/src/stateMachinePopup.ts
navigateReviewMode() now uses review-mode visibility to choose between direct navigation and reopening with cached review data, and both view-opening paths now reveal the active Visualizer webview before dispatching their state-machine events.

Sequence Diagram

sequenceDiagram
  actor User
  participant ApprovalViewManager
  participant StateMachine
  participant StateMachinePopup
  participant VisualizerWebview

  User->>ApprovalViewManager: navigateReviewMode(index)
  alt ReviewMode visible
    ApprovalViewManager->>StateMachine: navigateReviewIndex(index)
  else ReviewMode not visible
    ApprovalViewManager->>StateMachine: reopen ReviewMode with cachedReviewData
    ApprovalViewManager->>StateMachine: reviewModeOpened(currentIndex)
  end

  User->>StateMachine: openView(type, viewLocation)
  StateMachine->>VisualizerWebview: reveal()
  StateMachine->>StateMachine: send state event

  User->>StateMachinePopup: openPopupView(EVENT_TYPE.OPEN_VIEW, ...)
  StateMachinePopup->>VisualizerWebview: reveal()
  StateMachinePopup->>StateMachinePopup: send popup event
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I hopped through code with a cheerful grin,
The Visualizer now pops right in.
With reveal() bright and review-mode aware,
The panel appears and says, “I’m here!”
Soft focus fluffs through every pane.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning Most template sections are left as placeholders, so the description is largely incomplete. Fill in Purpose, Goals, Approach, tests, security, docs, and other required template sections with concrete details.
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 accurately summarizes the visualizer focus/navigation fix.
Linked Issues check ✅ Passed The changes reveal or reopen the visualizer when needed, matching the focus/visibility issue in #1375.
Out of Scope Changes check ✅ Passed All edits relate to panel visibility/focus handling; no unrelated changes are evident.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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
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