Skip to content

Add setup flow engine for interactive provider and player setup - #4952

Merged
marcelveldt merged 3 commits into
devfrom
setup-flow-engine
Jul 24, 2026
Merged

marcelveldt merged 3 commits into
devfrom
setup-flow-engine

Conversation

@marcelveldt

Copy link
Copy Markdown
Member

What does this implement/fix?

Groundwork for the new interactive setup flows: a server-driven flow engine that replaces the action-based config-entry workarounds for provider/player setup (credentials, OAuth, pairing) — with a clear begin and end, multiple steps, progress and proper cancellation. Purely additive: nothing changes yet for existing providers or clients.

  • New SetupSession: a provider authors its setup as one plain coroutine (run_setup(session) in providers/<domain>/setup_flow.py) using awaitable form() / external() / progress_until() steps, optional step deadlines and clean abort/cleanup semantics
  • New api commands: config/providers/setup, config/providers/reconfigure (also covers re-authentication) and config/players/setup, plus config/flows/submit|get|abort; step changes are pushed via the new SETUP_FLOW_UPDATED event
  • Providers that need no setup input are created immediately, so the add-provider path is uniform for all providers
  • Values collected by flows land in the new setup_data config section: encrypted at rest and never exposed over the API
  • Options saves no longer drop stored values that have no config entry (ports the player-config preservation guard to provider configs)

Related: music-assistant/models#324 (shipped in models 1.1.169)

Types of changes

  • Bugfix (non-breaking change which fixes an issue) — bugfix
  • New feature (non-breaking change which adds functionality) — new-feature
  • Enhancement to an existing feature — enhancement
  • New music/player/metadata/plugin provider — new-provider
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — breaking-change
  • Refactor (no behaviour change) — refactor
  • Documentation only — documentation
  • Maintenance / chore — maintenance
  • CI / workflow change — ci
  • Dependencies bump — dependencies

Checklist

  • The code change is tested and works locally.
  • pre-commit run --all-files passes.
  • pytest passes, and tests have been added/updated under tests/ where applicable.
  • For changes to shared models, the companion PR in music-assistant/models is linked.
  • For changes affecting the UI, the companion PR in music-assistant/frontend is linked.
  • I have read and complied with the project's AI Policy for any AI-assisted contributions.
  • I have raised a PR against the documentation repository targeting the main or beta branch as appropriate.

Copilot AI review requested due to automatic review settings July 24, 2026 00:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces the groundwork for interactive, server-driven setup flows for providers and players by adding a flow session model (SetupSession) and a ConfigController flow engine (SetupFlowMixin) with new API commands and events. This enables multi-step setup/reconfigure/pairing with deadlines, progress steps, callbacks, and cancellation semantics while remaining additive to existing configuration paths.

Changes:

  • Added a new setup-flow engine in the config controller (SetupFlowMixin) with API commands for starting/continuing/aborting flows and an idle-flow sweeper.
  • Added the session/step authoring surface (SetupSession, SetupFlowContext, flow exceptions) plus provider/player hooks for setup data.
  • Added test coverage for setup flows and updated provider config saving to preserve unknown stored values and carry setup_data.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/controllers/config/test_setup_flows.py New end-to-end tests for provider/player flows (forms, external callback, expiry, abort, sweep, reconfigure).
tests/controllers/config/test_provider_config_load.py Adds regression test ensuring provider config saves preserve unknown stored values and setup_data.
music_assistant/models/setup_flow.py New SetupSession + context/exceptions and step publishing/validation/callback handling.
music_assistant/models/provider.py Adds provider helpers for reading and updating setup_data (with encryption and legacy fallback).
music_assistant/models/player.py Adds overridable run_setup_flow(session) hook for interactive player setup.
music_assistant/controllers/config/providers.py Preserves unknown stored values on save and factors provider instance creation into _create_provider_instance with cancellation cleanup.
music_assistant/controllers/config/flows.py New flow engine + API endpoints for starting/submitting/getting/aborting flows and finish handlers.
music_assistant/controllers/config/controller.py Wires the new SetupFlowMixin into ConfigController.

Comment thread music_assistant/models/setup_flow.py Resolved
Copilot AI review requested due to automatic review settings July 24, 2026 01:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread music_assistant/models/setup_flow.py Resolved
Copilot AI review requested due to automatic review settings July 24, 2026 01:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread music_assistant/models/setup_flow.py Resolved
@marcelveldt
marcelveldt merged commit 839a847 into dev Jul 24, 2026
15 checks passed
@marcelveldt
marcelveldt deleted the setup-flow-engine branch July 24, 2026 01:33
marcelveldt added a commit that referenced this pull request Jul 24, 2026
# What does this implement/fix?

Follow-up on #4952 (flagged in review): the setup-flow external-step
callback declares its params as `dict[str, str]`, but a JSON POST body
could inject numbers/bools into it.

- Coerce JSON body keys/values to strings before merging into the
callback params
- Ignore non-object JSON bodies (logged) instead of merging garbage
- Test covering a JSON callback body with non-string values

## Types of changes

- [x] Bugfix (non-breaking change which fixes an issue) — `bugfix`
- [ ] New feature (non-breaking change which adds functionality) —
`new-feature`
- [ ] Enhancement to an existing feature — `enhancement`
- [ ] New music/player/metadata/plugin provider — `new-provider`
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected) — `breaking-change`
- [ ] Refactor (no behaviour change) — `refactor`
- [ ] Documentation only — `documentation`
- [ ] Maintenance / chore — `maintenance`
- [ ] CI / workflow change — `ci`
- [ ] Dependencies bump — `dependencies`

## Checklist

- [x] The code change is tested and works locally.
- [x] `pre-commit run --all-files` passes.
- [x] `pytest` passes, and tests have been added/updated under `tests/`
where applicable.
- [ ] For changes to shared models, the companion PR in
`music-assistant/models` is linked.
- [ ] For changes affecting the UI, the companion PR in
`music-assistant/frontend` is linked.
- [x] I have read and complied with the project's [AI
Policy](https://github.com/music-assistant/.github/blob/main/AI_POLICY.md)
for any AI-assisted contributions.
- [ ] I have raised a PR against the documentation repository targeting
the main or beta branch as appropriate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants