Skip to content

Conversation

@KCSAbeywickrama
Copy link
Contributor

@KCSAbeywickrama KCSAbeywickrama commented Nov 27, 2025

Purpose

Fix wso2/product-ballerina-integrator#1794

Summary by CodeRabbit

  • Bug Fixes
    • Improved undo/redo state management during initialization for consistent behavior across sessions.
    • Enhanced undo functionality to better preserve context when working in the data mapper view.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 2025

Walkthrough

These changes fix undo button behavior in the inline data mapper by resetting undo/redo state during initialization and preventing navigation away from the inline mapper context when undoing with no current artifact.

Changes

Cohort / File(s) Summary
Undo/Redo State Management
workspaces/ballerina/ballerina-extension/src/rpc-managers/data-mapper/rpc-manager.ts
Imports undoRedoManager from state machine and invokes undoRedoManager?.reset() after initializing the source to clear undo/redo history on startup.
Inline Mapper Undo Condition
workspaces/ballerina/ballerina-extension/src/rpc-managers/visualizer/rpc-manager.ts
Tightens the undo() method condition to prevent opening PackageOverview when there is no current artifact AND the current UI view is not InlineDataMapper.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Straightforward state reset addition with optional chaining
  • Single condition enhancement with clear intent
  • No complex logic or cross-cutting concerns introduced

Suggested reviewers

  • hevayo
  • gigara
  • kanushka

Poem

🐰 Hopping through undo lanes so bright,
Reset state makes mappings right,
No more fleeing to Overview's sight—
Inline mapper stays in sight,
Bug fixed with delight!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description only contains the Purpose section with a link to the issue, missing most required sections like Goals, Approach, and other important details. Complete the PR description by adding Goals, Approach, and other relevant sections from the template to provide comprehensive context for reviewers.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main fix: undo button not working in the inline data mapper, which directly relates to the changeset.
Linked Issues check ✅ Passed The changes address the core objective: they prevent PackageOverview navigation during undo in the inline data mapper and reset undo/redo state on initialization.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the undo functionality in the inline data mapper, with no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
workspaces/ballerina/ballerina-extension/src/rpc-managers/visualizer/rpc-manager.ts (1)

120-142: Undo: InlineDataMapper guard correctly prevents unwanted navigation

The added StateMachine.context().view !== MACHINE_VIEW.InlineDataMapper guard around the PackageOverview navigation aligns with the issue: undo from the inline data mapper will now stay in the inline view even when currentArtifact is not found, instead of jumping to the overview. This looks correct for the reported behavior.

If you also want consistent behavior when the artifact update times out (lines 136–142), consider applying the same view check there so a slow/no artifact notification does not still kick users from InlineDataMapper to PackageOverview. That would keep the inline experience consistent while still surfacing the timeout error.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e007ce8 and aa9e164.

📒 Files selected for processing (2)
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/data-mapper/rpc-manager.ts (2 hunks)
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/visualizer/rpc-manager.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: KCSAbeywickrama
Repo: wso2/vscode-extensions PR: 653
File: workspaces/bi/bi-extension/src/test/e2e-playwright-tests/data-mapper/DataMapperUtils.ts:136-141
Timestamp: 2025-11-26T07:49:56.428Z
Learning: In workspaces/bi/bi-extension/src/test/e2e-playwright-tests/data-mapper/DataMapperUtils.ts, the goPrevViewBackButton() method is only called when in a focused view, ensuring breadcrumbs are always present. No guard for empty breadcrumbs is needed.
📚 Learning: 2025-11-26T07:49:56.428Z
Learnt from: KCSAbeywickrama
Repo: wso2/vscode-extensions PR: 653
File: workspaces/bi/bi-extension/src/test/e2e-playwright-tests/data-mapper/DataMapperUtils.ts:136-141
Timestamp: 2025-11-26T07:49:56.428Z
Learning: In workspaces/bi/bi-extension/src/test/e2e-playwright-tests/data-mapper/DataMapperUtils.ts, the goPrevViewBackButton() method is only called when in a focused view, ensuring breadcrumbs are always present. No guard for empty breadcrumbs is needed.

Applied to files:

  • workspaces/ballerina/ballerina-extension/src/rpc-managers/visualizer/rpc-manager.ts
📚 Learning: 2025-11-26T06:34:09.752Z
Learnt from: KCSAbeywickrama
Repo: wso2/vscode-extensions PR: 653
File: workspaces/bi/bi-extension/src/test/e2e-playwright-tests/data-mapper/DataMapperUtils.ts:128-134
Timestamp: 2025-11-26T06:34:09.752Z
Learning: In workspaces/bi/bi-extension/src/test/e2e-playwright-tests/data-mapper/DataMapperUtils.ts, the goPrevViewBreadcrumb() method is only called when in a focused view, ensuring breadcrumbs are always present. No guard for empty breadcrumbs is needed.

Applied to files:

  • workspaces/ballerina/ballerina-extension/src/rpc-managers/visualizer/rpc-manager.ts
🧬 Code graph analysis (2)
workspaces/ballerina/ballerina-extension/src/rpc-managers/data-mapper/rpc-manager.ts (1)
workspaces/ballerina/ballerina-extension/src/stateMachine.ts (1)
  • undoRedoManager (72-72)
workspaces/ballerina/ballerina-extension/src/rpc-managers/visualizer/rpc-manager.ts (1)
workspaces/ballerina/ballerina-extension/src/stateMachine.ts (1)
  • StateMachine (793-819)
🔇 Additional comments (1)
workspaces/ballerina/ballerina-extension/src/rpc-managers/data-mapper/rpc-manager.ts (1)

54-76: Resetting undo/redo on initial IDM source looks right; confirm global impact

Importing undoRedoManager and calling undoRedoManager?.reset() right after updateSource in getInitialIDMSource makes sense: it effectively treats the freshly generated inline data-mapper source as the new baseline so that undo in the mapper only walks back mapper-triggered edits, which should help avoid the wrong navigation behavior.

One thing to double‑check: since undoRedoManager is a global exported from stateMachine, this reset will clear any existing undo/redo history managed by the same instance. If other views (non‑inline visualizer flows, other editors) also rely on that shared manager, you might want to confirm that resetting here is acceptable for them, or consider scoping the reset to the relevant file/context in a follow‑up.

@KCSAbeywickrama KCSAbeywickrama merged commit 0163357 into wso2:main Nov 28, 2025
6 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.

[Data Mapper - Inline] Undo button not working in data mapper

2 participants