{"record":{"id":"c19257fda8d16f71","repo":"kovidgoyal/kitty","slug":"the-matched-tab-is-not-currently-visible-screensh","errorCode":null,"errorMessage":"The matched tab is not currently visible, screenshots can only be taken of visible tabs","messagePattern":"The matched tab is not currently visible, screenshots can only be taken of visible tabs","errorType":"exception","errorClass":"RemoteControlErrorWithoutTraceback","httpStatus":null,"severity":"error","filePath":"kitty/rc/screenshot.py","lineNumber":90,"sourceCode":"        if match:\n            windows = list(boss.match_windows(match, window))\n            if not windows:\n                raise MatchError(match)\n            w = windows[0]\n            tab = w.tabref()\n            tm = tab.tab_manager_ref() if tab is not None else None\n            if tab is None or tm is None or tm.active_tab is not tab or not w.is_visible_in_layout:\n                raise RemoteControlErrorWithoutTraceback('The matched window is not currently visible, screenshots can only be taken of visible windows')\n            os_window_id = w.os_window_id\n            target_window_id = w.id\n        elif match_tab:\n            tabs = list(boss.match_tabs(match_tab))\n            if not tabs:\n                raise MatchError(match_tab, 'tabs')\n            tab = tabs[0]\n            tm = tab.tab_manager_ref()\n            if tm is None or tm.active_tab is not tab:\n                raise RemoteControlErrorWithoutTraceback('The matched tab is not currently visible, screenshots can only be taken of visible tabs')\n            os_window_id = tab.os_window_id\n        else:\n            atm = boss.active_tab_manager\n            if atm is None:\n                raise RemoteControlErrorWithoutTraceback('There is no active OS window to screenshot')\n            os_window_id = atm.os_window_id\n            include_tab_bar = True\n\n        output_path = payload_get('output_path') or ''\n        responder = self.create_async_responder(payload_get, window)\n\n        def callback(cb_os_window_id: int, cb_window_id: int, pixels: bytes, width: int, height: int) -> None:\n            if not pixels:\n                responder.send_error('Failed to take screenshot, the OS window may have been closed')\n                return\n            try:\n                png_data = png_from_32bit_rgba_data(pixels, width, height, True)\n                if output_path:","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/rc/screenshot.py#L72-L108","documentation":"Raised by the screenshot command when a tab match succeeds but the matched tab is not the active tab in its OS window (or its tab manager is gone). Screenshot capture works by compositing what is on screen, so background tabs cannot be captured.","triggerScenarios":"kitten @ screenshot --match-tab <expr> where the matched tab is a background tab in its OS window, or its tab manager has been destroyed.","commonSituations":"Automation screenshotting tabs by title/id while another tab is focused; races where the user switches tabs between listing and capturing; stale tab ids after tab rearrangement.","solutions":["Activate the tab first: kitten @ focus-tab --match <expr>, then screenshot","Capture the active tab / OS window instead of matching a background tab","Verify with kitty @ ls that the matched tab is its parent's active_tab before capturing"],"exampleFix":"# before\nkitten @ screenshot --match-tab title:logs\n# after\nkitten @ focus-tab --match title:logs && kitten @ screenshot --match-tab title:logs","handlingStrategy":"validation","validationCode":"import json, subprocess\nls = json.loads(subprocess.check_output(['kitten','@','ls']))\nentry = find_tab(ls, match_tab)\nif not entry['tab'].get('is_active'):\n    subprocess.run(['kitten','@','focus-tab','--match', match_tab])","typeGuard":"def is_active_tab(tab: dict) -> bool:\n    return bool(tab.get('is_active', tab.get('is_focused', False)))","tryCatchPattern":"try:\n    capture_tab(match_tab)\nexcept RCError as e:\n    if 'not currently visible' in str(e):\n        subprocess.run(['kitten','@','focus-tab','--match', match_tab]); capture_tab(match_tab)","preventionTips":["Activate the tab before screenshotting it","Screenshot the active tab or OS window in automated flows","Re-validate tab ids right before capture"],"tags":["kitty","remote-control","screenshot","tab-matching","visibility"],"backgroundTag":"invalid-window-target","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}