jim800121chen c649a81d9f fix(local-tool): Windows 首次啟動再修 — waitHealthy pause + shutdown modal hide
續 a209470 修 Windows 乾淨環境啟動問題。使用者回報:
- 紅 banner「伺服器無法啟動 / 啟動時間超過 60 秒」— 即 pipeline total-timeout
- 但上方狀態列顯示「執行中 :3721 PID 8568 uptime 00:00:44」— server 實際活著
- Settings popup 上疊 shutdown-modal「正在停止伺服器…」永遠卡住

三個獨立問題:

1. Stage 3 waitHealthy 在 Windows 首次啟動時,Defender real-time scan
   會延遲 30-60 秒才讓 visiona-local-server.exe 真正 bind port。原本
   30 秒 timeout 可能 stage-failure,且這段等候時間計入 pipeline 60 秒
   total budget。修法:
   (a) healthCheckTimeout 30 秒 → 60 秒
   (b) startServerV2 的 waitHealthy call 在冷啟動時(IsInColdStart)
       包進 Pause/Resume hard timeout — 和 Stage 2 Python bootstrap 同理,
       首次 bootstrap 的 Windows Defender 掃描不該算進日常啟動預算。
       Restart(pipeline 已 ready)維持嚴格計時,不 pause。

2. stopGraceful 只 emit "shutdown:modal-show" 沒有對稱的 hide event,
   前端 popup 顯示後無法關閉(只能等應用重開)。修法:
   (a) stopGraceful 用 defer emit "shutdown:modal-hide"(若曾 show)
   (b) 前端 app.js 加對應 EventsOn listener 把 hidden attribute 設回

3. 配套:cwd bash working dir 會在 session 內持久(system prompt 明說
   "working directory persists between commands"),但 env vars 不持久
   — 非本次 commit 相關,僅自己的 mental note。

驗證:
- visiona-local 套件 go build / vet / test -race 全綠
- macOS dmg 重 build 163MB OK

給 Windows 驗證用的 log 位置:
  %APPDATA%\visiona-local\logs\server.stdout.log     — server 端 log
  %APPDATA%\visiona-local\logs\server.stderr.log     — server 端 panic / 崩潰
  %APPDATA%\visiona-local\logs\wails.log             — Wails app (appLog) 訊息

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 21:59:20 +08:00
..