Skip to content

Record pedalboard connections only when the backend confirms them - #7

Closed
sastraxi wants to merge 1 commit into
fix/stale-connections-on-midi-mode-switchfrom
fix/confirm-pedalboard-connections
Closed

sastraxi wants to merge 1 commit into
fix/stale-connections-on-midi-mode-switchfrom
fix/confirm-pedalboard-connections

Conversation

@sastraxi

Copy link
Copy Markdown
Collaborator

Problem

load_pb_connections sends each connect command with send_notmodified and discards the reply. Then it adds the entry to self.connections:

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))

A port that a pedalboard file names can be absent from JACK. This occurs if a MIDI device is not connected, or if the user did not enable the device. The connect command then fails. But mod-ui adds the entry to the record.

Effect

self.connections is the record that mod-ui keeps of the JACK graph. An incorrect entry has three effects:

  1. connect() starts with a test of this record. The test finds the incorrect entry and stops. mod-ui sends true to the browser, but mod-ui does not send the command to mod-host. The user cannot make that cable.
  2. mod-ui sends this record to each new browser. The browser shows a cable that JACK does not have.
  3. save() writes this record to the pedalboard file as an ingen:arc. The incorrect entry stays after a reload.

Change

load_pb_connections sends a callback with the connect command. It adds the entry to the record only if mod-host confirms the connection. If mod-host does not confirm, the code writes an error message and adds no entry.

jack_port_appeared already operates in this manner. It examines the result of connect_jack_ports() before it makes a record:

if not connect_jack_ports(self._fix_host_connection_port(connection[0]),
                          self._fix_host_connection_port(connection[1])):
    continue

self.connections.append(connection)
self.msg_callback("connect %s %s" % (connection[0], connection[1]))

Status of the tests

Read this section before you approve this pull request.

This change is not tested against a known failure. The related pull request #6 corrects a different code path with the same fault. That fault was made again on hardware, and the correction was tested. This code path has the same shape, but a failure from this path was not made again.

This change also makes the operation asynchronous. Before this change, self.connections was complete when load_pb_connections ended. After this change, the entries are added when mod-host replies. Code that reads self.connections immediately after a pedalboard load can find fewer entries. Two examples are a browser that connects during the load, and a save operation immediately after the load. This condition was not tested.

Upstream

This code is the same in upstream mod-audio/mod-ui at master (commit 0467c103), at mod/host.py:3953. No upstream issue reports this problem.

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 <noreply@anthropic.com>
@sastraxi

Copy link
Copy Markdown
Collaborator Author

Closed without a merge.

This change is not tested against a known failure. The fault in load_pb_connections was found by reading the code. A failure from this path was not made again on hardware. The related change in #6 corrects a different code path with the same fault, and that one was made again and tested.

This change also makes the operation asynchronous. self.connections is no longer complete when load_pb_connections ends. Code that reads the record immediately after a pedalboard load can find fewer entries. This condition was not tested.

The branch fix/confirm-pedalboard-connections stays in the repository. Open this pull request again if a failure from this path occurs, or after a test of the asynchronous behavior.

@sastraxi sastraxi closed this Aug 18, 2026
An error occurred while trying to automatically change base from fix/stale-connections-on-midi-mode-switch to main August 21, 2026 05:22
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