Skip to main content

ADR-001: GUI Device Connection Architecture

Status

Accepted

Context

The Conductor GUI displays available MIDI devices but cannot connect to them. The v3.0 unified input system (InputManager) wraps MidiDeviceManager and HidDeviceManager, but the device switching functionality was stubbed out during the v3.0 migration.

Users need to:

  1. See available MIDI devices
  2. Connect to a specific device by port index
  3. Disconnect from the current device
  4. See real-time connection status

Decision

Implement device connection through the existing IPC infrastructure:

  1. Expose MidiDeviceManager through InputManager - Add get_midi_manager() method
  2. Implement switch_device() in EngineManager - Use InputManager to access MIDI manager
  3. Add IPC client to GUI - Communicate with daemon via Unix socket
  4. Wire GUI buttons - Connect Svelte components to Tauri commands

Architecture Flow

DeviceList.svelte → stores.js → api.js → Tauri Command
→ IPC Client → Unix Socket → Daemon IPC Server
→ EngineManager.switch_device() → InputManager.get_midi_manager()
→ MidiDeviceManager.connect_to_port()

Why Not Direct MIDI Access in GUI?

  • Daemon already manages device lifecycle (reconnection, callbacks)
  • Avoids duplicate MIDI connections competing for same port
  • Maintains single source of truth for device state
  • Enables future multi-device support through daemon

Consequences

Positive

  • Single point of device management (daemon)
  • Consistent with existing architecture
  • Enables future multi-device support
  • Reuses existing IPC infrastructure

Negative

  • Requires daemon to be running for GUI device control
  • Additional IPC round-trip for each operation
  • Complexity in error propagation

Alternatives Considered

Alternative 1: Direct MIDI Access in GUI

  • GUI connects to MIDI directly using midir
  • Pros: No daemon dependency, simpler for single-device
  • Cons: Competing connections, no reconnection support, duplicated logic

Alternative 2: Shared State via File

  • Daemon writes device state to file, GUI reads
  • Pros: Simple, no IPC needed
  • Cons: Polling required, race conditions, no real-time feedback

References