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 <noreply@anthropic.com>
This commit is contained in:
25
wezterm.lua
25
wezterm.lua
@@ -94,7 +94,21 @@ end)
|
|||||||
-- ------------------------------------------------------------
|
-- ------------------------------------------------------------
|
||||||
local pane_start_times = {}
|
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)
|
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()
|
local pane_id = pane:pane_id()
|
||||||
if not pane_start_times[pane_id] then
|
if not pane_start_times[pane_id] then
|
||||||
pane_start_times[pane_id] = os.time()
|
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)
|
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 tab, pane, window = wezterm.mux.spawn_window(cmd or {})
|
||||||
local gui_window = window:gui_window()
|
|
||||||
list_system_fonts() -- 폰트 목록을 미리 캐싱해서, 나중에 폰트 설정 메뉴에서 조회 지연으로 화면이 깜빡이지 않게 함
|
list_system_fonts() -- 폰트 목록을 미리 캐싱해서, 나중에 폰트 설정 메뉴에서 조회 지연으로 화면이 깜빡이지 않게 함
|
||||||
show_main_menu(gui_window, pane)
|
show_main_menu(window:gui_window(), pane)
|
||||||
|
|
||||||
wezterm.time.call_after(2, function()
|
|
||||||
gui_window:perform_action(act.SpawnTab({ DomainName = "du5t" }), pane)
|
|
||||||
end)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- 시작 시 자동으로 워크스페이스/레이아웃을 구성하려면 아래 예시를 참고하세요.
|
-- 시작 시 자동으로 워크스페이스/레이아웃을 구성하려면 아래 예시를 참고하세요.
|
||||||
|
|||||||
Reference in New Issue
Block a user