comfyui-mcp 0.52.58 → 0.52.59

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.
@@ -1303,6 +1303,8 @@ const RECONNECT_WAIT_MAX_MS = 60_000;
1303
1303
  * healthy (panel#654): `panel_graph_outline` reported Connected: none and only a
1304
1304
  * hard refresh restored the tab. 35s covers those recoveries; the 60s ceiling stays. */
1305
1305
  const RECONNECT_WAIT_DEFAULT_S = 35;
1306
+ /** Fresh original-tab hello must persist this long before graph tools are ready (#2067). */
1307
+ const POST_RESTART_RECONNECT_STABLE_MS = 2000;
1306
1308
  function reconnectWaitTiming() {
1307
1309
  if (reconnectWaitTimingOverride)
1308
1310
  return reconnectWaitTimingOverride;
@@ -8770,6 +8772,11 @@ export function makePanelToolCtx(bridge, tabId, workflowTargets, onRunTicketOpen
8770
8772
  // fresh hello can keep the same tab/socket id or arrive under a new one; in the
8771
8773
  // latter case only rebind after the old target is gone, preserving strict
8772
8774
  // multi-tab routing and never guessing away from a still-live pre-restart tab.
8775
+ //
8776
+ // #2067 — the first newer generation is not durable. A ComfyUI restart can
8777
+ // hello, then drop the socket a moment later; returning true there reports
8778
+ // graph_tools_ready while the next graph call sees Connected: none. The same
8779
+ // identity must still be present after a short stability window.
8773
8780
  const awaitPostRestartReachable = async (before, budgetMs) => {
8774
8781
  // The actual UiBridge exposes a tab-session binding. Preserve historical
8775
8782
  // lightweight/mock-context behavior only when that capability does not exist
@@ -8781,14 +8788,24 @@ export function makePanelToolCtx(bridge, tabId, workflowTargets, onRunTicketOpen
8781
8788
  const timing = reconnectWaitTiming();
8782
8789
  const budget = Math.max(0, budgetMs != null ? Math.min(budgetMs, timing.budgetMs) : timing.budgetMs);
8783
8790
  const deadline = Date.now() + budget;
8791
+ const stableMs = Math.max(0, timing.stableMs ?? POST_RESTART_RECONNECT_STABLE_MS);
8784
8792
  const isOriginalTabReconnected = () => {
8785
8793
  const current = panelConnectionIdentity();
8786
8794
  return (current != null &&
8787
8795
  current.generation > before.generation &&
8788
8796
  current.tabSessionId === before.tabSessionId);
8789
8797
  };
8798
+ const originalTabStayedReconnected = async () => {
8799
+ if (!isOriginalTabReconnected())
8800
+ return false;
8801
+ const left = deadline - Date.now();
8802
+ if (left <= 0)
8803
+ return false;
8804
+ await sleep(Math.min(stableMs, left));
8805
+ return isOriginalTabReconnected();
8806
+ };
8790
8807
  for (;;) {
8791
- if (isOriginalTabReconnected())
8808
+ if (await originalTabStayedReconnected())
8792
8809
  return true;
8793
8810
  // A new tab id cannot resolve through the retired binding. Once that binding is
8794
8811
  // actually gone, the existing conservative rebind can follow the sole new tab.
@@ -8796,7 +8813,7 @@ export function makePanelToolCtx(bridge, tabId, workflowTargets, onRunTicketOpen
8796
8813
  const interactive = interactiveTabIds() ?? [];
8797
8814
  if (interactive.length > 0)
8798
8815
  ensureReachable();
8799
- if (isOriginalTabReconnected())
8816
+ if (await originalTabStayedReconnected())
8800
8817
  return true;
8801
8818
  }
8802
8819
  const left = deadline - Date.now();