terminal

package
v1.9.26 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package terminal provides a thin abstraction for spawning a new terminal window that attaches to an existing tmux session.

This is used by the TUI's Shift+Enter binding to "pop out" an agent-deck session into its own native terminal window (e.g. a fresh iTerm2 window on macOS), leaving agent-deck running undisturbed in the original window.

The cross-platform surface is intentionally tiny: callers pass the destination tmux session name (and optional `-L <socket>` selector) plus a hint at which terminal program they would like, and the platform-specific implementation does the rest. When a platform has no implementation, the stub returns ErrUnsupported so callers can show a friendly fallback.

Index

Constants

View Source
const SSHControlDir = "/tmp/agent-deck-ssh"

SSHControlDir is the directory the launcher tells SSH to keep its ControlMaster sockets in. Mirrors internal/session.sshControlDir so a remote attach launched via Shift+Enter shares the same multiplexed connection as a normal in-TUI remote attach.

Variables

View Source
var ErrUnsupported = errors.New("terminal: opening a new window is not yet supported on this platform")

ErrUnsupported is returned by OpenSessionInNewWindow on platforms that have no native implementation yet. Callers should surface a non-fatal message rather than treating this as an error condition.

Functions

func BuildAttachCommand added in v1.9.21

func BuildAttachCommand(req AttachRequest) string

BuildAttachCommand returns the shell command string that, when executed inside a fresh terminal window, attaches to the requested session.

For local requests (Remote == nil) it produces a `tmux attach …` invocation. For remote requests it produces an `ssh -tt … '<agent-deck-path> [-p profile] session attach <name>'` invocation that mirrors session.SSHRunner.Attach.

It is exported (and pure) so platform implementations and tests can share the exact same string-building logic without depending on os/exec.

func OpenSessionInNewWindow added in v1.9.21

func OpenSessionInNewWindow(_ AttachRequest) error

OpenSessionInNewWindow is a no-op on non-macOS platforms. It returns ErrUnsupported so the TUI can render a friendly "not yet supported" message instead of treating the case as a hard failure. A future implementation for Linux (`gnome-terminal --`, `kitty`, ...) or Windows (`wt.exe new-tab`) can replace this stub without changing call sites.

Types

type AttachRequest added in v1.9.21

type AttachRequest struct {
	// Name is the tmux session name (the `-t` argument of `tmux attach`)
	// for local sessions, or the remote agent-deck session ID when
	// Remote != nil.
	Name string

	// SocketName is the optional `-L <socket>` selector. Empty means the
	// default server. Ignored when Remote != nil.
	SocketName string

	// Terminal is an optional hint for which native terminal to use
	// (e.g. "iterm2"). Empty means "use the platform default".
	Terminal string

	// OpenAs controls whether the platform launcher opens a new tab or a
	// new window when both are supported (currently: iTerm2 on macOS).
	// Valid values: "tab", "window". Empty falls through to the platform
	// default, which is "tab" on macOS — matching iTerm's natural UX.
	// Issue #1100.
	OpenAs string

	// Remote, when non-nil, switches BuildAttachCommand from a local
	// `tmux attach` invocation to an `ssh` invocation that runs
	// `agent-deck session attach <Name>` on the remote host. Issue #1100,
	// follow-up to #1098 — Shift+Enter for remote sessions.
	Remote *RemoteAttach
}

AttachRequest describes the tmux session a new terminal window should attach to once spawned.

Name is required for local sessions. For remote sessions, Remote must be populated instead (Name then refers to the remote agent-deck session ID — what `agent-deck session attach <id>` expects on the other side). SocketName may be empty (meaning the default tmux server), matching the semantics of tmux.Session.SocketName.

type RemoteAttach added in v1.9.24

type RemoteAttach struct {
	// Host is the SSH destination (e.g. "user@host" or "user@host:port").
	Host string

	// AgentDeckPath is the agent-deck binary path on the remote host.
	// Empty defaults to "agent-deck".
	AgentDeckPath string

	// Profile is the remote profile selector. Empty or "default" omits
	// the -p flag.
	Profile string
}

RemoteAttach carries the SSH and agent-deck details needed to attach to a remote agent-deck session from a freshly-spawned terminal window.

Fields mirror the runtime values used by session.SSHRunner so the generated ssh command is byte-for-byte equivalent to what the in-TUI remote-attach path runs — same control-socket flags, same remote binary, same profile selector.

Jump to

Keyboard shortcuts

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