fix: enhance second instance command handling and maintain backward compatibility

This commit is contained in:
jahruz67
2026-05-20 14:58:59 -07:00
parent e8745f926c
commit 1987f413e4
+12 -13
View File
@@ -91,22 +91,21 @@ func runSecondInstanceListener() {
defer conn.Close() defer conn.Close()
buf := make([]byte, 1) buf := make([]byte, 1)
n, _ := conn.Read(buf) n, _ := conn.Read(buf)
cmd := instanceCmdShow
if n == 1 { if n == 1 {
select { cmd = buf[0]
case secondInstanceCommand <- buf[0]: }
default: // Backwards-compatible: any connection with no payload = show window.
} select {
} else { case secondInstanceCommand <- cmd:
// Backwards-compatible: any connection with no payload = show window. default:
select {
case secondInstanceCommand <- instanceCmdShow:
default:
}
} }
_, _ = io.Copy(io.Discard, conn) _, _ = io.Copy(io.Discard, conn)
select { if cmd == instanceCmdShow {
case secondInstanceWake <- struct{}{}: select {
default: case secondInstanceWake <- struct{}{}:
default:
}
} }
}(c) }(c)
} }