patchcord 0.5.60 → 0.5.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchcord",
3
- "version": "0.5.60",
3
+ "version": "0.5.61",
4
4
  "description": "Cross-machine agent messaging for Claude Code and Codex",
5
5
  "author": "ppravdin",
6
6
  "license": "MIT",
@@ -393,6 +393,43 @@ function runOnce(ticket, baseUrl, token, refreshTicket) {
393
393
  } catch {
394
394
  return;
395
395
  }
396
+
397
+ // Surface channel-state failures so silent server-side channel
398
+ // termination becomes visible. Previously we discarded every
399
+ // non-postgres_changes frame, which masked phx_join rejections,
400
+ // channel_error system messages, and post-refresh access_token
401
+ // rejections — exactly the cases where the WS stays "open" but
402
+ // realtime delivery is dead. Force a reconnect on any of those.
403
+ if (frame.event === "phx_reply") {
404
+ const status = frame.payload?.status;
405
+ if (status === "error") {
406
+ const reason = frame.payload?.response?.reason || frame.payload?.response || "unknown";
407
+ logErr(`subscribe: phx_reply error on topic=${frame.topic} ref=${frame.ref}: ${JSON.stringify(reason)}`);
408
+ done(new Error(`phx_reply error: ${JSON.stringify(reason)}`));
409
+ return;
410
+ }
411
+ return;
412
+ }
413
+ if (frame.event === "system") {
414
+ const status = frame.payload?.status;
415
+ const message = frame.payload?.message || frame.payload?.extension || "";
416
+ if (status === "error" || status === "channel_error") {
417
+ logErr(`subscribe: system error on topic=${frame.topic}: ${message}`);
418
+ done(new Error(`system error: ${message}`));
419
+ return;
420
+ }
421
+ // Successful subscribe ack — log once for confirmation, then quiet.
422
+ if (status === "ok" && message) {
423
+ logErr(`subscribe: system ok on ${frame.topic}: ${message}`);
424
+ }
425
+ return;
426
+ }
427
+ if (frame.event === "phx_error" || frame.event === "phx_close") {
428
+ logErr(`subscribe: ${frame.event} on topic=${frame.topic}: ${JSON.stringify(frame.payload || {})}`);
429
+ done(new Error(`${frame.event} on ${frame.topic}`));
430
+ return;
431
+ }
432
+
396
433
  if (frame.event !== "postgres_changes") return;
397
434
  const data = frame.payload?.data;
398
435
  if (!data || data.type !== "INSERT") return;