zellij-org/zellij · error · anyhow::Error

Failed to find pane

Error message

Failed to find pane {pane_id:?}

What it means

Thrown in the MouseAction::StartSelection handler (zellij-server/src/tab/mouse_handler.rs) when tab.get_pane_with_id_mut(pane_id) returns None. Mouse actions are computed during mouse-event processing and executed afterwards, so this fires when the pane a selection was started in no longer exists by the time the action runs.

Solutions

  1. If occasional and correlated with a pane exiting mid-drag, it is a benign race — the selection is simply dropped; retry in a live pane.
  2. If it persists, check whether the pane id in the message belongs to a different tab (cross-tab mouse routing) and report the exact mouse sequence upstream.
  3. Update zellij for mouse-action lifetime fixes.
Defensive patterns

Strategy: try-catch

Validate before calling

// check the pane still exists before starting a selection
if tab.get_pane_with_id_mut(pane_id).is_some() {
    // proceed with MouseAction::StartSelection
} else {
    return Ok(MouseEffect::default()); // pane gone: drop the action
}

Try / catch

match result {
    Ok(effect) => effect,
    Err(e) if e.to_string().contains("Failed to find pane") => {
        log::debug!("mouse selection dropped: pane {pane_id:?} gone");
        MouseEffect::default()
    },
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Mouse drag/click selects in a pane that exits between event parsing and action execution: a command pane finishing, a pane closed by another client in the same session, or replayed/queued mouse events referencing an already-closed pane id.

Common situations: Dragging a selection right as the pane's shell command exits; multi-client sessions where one user closes a pane while another is selecting in it.

Related errors


AI-assisted analysis of zellij-org/zellij@bf8d23a4f7 (2026-08-19). Data as JSON: /api/errors/f1f7d7c410f1c940. Report an issue: GitHub.

Appendix: source

Thrown at zellij-server/src/tab/mouse_handler.rs:796

                pane_id: _,
                position,
            } => Self::execute_focus_pane(tab, position, client_id),
            MouseAction::FocusPaneAndClickThrough {
                pane_id: _,
                position,
                event: click_event,
            } => Self::execute_focus_pane_and_click_through(tab, position, click_event, client_id),
            MouseAction::ShowFloatingPanesAndFocus { pane_id } => {
                tab.show_floating_panes();
                tab.floating_panes.focus_pane(pane_id, client_id);
                Ok(MouseEffect::state_changed())
            },
            MouseAction::StartSelection { pane_id, position } => {
                let osc133_command_selection = tab.osc133_command_selection;
                let word_separators = tab.word_separators.clone();
                let pane = tab
                    .get_pane_with_id_mut(pane_id)
                    .ok_or_else(|| anyhow!("Failed to find pane {pane_id:?}"))?;
                let relative_position = pane.relative_position(&position);

                let mut leave_clipboard_message = false;
                pane.set_selection_options(osc133_command_selection, &word_separators);
                pane.start_selection(&relative_position, client_id);
                if pane.get_selected_text(client_id).is_some() {
                    leave_clipboard_message = true;
                }
                if pane.supports_mouse_selection() {
                    tab.selecting_with_mouse_in_pane = Some(pane_id);
                }
                if leave_clipboard_message {
                    Ok(MouseEffect::state_changed_and_leave_clipboard_message())
                } else {
                    Ok(MouseEffect::default())
                }
            },
            MouseAction::UpdateSelection { position } => {

View on GitHub (pinned to bf8d23a4f7)