Skip to content

fix(web): reapply broker config on change instead of short-circuiting#81

Merged
xiduzo merged 2 commits into
mainfrom
fix/mqtt-broker-config-change-reconnect
Jun 20, 2026
Merged

fix(web): reapply broker config on change instead of short-circuiting#81
xiduzo merged 2 commits into
mainfrom
fix/mqtt-broker-config-change-reconnect

Conversation

@xiduzo

@xiduzo xiduzo commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Problem

MqttManager::connect() short-circuits on "already connected" before applying the supplied BrokerConfig. So editing a broker's URL or credentials while it was connected silently never took effect — the flow kept using the old connection.

This surfaced while fixing the broader subscription churn (already on main): the per-flow_update auto-connect now detects an unchanged config and skips, but a changed config still needs to actually reconnect.

Fix

In flow_update's broker auto-connect loop:

  • Already connected + unchanged config → skip (no-op, no log churn). (prior commit)
  • Already connected + changed config → disconnect() first, then connect, so the new URL/creds apply.
  • disconnect() drops the broker-side subscriptions, so the broker's tracked figma_subscriptions are cleared at the same time. The existing subscription reconciliation then re-subscribes those topics on the fresh connection instead of treating them as still-live and skipping them.

Scope

One file: apps/web/src-tauri/src/runtime/commands.rs (+19/−5). Browser (wasm) runtime has no MQTT, so it's unaffected.

Verification

  • cargo check -p microflow
  • cargo clippy -p microflow → no issues ✓

🤖 Generated with Claude Code

xiduzo and others added 2 commits June 20, 2026 11:46
MqttManager::connect() returns early on "already connected" before applying
the supplied config, so editing a broker's url/credentials while it was
connected never took effect. flow_update now detects a changed config on a
live broker and disconnects first so the reconnect applies the new config.

disconnect() drops the broker-side subscriptions, so the broker's tracked
figma_subscriptions are cleared at the same time; the existing subscription
reconciliation then re-subscribes those topics on the fresh connection
rather than treating them as still-live and skipping them.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
CI runs `cargo clippy --workspace --all-targets -- -D warnings
-W clippy::pedantic`. The wildcard arm in compare_expr matched only the
remaining Boolean variant, tripping match_wildcard_for_single_variants and
failing the Rust check — red on main since before this branch, so it also
blocked this PR. Name the Boolean arm explicitly: the match is now
exhaustive and a future variant is a compile error instead of a silent
fall-through.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@xiduzo xiduzo force-pushed the fix/mqtt-broker-config-change-reconnect branch from 3db45dc to 9fa81b8 Compare June 20, 2026 10:00
@xiduzo xiduzo merged commit e28c04a into main Jun 20, 2026
7 checks passed
@xiduzo xiduzo deleted the fix/mqtt-broker-config-change-reconnect branch June 20, 2026 10:16
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