zellij-org/zellij · error · anyhow::Error
Failed to find pane {pane_id:?}
Error message
Failed to find pane {pane_id:?} What it means
Returned by the mouse handler's StartSelection action when tab.get_pane_with_id_mut cannot find the pane id attached to the mouse action. The mouse click that should start a text selection cannot locate its target pane, so the selection gesture is aborted with an error.
Source
Thrown at zellij-server/src/tab/mouse_handler.rs:784
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 98a0837077)
Solutions
- Retry the selection gesture - if the pane list changed, the next click resolves fresh state
- Avoid clicking into a pane that is in the middle of closing/resizing; let the layout settle
- If reproducible on stable layouts, capture `zellij --debug` logs and the exact click coordinates; report as a pane-id staleness bug
- Plugin authors: recompute pane positions after receiving layout-change events instead of reusing cached ids
Example fix
// before
let pane = tab
.get_pane_with_id_mut(pane_id)
.ok_or_else(|| anyhow!("Failed to find pane {pane_id:?}"))?;
// after: no-op gracefully when the pane vanished mid-gesture
let Some(pane) = tab.get_pane_with_id_mut(pane_id) else {
log::debug!("StartSelection: pane {pane_id:?} no longer exists, ignoring");
return Ok(MouseEffect::default());
}; Defensive patterns
Strategy: try-catch
Validate before calling
// before acting on a mouse action carrying a pane id:
if tab.get_pane_with_id_mut(pane_id).is_none() {
return Ok(MouseEffect::default());
} Type guard
fn selection_target_exists(tab: &Tab, pane_id: PaneId) -> bool {
tab.get_pane_with_id(pane_id).is_some()
} Try / catch
// in MouseHandler dispatch: degrade selection failures to no-ops
match MouseHandler::handle_mouse_action(action, tab, position, client_id) {
Ok(effect) => effect,
Err(e) => {
log::debug!("mouse action {action:?} skipped: {e:#}");
MouseEffect::default()
},
} Prevention
- Treat pane ids embedded in mouse state as ephemeral: valid only until the next layout change
- Discard in-flight drag/selection state when a pane-close or layout event arrives
- For tests injecting mouse events, re-derive pane positions after every layout mutation
When it happens
Trigger: A mouse press that begins a selection arrives with a pane id that no longer exists in the tab - typically because the pane closed while a click/drag was in flight, or the action was computed from stale pane geometry after a layout change.
Common situations: Click-drag text selection racing a pane exit or resize; selecting text in a pane closed by a background process; mouse events processed after a layout swap (swap-layout) invalidated pane ids; remote/latency-induced reordering of close vs. click events.
Related errors
- Could not find editor pane to replace
- failed to find pane with id {pane_id:?}
- Failed to find active pane
- Failed to find pane {active_pane_id:?}
- Failed to find pane at position
AI-assisted analysis of zellij-org/zellij@98a0837077 (2026-08-16).
Data as JSON: /api/errors/f1f7d7c410f1c940.
Report an issue: GitHub.