From 0d0095a49941a727ad8f2ffe6a1d6aa03134a991 Mon Sep 17 00:00:00 2001 From: gm Date: Sat, 18 Jul 2026 02:14:18 +0900 Subject: [PATCH] Drop fixed-delay SSH auto-connect, trigger from update-right-status instead Both the 0.5s and 2s wezterm.time.call_after delays in gui-startup still hit "domain name du5t is invalid" -- guessing a fixed delay for mux domain registration isn't reliable. Moved the auto-connect attempt into update-right-status, which only starts firing once the window is actually up and rendering (well past the registration race), and made it generic: it looks at config.ssh_domains[1] instead of hardcoding "du5t", so it auto-connects to whatever SSH domain happens to be registered, or does nothing if none are configured. Runs exactly once per session via startup_ssh_connect_tried. Co-Authored-By: Claude Sonnet 5 --- wezterm.lua | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/wezterm.lua b/wezterm.lua index 9625262..b0db593 100644 --- a/wezterm.lua +++ b/wezterm.lua @@ -94,7 +94,21 @@ end) -- ------------------------------------------------------------ local pane_start_times = {} +-- gui-startup 시점엔 SSH 도메인이 아직 mux에 등록되기 전이라 바로 접속을 시도하면 항상 +-- "domain name is invalid" 에러가 난다 (고정 지연 0.5초/2초 모두 시도했지만 재현됨). +-- 대신 창이 실제로 정상 작동 중일 때만 도는 update-right-status 훅에서 딱 한 번, +-- 등록된 SSH 도메인이 있으면 그걸로 자동 접속한다 (특정 이름 하드코딩 없음) +local startup_ssh_connect_tried = false + wezterm.on("update-right-status", function(window, pane) + if not startup_ssh_connect_tried then + startup_ssh_connect_tried = true + local first_domain = config.ssh_domains and config.ssh_domains[1] + if first_domain then + window:perform_action(act.SpawnTab({ DomainName = first_domain.name }), pane) + end + end + local pane_id = pane:pane_id() if not pane_start_times[pane_id] then pane_start_times[pane_id] = os.time() @@ -750,18 +764,11 @@ end) -- 시작 시 첫 화면으로 메인 메뉴를 띄워 설정과 연결 메뉴에 바로 접근합니다. +-- SSH 자동 접속은 update-right-status 훅에서 처리 (위 pane_start_times 근처 참고) wezterm.on("gui-startup", function(cmd) - -- gui-startup 시점엔 아직 SSH 도메인이 mux에 등록되기 전이라, 스폰 시 domain을 바로 - -- "du5t"로 지정하면 "domain name is invalid" 에러가 난다. 일단 로컬 셸로 창을 띄운 뒤 - -- 잠깐 기다렸다가 du5t 탭을 새로 열어 그 탭을 활성화하는 방식으로 우회한다 local tab, pane, window = wezterm.mux.spawn_window(cmd or {}) - local gui_window = window:gui_window() list_system_fonts() -- 폰트 목록을 미리 캐싱해서, 나중에 폰트 설정 메뉴에서 조회 지연으로 화면이 깜빡이지 않게 함 - show_main_menu(gui_window, pane) - - wezterm.time.call_after(2, function() - gui_window:perform_action(act.SpawnTab({ DomainName = "du5t" }), pane) - end) + show_main_menu(window:gui_window(), pane) end) -- 시작 시 자동으로 워크스페이스/레이아웃을 구성하려면 아래 예시를 참고하세요.