LGUG2Z/komorebi · info

a container must have at least one window

Error message

a container must have at least one window

What it means

remove_window_from_container detaches the focused window into its own container. A container must retain at least one window, so when the focused container currently holds exactly one window the removal is rejected — otherwise komorebi's layout invariant (non-empty containers) would be violated.

Source

Thrown at komorebi/src/window_manager.rs:3001

        tracing::info!("promoting focus");

        let target_idx = match &workspace.layout {
            Layout::Default(_) => 0,
            Layout::Custom(custom) => custom.first_container_idx(custom.primary_idx().unwrap_or(0)),
        };

        workspace.focus_container(target_idx);
        self.update_focused_workspace(self.mouse_follows_focus, true)
    }

    #[tracing::instrument(skip(self))]
    pub fn remove_window_from_container(&mut self) -> eyre::Result<()> {
        self.handle_unmanaged_window_behaviour()?;

        tracing::info!("removing window");

        if self.focused_container()?.windows().len() == 1 {
            bail!("a container must have at least one window");
        }

        let workspace = self.focused_workspace_mut()?;

        workspace.new_container_for_focused_window()?;
        self.update_focused_workspace(self.mouse_follows_focus, false)
    }

    #[tracing::instrument(skip(self))]
    pub fn toggle_tiling(&mut self) -> eyre::Result<()> {
        let workspace = self.focused_workspace_mut()?;
        workspace.tile = !workspace.tile;
        self.update_focused_workspace(false, false)
    }

    #[tracing::instrument(skip(self))]
    pub fn toggle_float(&mut self, force_float: bool) -> eyre::Result<()> {
        let hwnd = WindowsApi::foreground_window()?;

View on GitHub (pinned to e0709f02bf)

Solutions

  1. Only call unstack when the container has 2+ windows (check state first)
  2. Use a different command if the goal is closing/removing the window from the layout entirely
  3. Swallow the error in batch unstack loops and continue with remaining containers
  4. Restack a second window before attempting to remove one if the container must stay intact

Example fix

// before
komorebic unstack // fails on single-window container
// after
if [ "$(komorebic query focused-container-length 2>/dev/null)" -gt 1 ]; then komorebic unstack; fi
Defensive patterns

Strategy: validation

Validate before calling

if query_focused_container_window_count() > 1 {
    komorebic unstack
}

Prevention

When it happens

Trigger: Calling remove_window_from_container (komorebic unstack / remove keybinds) when focused_container().windows().len() == 1, i.e. unstacking a window that has no stack partners.

Common situations: Unstack hotkey pressed on a normal single-window tiled container; scripts that unstack all containers blindly after stacking operations.

Related errors


AI-assisted analysis of LGUG2Z/komorebi@e0709f02bf (2026-09-06). Data as JSON: /api/errors/78ba23a8a9cf9ff9. Report an issue: GitHub.