{"record":{"id":"12c57652ba10649f","repo":"kovidgoyal/kitty","slug":"the-os-window-os-window-id-does-not-exist","errorCode":null,"errorMessage":"The OS Window {os_window_id} does not exist","messagePattern":"The OS Window (.+?) does not exist","errorType":"exception","errorClass":"RemoteControlErrorWithoutTraceback","httpStatus":null,"severity":"error","filePath":"kitty/rc/resize_os_window.py","lineNumber":121,"sourceCode":"            'os_panel': args,\n        }\n\n    def response_from_kitty(self, boss: Boss, window: Window | None, payload_get: PayloadGetType) -> ResponseType:\n        from kitty.fast_data_types import (\n            get_os_window_size,\n            layer_shell_config_for_os_window,\n            set_layer_shell_config,\n            toggle_fullscreen,\n            toggle_os_window_visibility,\n        )\n\n        windows = self.windows_for_match_payload(boss, window, payload_get)\n        if windows:\n            ac = payload_get('action')\n            for os_window_id in {w.os_window_id for w in windows if w}:\n                metrics = get_os_window_size(os_window_id)\n                if metrics is None:\n                    raise RemoteControlErrorWithoutTraceback(f'The OS Window {os_window_id} does not exist')\n                panels = payload_get('os_panel')\n                is_panel = metrics['is_layer_shell']\n                if ac == 'os-panel':\n                    if not is_panel:\n                        raise RemoteControlErrorWithoutTraceback(\n                            f'The OS Window {os_window_id} is not a panel you should not use the --action=resize option to resize it'\n                        )\n                    if not panels:\n                        raise RemoteControlErrorWithoutTraceback('Must specify at least one panel setting')\n                    if payload_get('incremental'):\n                        existing = layer_shell_config_for_os_window(os_window_id)\n                        if existing is None:\n                            raise RemoteControlErrorWithoutTraceback(f'The OS Window {os_window_id} has no panel configuration')\n                        from kittens.panel.main import incrementally_update_layer_shell_config\n\n                        try:\n                            lsc = incrementally_update_layer_shell_config(existing, panels)\n                        except Exception as e:","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/rc/resize_os_window.py#L103-L139","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-query live windows immediately before resizing: kitten @ ls, then use the fresh os_window_id","Narrow --match so it targets exactly one window/tab and is less likely to hit a destroyed one","Retry once if the automation races with window lifecycle changes"],"exampleFix":"# before\nos_window_id=$(kitten @ ls | jq -r '.[0].os_window_id')  # possibly stale\nsleep 60\nkitten @ resize-os-window --self --width 80\n\n# after\nkitten @ resize-os-window --match 'state:focused' --width 80  # resolve at call time","handlingStrategy":"retry","validationCode":"# verify the window still exists right before resizing\nimport json, subprocess\nlive = json.loads(subprocess.check_output(['kitten', '@', 'ls']))\nids = {str(w.get('os_window_id')) for w in live if isinstance(w, dict) and w.get('os_window_id') is not None}\nif str(os_window_id) in ids:\n    subprocess.run(['kitten', '@', 'resize-os-window', '--os-window-id', str(os_window_id), '--width', '80'])","typeGuard":"def is_live_os_window(os_window_id: int, live_ids: set[int]) -> bool:\n    return os_window_id in live_ids","tryCatchPattern":"for attempt in range(2):\n    r = subprocess.run(argv, capture_output=True, text=True)\n    if 'does not exist' not in r.stderr:\n        break\n    os_window_id = refetch_os_window_id()  # refresh handle and rebuild argv\nelse:\n    log.error('os window vanished; giving up')","preventionTips":["Never cache os_window_id across sleeps or long jobs; resolve at call time via --match or a fresh 'kitten @ ls'","Match on stable criteria (title, env) rather than numeric ids in automation"],"tags":["kitty","remote-control","os-window","stale-reference"],"backgroundTag":"stale-window-handle","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}