# LibTmux::Model

- **Package:** LibTmux
- **Language:** Raku
- **Kind:** module
- **Source:** https://github.com/libtmux/libtmux-raku/blob/e76160bcce6e03976d49424da15b7c31afb2c68e/lib/LibTmux/Model.rakumod#L3
- **Page:** https://libtmux.org/en/raku/latest/reference/libtmux-model/

# Captured graph

Snapshot captures observations over an interval. Its field accessors, raw bytes,
relations and typed selections perform no I/O. It retains endpoint settings and
incarnation values, never the Runtime that acquired it. Reference construction
is local; reference commands create and close a fresh bounded client executor.

Physical windows and panes are unique by scoped ID. WindowLink represents one
session/index association, including repeated links to the same physical window.
Raw contextual rows preserve their multiplicity. Contradictory duplicate records
and missing targets in complete collections raise InconsistentSnapshot.
An incomplete relation raises MissingData rather than appearing empty.

same-entity compares daemon-scoped identity. WindowLink has no stable identity
between captures, so its comparison is confined to one captured graph. A link
reference checks its expected physical window before selecting or unlinking;
renumbering between that check and the operation remains a documented race.

Window.decoded-layout parses captured layout bytes locally. Strict text access
can fail for invalid UTF-8 while bytes remains available.



# Explicit commands

SessionRef.new-window and PaneRef.split/new-floating return references from the
command's declared identity projection. PaneRef.break returns the resulting
WindowRef; older profiles that omit the identity for a single-pane break use
an ID-filtered observation afterward. A new observation is acquired only by
inspect. If the source window has several placements, break requires an
explicit :from(WindowLinkRef) so tmux cannot choose which association to move.
Other mutations return a command Result. Completion means the tmux
client completed; pane input processing, rendering and child programs may
continue afterward.

WindowRef.link and WindowLinkRef.move require a destination session and index.
They return a WindowLinkRef for that placement. Moving, swapping or unlinking a
placement is separate from WindowRef.kill, which destroys the physical window
and all its links. tmux synchronizes placement changes across grouped sessions;
unlinking a placement also removes its corresponding peer placements. Physical
window linking prefers the destination session's existing source context when
the window is already present there. Link checks and mutations are separate operations;
concurrent renumbering can race between them. Cross-daemon targets are rejected.

References expose value-only options and hooks facades; SessionRef also exposes
environment. Creating these facades performs no I/O. Their get, set and other
methods explicitly acquire or mutate current configuration. See
:obj:`LibTmux::Configuration <LibTmux::Configuration>` for typed option, environment and command-value rules.

Client.ref creates a ClientRef with the observed name bytes, PID and creation
time. inspect requires that identity to remain attached. Client commands are
inherited from :obj:`LibTmux::Client <LibTmux::Client>`; client disconnection and name reuse can still
race between the identity check and the command.

Names and start directories are literal. Names that tmux would silently change
are refused, and separator support follows the daemon's capability profile.
PaneRef.set-title quotes one FORMAT expansion; tmux's title validation still
applies. The low-level command method keeps native tmux argument semantics.
Shell commands passed to creation and respawn run through tmux's shell-command
contract. PaneRef.pipe deliberately accepts tmux FORMAT and strftime syntax as
well as shell syntax. It closes an existing pipe when called without a command;
:toggle follows [pipe-pane](/en/tmux/latest/manual/pipe-pane/) -o, which closes an already open pipe.

Literal pane input uses send-text and never appends Enter. [send-keys](/en/tmux/latest/manual/send-keys/) accepts
key names and a positive :repeat. capture and capture-pending return Blob data
without text conversion or whitespace removal. copy-command sends an explicit
[copy-mode](/en/tmux/latest/manual/copy-mode/) command; it does not interpret arbitrary text as a key sequence.
reset queues terminal-state reset followed by history clearing without a client
roundtrip between them. It is not transactional: failure can leave partial
effects. reset-terminal only resets terminal state. Running a shell's ` reset `
program is a separate application action: send-text('reset') followed by
[send-keys](/en/tmux/latest/manual/send-keys/)('Enter') requests it without promising what the pane application does.

Split dimensions use :size or :percent exclusively. Percentage splits use the
size syntax across profiles, avoiding the known percentage-flag defect. Empty
pane creation selects its documented profile encoding; empty windows require
the corresponding capability. Floating creation, movement, stacking, modal
panes and layout variants have independent capability checks. The defective
[break-pane](/en/tmux/latest/manual/break-pane/) profile is refused before either named or unnamed operations.

See :obj:`LibTmux::Server <LibTmux::Server>` for endpoint ownership and acquisition,
:obj:`LibTmux::Selection <LibTmux::Selection>` for captured collection operations, and
:obj:`LibTmux::Transport <LibTmux::Transport>` for Result and process cancellation contracts.

## Members

### Common operations

- [`Session`](/en/raku/latest/reference/libtmux-model-session/) (class): Captured session with local window-link and group relationships.
- [`Window`](/en/raku/latest/reference/libtmux-model-window/) (class): Captured physical window; session-relative indices belong to WindowLink.
- [`Pane`](/en/raku/latest/reference/libtmux-model-pane/) (class): Captured pane fields and its local physical-window relationship.

### Other members

- [`Buffer`](/en/raku/latest/reference/libtmux-model-buffer/) (class): Captured buffer metadata; it does not retain or implicitly load buffer content.
- [`BufferSelection`](/en/raku/latest/reference/libtmux-model-bufferselection/) (class): Replayable typed buffer membership with local filtering.
- [`Client`](/en/raku/latest/reference/libtmux-model-client/) (class): Captured attached-client fields; commands use its separate reference.
- [`ClientRef`](/en/raku/latest/reference/libtmux-model-clientref/) (class): A captured client identity with explicit inspection and inherited client commands.
- [`ClientSelection`](/en/raku/latest/reference/libtmux-model-clientselection/) (class): Replayable typed client membership with local filtering.
- [`PaneRef`](/en/raku/latest/reference/libtmux-model-paneref/) (class): Value-only command target for a physical pane in one daemon incarnation.
- [`PaneSelection`](/en/raku/latest/reference/libtmux-model-paneselection/) (class): Replayable typed pane membership with local filtering.
- [`SessionGroup`](/en/raku/latest/reference/libtmux-model-sessiongroup/) (class): Captured session group whose members are resolved within this graph.
- [`SessionGroupSelection`](/en/raku/latest/reference/libtmux-model-sessiongroupselection/) (class): Replayable typed sessiongroup membership with local filtering.
- [`SessionRef`](/en/raku/latest/reference/libtmux-model-sessionref/) (class): Value-only command target for a session in one daemon incarnation.
- [`SessionSelection`](/en/raku/latest/reference/libtmux-model-sessionselection/) (class): Replayable typed session membership with local filtering.
- [`Snapshot`](/en/raku/latest/reference/libtmux-model-snapshot/) (class): Captured records and indexed relations; it retains no transport or live owner.
- [`View`](/en/raku/latest/reference/libtmux-model-view/) (class): A local view of one captured record. Accessors and relations never perform I/O.
- [`WindowLink`](/en/raku/latest/reference/libtmux-model-windowlink/) (class): One captured session/index association with an expected physical window.
- [`WindowLinkRef`](/en/raku/latest/reference/libtmux-model-windowlinkref/) (class): A session/index target with an expected window. Renumbering checks are not atomic.
- [`WindowLinkSelection`](/en/raku/latest/reference/libtmux-model-windowlinkselection/) (class): Replayable typed window-link membership with local filtering.
- [`WindowRef`](/en/raku/latest/reference/libtmux-model-windowref/) (class): Value-only command target for a physical window, independent of its links.
- [`WindowSelection`](/en/raku/latest/reference/libtmux-model-windowselection/) (class): Replayable typed window membership with local filtering.
