@trops/dash-core 0.1.560 → 0.1.562

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/dist/index.esm.js CHANGED
@@ -18959,18 +18959,38 @@ var WidgetCardHeader = function WidgetCardHeader(_ref) {
18959
18959
  };
18960
18960
  var providerRequirements = getProviderRequirements();
18961
18961
 
18962
- // Check if provider is configured — used only for the amber-dot
18963
- // indicator now. Actual provider editing lives in the config
18964
- // modal's Providers section (opened via the "Providers" menu item).
18965
- var isProviderConfigured = function isProviderConfigured(providerType) {
18966
- return selectedProviders[providerType] != null;
18962
+ // App providers — needed to detect when a global default
18963
+ // (`isDefaultForType: true`) exists for a required provider type.
18964
+ // The runtime resolution chain in useMcpProvider / useWebSocketProvider
18965
+ // falls through to the default when no per-instance pick is set, so
18966
+ // the amber-dot indicator should respect that fallback: a widget
18967
+ // whose required type has a default ISN'T actually unresolved.
18968
+ // Without this, the dot fires on every widget the user hasn't
18969
+ // explicitly bound, even though the runtime is happy.
18970
+ var appCtx = useContext(AppContext);
18971
+ var appProviders = (appCtx === null || appCtx === void 0 ? void 0 : appCtx.providers) || {};
18972
+
18973
+ // Check if a required provider has a resolved provider for it —
18974
+ // either a per-instance pick OR a global `isDefaultForType: true`
18975
+ // provider of the matching type. Mirrors the resolution chain in
18976
+ // `utils/providerResolution.js` so the indicator agrees with what
18977
+ // the runtime hook actually does.
18978
+ var isProviderResolved = function isProviderResolved(providerType) {
18979
+ if (selectedProviders[providerType] != null) return true;
18980
+ // Walk appProviders looking for a default of this type.
18981
+ var entries = appProviders && _typeof(appProviders) === "object" ? Object.values(appProviders) : [];
18982
+ return entries.some(function (p) {
18983
+ return p && p.type === providerType && p.isDefaultForType === true;
18984
+ });
18967
18985
  };
18968
18986
 
18969
- // True when any required provider lacks a selection — drives the
18970
- // amber dot on the overflow button so the user can see unresolved
18971
- // state at a glance without opening the menu.
18987
+ // True when any required provider has neither a per-instance pick
18988
+ // nor a global default — drives the amber dot on the overflow
18989
+ // button + the "!" badge on the Providers menu item so the user
18990
+ // can see truly-unresolved state at a glance. Widgets relying on
18991
+ // a global default no longer trip this.
18972
18992
  var hasUnresolvedRequiredProvider = providerRequirements.some(function (req) {
18973
- return req.required && !isProviderConfigured(req.type);
18993
+ return req.required && !isProviderResolved(req.type);
18974
18994
  });
18975
18995
 
18976
18996
  // Build overflow actions list — single source of truth for the
@@ -32333,6 +32353,12 @@ function _arrayLikeToArray$q(r, a) { (null == a || a > r.length) && (a = r.lengt
32333
32353
  * Matches the provider resolution pattern used by useMcpProvider:
32334
32354
  * 1. Widget-level: widgetData.selectedProviders[providerType] (set by handleSelectProvider on the layout item)
32335
32355
  * 2. Workspace-level fallback: workspace.workspaceData.selectedProviders[widgetId][providerType]
32356
+ * 3. App-default fallback: any provider of matching type flagged `isDefaultForType` in AppContext.providers
32357
+ * (managed via Settings → Providers "Use as default…" toggle)
32358
+ * 4. null — widget surfaces its own "no provider" empty state
32359
+ *
32360
+ * Existing widgets/workspaces retain their explicit bindings; the default layer only
32361
+ * activates for widgets with no explicit binding (mirrors useMcpProvider exactly).
32336
32362
  *
32337
32363
  * Reads provider data from AppContext.providers (not DashboardContext.providers, which has a
32338
32364
  * structural issue where providers don't flow through from AppWrapper).
@@ -32374,9 +32400,10 @@ var useWidgetProviders = function useWidgetProviders() {
32374
32400
  // Get all provider type declarations from the widget config
32375
32401
  var providerDeclarations = (widgetData === null || widgetData === void 0 ? void 0 : widgetData.providers) || [];
32376
32402
 
32377
- // Resolve each declared provider using the same two-layer lookup as useMcpProvider:
32403
+ // Resolve each declared provider using the same three-layer lookup as useMcpProvider:
32378
32404
  // 1. Widget-level: stored directly on the layout item by handleSelectProvider
32379
32405
  // 2. Workspace-level: stored as workspace.selectedProviders[widgetId][providerType]
32406
+ // 3. App-default: any provider in AppContext.providers flagged isDefaultForType
32380
32407
  var providers = {};
32381
32408
  var _iterator = _createForOfIteratorHelper$q(providerDeclarations),
32382
32409
  _step;
@@ -32395,6 +32422,23 @@ var useWidgetProviders = function useWidgetProviders() {
32395
32422
  providerName = (workspace === null || workspace === void 0 || (_workspace$workspaceD = workspace.workspaceData) === null || _workspace$workspaceD === void 0 || (_workspace$workspaceD = _workspace$workspaceD.selectedProviders) === null || _workspace$workspaceD === void 0 || (_workspace$workspaceD = _workspace$workspaceD[widgetId]) === null || _workspace$workspaceD === void 0 ? void 0 : _workspace$workspaceD[providerType]) || null;
32396
32423
  }
32397
32424
 
32425
+ // 3. App-default fallback — only kicks in for widgets with no explicit
32426
+ // per-widget or per-workspace binding. Walking the map is O(N)
32427
+ // in the provider count, which is small (typically <20 even for
32428
+ // heavy users); the cost is bounded and the lookup runs once per
32429
+ // declared provider type per render.
32430
+ if (!providerName && app !== null && app !== void 0 && app.providers && _typeof(app.providers) === "object") {
32431
+ for (var _i = 0, _Object$entries = Object.entries(app.providers); _i < _Object$entries.length; _i++) {
32432
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
32433
+ name = _Object$entries$_i[0],
32434
+ data = _Object$entries$_i[1];
32435
+ if ((data === null || data === void 0 ? void 0 : data.type) === providerType && (data === null || data === void 0 ? void 0 : data.isDefaultForType) === true) {
32436
+ providerName = name;
32437
+ break;
32438
+ }
32439
+ }
32440
+ }
32441
+
32398
32442
  // Look up from AppContext.providers (not DashboardContext)
32399
32443
  if (providerName) {
32400
32444
  var _app$providers;