From 8d924d09399f2825004eba0a892fa4c40be16f2f Mon Sep 17 00:00:00 2001 From: Cam Gorrie Date: Mon, 17 Aug 2026 23:22:12 -0400 Subject: [PATCH] Record pedalboard connections only when the backend confirms them load_pb_connections sent the connect with send_notmodified and discarded the response, then appended to self.connections unconditionally. A port named in the pedalboard can be absent from JACK -- a MIDI device that is not plugged in or not enabled -- so the connect fails and the entry becomes a phantom. A phantom is never retried. connect() short-circuits on its "already exists" guard, and save() serialises self.connections into the pedalboard as a real ingen:arc, so the phantom survives a reload. Pass a callback and append only on success. This matches jack_port_appeared, which already checks connect_jack_ports() before it records anything. Co-Authored-By: Claude Opus 5 --- mod/host.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mod/host.py b/mod/host.py index 6f92bbb5b..ee58f3521 100644 --- a/mod/host.py +++ b/mod/host.py @@ -4048,9 +4048,20 @@ def load_pb_connections(self, connections, mappedOldMidiIns, mappedOldMidiOuts, port_to_2 = self._fix_host_connection_port(port_to) except: continue - self.send_notmodified("connect %s %s" % (port_from_2, port_to_2)) - self.connections.append((port_from, port_to)) - self.msg_callback("connect %s %s" % (port_from, port_to)) + # Record the connection only when mod-host confirms it. A port named + # in the pedalboard can be absent from JACK (a MIDI device that is not + # plugged in or not enabled), and an unconfirmed entry in + # self.connections is never retried: connect() short-circuits on it, + # and save() writes it to the pedalboard as a real arc. + def connected(ok, port_from=port_from, port_to=port_to): + if not ok: + print("ERROR: backend failed to connect ports: '%s' => '%s'" % (port_from, port_to)) + return + self.connections.append((port_from, port_to)) + self.msg_callback("connect %s %s" % (port_from, port_to)) + + self.send_notmodified("connect %s %s" % (port_from_2, port_to_2), + connected, datatype='boolean') elif aliasname1 is not None or aliasname2 is not None: for port_symbol, port_alias, port_conns in self.midiports: