# LibTmux.Server.waitForPaneState

- **Package:** libtmux-haskell
- **Language:** Haskell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-haskell/blob/72edb54317bf619c6dc54bff311844f062f8984c/src/LibTmux/Server.hs#L1127
- **Page:** https://libtmux.org/en/haskell/latest/reference/libtmux-server-v-waitforpanestate/

```haskell
waitForPaneState
  :: Server
  -> WindowSlot
  -> PaneRef
  -> PaneState
  -> PaneStateWaitOptions
  -> IO PaneStateWaitResult
```

Signature types: [`Server`](/en/haskell/latest/reference/libtmux-server-t-server/), [`WindowSlot`](/en/haskell/latest/reference/libtmux-creation-t-windowslot/), [`PaneRef`](/en/haskell/latest/reference/libtmux-snapshot-t-paneref/), [`PaneState`](/en/haskell/latest/reference/libtmux-server-t-panestate/), [`PaneStateWaitOptions`](/en/haskell/latest/reference/libtmux-server-t-panestatewaitoptions/), [`IO`](https://hackage.haskell.org/package/base-4.22.0.0/docs/Prelude.html#t:IO), [`PaneStateWaitResult`](/en/haskell/latest/reference/libtmux-server-t-panestatewaitresult/).

Observe an exact pane without sending it input. For [`PaneActive`](/en/haskell/latest/reference/libtmux-server-v-paneactive/) the
 link must be current in the session named by the slot. For [`PaneDead`](/en/haskell/latest/reference/libtmux-server-v-panedead/) and
 [`PaneAbsent`](/en/haskell/latest/reference/libtmux-server-v-paneabsent/) the slot's session anchors the observer, and the observation
 covers the whole daemon. Both references must belong to this Server.

Check the state immediately and again after attaching. Control notifications
 wake the waiter, which confirms state in a fresh capture. Bounded rechecks
 cover silent changes such as a retained pane dying or window links swapping.
 This is a level observation and cannot recover a state that has already
 changed back. Attach hooks can run just as with [`withControl`](/en/haskell/latest/reference/libtmux-server-v-withcontrol/).

One monotonic deadline covers attachment, observation, and waiting. Scope
 retirement has its own cleanup budget. Cancellation preserves the incoming
 exception and any retained owners in its context.

## Referenced declarations

- [`LibTmux.Snapshot.PaneRef`](/en/haskell/latest/reference/libtmux-snapshot-t-paneref/) (data type)
- [`LibTmux.Server.PaneState`](/en/haskell/latest/reference/libtmux-server-t-panestate/) (data type)
- [`LibTmux.Server.PaneStateWaitOptions`](/en/haskell/latest/reference/libtmux-server-t-panestatewaitoptions/) (data type)
- [`LibTmux.Server.PaneStateWaitResult`](/en/haskell/latest/reference/libtmux-server-t-panestatewaitresult/) (data type)
- [`LibTmux.Server.Server`](/en/haskell/latest/reference/libtmux-server-t-server/) (data type)
- [`LibTmux.Creation.WindowSlot`](/en/haskell/latest/reference/libtmux-creation-t-windowslot/) (data type)

## tmux command

The tmux commands behind `waitForPaneState`.

- [`attach-session`](/en/tmux/latest/manual/attach-session/) (when the initial pane state does not match)
- [`display-message`](/en/tmux/latest/manual/display-message/)
- [`if-shell`](/en/tmux/latest/manual/if-shell/)
- [`list-clients`](/en/tmux/latest/manual/list-clients/) (when the server has sessions)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_attach_session_entry`](/en/tmux/latest/reference/c-variable-cmd_attach_session_entry/) (attribute)
- [`cmd_attach_session_exec`](/en/tmux/latest/reference/c-function-cmd-attach-session-c-cmd_attach_session_exec/) (function)
- [`cmd_display_message_entry`](/en/tmux/latest/reference/c-variable-cmd_display_message_entry/) (attribute)
- [`cmd_display_message_exec`](/en/tmux/latest/reference/c-function-cmd-display-message-c-cmd_display_message_exec/) (function)
- [`cmd_if_shell_entry`](/en/tmux/latest/reference/c-variable-cmd_if_shell_entry/) (attribute)
- [`cmd_if_shell_exec`](/en/tmux/latest/reference/c-function-cmd-if-shell-c-cmd_if_shell_exec/) (function)
- [`cmd_list_clients_entry`](/en/tmux/latest/reference/c-variable-cmd_list_clients_entry/) (attribute)
- [`cmd_list_clients_exec`](/en/tmux/latest/reference/c-function-cmd-list-clients-c-cmd_list_clients_exec/) (function)

## Guides

Pages that discuss `waitForPaneState`.

- [Observe control notifications](/en/haskell/latest/guides/control/)
- [Implementation status](/en/haskell/latest/guides/status/)
