()
| 62 | } |
| 63 | |
| 64 | function computeConnectedHighestApprovalMode() { |
| 65 | if (!state.wss) return 'default'; |
| 66 | let best = 'default'; |
| 67 | let bestScore = APPROVAL_MODE_ORDER.default; |
| 68 | for (const ws of state.wss.clients) { |
| 69 | if (!isAuthenticatedClient(ws)) continue; |
| 70 | const mode = normalizeApprovalMode(ws._approvalMode); |
| 71 | const score = APPROVAL_MODE_ORDER[mode]; |
| 72 | if (score > bestScore) { |
| 73 | best = mode; |
| 74 | bestScore = score; |
| 75 | } |
| 76 | } |
| 77 | return best; |
| 78 | } |
| 79 | |
| 80 | function sendWs(ws, msg, context = '') { |
| 81 | if (!ws || ws.readyState !== WebSocket.OPEN) return false; |
no test coverage detected