Skip to content

IDE-321 Feat: Finalize multi-step undo/redo system#5180

Open
harshsomankar123-tech wants to merge 23 commits intoCatrobat:developfrom
harshsomankar123-tech:feature/multi-step-undo
Open

IDE-321 Feat: Finalize multi-step undo/redo system#5180
harshsomankar123-tech wants to merge 23 commits intoCatrobat:developfrom
harshsomankar123-tech:feature/multi-step-undo

Conversation

@harshsomankar123-tech
Copy link
Copy Markdown
Member

@harshsomankar123-tech harshsomankar123-tech commented Mar 31, 2026

Jira Ticket: https://catrobat.atlassian.net/browse/IDE-321

Description

Implements a robust project-scoped multi-step undo/redo system. This PR focuses exclusively on the core reliability of the undo/redo chain, state persistence, and UI synchronization.

Key Fixes & Features:

  • Multi-Step Stability: Fixes stale code.xml snapshots by ensuring project saves before every undo/redo push.
  • Race Condition Protection: Adds an isUndoRedoInProgress guard to prevent overlapping async project loads during rapid clicking.
  • Correct UI Refresh: Fixes the fragment lookup bug (findFragmentByTagfindFragmentById) so the script view correctly updates after every operation.
  • Context Preservation: Ensures sceneName and spriteName are correctly stored in all history entries.
  • Memory Safety: Deep-copies variable lists to prevent shared reference mutation between history steps.
  • Modern UI: Undo/Redo buttons stay visible but greyed out when no history is available, providing better visual feedback.
  • History Management: Prunes snapshots after 1 hour (TTL) and clears history during project delete, rename, or copy.

Screen Recording

Screen.Recording.2026-03-31.at.06.33.02.mov

Checklist for this pull request

Please review the contributing guidelines and wiki pages of this repository.

  • Include the name of the Jira ticket in the PR’s title
  • Include a summary of the changes plus the relevant context
  • Choose the proper base branch (develop)
  • Confirm that the changes follow the project’s coding guidelines
  • Verify that the changes generate no compiler or linter warnings
  • Perform a self-review of the changes
  • Verify to commit no other files than the intentionally changed ones
  • Include reasonable and readable tests verifying the added or changed behavior
  • Confirm that new and existing unit tests pass locally
  • Check that the commits’ message style matches the project’s guideline
  • Stick to the project’s gitflow workflow
  • Verify that your changes do not have any conflicts with the base branch
  • After the PR, verify that all CI checks have passed
  • Post a message in the catroid-stage or catroid-ide Slack channel and ask for a code reviewer

Comment thread catroid/src/main/java/org/catrobat/catroid/ui/SpriteActivity.java Fixed
@harshsomankar123-tech harshsomankar123-tech changed the title Feature/multi step undo IDE-321 Feat: Finalize multi-step undo/redo system Mar 31, 2026
@harshsomankar123-tech harshsomankar123-tech added the Active Member Tickets that are assigned to members that are still currently active label Mar 31, 2026
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

Implements a project-scoped multi-step undo/redo mechanism by introducing a dedicated snapshot/history manager, wiring it into ScriptFragment/SpriteActivity, and updating UI/tests to reflect the new enabled/disabled behavior.

Changes:

  • Added ProjectUndoManager to manage per-project snapshot stacks (undo/redo) and variable snapshots.
  • Updated ScriptFragment and SpriteActivity to drive undo/redo via the new manager and keep menu items visible but disabled when unavailable.
  • Added/updated unit + UI tests and ensured undo history is cleared on project delete/rename.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ProjectUndoManager.java New undo/redo snapshot manager with disk-backed snapshots, TTL cleanup, and clear helpers.
catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ScriptFragment.java Integrates multi-step undo/redo, adds async-guard, and refreshes UI after project reload.
catroid/src/main/java/org/catrobat/catroid/ui/SpriteActivity.java Adds lazy ProjectUndoManager, introduces redo menu handling, and updates menu enable/visibility logic.
catroid/src/main/res/menu/menu_script_activity.xml Adds redo action and defaults undo/redo to disabled + hidden until prepared.
catroid/src/main/java/org/catrobat/catroid/common/Constants.java Adds UNDO_DIRECTORY_NAME constant for snapshot storage.
catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/fragment/ProjectListFragment.kt Clears undo history when deleting/renaming projects from the list.
catroid/src/main/java/org/catrobat/catroid/ui/fragment/ProjectOptionsFragment.kt Clears undo history on project rename/delete via project options.
catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/fragment/UndoTest.java Updates existing undo assertions and adds multi-step + rapid-click coverage.
catroid/src/test/java/org/catrobat/catroid/ui/recyclerview/fragment/ProjectUndoManagerTest.java Adds unit tests for stack limiting/history clearing (currently has issues).

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

Comment thread catroid/src/main/java/org/catrobat/catroid/ui/SpriteActivity.java
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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


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

@harshsomankar123-tech harshsomankar123-tech marked this pull request as draft April 2, 2026 10:21
@harshsomankar123-tech harshsomankar123-tech marked this pull request as ready for review April 2, 2026 21:16
@wslany wslany requested a review from Copilot April 3, 2026 14:04
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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.


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

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.


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

Comment thread catroid/src/main/java/org/catrobat/catroid/ui/SpriteActivity.java
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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.


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

Comment thread catroid/src/main/java/org/catrobat/catroid/ui/SpriteActivity.java
@harshsomankar123-tech harshsomankar123-tech marked this pull request as draft April 5, 2026 10:15
Copy link
Copy Markdown

@github-advanced-security github-advanced-security AI left a comment

Choose a reason for hiding this comment

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

detekt found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@harshsomankar123-tech harshsomankar123-tech marked this pull request as ready for review April 5, 2026 21:09
@wslany wslany requested a review from Copilot April 6, 2026 04:38
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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.


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

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Active Member Tickets that are assigned to members that are still currently active

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants