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

ClearScreenByPaneId missing pane_id

Error message

ClearScreenByPaneId missing pane_id

What it means

ClearScreenByPaneId clears the screen of one specific pane. Its protobuf message ClearScreenByPaneIdAction has one optional pane_id field which the internal Action requires. If the message arrives with pane_id = None, conversion fails with 'ClearScreenByPaneId missing pane_id' and the clear never runs.

Source

Thrown at zellij-utils/src/ipc/protobuf_conversion.rs:3014

                        .pane_id
                        .ok_or_else(|| anyhow!("MovePaneByPaneId missing pane_id"))?
                        .try_into()?,
                    direction,
                })
            },
            ActionType::MovePaneBackwardsByPaneId(a) => {
                Ok(crate::input::actions::Action::MovePaneBackwardsByPaneId {
                    pane_id: a
                        .pane_id
                        .ok_or_else(|| anyhow!("MovePaneBackwardsByPaneId missing pane_id"))?
                        .try_into()?,
                })
            },
            ActionType::ClearScreenByPaneId(a) => {
                Ok(crate::input::actions::Action::ClearScreenByPaneId {
                    pane_id: a
                        .pane_id
                        .ok_or_else(|| anyhow!("ClearScreenByPaneId missing pane_id"))?
                        .try_into()?,
                })
            },
            ActionType::EditScrollbackByPaneId(a) => {
                Ok(crate::input::actions::Action::EditScrollbackByPaneId {
                    pane_id: a
                        .pane_id
                        .ok_or_else(|| anyhow!("EditScrollbackByPaneId missing pane_id"))?
                        .try_into()?,
                    ansi: a.ansi,
                })
            },
            ActionType::ToggleFullscreenByPaneId(a) => Ok(
                crate::input::actions::Action::ToggleFocusFullscreenByPaneId {
                    pane_id: a
                        .pane_id
                        .ok_or_else(|| anyhow!("ToggleFullscreenByPaneId missing pane_id"))?
                        .try_into()?,

View on GitHub (pinned to 98a0837077)

Solutions

  1. Set pane_id: Some(PaneId { pane_type: Some(PaneType::Terminal(id)) }) before sending.
  2. Use the plain Clear action for the focused pane.
  3. Keep both IPC ends on the same zellij version.
  4. Validate the assembled message with a shared helper before dispatch.

Example fix

// before
let action = ActionType::ClearScreenByPaneId(
    ClearScreenByPaneIdAction { pane_id: None },
); // -> "ClearScreenByPaneId missing pane_id"

// after
let action = ActionType::ClearScreenByPaneId(
    ClearScreenByPaneIdAction {
        pane_id: Some(PaneId { pane_type: Some(PaneType::Terminal(1)) }),
    },
);
Defensive patterns

Strategy: validation

Validate before calling

fn is_sendable(a: &ClearScreenByPaneIdAction) -> bool {
    a.pane_id
        .as_ref()
        .and_then(|p| p.pane_type.as_ref())
        .is_some()
}

Type guard

fn has_valid_pane_id(a: &ClearScreenByPaneIdAction) -> bool {
    matches!(
        a.pane_id.as_ref().and_then(|p| p.pane_type.as_ref()),
        Some(pane_id::PaneType::Terminal(_)) | Some(pane_id::PaneType::Plugin(_))
    )
}

Try / catch

match Action::try_from(proto_action) {
    Ok(action) => dispatch(action),
    Err(e) if e.to_string().contains("ClearScreenByPaneId missing pane_id") => {
        log::warn!("clear action without pane target: {e}");
    },
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Sending ActionType::ClearScreenByPaneId with ClearScreenByPaneIdAction.pane_id unset (None).

Common situations: Plugins sending per-pane clear commands; hand-built action messages; client/server protobuf version mismatch; intending the focused-pane Clear variant.

Related errors


AI-assisted analysis of zellij-org/zellij@98a0837077 (2026-08-16). Data as JSON: /api/errors/36a6aa3fe05483d2. Report an issue: GitHub.