comfy-ts 2.4.0 → 2.4.2

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.
Files changed (34) hide show
  1. package/dist/{DefinedWorkflow-QrhT6V66.js → DefinedWorkflow-CnzmQrBh.js} +45 -13
  2. package/dist/DefinedWorkflow-CnzmQrBh.js.map +1 -0
  3. package/dist/{DraftsSt-D9Fhk4qR.js → DraftsSt-C1MbWnEp.js} +2 -2
  4. package/dist/{DraftsSt-D9Fhk4qR.js.map → DraftsSt-C1MbWnEp.js.map} +1 -1
  5. package/dist/cli.js +18 -11
  6. package/dist/cli.js.map +1 -1
  7. package/dist/index.cjs +38 -14
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +27 -5
  10. package/dist/index.d.ts +27 -5
  11. package/dist/index.js +38 -15
  12. package/dist/index.js.map +1 -1
  13. package/dist/{run-serve-C9E8dyLP.js → run-serve-D47Zas-a.js} +3 -3
  14. package/dist/{run-serve-C9E8dyLP.js.map → run-serve-D47Zas-a.js.map} +1 -1
  15. package/dist/{run-tui-cawSJuuh.js → run-tui-BqNO9Ck0.js} +21 -12
  16. package/dist/run-tui-BqNO9Ck0.js.map +1 -0
  17. package/dist/{state-BbKuSDCV.js → state-D9w1aJow.js} +11 -3
  18. package/dist/{state-BbKuSDCV.js.map → state-D9w1aJow.js.map} +1 -1
  19. package/dist/web.d.ts +27 -5
  20. package/dist/web.js +38 -15
  21. package/dist/web.js.map +1 -1
  22. package/package.json +1 -1
  23. package/src/cli/loras.ts +20 -9
  24. package/src/cli/tui/components/TuiApp.tsx +1 -1
  25. package/src/cli/tui/protocolImagePainter.ts +1 -1
  26. package/src/cli/tui/state/ExecSt.ts +3 -3
  27. package/src/cli/tui/state/LorasSt.ts +19 -5
  28. package/src/coreExports.ts +1 -0
  29. package/src/host/ComfyHost.ts +9 -0
  30. package/src/host/ResilientWebsocket.ts +20 -0
  31. package/src/host/loraInfoCache.ts +34 -13
  32. package/src/host/loraManagerApi.ts +25 -4
  33. package/dist/DefinedWorkflow-QrhT6V66.js.map +0 -1
  34. package/dist/run-tui-cawSJuuh.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -15873,6 +15873,14 @@ declare class ResilientWebSocketClient {
15873
15873
  /** transport unrecoverable (no ws package AND no global WebSocket, or ctor threw):
15874
15874
  * reported here ONCE, the client goes permanently closed — never a retry storm */
15875
15875
  onTransportDead?: (error: unknown) => void;
15876
+ /**
15877
+ * the socket closed WITHOUT ever opening: nothing is listening there.
15878
+ * That is a definitive answer, not a blip, so it is reported instead of
15879
+ * retried and the caller decides. The 2s retry loop exists to heal an
15880
+ * ESTABLISHED session; spending it on a refused connect only makes every
15881
+ * waiter sit for the full connect deadline. No callback = retry as before.
15882
+ */
15883
+ onFirstConnectFailed?: (error: unknown) => void;
15876
15884
  };
15877
15885
  private url;
15878
15886
  private currentWS?;
@@ -15893,7 +15901,17 @@ declare class ResilientWebSocketClient {
15893
15901
  /** transport unrecoverable (no ws package AND no global WebSocket, or ctor threw):
15894
15902
  * reported here ONCE, the client goes permanently closed — never a retry storm */
15895
15903
  onTransportDead?: (error: unknown) => void;
15904
+ /**
15905
+ * the socket closed WITHOUT ever opening: nothing is listening there.
15906
+ * That is a definitive answer, not a blip, so it is reported instead of
15907
+ * retried and the caller decides. The 2s retry loop exists to heal an
15908
+ * ESTABLISHED session; spending it on a refused connect only makes every
15909
+ * waiter sit for the full connect deadline. No callback = retry as before.
15910
+ */
15911
+ onFirstConnectFailed?: (error: unknown) => void;
15896
15912
  });
15913
+ /** an established session heals by retrying; a first connect that never opened does not */
15914
+ private hasEverOpened;
15897
15915
  private reconnectTimeout?;
15898
15916
  private permanentlyClosed;
15899
15917
  /** close and stop reconnecting (lets a script exit cleanly) */
@@ -17435,10 +17453,14 @@ type LoraMirror = {
17435
17453
  loras: Record<string, LmLoraItem>;
17436
17454
  };
17437
17455
  /**
17438
- * forget everything loaded, so the next read picks up a fresh `comfy-ts loras`.
17439
- * A long-lived process (the TUI, `comfy-ts serve`) has no other way to see a
17440
- * re-sync that happened in another terminal.
17441
- */
17456
+ * re-read any mirror whose file changed (or appeared) since we loaded it.
17457
+ * `comfy-ts loras` in another terminal is the normal case, and without this a
17458
+ * TUI session kept the stale data — or kept knowing NOTHING, for a host whose
17459
+ * first sync happened while it was open. One stat per registered host, so this
17460
+ * belongs at user-initiated moments (opening the loras overlay), never in a render.
17461
+ */
17462
+ declare function refreshLoraInfoCacheIfChanged(): void;
17463
+ /** forget everything loaded, so the next read re-reads from disk (tests, and a hard refresh) */
17442
17464
  declare function reloadLoraInfoCache(): void;
17443
17465
  /**
17444
17466
  * the lm item for a raw lora name (`styles\x.safetensors`).
@@ -17492,5 +17514,5 @@ declare function exampleImagePath(name: string): string;
17492
17514
  //#region src/cli/tui-env.d.ts
17493
17515
  declare function isTuiActive(): boolean;
17494
17516
  //#endregion
17495
- export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, ComfyHostUnreachableError, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraMirror, type LoraNameOf, type LoraStrength, type LoraSweep, type LorasHost, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, type NodeMode, NodeOf, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptRelated_WsMsg, type PromptValue, PromptVar, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, ToggleVar, type VarKind, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17517
+ export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, ComfyHostUnreachableError, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraMirror, type LoraNameOf, type LoraStrength, type LoraSweep, type LorasHost, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, type NodeMode, NodeOf, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptRelated_WsMsg, type PromptValue, PromptVar, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, ToggleVar, type VarKind, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17496
17518
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -15873,6 +15873,14 @@ declare class ResilientWebSocketClient {
15873
15873
  /** transport unrecoverable (no ws package AND no global WebSocket, or ctor threw):
15874
15874
  * reported here ONCE, the client goes permanently closed — never a retry storm */
15875
15875
  onTransportDead?: (error: unknown) => void;
15876
+ /**
15877
+ * the socket closed WITHOUT ever opening: nothing is listening there.
15878
+ * That is a definitive answer, not a blip, so it is reported instead of
15879
+ * retried and the caller decides. The 2s retry loop exists to heal an
15880
+ * ESTABLISHED session; spending it on a refused connect only makes every
15881
+ * waiter sit for the full connect deadline. No callback = retry as before.
15882
+ */
15883
+ onFirstConnectFailed?: (error: unknown) => void;
15876
15884
  };
15877
15885
  private url;
15878
15886
  private currentWS?;
@@ -15893,7 +15901,17 @@ declare class ResilientWebSocketClient {
15893
15901
  /** transport unrecoverable (no ws package AND no global WebSocket, or ctor threw):
15894
15902
  * reported here ONCE, the client goes permanently closed — never a retry storm */
15895
15903
  onTransportDead?: (error: unknown) => void;
15904
+ /**
15905
+ * the socket closed WITHOUT ever opening: nothing is listening there.
15906
+ * That is a definitive answer, not a blip, so it is reported instead of
15907
+ * retried and the caller decides. The 2s retry loop exists to heal an
15908
+ * ESTABLISHED session; spending it on a refused connect only makes every
15909
+ * waiter sit for the full connect deadline. No callback = retry as before.
15910
+ */
15911
+ onFirstConnectFailed?: (error: unknown) => void;
15896
15912
  });
15913
+ /** an established session heals by retrying; a first connect that never opened does not */
15914
+ private hasEverOpened;
15897
15915
  private reconnectTimeout?;
15898
15916
  private permanentlyClosed;
15899
15917
  /** close and stop reconnecting (lets a script exit cleanly) */
@@ -17435,10 +17453,14 @@ type LoraMirror = {
17435
17453
  loras: Record<string, LmLoraItem>;
17436
17454
  };
17437
17455
  /**
17438
- * forget everything loaded, so the next read picks up a fresh `comfy-ts loras`.
17439
- * A long-lived process (the TUI, `comfy-ts serve`) has no other way to see a
17440
- * re-sync that happened in another terminal.
17441
- */
17456
+ * re-read any mirror whose file changed (or appeared) since we loaded it.
17457
+ * `comfy-ts loras` in another terminal is the normal case, and without this a
17458
+ * TUI session kept the stale data — or kept knowing NOTHING, for a host whose
17459
+ * first sync happened while it was open. One stat per registered host, so this
17460
+ * belongs at user-initiated moments (opening the loras overlay), never in a render.
17461
+ */
17462
+ declare function refreshLoraInfoCacheIfChanged(): void;
17463
+ /** forget everything loaded, so the next read re-reads from disk (tests, and a hard refresh) */
17442
17464
  declare function reloadLoraInfoCache(): void;
17443
17465
  /**
17444
17466
  * the lm item for a raw lora name (`styles\x.safetensors`).
@@ -17492,5 +17514,5 @@ declare function exampleImagePath(name: string): string;
17492
17514
  //#region src/cli/tui-env.d.ts
17493
17515
  declare function isTuiActive(): boolean;
17494
17516
  //#endregion
17495
- export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, ComfyHostUnreachableError, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraMirror, type LoraNameOf, type LoraStrength, type LoraSweep, type LorasHost, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, type NodeMode, NodeOf, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptRelated_WsMsg, type PromptValue, PromptVar, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, ToggleVar, type VarKind, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17517
+ export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, ComfyHostUnreachableError, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraMirror, type LoraNameOf, type LoraStrength, type LoraSweep, type LorasHost, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, type NodeMode, NodeOf, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptRelated_WsMsg, type PromptValue, PromptVar, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, ToggleVar, type VarKind, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17496
17518
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -110,7 +110,7 @@ function createNodeStorage() {
110
110
  }
111
111
  //#endregion
112
112
  //#region package.json
113
- var version = "2.4.0";
113
+ var version = "2.4.2";
114
114
  //#endregion
115
115
  //#region src/litegraph/LiteGraphLinkID.ts
116
116
  const asLiteGraphLinkID = (id) => id;
@@ -3811,6 +3811,7 @@ var ResilientWebSocketClient = class {
3811
3811
  this.messageBuffer = [];
3812
3812
  this.isOpen = false;
3813
3813
  this.debugMessages = [];
3814
+ this.hasEverOpened = false;
3814
3815
  this.permanentlyClosed = false;
3815
3816
  this.url = options.url();
3816
3817
  this.connect();
@@ -3862,6 +3863,7 @@ var ResilientWebSocketClient = class {
3862
3863
  ws.onopen = () => {
3863
3864
  if (ws !== this.currentWS) return;
3864
3865
  this.addInfo("✅ WebSocket connected to " + this.url);
3866
+ this.hasEverOpened = true;
3865
3867
  this.isOpen = true;
3866
3868
  this.options.onConnectOrReconnect();
3867
3869
  this.flushMessageBuffer();
@@ -3872,6 +3874,11 @@ var ResilientWebSocketClient = class {
3872
3874
  this.options.onClose();
3873
3875
  if (this.permanentlyClosed) return;
3874
3876
  this.addError(`WebSocket closed (reason=${JSON.stringify(event.reason)}, code=${event.code})`);
3877
+ if (!this.hasEverOpened && this.options.onFirstConnectFailed != null) {
3878
+ this.permanentlyClosed = true;
3879
+ this.options.onFirstConnectFailed(/* @__PURE__ */ new Error(`connection refused (code=${event.code}${event.reason === "" ? "" : `, ${event.reason}`})`));
3880
+ return;
3881
+ }
3875
3882
  this.addInfo("⏱️ reconnecting in 2 seconds...");
3876
3883
  this.reconnectTimeout = setTimeout(() => void this.connect(), 2e3);
3877
3884
  };
@@ -3990,25 +3997,40 @@ function readLoraMirror(hostId) {
3990
3997
  * `comfyts.hosts` — exactly the hosts this process can be asked about.
3991
3998
  */
3992
3999
  const byHost = /* @__PURE__ */ new Map();
3993
- /** hosts already looked for, INCLUDING the ones with no mirror (see reloadLoraInfoCache) */
3994
- const loadedHostIds = /* @__PURE__ */ new Set();
4000
+ /** hosts already looked for, INCLUDING the ones with no mirror on disk → their mtime is null */
4001
+ const loadedMtimes = /* @__PURE__ */ new Map();
4002
+ /** cheap: no stat, no parse — this runs inside the overlay's render for every row */
3995
4003
  function ensureLoaded() {
3996
- for (const hostId of comfyts.hosts.keys()) {
3997
- if (loadedHostIds.has(hostId)) continue;
3998
- loadedHostIds.add(hostId);
3999
- const mirror = readLoraMirror(hostId);
4000
- if (mirror == null) continue;
4001
- byHost.set(hostId, new Map(Object.entries(mirror.loras)));
4002
- }
4004
+ for (const hostId of comfyts.hosts.keys()) if (!loadedMtimes.has(hostId)) loadHost(hostId);
4005
+ }
4006
+ function loadHost(hostId) {
4007
+ const storage = getComfyStorage();
4008
+ const path = loraMirrorPath(hostId);
4009
+ loadedMtimes.set(hostId, storage.mtimeMs(path));
4010
+ const mirror = readLoraMirror(hostId);
4011
+ if (mirror != null) byHost.set(hostId, new Map(Object.entries(mirror.loras)));
4012
+ else if (storage.exists(path)) byHost.set(hostId, /* @__PURE__ */ new Map());
4013
+ else byHost.delete(hostId);
4003
4014
  }
4004
4015
  /**
4005
- * forget everything loaded, so the next read picks up a fresh `comfy-ts loras`.
4006
- * A long-lived process (the TUI, `comfy-ts serve`) has no other way to see a
4007
- * re-sync that happened in another terminal.
4016
+ * re-read any mirror whose file changed (or appeared) since we loaded it.
4017
+ * `comfy-ts loras` in another terminal is the normal case, and without this a
4018
+ * TUI session kept the stale data — or kept knowing NOTHING, for a host whose
4019
+ * first sync happened while it was open. One stat per registered host, so this
4020
+ * belongs at user-initiated moments (opening the loras overlay), never in a render.
4008
4021
  */
4022
+ function refreshLoraInfoCacheIfChanged() {
4023
+ const storage = getComfyStorage();
4024
+ for (const hostId of comfyts.hosts.keys()) {
4025
+ const seen = loadedMtimes.get(hostId);
4026
+ const now = storage.mtimeMs(loraMirrorPath(hostId));
4027
+ if (!loadedMtimes.has(hostId) || seen !== now) loadHost(hostId);
4028
+ }
4029
+ }
4030
+ /** forget everything loaded, so the next read re-reads from disk (tests, and a hard refresh) */
4009
4031
  function reloadLoraInfoCache() {
4010
4032
  byHost.clear();
4011
- loadedHostIds.clear();
4033
+ loadedMtimes.clear();
4012
4034
  }
4013
4035
  /**
4014
4036
  * the lm item for a raw lora name (`styles\x.safetensors`).
@@ -5185,6 +5207,7 @@ var ComfyHost = class {
5185
5207
  url: () => this.getWSUrl(),
5186
5208
  headers: () => this.authHeaders(),
5187
5209
  onTransportDead: (e) => this.markFailed(e),
5210
+ onFirstConnectFailed: (e) => this.markFailed(new ComfyHostUnreachableError(`host '${this.data.id}' is not reachable at ${this.getWSUrl()} — ${extractErrorMessage(e)}. Is ComfyUI running there ?`)),
5188
5211
  onClose: () => {
5189
5212
  logInfo(`[👢] WEBSOCKET: closed connection to ComfyUI host ${this.data.id}`);
5190
5213
  }
@@ -6039,6 +6062,6 @@ function isTuiActive() {
6039
6062
  */
6040
6063
  setDefaultComfyStorage(createNodeStorage());
6041
6064
  //#endregion
6042
- export { ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyHostUnreachableError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DefinedWorkflow, FloatVar, ImageVar, ImageVarEmptyError, IntVar, InvalidPromptError, LorasVar, MediaImage, PromptVar, ResilientWebSocketClient, SeedVar, SizeVar, TextVar, ToggleVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
6065
+ export { ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyHostUnreachableError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DefinedWorkflow, FloatVar, ImageVar, ImageVarEmptyError, IntVar, InvalidPromptError, LorasVar, MediaImage, PromptVar, ResilientWebSocketClient, SeedVar, SizeVar, TextVar, ToggleVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
6043
6066
 
6044
6067
  //# sourceMappingURL=index.js.map