Skip to content

feat: add SettablePlugin protocol to unify plugin settings#276

Merged
datlechin merged 2 commits intomainfrom
feat/settable-plugin-protocol
Mar 11, 2026
Merged

feat: add SettablePlugin protocol to unify plugin settings#276
datlechin merged 2 commits intomainfrom
feat/settable-plugin-protocol

Conversation

@datlechin
Copy link
Owner

@datlechin datlechin commented Mar 11, 2026

Summary

  • Adds SettablePlugin protocol to TableProPluginKit SDK with SettablePluginDiscoverable type-erased witness for runtime discovery
  • Migrates all 6 plugins with settings (CSV, SQL, JSON, XLSX, MQL export + SQL import) from duplicated boilerplate to the unified protocol pattern
  • Replaces 3 separate as? casts in InstalledPluginsView with single as? any SettablePluginDiscoverable
  • Removes optionsView() from ExportFormatPlugin/ImportFormatPlugin and settingsView() from DriverPlugin protocols (now provided by SettablePlugin conformance)

Test plan

  • Build succeeds (xcodebuild -configuration Debug build)
  • swiftlint lint --strict passes on all changed files (0 violations)
  • PluginSettingsStorageTests pass (8/8)
  • Manual: Settings > Plugins — expand a plugin with settings, verify options render
  • Manual: Export dialog — verify format-specific options render for CSV/SQL/JSON/XLSX/MQL
  • Manual: Import dialog — verify SQL import options render
  • Manual: Change a setting, quit & relaunch, verify setting persisted

Summary by CodeRabbit

  • New Features

    • Unified plugin settings framework enabling opt-in per-plugin settings with a discoverable settings UI.
  • Improvements

    • Consistent settings UI and automatic persistence for CSV, JSON, MQL, SQL, XLSX and select import plugins.
    • Export/Import dialogs and Installed Plugins view now surface plugin settings via the new discoverable pathway for a simpler, consolidated experience.

@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5eb382bd-d7b0-44b7-8311-bbc15e01c405

📥 Commits

Reviewing files that changed from the base of the PR and between a36a2b0 and 7610df3.

📒 Files selected for processing (1)
  • Plugins/CSVExportPlugin/CSVExportPlugin.swift

📝 Walkthrough

Walkthrough

A new SettablePlugin protocol and discoverable witness standardize plugin settings: plugins now expose a settingsView(), have a Settings associated type and storage ID, and gain loadSettings()/saveSettings() persistence. Existing per-plugin optionsView()/settings hooks were removed in favor of this unified pathway.

Changes

Cohort / File(s) Summary
New SettablePlugin Protocol
Plugins/TableProPluginKit/SettablePlugin.swift
Adds SettablePluginDiscoverable and SettablePlugin protocols, with default settingsView(), loadSettings(), and saveSettings() implementations using PluginSettingsStorage.
Protocol API Removals
Plugins/TableProPluginKit/ExportFormatPlugin.swift, Plugins/TableProPluginKit/ImportFormatPlugin.swift, Plugins/TableProPluginKit/DriverPlugin.swift
Removes optionsView() / settingsView() requirements and their default implementations from these protocol definitions.
Export Plugins → SettablePlugin
Plugins/CSVExportPlugin/..., Plugins/JSONExportPlugin/..., Plugins/MQLExportPlugin/..., Plugins/SQLExportPlugin/..., Plugins/XLSXExportPlugin/...
Each export plugin now conforms to SettablePlugin; options replaced by settings (with typealias Settings and static settingsStorageId), initialization uses loadSettings(), didSet calls saveSettings(), UI bindings changed from plugin.options.* to plugin.settings.*, and optionsView() renamed to settingsView().
Import Plugin Migration
Plugins/SQLImportPlugin/SQLImportPlugin.swift, Plugins/SQLImportPlugin/SQLImportOptionsView.swift
SQLImportPlugin now conforms to SettablePlugin; replaces options with persisted settings, uses loadSettings()/saveSettings(), renames view to settingsView(), and switches internal logic/UI bindings to settings.*.
UI Callsites Updated
TablePro/Views/Export/ExportDialog.swift, TablePro/Views/Import/ImportDialog.swift, TablePro/Views/Settings/Plugins/InstalledPluginsView.swift
Replaces direct optionsView() calls with casts to any SettablePluginDiscoverable and settingsView(); consolidates plugin settings retrieval into a single discoverable pathway.
Options Views UI Bindings
Plugins/*/*OptionsView.swift (CSV, JSON, MQL, SQL, XLSX)
Multiple options view files updated to rebind controls from plugin.options.* to plugin.settings.* (minor UI tweaks like font added in JSON view).
Docs
docs/development/plugin-settings-tracking.md, CHANGELOG.md
Documents the SettablePlugin approach, storage key conventions, migration status for export/import plugins, and replaces per-plugin storage descriptions with the new protocol-based flow.

Sequence Diagram(s)

sequenceDiagram
  participant UI as "TablePro UI"
  participant Plugin as "Plugin (SettablePlugin)"
  participant Storage as "PluginSettingsStorage\n(UserDefaults JSON)"

  rect rgba(200,230,255,0.5)
    UI->>Plugin: instantiate plugin (required init)
    Plugin->>Storage: loadSettings() → read JSON for settingsStorageId
    Storage-->>Plugin: saved Settings? (decoded JSON)
    Plugin-->>UI: settingsView() (AnyView?) rendered in dialog
  end

  rect rgba(200,255,200,0.5)
    UI->>Plugin: user updates settings via settingsView
    Plugin-->>Plugin: settings property = newValue (didSet)
    Plugin->>Storage: saveSettings() → encode & write JSON
    Storage-->>Plugin: OK
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐇 I nibble bytes and tuck them tight,

Settings hop from dusk to light.
One protocol binds our scattered bits,
Saved in JSON, no more skits.
Hooray for tidy, persistent springs—
—signed, a very happy rabbit.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: introducing a SettablePlugin protocol to unify plugin settings, which is the central focus of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/settable-plugin-protocol

Comment @coderabbitai help to get the list of available commands and usage tips.

@datlechin datlechin merged commit 83de4e2 into main Mar 11, 2026
2 checks passed
@datlechin datlechin deleted the feat/settable-plugin-protocol branch March 11, 2026 12:45
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