{"record":{"id":"21b355f8c5dee4ac","repo":"wezterm/wezterm","slug":"to-resolve-my-own-window-id","errorCode":null,"errorMessage":"to resolve my own window_id","messagePattern":"to resolve my own window_id","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wezterm-gui/src/overlay/launcher.rs","lineNumber":95,"sourceCode":"    ) -> Self {\n        let mux = Mux::get();\n\n        let active_workspace = mux.active_workspace();\n\n        let workspaces = if flags.contains(LauncherFlags::WORKSPACES) {\n            mux.iter_workspaces()\n        } else {\n            vec![]\n        };\n\n        let tabs = if flags.contains(LauncherFlags::TABS) {\n            // Ideally we'd resolve the tabs on the fly once we've started the\n            // overlay, but since the overlay runs in a different thread, accessing\n            // the mux list is a bit awkward.  To get the ball rolling we capture\n            // the list of tabs up front and live with a static list.\n            let window = mux\n                .get_window(mux_window_id)\n                .expect(\"to resolve my own window_id\");\n            window\n                .iter_tabs()\n                .enumerate()\n                .map(|(tab_idx, tab)| {\n                    let tab_title = tab.get_title();\n                    let title = if tab_title.is_empty() {\n                        tab.get_active_pane()\n                            .expect(\"tab to have a pane\")\n                            .get_title()\n                    } else {\n                        tab_title\n                    };\n                    LauncherTabEntry {\n                        title,\n                        tab_idx,\n                        pane_count: tab.count_panes(),\n                    }\n                })","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/wezterm/wezterm/blob/08e5e0afc6007567d3d131bc2ec1382423c0d2da/wezterm-gui/src/overlay/launcher.rs#L77-L113","documentation":"wezterm panics with this message when the mux cannot find a window for the window_id that the launcher overlay was created with. In `LauncherOverlay::new` the overlay thread captures the tab list up front by calling `mux.get_window(mux_window_id)`, which returns an Option; the code asserts it must succeed because the id was just obtained from the mux itself. The expect() firing means the mux window registry no longer contains that id (e.g. the window was closed/removed from the mux between obtaining the id and building the overlay) or the id was somehow wrong/foreign.","triggerScenarios":"Calling `mux.get_window(mux_window_id)` inside `LauncherOverlay::new` when the mux_window_id does not exist in the mux: the window was closed concurrently, the id belongs to a different mux instance/domain (e.g. after detaching/re-attaching or across a mux server restart), or a stale id was passed in from another thread.","commonSituations":"Opening the launcher (Ctrl-Shift-L / spawn_command) in a race with window close or mux server shutdown; connecting to a mux domain whose server restarted so window ids were regenerated; programmatic API/script use that caches a window_id and reuses it later after the window is gone.","solutions":["Update wezterm to the latest version; races between window close and launcher open have been fixed over time.","Reproduce deterministically? File a bug with the wezterm GUI logs (WEZTERM_LOG=debug) including the steps that closed the window before opening the launcher.","Avoid reusing cached window ids across mux reconnects: always re-resolve the current window id from the active pane before opening the launcher.","If it occurs during development/embedding, verify the mux_window_id passed to LauncherOverlay::new came from the same live mux instance.","As a stopgap, restart the GUI window/process; the panic is non-recoverable for that overlay thread."],"exampleFix":"// before\nlet window = mux\n    .get_window(mux_window_id)\n    .expect(\"to resolve my own window_id\");\n// after (defensive, mirrors the library's own fix style)\nlet window = mux.get_window(mux_window_id)\n    .with_context(|| format!(\"window {mux_window_id:?} missing from mux when opening launcher\"))?;","handlingStrategy":"try-catch","validationCode":"// Before opening the launcher programmatically, verify the window still exists:\nlet window_exists = mux.get_window(mux_window_id).is_some();\nif !window_exists { /* re-resolve window id or abort */ }","typeGuard":"fn window_is_live(mux: &Mux, window_id: MuxWindowId) -> bool {\n    mux.get_window(window_id).is_some()\n}","tryCatchPattern":"// This is a panic (expect), not a Result; as an embedder, catch_unwind around overlay creation:\nlet result = std::panic::catch_unwind(|| open_launcher_overlay(mux_window_id));\nmatch result {\n    Ok(overlay) => overlay,\n    Err(_) => { /* log and re-resolve the window id, then retry */ }\n}","preventionTips":["Never cache mux_window_id across mux server restarts or domain re-attachments; re-resolve from the active pane.","Keep wezterm updated to pick up race fixes between window close and launcher spawn.","When scripting, check window existence via the mux/CLI before issuing launcher commands.","Enable debug logging during reproduction so window close/creation ordering is visible if it recurs."],"tags":["rust","panic","mux","window-id","wezterm"],"backgroundTag":"mux-window-not-found","analyzedSha":"08e5e0afc6007567d3d131bc2ec1382423c0d2da","analyzedAt":"2026-08-30T22:35:53.268Z","contentChangedAt":"2026-08-30T22:35:53.268Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}