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

Tab index {:?} not found

Error message

Tab index {:?} not found

What it means

After switching a client to a new tab, the screen re-fetches the previously active tab by index to hide it. get_indexed_tab_mut(current_tab_index) returned None — that index no longer maps to a live Tab — so zellij logs this non-fatal error and continues with the switch.

Source

Thrown at zellij-server/src/screen.rs:2020

                        .with_context(err_context)?;
                        match (
                            should_change_pane_focus,
                            self.get_indexed_tab_mut(new_tab_index),
                        ) {
                            (Some(direction), Some(new_tab)) => {
                                new_tab.focus_pane_on_edge(direction, client_id);
                            },
                            _ => {},
                        }
                        self.update_client_tab_focus(client_id, new_tab_index);
                    }

                    if let Some(current_tab) = self.get_indexed_tab_mut(current_tab_index) {
                        if current_tab.has_no_connected_clients() {
                            current_tab.visible(false).with_context(err_context)?;
                        }
                    } else {
                        Err::<(), _>(anyhow!("Tab index {:?} not found", current_tab_index))
                            .with_context(err_context)
                            .non_fatal();
                    }

                    // Clear tab bell notification for the newly active tab
                    if let Some(new_tab) = self.tabs.get_mut(&new_tab_index) {
                        let tab_id = new_tab.id;
                        new_tab.clear_tab_bell_notification();
                        let _ = self
                            .bus
                            .senders
                            .send_to_background_jobs(BackgroundJob::StopFlashTabBell(tab_id));
                    }

                    self.recompute_tab_size(current_tab_index)
                        .with_context(err_context)?;
                    self.recompute_tab_size(new_tab_index)
                        .with_context(err_context)?;

View on GitHub (pinned to 98a0837077)

Solutions

  1. No action required — non-fatal; the visible effect (old tab not hidden) self-corrects on the next render
  2. Avoid firing switch-tab and close-tab for the same tab in one action batch
  3. If it recurs constantly, report upstream with a reproduction — it indicates a tab-index desync
Defensive patterns

Strategy: fallback

Type guard

fn tab_exists(tabs: &BTreeMap<usize, Tab>, index: usize) -> bool {
    tabs.contains_key(&index)
}

Try / catch

if let Some(current_tab) = self.get_indexed_tab_mut(current_tab_index) {
    if current_tab.has_no_connected_clients() { current_tab.visible(false).with_context(err_context)?; }
} else {
    Err::<(), _>(anyhow!("Tab index {:?} not found", current_tab_index)).with_context(err_context).non_fatal();
}

Prevention

When it happens

Trigger: The old tab was closed concurrently (by another client, a plugin, or a command) between recording current_tab_index and the post-switch bookkeeping; or tab indices were renumbered by an insert/close in the same instruction batch.

Common situations: Fast tab switching combined with tab-close keybindings; multiple clients manipulating tabs simultaneously; plugins issuing switch-tab and close-tab actions in quick succession.

Related errors


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