Skip to content

Kit profile persistence via settings.server_files #5

Closed

Description

@cchacs

Part of #2. Depends on #4 (calibration produces the data to persist).

Store kit profiles server-side via the plugin manifest's settings.server_files opt-in (see core CLAUDE.md's plugin-system section), not localStorage — this is an intentional improvement over drum_highway_3d's ad hoc localStorage keys (drum_h3d_kit_v1, drum_h3d_midi_pick_v2, etc.), so profiles:

  • survive a browser/device change,
  • show up in the unified Settings export/import flow (feedBack#113) and the diagnostics bundle,
  • can be backed up/restored like any other plugin state.

Shape (draft, refine during implementation):

{
  "profiles": {
    "<profile name>": {
      "pieces": {
        "kick": { "note": 36, "channel": 9, "logicalSourceKey": "..." },
        "snare": { "note": 38, "channel": 9, "logicalSourceKey": "..." }
      },
      "updatedAt": "..."
    }
  },
  "activeProfile": "<profile name>",
  "perSongOverrides": {
    "<song id or filename>": { "snare": { "note": 40, ... } }
  }
}

Backend (routes.py):

  • GET/POST /api/plugins/midi_drums/profiles (or similar) — follow the my-plugin template's pattern: schema validation before any write, bounded request body size, asyncio.to_thread for the blocking file write, logging via context["log"] not print().
  • plugin.json's settings.server_files lists the relpath(s) under config_dir this data lives at (relpaths only, no .., no absolute paths — per the allowlist rules in core CLAUDE.md).

Acceptance:

  • A kit profile created in the wizard survives a server restart.
  • The profile file appears correctly in a Settings → Export bundle and round-trips through import.
  • Unknown/removed-plugin-field tolerance: an older profile file missing a newer field doesn't crash a load (merge-with-defaults, same pattern as the my-plugin template's _read()).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions