Driving a Desktop Companion from a Coding Assistant: An Event-Driven Interaction Practice

    A desktop companion that moves when a coding assistant is waiting looks like a small creative project, but it raises a broader question: how to turn internal software state into physical feedback users can notice. This article explains an event-driven approach—hooks, a layered architecture, a state machine, constrained commands, and independent safety checks—so reminders stay accurate, brief, and separate from authorization.

    1. Movement is only the surface; the real topic is making software state tangible

    A desktop companion that starts moving while a coding assistant waits for input looks like a light creative project. The technical question behind it is more general: how do you turn a program’s internal runtime state into physical feedback a person can notice directly?

    Traditional development tools mostly communicate through windows, text, and notification sounds. When a developer switches to another task or stops looking at the current window, states such as “confirmation needed” or “waiting for input” are easy to miss. A desktop device offers another channel: motion, light, or other low-interruption feedback that maps important software states into the physical environment.

    This kind of project should not be understood only as adding motion to a toy. It is a small event-driven system covering event capture, state decisions, message delivery, actuation, and failure handling.

    Mechanical design decides what the device can do. Software integration decides when it should act. For a prototype that already has basic motion, the software side often determines whether the interaction feels useful.

    2. Look for event hooks first, instead of guessing UI state

    2.1 What an event hook does

    An event hook is an extension point a program opens at a specific point in its lifecycle. When that kind of event occurs, the software can call a user-configured script or handler so external logic can take part in what happens next.

    In an AI coding workflow, the states that matter for interaction usually include task start, waiting for the user, task end, and execution failure. These are general categories. They do not mean any particular tool exposes events with those exact names. Before integrating, confirm which extension points the tool supports, when each event fires, and what information the callback can provide.

    If the software already offers a reliable event entry point, you do not need to infer state by reading on-screen text, scanning log fragments, or polling processes. Compared with those indirect methods, hooks usually have clearer meaning and make stable handling rules easier to define.

    2.2 “Waiting for input” is not the same as every pause

    Waiting for text, asking for permission, and waiting for an external task to return can all look like the software has stopped moving forward. Their meanings are different.

    A permission prompt requires the user to review risk. An ordinary input wait may only ask for missing information. Waiting on an external task often needs no user action at all. Mapping all of these to the same motion makes the reminder hard to interpret.

    A sound integration starts from a clear goal: are you signaling “I need a decision,” or “the program has finished”? Then choose an event that actually carries that meaning. Do not react to every callback just because it is easy to obtain.

    3. Use layers to reduce coupling between software and hardware

    Split the system into four parts:

    Coding-tool event entry
    → event adapter
    → local bridge
    → microcontroller and actuators

    This is a general architecture sketch, not an official integration guide for any specific product.

    3.1 Event adapter: normalize meaning, do not drive mechanics

    The adapter receives software callbacks and turns them into internal events with a shared shape. An internal event can include:

    • Event type: distinguish waiting for the user, resuming, task completion, and similar states
    • Session ID: distinguish tasks or windows
    • Event ID: help detect duplicates
    • Timestamp: help decide whether a message is stale
    • Source sequence number: help judge order when the source provides one

    These are custom design fields. They should not be treated as existing parameters of an external tool’s API.

    Keep the adapter short. It should only filter what is needed and hand the message off. Some hooks run synchronously, and a slow script will delay the original workflow. Do not play a full motion sequence inside the callback, and do not wait for the hardware to finish moving before returning.

    3.2 Local bridge: own the reliability logic

    The bridge maintains the device connection, interprets events, tracks state, and sends control commands. It is also the right place for deduplication, rate limiting, timeouts, and logging.

    For a single-machine desktop prototype, local interprocess communication or a serial link is usually enough. Whether to add a network depends on distance, deployment, and management needs—not on a desire to make the system more complex.

    If you do use a network, you also need to consider authentication, access scope, reconnect behavior, and message expiry. Interaction that can stay local should not be exposed to an external network by default.

    3.3 Microcontroller: run only limited, checkable motions

    The microcontroller does not need to understand the coding task. It only accepts constrained action requests, such as enter reminder mode, stop, or return to a safe position.

    Leaving complex business decisions in the bridge reduces how often firmware must change. That does not mean the hardware can fully trust the host. Motion range, maximum run time, and what happens when communication is lost should still be enforced on the device itself.

    4. Use a state machine to decide when to move, not “move on every message”

    The most direct prototype starts a motion every time a wait event arrives. That shows an effect quickly, but it tends to repeat motion, replay old messages, and keep reminding after the task has already ended.

    A state machine is more reliable. Internal states can include:

    • Idle: no task needs attention
    • Running: a task is in progress
    • Waiting for user: input or confirmation is required
    • Finished: the task completed or was stopped
    • Fault: the device or the link has failed

    Trigger a reminder once when the state changes from Running to Waiting for user. If the same waiting state arrives again, do not start the motion again. After the user acts, stop the reminder as soon as a resume or task-end event arrives.

    One easy miss: some tools expose only a wait event and no clear resume event. The system must not pretend it knows the task has resumed. Use a time-limited reminder, or end the motion from another event you have actually confirmed. Continuous motion should not be the default.

    With multiple sessions, one global state may also be insufficient. The bridge should track each session separately, then apply an explicit rule for the device’s overall behavior—for example, prefer the session that needs the user—so tasks do not overwrite each other.

    5. The protocol should express intended actions, not pass raw data through

    The simpler the hardware protocol, the easier it is to test and maintain. For this kind of desktop device, software usually needs to send only a small set of action types, not unchecked motor parameters.

    A sketch of the logic:

    1. On a normalized event:
    2. Check source, message format, and session ID
    3. If the event was already handled, ignore it
    4. If the event is stale, ignore it
    5. Update that session’s state
    6. Compute the target action from all session states
    7. If the target action differs from the current action:
    8. Send the target action to the device
    9. When the device receives an action request:
    10. Check that the request is in the allowed action set
    11. Run the corresponding limited motion sequence
    12. Return an accepted status or an error status
    13. Stop when the run-time limit is reached

    The block above is architectural pseudocode. It does not match any real interface of a specific tool or device.

    The protocol should also separate “the message was delivered” from “the motion finished.” A device ack only means the request was accepted, not that the mechanism succeeded. A novelty prototype can log acceptance only. A device that needs more reliable feedback should also report motion results or faults.

    Retries need care. Resending an old wait event after a disconnect can remind the user about a task that has already ended. After reconnect, syncing the current target state usually fits this kind of system better than replaying historical actions.

    6. Mechanical, electrical, and permission safety must be designed separately

    6.1 Motion needs physical limits

    A companion can be driven by a small motor or another actuator. The choice depends on load, structure, range of motion, and power. Small size alone does not mean the risk can be ignored.

    Account for pinch points, collisions between moving parts, base stability, cable pull, and mechanisms that jam. Reminder motions should be short and limited in amplitude, with an easy way to stop.

    A lost connection must not leave the device running indefinitely. The device should enforce its own run-time limit and, on failure, stop or enter a safe state.

    6.2 Power should not be an ad hoc splice

    Actuators can draw much more current when they start or stall. An undersized supply can reset the microcontroller, drop the link, or produce bad motion.

    Design supply and drive circuitry from the actual component ratings. Do not connect an actuator directly to a pin meant only for signals. Where needed, separate control-side and actuator-side power, and handle reference potential, noise, and protection as the circuit requires.

    6.3 Reminders and authorization must stay strictly separate

    When software asks the user to confirm an action, hardware may alert the user. It must not approve the action on the user’s behalf. Mapping “confirmation needed” directly to “continue automatically” breaks the existing permission boundary.

    Messages sent to the companion also usually do not need source code, full input text, file paths, or credentials. Send only what the state mapping requires, and limit exposure of sensitive data.

    7. Validate in stages instead of wiring the whole path at once

    Three stages work better than one end-to-end attempt.

    Stage one validates events only. Leave the hardware disconnected and write callback results to a local log. Check that wait, resume, and end events match expectations, and observe cancel, multiple sessions, and abnormal exit.

    Stage two validates the bridge. Use a simulated device to receive action requests. Focus on duplicate messages, stale messages, reconnect after disconnect, bad formats, and unknown actions. Failures must not block the coding tool itself.

    Stage three connects real hardware. Start with a single short motion, then add continuous reminders and state changes. In particular, check a stop request while motion is in progress, a dropped connection, and a stalled actuator.

    “The companion can move” is not a sufficient acceptance criterion. More important: it reminds the user when intervention is needed, it does not interrupt often when intervention is not needed, motion does not linger after the task ends, and a hardware failure does not disrupt the main development workflow.

    8. Good desktop interaction is restrained state feedback

    The value of this practice is that a small, visible device shows how software events can connect to physical feedback. Hooks make state easier to obtain, layers reduce maintenance cost, and a state machine plus safety limits give the prototype a basis for longer use.

    What is worth refining is not how elaborate the motion is, but whether the feedback is accurate, timely, and restrained. Only when the device alerts the user at the right moment—without leaking information, bypassing authorization, or adding extra noise—does it stop being a dancing novelty and become a useful desktop interaction aid.