tmuxctl

package
v0.3.32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package tmuxctl builds TaskYou's tmux commands and says which server each one goes to.

There are two servers in play, and they are not always the same one:

  • The agent server holds every task's executor and shell panes, the daemon session, and the TUI sessions `ty` creates for itself. Fresh installs run it as a private server (`tmux -L taskyou`), so TaskYou's sessions, options and root key bindings never mix with the user's own tmux.
  • The UI server is whichever server the running TUI sits in: $TMUX. It is the agent server when `ty` started its own session, and the user's own server when they ran `ty` inside their tmux.

Nothing ever moves a pane between the two: the detail view shows a task's window through a nested client (see ViewAttachScript), which works across servers.

Index

Constants

View Source
const (
	PaneTaskOption = "@ty_task"
	PaneRoleOption = "@ty_role"
	RoleAgent      = "agent"
	RoleShell      = "shell"
)

Pane tags on the agent server. A pane carries what it is, so a task's panes are found by asking tmux, not by a pane ID remembered from earlier: tmux reuses IDs, and a stored one can end up naming another task's pane.

View Source
const (
	DefaultWidth  = 200
	DefaultHeight = 50
)

The size of an agent session nobody is looking at. A detached session otherwise starts at tmux's 80x24, and an agent that lays itself out for that has to reflow the moment someone attaches.

View Source
const EnvSocket = "TASKYOU_TMUX_SOCKET"

EnvSocket overrides the agent server: a socket name for `tmux -L`, or "default" for tmux's own default server.

View Source
const PrivateSocket = "taskyou"

PrivateSocket is the server a fresh install runs its agents on.

Variables

This section is empty.

Functions

func Agent

func Agent(ctx context.Context, args ...string) *exec.Cmd

Agent builds a tmux command for the agent server.

func AgentArgs

func AgentArgs(args ...string) []string

AgentArgs prefixes args with the agent server's socket.

func AgentShell

func AgentShell() string

AgentShell is the agent server's tmux invocation as a shell word list, for command strings that tmux or a shell will run: "tmux" or "tmux -L 'taskyou'". $TMUX is cleared so the command reaches the named server even from inside another tmux.

func AgentShellDQ

func AgentShellDQ() string

AgentShellDQ is AgentShell with the socket name in double quotes, for shell scripts that are themselves wrapped in single quotes. Anything but letters, digits, dot, dash and underscore is dropped from the name.

func DefaultSize

func DefaultSize() string

DefaultSize is the same size as a tmux "default-size" value.

func DefaultSizeArgs

func DefaultSizeArgs() []string

DefaultSizeArgs are new-session's size flags for DefaultWidth x DefaultHeight.

func ExitWithProcess

func ExitWithProcess(pid int, script string) string

ExitWithProcess prefixes a pane's shell command with a watcher that closes the pane once process pid is gone. ty's view and remote-attach panes run clients of their own, so a TUI that crashes or is killed -9 would otherwise leave them behind, with the user's terminal showing an agent through a pane nothing manages. The watcher checks once a second and uses the pane's own $TMUX, so it reaches whichever server the pane is on. When the pane closes normally, the watcher gets the pane's SIGHUP and exits with it.

func Peek added in v0.3.31

func Peek() (socket string, recorded bool)

Peek returns the agent server this install uses, WITHOUT recording a choice. The second result says whether a choice had already been recorded.

Socket() records one the first time it is asked, which is right for anything that is about to run an agent and wrong for `ty doctor`: a read-only report must not be the thing that decides, permanently, which tmux server this install's agents live on.

func SameServer

func SameServer() bool

SameServer reports whether the UI and agent servers are one server, which is true whenever the TUI runs in a session `ty` created for itself.

func Socket

func Socket() string

Socket returns the `-L` name of the agent server, or "" for tmux's default server.

func TagPaneArgs

func TagPaneArgs(pane string, taskID int64, role string) [][]string

TagPaneArgs are the commands that tag pane as taskID's agent or shell.

func UI

func UI(ctx context.Context, args ...string) *exec.Cmd

UI builds a tmux command for the server the running TUI sits in ($TMUX).

func ViewAttachScript

func ViewAttachScript(view string) string

ViewAttachScript is the shell line a detail-view pane runs to show a task's window without moving any pane: a nested client attached to view, a session grouped with the daemon's that the caller has pointed at the task window.

destroy-unattached is set only after the client connects, chained with tmux's ";", so it cannot fire first and take the session with it. When the pane is killed the client detaches and tmux disposes of the view session; the shared window, and the agent in it, stay where they are.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL