Interaction multiplexing
Interaction multiplexing
Posted Dec 21, 2025 14:05 UTC (Sun) by SLi (subscriber, #53131)In reply to: run0 by mathstuf
Parent article: Conill: Rethinking sudo with object capabilities
I would frame the generic problem as:
> Given this process, what human-facing I/O endpoints are actually reachable right now, and which one is the user currently attending to, even if that differs from the environment at exec time?
(Now this is still ambiguous to an extent; one can attach to tmux from multiple places.)
Is there a generic way we could approach solving this? I *think* there is.
Terminal managers like tmux are at a position where they can have that information, probably better than anyone else. They just aren't able to modify the environment of the running program to inform it, so there needs to be an out-of-band way to query the terminal emulator for the information.
I first thought of weird query-response OSC escape sequences; but they are tricky, and I think don't have an advantage in this case, because the one thing tmux *can* provide to all programs is an out-of-band mechanism.
Here's where this line of thought evolved. Option A keeps tmux self-contained and maximally useful on its own; option B minimizes tmux-specific policy and makes it easier to share semantics with other multiplexers or brokers.
# Option A ("flat"):
- We have an environment variable. I'm bad at naming, so I call it INTERACTIVE_CONTEXT.
- it contains a capability-ish _pointer_ to "who can route interaction for me", not the answer:
> INTERACTIVE_CONTEXT=unix:/run/user/1000/interactive/ctx-<token>.sock
- It is set initially by PAM or systemd user manager (or something using something like XDG_RUNTIME_DIR on non-systemd contexts)
- On a GUI login, it points to the GUI session broker. On a SSH login, it points to the SSH session broker
- Multiplexers like tmux wrap it. When tmux starts a session/window, it sets it to
> INTERACTIVE_CONTEXT = unix:/run/user/1000/interactive/tmux-ctx-<serverid>.sock
- The tmux context service can select "the most suitable client" (last-active, last-attached, view-of-pane, whatever); then either handle prompting itself, forward to the outer context of the chosen client, or maybe just tell "sorry, interaction is not available".
- To forward, tmux needs to remember each client's "outer" INTERACTIVE_CONTEXT at attach time. So when `tmux attach` runs, it captures the attaching environment's INTERACTIVE_CONTEXT and stores it per-client.
# Option B (delegating pointer chain)
Like option A, but instead of tmux implementing everything, its socket would implement only
- `resolve()` -> returns INTERACTIVE_CONTEXT for best client
- `describe()` -> says "I'm a multiplexer; here's what I'd choose"
- optionally `prompt()` implemented by forwarding (not UI)
---
I think there are some security implications that need thinking. I think the most useful model here is that the terminal multiplexer arbitrates "the most suitable client" and external policy decides "what this endpoint is allowed to do". One useful mental model may be to treat INTERACTIVE_CONTEXT as a bearer capability scoped to a login or multiplexer context, rather than as a global per-user resource (instead of "any same-UID process can pop auth prompts everywhere")
