Skip to content

fix: persist webview state during apply and undo operations (v0.1.9) - #46

Merged
Harsh16gupta merged 1 commit into
masterfrom
fix/apply-undo-webview-state-persistence
Aug 16, 2026
Merged

fix: persist webview state during apply and undo operations (v0.1.9)#46
Harsh16gupta merged 1 commit into
masterfrom
fix/apply-undo-webview-state-persistence

Conversation

@Harsh16gupta

Copy link
Copy Markdown
Collaborator

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: Updated getInitialState so 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: Hooked runNativeUndo to setPanelState so 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 so isApplying, applySuccess, isUndoing, and undoSuccess restore 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 the panelState type 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.
  • Version: Bumped version to 0.1.9.

Testing & Verification:

  • Verified locally by applying/undoing changes, switching between Joplin options and sidebar, and confirming progress and completion banners persist.

@Harsh16gupta Harsh16gupta self-assigned this Aug 16, 2026
@Harsh16gupta
Harsh16gupta force-pushed the fix/apply-undo-webview-state-persistence branch from 224d395 to 97b3202 Compare August 16, 2026 07:47
@Harsh16gupta

Copy link
Copy Markdown
Collaborator Author

the changes has been thoroughly tested
so merging this

@Harsh16gupta
Harsh16gupta merged commit c3289eb into master Aug 16, 2026
1 check 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.

1 participant