feat(plugins): remember last-used export and import settings#1593
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a87029ebfa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| private func resetCurrentFormatSettings() { | ||
| guard let settable = currentPlugin as? any SettablePluginDiscoverable else { return } | ||
| settable.resetSettingsToDefaults() | ||
| settingsSnapshots[config.formatId] = settable.snapshotSettingsData() |
There was a problem hiding this comment.
Keep reset changes cancellable
When a user clicks Reset to Defaults and then cancels/closes the export dialog, this line replaces the original on-appear snapshot with the reset data. onDisappear then restores the reset settings rather than the pre-dialog settings, and restoreSettingsData persists through the plugin didSet, so cancelling still overwrites saved plugin options; the analogous import reset path has the same behavior. Keep the original snapshot until a successful export/import clears it.
Useful? React with 👍 / 👎.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
…er dialog storage
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0b1d83f793
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| func snapshotSettingsData() -> Data? | ||
| func restoreSettingsData(_ data: Data) | ||
| func resetSettingsToDefaults() |
There was a problem hiding this comment.
Bump the plugin kit ABI version
Adding these requirements changes the SettablePluginDiscoverable witness table that export/import plugins compiled against kit 18 provide, but PluginManager.currentPluginKitVersion and the bundled Info.plist kit declarations still remain at 18. In an installation with an existing third-party settable export/import plugin built against the previous kit 18, version validation will still accept and load it, and the new dialog paths call snapshotSettingsData/resetSettingsToDefaults through this existential, which can dispatch against a stale witness table instead of forcing the plugin to rebuild against the new protocol. Please bump the plugin kit version and bundled plugin declarations so incompatible plugins are rejected or updated.
Useful? React with 👍 / 👎.
Closes #1591
What
Export and import dialogs reopen with the last-used format, options, and encoding. Option changes are kept only when the export or import completes, so cancelling no longer overwrites saved settings. A Reset to Defaults button in both dialogs restores the stock options for the current format.
Why
Format-specific options have persisted since v0.18.0, but three gaps made repeat exports feel like starting over:
ExportConfigurationeach presentation.didSetwrites to UserDefaults on every toggle. Cancelling a dialog silently committed half-changed options.The fix follows HIG Launching ("restore the previous state... avoid making people retrace steps") and the persist-on-success contract Sequel Ace uses (state saved only in the OK handler, never on Cancel).
How
TransferDialogStorage(UserDefaults, same pattern asAppSettingsStorage) holds the last export format id and last import encoding. Both are written only on successful completion. The query-results export sharesExportDialog, so it gets format memory for free.SettablePluginDiscoverablegainssnapshotSettingsData(),restoreSettingsData(_:), andresetSettingsToDefaults(), all with default implementations. Additive under Library Evolution: no PluginKit version bump, no plugin re-release. Each bundled plugin overrides reset with one line because theSettingsassociated type has noinit()requirement.directoryURLunset, so macOS continues to remember the last directory natively.Tests
TransferDialogStorageTests: round-trips, overwrite, empty defaults, unknown-encoding fallback, on an isolated UserDefaults suite.SettablePluginSnapshotTests: snapshot encodes current settings, restore reverts memory and storage, invalid data ignored, reset returns defaults, dispatch through the type-erased protocol as the dialogs use it.No UI automation: the dialogs need a live database connection and the out-of-process NSSavePanel/NSOpenPanel, which UI tests cannot drive deterministically. The persistence logic is covered by the unit tests above.
Notes