@trops/dash-core 0.1.556 → 0.1.561

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.js CHANGED
@@ -14430,7 +14430,35 @@ var PanelEditItemProviders = function PanelEditItemProviders(_ref) {
14430
14430
  }, p);
14431
14431
  });
14432
14432
  var isConfigured = !!current;
14433
- var isMissing = req.required && !isConfigured;
14433
+ // Detect the global default for this type. If one exists,
14434
+ // the runtime resolution chain (widget → workspace → app
14435
+ // default → null, see useMcpProvider.js + providerResolution.js)
14436
+ // will use it even when no per-instance override is set —
14437
+ // so the user isn't actually missing anything.
14438
+ //
14439
+ // Without this fallback awareness the UI flagged every
14440
+ // widget with no per-instance pick as "REQUIRED" in red,
14441
+ // even though the widget worked fine at runtime via the
14442
+ // default. Three states now drive the styling instead of
14443
+ // two:
14444
+ // - overridden: user explicitly picked a per-instance
14445
+ // provider → neutral panel + "override" tag
14446
+ // - using-default: per-instance empty but a global
14447
+ // default exists → neutral panel + "using default
14448
+ // <name>" hint
14449
+ // - missing: per-instance empty AND no global default
14450
+ // for this type → red panel + "REQUIRED" tag
14451
+ var defaultOption = options.find(function (o) {
14452
+ return o.isDefaultForType;
14453
+ });
14454
+ var isUsingDefault = !isConfigured && !!defaultOption;
14455
+ var isMissing = req.required && !isConfigured && !defaultOption;
14456
+ // resolvedName is what runtime will actually use — either
14457
+ // the per-instance override, or the global default if one
14458
+ // exists. Surfaced in the "using default" hint so the user
14459
+ // can see which provider is actually wired in without
14460
+ // opening Settings → Providers.
14461
+ var resolvedName = isConfigured ? current : isUsingDefault ? defaultOption.name : null;
14434
14462
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
14435
14463
  className: "rounded border px-3 py-2 ".concat(isMissing ? "bg-red-900 border-red-500" : "bg-gray-800 border-gray-700"),
14436
14464
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -14441,10 +14469,24 @@ var PanelEditItemProviders = function PanelEditItemProviders(_ref) {
14441
14469
  }), /*#__PURE__*/jsxRuntime.jsx("span", {
14442
14470
  className: "text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded font-semibold ".concat(isMissing ? "bg-red-600 text-white" : req.required ? "bg-indigo-800 text-indigo-100" : "bg-gray-700 text-gray-300"),
14443
14471
  children: req.required ? "required" : "optional"
14472
+ }), isUsingDefault && /*#__PURE__*/jsxRuntime.jsx("span", {
14473
+ className: "text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded font-semibold bg-emerald-800 text-emerald-100",
14474
+ title: "No per-widget override set \u2014 runtime resolves to the global default \"".concat(resolvedName, "\" (Settings \u2192 Providers)."),
14475
+ children: "using default"
14476
+ }), isConfigured && /*#__PURE__*/jsxRuntime.jsx("span", {
14477
+ className: "text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded font-semibold bg-indigo-900 text-indigo-200",
14478
+ title: "A per-widget provider is set; overrides the global default.",
14479
+ children: "override"
14444
14480
  })]
14445
14481
  }), req.description && /*#__PURE__*/jsxRuntime.jsx("div", {
14446
14482
  className: "text-xs opacity-60 mt-1",
14447
14483
  children: req.description
14484
+ }), isUsingDefault && /*#__PURE__*/jsxRuntime.jsxs("div", {
14485
+ className: "mt-1 text-[11px] text-emerald-300",
14486
+ children: ["Using global default:", " ", /*#__PURE__*/jsxRuntime.jsx("span", {
14487
+ className: "font-mono",
14488
+ children: resolvedName
14489
+ }), ". Pick a specific provider below to override."]
14448
14490
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
14449
14491
  className: "mt-2",
14450
14492
  children: [/*#__PURE__*/jsxRuntime.jsxs("select", {
@@ -14455,11 +14497,11 @@ var PanelEditItemProviders = function PanelEditItemProviders(_ref) {
14455
14497
  className: "w-full bg-gray-900 border rounded px-2 py-1.5 text-sm ".concat(isMissing ? "border-red-500" : "border-gray-700"),
14456
14498
  children: [/*#__PURE__*/jsxRuntime.jsx("option", {
14457
14499
  value: "",
14458
- children: req.required ? "— select a provider —" : "— none —"
14500
+ children: isUsingDefault ? "\u2014 use default (".concat(resolvedName, ") \u2014") : req.required ? "— select a provider —" : "— none —"
14459
14501
  }), options.map(function (opt) {
14460
- return /*#__PURE__*/jsxRuntime.jsx("option", {
14502
+ return /*#__PURE__*/jsxRuntime.jsxs("option", {
14461
14503
  value: opt.name,
14462
- children: opt.name
14504
+ children: [opt.name, opt.isDefaultForType ? " (default)" : ""]
14463
14505
  }, opt.name);
14464
14506
  })]
14465
14507
  }), options.length === 0 && /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -18935,18 +18977,38 @@ var WidgetCardHeader = function WidgetCardHeader(_ref) {
18935
18977
  };
18936
18978
  var providerRequirements = getProviderRequirements();
18937
18979
 
18938
- // Check if provider is configured — used only for the amber-dot
18939
- // indicator now. Actual provider editing lives in the config
18940
- // modal's Providers section (opened via the "Providers" menu item).
18941
- var isProviderConfigured = function isProviderConfigured(providerType) {
18942
- return selectedProviders[providerType] != null;
18980
+ // App providers — needed to detect when a global default
18981
+ // (`isDefaultForType: true`) exists for a required provider type.
18982
+ // The runtime resolution chain in useMcpProvider / useWebSocketProvider
18983
+ // falls through to the default when no per-instance pick is set, so
18984
+ // the amber-dot indicator should respect that fallback: a widget
18985
+ // whose required type has a default ISN'T actually unresolved.
18986
+ // Without this, the dot fires on every widget the user hasn't
18987
+ // explicitly bound, even though the runtime is happy.
18988
+ var appCtx = React.useContext(AppContext);
18989
+ var appProviders = (appCtx === null || appCtx === void 0 ? void 0 : appCtx.providers) || {};
18990
+
18991
+ // Check if a required provider has a resolved provider for it —
18992
+ // either a per-instance pick OR a global `isDefaultForType: true`
18993
+ // provider of the matching type. Mirrors the resolution chain in
18994
+ // `utils/providerResolution.js` so the indicator agrees with what
18995
+ // the runtime hook actually does.
18996
+ var isProviderResolved = function isProviderResolved(providerType) {
18997
+ if (selectedProviders[providerType] != null) return true;
18998
+ // Walk appProviders looking for a default of this type.
18999
+ var entries = appProviders && _typeof(appProviders) === "object" ? Object.values(appProviders) : [];
19000
+ return entries.some(function (p) {
19001
+ return p && p.type === providerType && p.isDefaultForType === true;
19002
+ });
18943
19003
  };
18944
19004
 
18945
- // True when any required provider lacks a selection — drives the
18946
- // amber dot on the overflow button so the user can see unresolved
18947
- // state at a glance without opening the menu.
19005
+ // True when any required provider has neither a per-instance pick
19006
+ // nor a global default — drives the amber dot on the overflow
19007
+ // button + the "!" badge on the Providers menu item so the user
19008
+ // can see truly-unresolved state at a glance. Widgets relying on
19009
+ // a global default no longer trip this.
18948
19010
  var hasUnresolvedRequiredProvider = providerRequirements.some(function (req) {
18949
- return req.required && !isProviderConfigured(req.type);
19011
+ return req.required && !isProviderResolved(req.type);
18950
19012
  });
18951
19013
 
18952
19014
  // Build overflow actions list — single source of truth for the