kovidgoyal/kitty · error · RemoteControlErrorWithoutTraceback

The OS Window {os_window_id} does not exist

Error message

The OS Window {os_window_id} does not exist

What it means

RemoteControlErrorWithoutTraceback from @ resize-os-window when the OS window id being resized no longer maps to a live OS window — get_os_window_size() returns None for that id. The id came from the matched windows themselves, so this indicates the window was destroyed mid-request or the id is stale/invalid.

Source

Thrown at kitty/rc/resize_os_window.py:121

            'os_panel': args,
        }

    def response_from_kitty(self, boss: Boss, window: Window | None, payload_get: PayloadGetType) -> ResponseType:
        from kitty.fast_data_types import (
            get_os_window_size,
            layer_shell_config_for_os_window,
            set_layer_shell_config,
            toggle_fullscreen,
            toggle_os_window_visibility,
        )

        windows = self.windows_for_match_payload(boss, window, payload_get)
        if windows:
            ac = payload_get('action')
            for os_window_id in {w.os_window_id for w in windows if w}:
                metrics = get_os_window_size(os_window_id)
                if metrics is None:
                    raise RemoteControlErrorWithoutTraceback(f'The OS Window {os_window_id} does not exist')
                panels = payload_get('os_panel')
                is_panel = metrics['is_layer_shell']
                if ac == 'os-panel':
                    if not is_panel:
                        raise RemoteControlErrorWithoutTraceback(
                            f'The OS Window {os_window_id} is not a panel you should not use the --action=resize option to resize it'
                        )
                    if not panels:
                        raise RemoteControlErrorWithoutTraceback('Must specify at least one panel setting')
                    if payload_get('incremental'):
                        existing = layer_shell_config_for_os_window(os_window_id)
                        if existing is None:
                            raise RemoteControlErrorWithoutTraceback(f'The OS Window {os_window_id} has no panel configuration')
                        from kittens.panel.main import incrementally_update_layer_shell_config

                        try:
                            lsc = incrementally_update_layer_shell_config(existing, panels)
                        except Exception as e:

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Re-query live windows immediately before resizing: kitten @ ls, then use the fresh os_window_id
  2. Narrow --match so it targets exactly one window/tab and is less likely to hit a destroyed one
  3. Retry once if the automation races with window lifecycle changes

Example fix

# before
os_window_id=$(kitten @ ls | jq -r '.[0].os_window_id')  # possibly stale
sleep 60
kitten @ resize-os-window --self --width 80

# after
kitten @ resize-os-window --match 'state:focused' --width 80  # resolve at call time
Defensive patterns

Strategy: retry

Validate before calling

# verify the window still exists right before resizing
import json, subprocess
live = json.loads(subprocess.check_output(['kitten', '@', 'ls']))
ids = {str(w.get('os_window_id')) for w in live if isinstance(w, dict) and w.get('os_window_id') is not None}
if str(os_window_id) in ids:
    subprocess.run(['kitten', '@', 'resize-os-window', '--os-window-id', str(os_window_id), '--width', '80'])

Type guard

def is_live_os_window(os_window_id: int, live_ids: set[int]) -> bool:
    return os_window_id in live_ids

Try / catch

for attempt in range(2):
    r = subprocess.run(argv, capture_output=True, text=True)
    if 'does not exist' not in r.stderr:
        break
    os_window_id = refetch_os_window_id()  # refresh handle and rebuild argv
else:
    log.error('os window vanished; giving up')

Prevention

When it happens

Trigger: Calling 'kitten @ resize-os-window' with --match criteria whose window's OS window closes between match and resize, or passing a stale os_window_id from a previous 'kitten @ ls' in a script.

Common situations: Race conditions in automation scripts (window closed while the command is in flight), reusing cached window ids after kitty windows were closed/rearranged, or i3/sway layer-shell panel edge cases.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/12c57652ba10649f. Report an issue: GitHub.