@trops/dash-core 0.1.384 → 0.1.385

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.
@@ -28960,7 +28960,7 @@ const themeTools$1 = [
28960
28960
  {
28961
28961
  name: "apply_theme",
28962
28962
  description:
28963
- "Apply a saved theme to the active dashboard. The theme must already exist -- use list_themes to see available themes, or create one first with create_theme or create_theme_from_url.",
28963
+ "Apply a saved theme. Omit `dashboard` to set the app-wide default theme (affects every dashboard that doesn't have its own override). Pass `dashboard` (name or ID) to set that dashboard's theme override instead — useful when the user asks for a theme on a specific dashboard (e.g. 'apply ocean to my Sales dashboard'). The theme must already exist; use list_themes to see available themes or create one with create_theme / create_theme_from_url.",
28964
28964
  inputSchema: {
28965
28965
  type: "object",
28966
28966
  properties: {
@@ -28968,6 +28968,11 @@ const themeTools$1 = [
28968
28968
  type: "string",
28969
28969
  description: "Name of the theme to apply",
28970
28970
  },
28971
+ dashboard: {
28972
+ type: "string",
28973
+ description:
28974
+ "Optional dashboard name or numeric ID. Omit for app-wide application.",
28975
+ },
28971
28976
  },
28972
28977
  required: ["name"],
28973
28978
  },
@@ -60605,7 +60610,7 @@ async function handleCreateThemeFromUrl$1({ url, name }) {
60605
60610
  * apply_theme — Applies a saved theme to the active dashboard.
60606
60611
  * Updates settings to set the active theme key and notifies the renderer.
60607
60612
  */
60608
- async function handleApplyTheme$1({ name }) {
60613
+ async function handleApplyTheme$1({ name, dashboard }) {
60609
60614
  if (!name || typeof name !== "string" || !name.trim()) {
60610
60615
  return {
60611
60616
  content: [
@@ -60652,7 +60657,93 @@ async function handleApplyTheme$1({ name }) {
60652
60657
  };
60653
60658
  }
60654
60659
 
60655
- // Update settings to set the active theme
60660
+ // Dashboard-scoped apply: if the caller provided `dashboard`
60661
+ // (either a workspace ID or a workspace name), set that workspace's
60662
+ // theme override instead of the global default. Empty/omitted
60663
+ // `dashboard` means app-level.
60664
+ const dashboardRef =
60665
+ typeof dashboard === "string" ? dashboard.trim() : dashboard;
60666
+ if (
60667
+ dashboardRef !== undefined &&
60668
+ dashboardRef !== null &&
60669
+ dashboardRef !== ""
60670
+ ) {
60671
+ const wsList = workspaceController$2.listWorkspacesForApplication(win, appId);
60672
+ if (wsList?.error) {
60673
+ return {
60674
+ content: [
60675
+ { type: "text", text: JSON.stringify({ error: wsList.message }) },
60676
+ ],
60677
+ isError: true,
60678
+ };
60679
+ }
60680
+ const workspaces = wsList?.workspaces || [];
60681
+ // Match by numeric ID first, then by name (case-insensitive).
60682
+ const asNumber = Number(dashboardRef);
60683
+ const match =
60684
+ (!Number.isNaN(asNumber) &&
60685
+ workspaces.find((w) => Number(w.id) === asNumber)) ||
60686
+ workspaces.find(
60687
+ (w) =>
60688
+ typeof w.name === "string" &&
60689
+ w.name.toLowerCase() === String(dashboardRef).toLowerCase(),
60690
+ );
60691
+ if (!match) {
60692
+ return {
60693
+ content: [
60694
+ {
60695
+ type: "text",
60696
+ text: JSON.stringify({
60697
+ error: `Dashboard not found: ${dashboardRef}. Use list_dashboards to see available dashboards.`,
60698
+ }),
60699
+ },
60700
+ ],
60701
+ isError: true,
60702
+ };
60703
+ }
60704
+ // The renderer reads `workspace.themeKey` (via WorkspaceModel and
60705
+ // DashboardThemeProvider) — NOT `workspace.theme`. Set both for
60706
+ // forward-compat in case anything else reads the older field, but
60707
+ // `themeKey` is the one that actually drives the override.
60708
+ const updated = { ...match, themeKey: themeName, theme: themeName };
60709
+ const saveResult = workspaceController$2.saveWorkspaceForApplication(
60710
+ win,
60711
+ appId,
60712
+ updated,
60713
+ );
60714
+ if (saveResult?.error) {
60715
+ return {
60716
+ content: [
60717
+ {
60718
+ type: "text",
60719
+ text: JSON.stringify({ error: saveResult.message }),
60720
+ },
60721
+ ],
60722
+ isError: true,
60723
+ };
60724
+ }
60725
+ win.webContents.send("workspace:saved");
60726
+ return {
60727
+ content: [
60728
+ {
60729
+ type: "text",
60730
+ text: JSON.stringify(
60731
+ {
60732
+ name: themeName,
60733
+ applied: true,
60734
+ scope: "dashboard",
60735
+ dashboardId: String(match.id),
60736
+ dashboardName: match.name,
60737
+ },
60738
+ null,
60739
+ 2,
60740
+ ),
60741
+ },
60742
+ ],
60743
+ };
60744
+ }
60745
+
60746
+ // App-level apply: update application settings
60656
60747
  const settingsResult = settingsController$2.getSettingsForApplication(win);
60657
60748
  const settings = settingsResult?.settings || {};
60658
60749
  settings.theme = themeName;
@@ -60681,7 +60772,11 @@ async function handleApplyTheme$1({ name }) {
60681
60772
  content: [
60682
60773
  {
60683
60774
  type: "text",
60684
- text: JSON.stringify({ name: themeName, applied: true }, null, 2),
60775
+ text: JSON.stringify(
60776
+ { name: themeName, applied: true, scope: "app" },
60777
+ null,
60778
+ 2,
60779
+ ),
60685
60780
  },
60686
60781
  ],
60687
60782
  };