fix: persist webview state during apply and undo operations (v0.1.9) - #46
Merged
Merged
Conversation
Harsh16gupta
force-pushed
the
fix/apply-undo-webview-state-persistence
branch
from
August 16, 2026 07:47
224d395 to
97b3202
Compare
Collaborator
Author
|
the changes has been thoroughly tested |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
While using the plugin, I noticed that when applying categorization changes (or undoing them) and navigating to another section in Joplin (like opening Tools → Options or closing/reopening the sidebar), the webview loses its state upon returning. The progress bar disappears, polling stops, and the UI resets back to the initial "Apply" button even though the background task is still running or finished.
This PR fixes the webview state persistence across remounts and properly connects native Joplin settings undo triggers to the panel.
What was changed:
src/panel/setupPanel.ts: UpdatedgetInitialStateso it preserves and returns the clustered notes together with the active/completed apply or undo state (apply_progress,apply_complete,undo_progress,undo_complete, etc.). Also made sure editing/renaming clusters resets any completed apply banners so stale messages don't show up.src/settings/registerSettings.ts: HookedrunNativeUndotosetPanelStateso that when undo is triggered from the Joplin Tools menu or Settings, the panel picks up the updated state on remount.src/webview/context/AppStateContext.tsx: Handled the nested operation state on mount soisApplying,applySuccess,isUndoing, andundoSuccessrestore properly. Also ensured polling automatically resumes if a task is still in progress.src/webview/pages/DashboardPage.tsx&EmptyStatePage.tsx: Added banners for undo progress, completion, and errors.src/types/panel.ts: Narrowed thepanelStatetype on results to valid apply/undo messages.test/panel/setupPanel.test.ts: Added unit tests covering initial state recovery, apply/undo progress, completion, and mutation resets.0.1.9.Testing & Verification: