Skip to content

feat: add plugin configuration API#184

Merged
fuzzzerd merged 2 commits intomasterfrom
fuzzz/plugin-config-api
Apr 23, 2026
Merged

feat: add plugin configuration API#184
fuzzzerd merged 2 commits intomasterfrom
fuzzz/plugin-config-api

Conversation

@fuzzzerd
Copy link
Copy Markdown
Owner

Adds a configuration API so plugins can declare user-tunable settings and the host handles persistence + UI.

  • New PluginConfigSchema + PluginConfigField types in SharpFM.Plugin (String, MultilineString, Bool, Int, Double, Enum).
  • Two new required IPlugin members: ConfigSchema and OnConfigChanged. Plugins without config return PluginConfigSchema.Empty and a no-op handler.
  • PluginConfigService persists per-plugin JSON at %LocalAppData%/SharpFM/plugin-config/{id}.json, with type coercion, default fallback for missing/invalid/drifted fields, and filename sanitization to prevent path traversal.
  • PluginService calls PluginConfigService.Apply right after Initialize so plugins receive persisted values at startup; exceptions from OnConfigChanged are caught and logged.
  • Plugin Manager gains a Configure... button that opens a generic dialog generated from the schema (TextBox, multi-line TextBox, CheckBox, NumericUpDown, ComboBox). The button is disabled for plugins with an empty schema.
  • ClipInspectorPlugin gets two demo bool fields (show element count, show XML size) so the feature is exercisable end-to-end in the shipped sample.
  • New tests: PluginConfigSchemaTests, PluginConfigServiceTests — 38 cases covering round-trip for every field type, malformed JSON fallback, missing/wrong-type/unknown-key handling, enum validation, pluginId sanitization, and the lifecycle (InitializeOnConfigChanged, empty-schema no-op, exception containment, fresh-service reload). Full suite: 1155 passed.

Closes #183

Plugins declare a typed PluginConfigSchema and receive persisted values via
OnConfigChanged. The host stores per-plugin JSON under
%LocalAppData%/SharpFM/plugin-config/ and renders a generic settings dialog
from the schema in the Plugin Manager. Plugins with an empty schema incur
zero overhead and show a disabled Configure button.

Closes #183
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

Test Results

✔️ Tests 1155 / 1155 - passed in 9.9s
✔️ Coverage 78.08% - passed with 70% threshold
📏 13104 / 15325 lines covered 🌿 4506 / 7229 branches covered
🔍 click here for more details

✏️ updated for commit ef9805f

IPluginHost requires SelectedClipChanged, ClipContentChanged, and
ClipCollectionChanged, but test mocks don't need to raise them. Scope
the suppression tightly with #pragma so it doesn't mask real issues.
@fuzzzerd fuzzzerd merged commit 7c04038 into master Apr 23, 2026
6 checks passed
@fuzzzerd fuzzzerd deleted the fuzzz/plugin-config-api branch April 23, 2026 00:24
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.

feat: plugin configuration API

1 participant