Introducing a new way to review your PRs.

Read the announcement

aprilnea / openlogi

⚡️A native, local-first alternative to Logitech Options+, written in Rust 🦀 — remap buttons, DPI, and SmartShift over HID++. No account, no telemetry.

View on GitHub

25 documents · Updated Nov 23, 2026

docs / interprocess-communication

Interprocess communication

OpenLogi IPC is the local client-server boundary between the always-on agent and the desktop, overlay, and command-line processes that use its device and input services. The agent keeps ownership of live hardware work. Other processes use one shared, versioned service contract to read state and request actions. See Application composition for the wider process model, Desktop application for the main GUI client, Agent service for the server, and Command-line interface for the command-line client.

Process roles

The IPC design gives each process a clear responsibility. The agent owns live hardware work, while desktop, overlay, and command-line processes use that work through local client connections.

Agent service

The agent is the IPC server and the owner of device reads and writes, input monitoring, pairing, and Actions Ring sessions. It publishes the state that other processes need instead of allowing them to open the same hardware themselves. The service is implemented by crates/…/server.rs and is started with the agent runtime described in Agent service.

The agent can serve more than one local client. The desktop uses the service for its main window, while the overlay helper uses the same service for Actions Ring display and user interaction.

References: crates/…/server.rs• L1-7 crates/…/server.rs• L43-56 crates/…/main.rs• L284-334

Desktop client

The desktop is an IPC client. It receives complete agent snapshots for health, inventory, standalone devices, camera use, foreground applications, lighting state, pairing state, secure-input state, virtual-keyboard state, transient keyboard-backlight indicators, and Flow status. It sends commands for settings, device reads and writes, config reload, permission prompts, pairing, host switching, sidetone, onboard controls, and Flow pairing. IPC results return to the desktop state model as updates while the UI remains separate from the async client work. See Desktop application for the UI flow.

The IPC contract also provides AgentStatus::secure_input_pausing_keys as the single answer to whether Secure Event Input is stopping OpenLogi key bindings. It combines the Secure Event Input reading with the presence of key bindings and an installed hook, so clients do not treat every SecureInput::On state as a pause.

The desktop also starts the agent when the endpoint is down and keeps trying to reconnect. This makes the desktop a user-facing supervisor of the connection, not the owner of the agent's hardware work.

References: crates/…/ipc.rs• L1-21 crates/…/ipc.rs• L60-130 crates/…/main.rs• L91-97 crates/…/ipc.rs• L270-315

Command-line client

The command-line interface is an IPC client. It connects with the Cli client kind and uses the same local service boundary as the desktop. The agent can therefore keep ownership of live device work while the command-line process requests the service's supported operations.

The client kind also tells the agent why the connection exists. A command-line connection can read or use service state without arming a dormant agent, which reserves that activation decision for the GUI client.

References: crates/…/client.rs• L1-15 crates/…/client.rs• L120-149 crates/…/ipc.rs• L951-964 crates/…/ipc.rs• L1089-1093

Transport boundary

The transport carries the same local service across supported desktop platforms. The agent binds a local endpoint. Clients connect to it. Both sides use the same framed serialized messages.

Local endpoint

The endpoint is local to the user machine. Unix uses a Unix-domain socket and Windows uses a named pipe. This keeps one client-server model across platforms. A failed agent can leave a stale Unix socket, so a later agent reclaims that endpoint before it listens.

The transport does not provide a remote service or a network API. Its purpose is process separation with local operating-system access control and a small shared path between the agent and its clients.

References: crates/…/transport.rs• L1-10 crates/…/transport.rs• L21-49 crates/…/transport.rs• L52-87

Connection handshake

Every client uses one shared connection policy. It opens the local endpoint, asks for the agent's protocol version, checks for an exact match, and declares its client kind before it sends a real request. The complete sequence has a two-second limit, so a silent or wedged endpoint is treated as unavailable.

The version is strict rather than negotiated. An older agent is left for replacement and the client keeps retrying. A newer agent means that the client process is stale and must relaunch. The agent's takeover probe asks only for the version and does not declare a client, while a matching GUI declaration can arm a dormant agent.

References: crates/…/client.rs• L62-69 crates/…/client.rs• L120-149 crates/…/client.rs• L179-195 crates/…/ipc.rs• L966-979 crates/…/ipc.rs• L1089-1093 crates/…/client.rs• L800-804

Wire contract

The wire contract is the Agent service and the serializable values that its requests and replies carry. The service uses request/response calls over local-socket framing and bincode serialization. The contract includes shared device and config types, typed device errors, health values, inventory, pairing state, foreground application state, Flow identity and peer state, secure-input and virtual-keyboard state, monitor events, semantic device reads and writes, receiver unpairing, lighting state, pointer speed, force sensing, disable-key state, onboard state, host switching, sidetone, save-reload results, and focused overlay presentation data.

The wire format is positional. Service method order and enum variant order affect decoding, so methods and variants are append-only. The current protocol version is 46. Recent additions include G-series onboard and keypad controls, software host switching, Flow identity and pairing, headset sidetone, Actions Ring unhover and size, G/M-key controls, macro-record controls, bare-modifier holds, config-file revision state, and the derived Secure Event Input pause decision. The contract is wider than the IPC crate because shared types from the core and HID layers also cross the boundary.

The wire tests pin the exact bytes for every serialized type that crosses the boundary. They use the same varint and little-endian encoding as the transport and also verify that each value can round-trip through serialization and decoding. The fixtures cover request positions, snapshots, Flow pairing, onboard state, device-control results, force-sensing, disable-key, backlight, configuration-reload, and key-combination shapes. This catches changes to field order, field types, enum variants, and request method positions before different agent and client builds can misread each other.

References: crates/…/ipc.rs• L30-35 crates/…/ipc.rs• L146-197 crates/…/ipc.rs• L951-1266 crates/…/wire_format.rs• L1-20 crates/…/wire_format.rs• L117-227 crates/…/wire_format.rs• L634-842 crates/…/wire_format.rs• L966-1025 crates/…/wire_format.rs• L1475-1494

Service contracts

The service separates durable state from commands. Clients can rebuild their view from current observations. Commands ask the agent to perform work and return either a typed result or a transport failure.

State observations

An observation is a generation number plus the complete AgentSnapshot. A client sends the last generation it saw. The agent waits until its state changes or a hold period ends. Because the reply is a whole snapshot rather than a change record, a new client, a reconnect, or an agent restart can converge without subscriptions, replay, or gap repair.

The shared Observer keeps one connection's generation ledger and one observe call in flight. It starts at generation zero, accepts only newer observations, and treats equal or older replies as heartbeats or stale data. A new observer after reconnect starts at zero so the replacement agent's first complete state is accepted.

The snapshot groups facts that must agree, such as inventory health and the inventory list. It also carries standalone devices, camera use, foreground applications, lighting state, secure-input and virtual-keyboard state, the current pairing phase, and coarse Flow peer state. Pairing and Flow pairing are represented as current state with terminal results. A missed response therefore does not leave the desktop waiting for an event that already passed.

The overlay and keyboard-backlight, notice, and lock-key indicators use separate observation channels because they need small, focused state. A missing ring invocation means no ring, including dismissal. The overlay can recover the ring that is active after it reconnects. Focused channels let transient indicators recover their current state without waking clients on unrelated agent changes.

The following flow shows how a state change reaches a client without a fixed polling cadence.

flowchart LR
    S[Agent state source] --> C[Observable state]
    C -->|new generation| O[observe request]
    O --> A[Complete snapshot]
    A --> G[Desktop, overlay, or CLI state]
    O -->|no change before hold ends| H[Heartbeat snapshot]
    H --> G

References: crates/…/ipc.rs• L255-277 crates/…/ipc.rs• L290-315 crates/…/ipc.rs• L318-350 crates/…/ipc.rs• L361-410 crates/…/ipc.rs• L580-628 crates/…/client.rs• L198-405 crates/…/wire_format.rs• L634-842

Device commands

Device commands cross the boundary because the agent must be the only process that owns live device I/O. The service covers reads and immediate writes for pointer settings, lighting, SmartShift, wheel mode, keyboard backlight, Fn-lock state, report rate, Easy-Switch host data and switching, force sensing, disable-key state, onboard state, headset sidetone, standalone lights, receiver unpairing, config reload, and permission prompts.

The service returns typed device errors separately from a broken connection. These errors include cases where a value is unsupported or the device keeps a different value. The contract also carries current capability ranges and accepted state so the desktop can show the device's real result. The desktop can then show a feature error or wait for the agent as needed.

References: crates/…/ipc.rs• L720-756 crates/…/ipc.rs• L947-975 crates/…/ipc.rs• L1059-1203 crates/…/wire_format.rs• L222-319 crates/…/wire_format.rs• L1027-1139 crates/…/wire_format.rs• L1363-1473

Pairing contract

Pairing is an agent-owned session because it needs exclusive receiver access while the agent's normal capture path is active. The desktop starts, advances, or cancels the session through commands. It then renders the current PairingPhase from observations.

The contract keeps two kinds of failure separate. An acceptance error means the agent could not start or receive a command. A PairingFailure describes a session that ended after acceptance. This prevents the desktop from waiting for progress from a session that never existed.

References: crates/…/ipc.rs• L361-484 crates/…/ipc.rs• L747-756 crates/…/wire_format.rs• L629-755 crates/…/wire_format.rs• L992-1025

Actions Ring contract

The Actions Ring uses a client for presentation and a service for authority. The agent sends the overlay a read-only presentation with a session identity, labels, icons, locale, and size. Executable actions remain in the agent-owned session. The overlay sends hover, unhover, activate, or cancel commands with that identity.

The session identity makes stale input safe. If the ring was replaced, cancelled, expired, or never existed, the agent rejects the command instead of applying it to a different ring. The overlay also checks the agent identity so an old helper can leave when a new agent run takes over.

References: crates/…/ipc.rs• L778-817 crates/…/ipc.rs• L905-914 crates/…/ipc.rs• L1005-1058 crates/…/ipc.rs• L1227-1266 crates/…/wire_format.rs• L465-510 crates/…/wire_format.rs• L523-585

Flow contract

Flow is the cross-machine feature, while this IPC boundary remains local. The agent exposes the local Flow identity, pairing controls, and a coarse state for configured peers through the service. The separate Flow link uses the exchanged identities and pinned keys to connect computers.

Flow pairing is represented as current state. Clients can show discovery, connection, code confirmation, success, or failure without replaying a lost event. The service reports whether each configured peer is connected, degraded, or lost, while fast link metrics stay out of the low-rate UI snapshot.

References: crates/…/ipc.rs• L330-490 crates/…/ipc.rs• L1205-1261 crates/…/wire_format.rs• L710-842

Client demand

Client declaration tells the agent why a connection exists. A GUI declaration is load-bearing for a dormant agent because it permits the agent to arm its normal work. CLI and overlay connections can read or display service state without arming the dormant agent. The declaration follows the version handshake, while a takeover probe uses only the version call and does not declare a client.

The shared connect_as entry point owns this policy for every consumer. Consumers do not compare protocol versions, declare themselves, or open the transport in separate ways. The only separate path is probe_version, which the agent uses to inspect an existing holder without declaring a client. This keeps the activation rule and handshake timeout the same for desktop, overlay, and command-line processes.

References: crates/…/ipc.rs• L916-929 crates/…/ipc.rs• L951-964 crates/…/ipc.rs• L966-979 crates/…/ipc.rs• L1089-1093 crates/…/client.rs• L120-195

Connection lifecycle

IPC treats process failure as a normal lifecycle event. Clients can lose a socket during an agent restart, recover by connecting again, and rebuild state from generation zero instead of trying to replay missed messages.

Reconnection behavior

The desktop keeps one state observation in flight while it accepts commands on the same connection. The shared Observer owns that pending observation and its generation ledger. A closed socket or an unanswered hold clears the connection and causes a new handshake. The first observation after reconnect uses generation zero. This requests the full current state from the replacement agent.

The shared client gives the initial connection and handshake two seconds. Observation requests use a deadline longer than the agent's hold, so a normal hold can finish before the client treats the connection as failed. The desktop reports a prolonged outage separately from a short startup delay. A command that cannot reach the agent also returns an explicit unavailable result.

References: crates/…/client.rs• L40-69 crates/…/client.rs• L224-289 crates/…/client.rs• L294-405

Agent replacement

An updated agent must replace an older process that still owns the singleton role and endpoint. The new agent can use the stable version handshake to identify an older holder and request its termination. One current agent can then remain.

The same version check protects clients. A desktop with an older contract does not drive a newer agent. A newer desktop does not interpret an older agent's replies. Debug agents also do not displace a running release agent. A takeover probe does not declare a client, and a holder that accepts but does not answer within the handshake window is left alone. This keeps development work from taking over the installed service.

References: crates/…/client.rs• L71-117 crates/…/client.rs• L138-150 crates/…/takeover.rs• L1-24 crates/…/takeover.rs• L48-95

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep protocol_version as the first service method. Append new service methods instead of inserting or removing them.
  • Keep wire enum variants and serialized field order stable. Check shared core and HID types, not only openlogi-ipc types.
  • For an intentional wire change, follow the release version policy in crates/…/AGENTS.md, update the pinned version when required, and update the golden-byte contract in crates/…/wire_format.rs. The golden test must use the transport's varint and little-endian encoding. New service methods must also be appended.
  • Keep key usage and modifier encoding stable when changing keyboard actions. Adding a usage such as Insert or Print Screen can change the bytes sent by both the command-line and desktop clients.
  • Keep snapshot generation rules aligned with every new state source. A state source that changes without a generation update can leave clients stale.
  • Keep the shared client handshake as the only path for opening an agent connection. A new client must use the correct ClientKind and must not duplicate version or declaration checks.
  • Keep the two-second handshake bound separate from the longer observation deadline. Changing either side can turn a slow or wedged endpoint into the wrong client state.
  • Keep client declaration rules aligned with dormant-agent arming. A client that declares the wrong kind can appear connected but fail to start the agent's normal work.
  • Keep typed command errors distinct from transport errors. The desktop uses that distinction to decide between recovery and feature-unavailable states.
  • Keep overlay session identity and agent identity checks aligned when changing Actions Ring commands or restart behavior.
  • Keep each focused observation channel aligned with its own generation state when adding transient overlay indicators or changing what the full snapshot contains.
  • Keep newly exposed health values, device settings, Flow state, and device actions in both the service contract and the matching golden-byte fixtures. This includes onboard profiles, host switching, sidetone, Flow pairing, G/M-key controls, macro recording, modifier holds, config revisions, and Secure Event Input state.
  • Keep AgentStatus::secure_input_pausing_keys as the single source of truth for whether Secure Event Input pauses OpenLogi key bindings. Keep the AST rule crates/…/ipc-secure-input-pause-owner.yml aligned when this ownership changes.
  • Keep save-reload verdicts aligned with the GUI's file revision checks. A new verdict must remain distinct from a transport failure and must be appended to the service contract.

Important failure modes

TriggerConsequenceGuard
Client and agent use different wire versionsRequests or replies may decode incorrectly, or the client may show no usable agentStrict handshake comparison before real RPCs
A service method is inserted or reorderedTarpc request indexes no longer name the same methodsAppend-only service order with protocol_version fixed at method zero
A serialized enum variant or field order changesBincode can map a value to the wrong meaningAppend-only variants, stable fields, and golden wire-format checks
A new key usage or action is sent to an older agentThe older agent can reject a valid action or misread a changed key contractStrict protocol matching and pinned key-combination bytes
The endpoint accepts a connection but does not answer the handshakeA client can hang or mistake a wedged agent for a busy oneOne two-second bound covers endpoint access and handshake calls
The agent endpoint is unavailableDesktop state becomes unavailable and device commands cannot applyReconnect loop, agent launch retry, and explicit unavailable updates
Inventory enumeration never completes or failsAn empty list could be mistaken for no hardwareScanning, Ready, and Unavailable inventory health states
A pairing command is rejected before a session startsDesktop could wait forever for progress that will never arriveTyped command rejection reported as an undeliverable pairing result
An overlay sends input for an old ringA stale click could affect a later ringSession identity checks and SessionNotFound rejection
A non-GUI client arms a dormant agentA state reader or orphaned helper can start agent workClientKind declaration arms only for Gui
A device rejects a requested value or keeps another valueThe desktop can show a setting that the device did not applyTyped write errors for unsupported and not-applied results
CLI and agent access the same hardware at onceDevice access can contend, especially during receiver useRoute command-line device work through the agent IPC service
A client carries a generation across an agent replacementThe first state from the replacement can be discarded as staleCreate a new observer with generation zero for each connection
A transient indicator is placed in the full snapshot without needSmall overlay changes wake clients that do not use that stateKeep focused channels such as ring, notice, backlight, and lock-key observation separate
A client reads a contract that lacks a new health, device, or Flow settingThe UI can show stale capability, peer, or control stateStrict protocol matching and pinned fixtures for the full wire shape
A receiver selector falls back to another receiver after an exact match failsPairing can target the wrong receiverUse the receiver product ID and unique ID as one exact selector
A force, disabled-key, onboard, host, or sidetone write is accepted but not appliedThe UI can report a setting that the device did not keepReturn typed read-back or not-applied errors
A saved file changes after the GUI writes itThe agent can load a different revision and the GUI can show stale save stateCarry the saved revision and return SavedConfigVerdict
Flow pairing progress is treated as a one-time eventA reconnecting client can miss the code or final resultExpose the pairing phase as current state
A client matches SecureInput::On without checking key bindings or hook stateThe UI can claim that key bindings are paused when no OpenLogi key binding is affectedUse AgentStatus::secure_input_pausing_keys and the IPC AST guard

Key files

FileWhy to read it
crates/…/lib.rsExplains the IPC crate boundary and the shared client, transport, and service contract roles.
crates/…/ipc.rsDefines the service surface, state messages, client roles, secure-input pause decision, command payloads, and version rules.
crates/…/transport.rsExplains the cross-platform local endpoint and message framing boundary.
crates/…/client.rsShows the single connection policy, handshake, client declaration, timeout, and generation tracking used by all clients.
crates/…/AGENTS.mdStates the wire compatibility rules and the requirement that all clients share the crate's connection policy.
crates/…/ipc-secure-input-pause-owner.ymlGuards the single owner of the Secure Event Input pause decision across clients.
crates/…/wire_format.rsShows which serialized shapes and positional rules are treated as compatibility contracts.
crates/…/server.rsConnects service calls to the agent's owned state and hardware actions.
crates/…/ipc.rsShows the desktop's observe, command, reconnect, and failure flow.
crates/…/observable.rsExplains how agent state becomes complete generation-stamped observations.
crates/…/pairing.rsShows why pairing stays in the agent and how its progress crosses IPC.
crates/…/agent.rsShows how the overlay observes the Actions Ring and reports interaction.
crates/…/takeover.rsShows how protocol versions support replacement of an old agent.
crates/…/mod.rsShows the command-line client entry point and its service-facing role.