@michengai/dsh-im-connect 1.0.23 → 1.0.25

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.25 - 2026-11-04
4
+
5
+ - Fix settings navigation icon compatibility across host generations: ensure the IM Assistant icon correctly appears in older DSH hosts without falling back to the default gear glyph, while cleanly using the native icon slot without duplicates on newer hosts.
6
+ - Graceful fallback for slot registration: ensure settings icon registration errors are isolated and automatically retried when switching views, preventing host settings dialog interruptions.
7
+
8
+ ## 1.0.24 - 2026-11-03
9
+
10
+ - Integrate official native settings navigation icon slot: present dedicated instant messaging vector icon on newer hosts while maintaining graceful compatibility with older hosts to prevent dual icons.
11
+
3
12
  ## 1.0.23 - 2026-11-03
4
13
 
5
14
  - Fix Telegram status emoji reactions not appearing on incoming messages (#55, PR #56): when sending messages to the Telegram bot, original messages now properly show status reactions (👀 processing / 🤔 waiting / 👍 finished / 👎 failed) as the assistant makes progress, resolving an issue where reaction updates were silently swallowed due to targeting event cursors instead of user message IDs.
@@ -4,6 +4,15 @@
4
4
 
5
5
  以下记录近期发布的版本。Git 标签与 GitHub Release 现已和这些条目同步;历史条目继续保留原始发布提交链接。
6
6
 
7
+ ## 1.0.25 - 2026-11-04
8
+
9
+ - 完善不同版本 DSH 宿主设置导航图标兼容性:修复老版本宿主下「IM 助理」图标可能意外退回默认齿轮的问题,同时保持在新版宿主中通过原生插槽优雅展示专属矢量图标,彻底避免双图标重叠。
10
+ - 增强图标插槽容错与自愈能力:隔离图标插槽注册异常并在入口位置切换时自动重试,确保不会影响宿主设置工作台的整体加载。
11
+
12
+ ## 1.0.24 - 2026-11-03
13
+
14
+ - 接入官方原生设置导航图标插槽:在 DSH 新版设置页中呈现专属即时通信矢量图标,并精准兼容老版宿主,彻底避免双图标重叠问题。
15
+
7
16
  ## 1.0.23 - 2026-11-03
8
17
 
9
18
  - 修复 Telegram 消息状态表情无法显示的问题(#55,PR #56):给 Telegram 机器人发送消息后,原消息能正常显示「👀 思考中 / 🤔 等待确认 / 👍 已完成 / 👎 失败」等状态表情;此前因目标消息识别偏差导致表情更新一直被静默忽略。
package/client.js CHANGED
@@ -4315,6 +4315,16 @@ window.__ModuleLoader__.load({
4315
4315
  function applySettingsNavIcon(button, wantedLabel) {
4316
4316
  const isOwn = isOwnNavRow(getNavButtonText(button), typeof wantedLabel === "function" ? wantedLabel() : wantedLabel);
4317
4317
  if (isOwn) {
4318
+ const hasSlotIcon = Array.from((button && button.children) || []).some((child) =>
4319
+ child.tagName === "SPAN" && child.className && String(child.className).includes("navIcon")
4320
+ ) || Boolean(button && typeof button.querySelector === "function" && button.querySelector('span[class*="navIcon"]'));
4321
+ if (hasSlotIcon) {
4322
+ if (button.hasAttribute(NAV_ICON_MARKER)) {
4323
+ button.removeAttribute(NAV_ICON_MARKER);
4324
+ return true;
4325
+ }
4326
+ return false;
4327
+ }
4318
4328
  if (button.getAttribute(NAV_ICON_MARKER) === "") return false;
4319
4329
  button.setAttribute(NAV_ICON_MARKER, "");
4320
4330
  return true;
@@ -4332,6 +4342,19 @@ window.__ModuleLoader__.load({
4332
4342
  return true;
4333
4343
  }
4334
4344
 
4345
+ /**
4346
+ * 宿主是否已声明设置图标插槽。
4347
+ * 实测宿主公开面只暴露 `spec`(`specDynamic` 仅在 SlotCore 内部使用),
4348
+ * 两个都探是为了兼容将来把宽形式提到公开面的宿主;返回值可能是 null,
4349
+ * 所以统一按 `!= null` 判定,不能写 `!== undefined`。
4350
+ */
4351
+ function hostDeclaresIconSlot(slots) {
4352
+ if (!slots) return false;
4353
+ if (typeof slots.specDynamic === "function" && slots.specDynamic("settings.section.icon") != null) return true;
4354
+ if (typeof slots.spec === "function" && slots.spec("settings.section.icon") != null) return true;
4355
+ return false;
4356
+ }
4357
+
4335
4358
  function installSettingsNavIcon(targetCtx, resolveLabel) {
4336
4359
  if (typeof document === "undefined") return;
4337
4360
  ensureNavIconStyle(document);
@@ -4369,7 +4392,74 @@ window.__ModuleLoader__.load({
4369
4392
  }, "im-connect: settings nav icon");
4370
4393
  }
4371
4394
 
4372
- installSettingsNavIcon(ctx, () => t("settings.label"));
4395
+ const hasIconSlot = hostDeclaresIconSlot(ctx.slots);
4396
+
4397
+ if (!hasIconSlot) {
4398
+ installSettingsNavIcon(ctx, () => t("settings.label"));
4399
+ }
4400
+
4401
+ function ImNavIcon({ size = 16 }) {
4402
+ return React.createElement(
4403
+ "svg",
4404
+ {
4405
+ xmlns: "http://www.w3.org/2000/svg",
4406
+ viewBox: "0 0 16 16",
4407
+ width: size,
4408
+ height: size,
4409
+ fill: "none",
4410
+ stroke: "currentColor",
4411
+ strokeWidth: 1.3,
4412
+ strokeLinecap: "round",
4413
+ strokeLinejoin: "round",
4414
+ },
4415
+ React.createElement("path", { d: "M5 6.75H11" }),
4416
+ React.createElement("path", { d: "M5 9H8" }),
4417
+ React.createElement("path", { d: "M2.37067 11.2497C1.5872 9.89252 1.32042 8.29798 1.61945 6.7597C1.91847 5.22141 2.76317 3.84293 3.99801 2.87809C5.23285 1.91325 6.7747 1.427 8.33964 1.50888C9.90458 1.59076 11.3873 2.23526 12.5147 3.32369C13.6422 4.41232 14.3384 5.8717 14.4751 7.43304C14.6118 8.99438 14.1797 10.5525 13.2585 11.8205C12.3372 13.0885 10.9889 13.9809 9.4617 14.3334C8.18666 14.6277 6.8587 14.529 5.64964 14.0601C5.17095 13.8745 4.76937 13.4929 4.26509 13.3963C3.67389 13.2832 2.95232 13.5595 2.0377 14.3334" }),
4418
+ );
4419
+ }
4420
+
4421
+ /**
4422
+ * 在宿主声明了 `settings.section.icon` 后注册插件图标,并跟随入口位置启停。
4423
+ * 注册动作必须自带清理:槽位声明被撤销后宿主会重跑 inject 回调,不返回 disposer
4424
+ * 会让本地 unregIcon 变成永久非空、图标再也注册不回去。
4425
+ * 注册失败只影响图标本身(宿主回退自带字形),不得把宿主 settings 壳的注册流程带崩。
4426
+ */
4427
+ function installSettingsIconSlot(targetCtx, controller, IconComponent) {
4428
+ targetCtx.slots.inject("settings.section.icon", () => {
4429
+ let unregIcon = null;
4430
+ const syncIcon = () => {
4431
+ const shouldShow = controller && typeof controller.isSettingsSectionEnabled === "function"
4432
+ ? controller.isSettingsSectionEnabled()
4433
+ : true;
4434
+ if (shouldShow && !unregIcon) {
4435
+ try {
4436
+ const res = targetCtx.slots.register({
4437
+ name: "settings.section.icon",
4438
+ id: "im-assistant",
4439
+ locale: IM_LOCALE_NS,
4440
+ }, IconComponent);
4441
+ unregIcon = typeof res === "function" ? res : () => {};
4442
+ } catch { /* 注册抛错时留空 unregIcon,等下一次位置变化重试 */ }
4443
+ } else if (!shouldShow && unregIcon) {
4444
+ try { unregIcon(); } catch {}
4445
+ unregIcon = null;
4446
+ }
4447
+ };
4448
+ syncIcon();
4449
+ const unlisten = controller && typeof controller.onLocationChange === "function"
4450
+ ? controller.onLocationChange(() => syncIcon())
4451
+ : null;
4452
+ return () => {
4453
+ if (typeof unlisten === "function") {
4454
+ try { unlisten(); } catch {}
4455
+ }
4456
+ if (unregIcon) {
4457
+ try { unregIcon(); } catch {}
4458
+ unregIcon = null;
4459
+ }
4460
+ };
4461
+ });
4462
+ }
4373
4463
 
4374
4464
  let unregSettings = null;
4375
4465
  const mountSettingsSection = () => {
@@ -4420,6 +4510,8 @@ window.__ModuleLoader__.load({
4420
4510
  };
4421
4511
  });
4422
4512
 
4513
+ installSettingsIconSlot(ctx, sidebarController, ImNavIcon);
4514
+
4423
4515
  if (sidebarController && typeof sidebarController.onLocationChange === "function") {
4424
4516
  sidebarController.onLocationChange(() => syncSettingsSection());
4425
4517
  }
package/lib/client.js CHANGED
@@ -4717,6 +4717,16 @@ function observePluginUpdate(options) {
4717
4717
  function applySettingsNavIcon(button, wantedLabel) {
4718
4718
  const isOwn = isOwnNavRow(getNavButtonText(button), typeof wantedLabel === "function" ? wantedLabel() : wantedLabel);
4719
4719
  if (isOwn) {
4720
+ const hasSlotIcon = Array.from((button && button.children) || []).some((child) =>
4721
+ child.tagName === "SPAN" && child.className && String(child.className).includes("navIcon")
4722
+ ) || Boolean(button && typeof button.querySelector === "function" && button.querySelector('span[class*="navIcon"]'));
4723
+ if (hasSlotIcon) {
4724
+ if (button.hasAttribute(NAV_ICON_MARKER)) {
4725
+ button.removeAttribute(NAV_ICON_MARKER);
4726
+ return true;
4727
+ }
4728
+ return false;
4729
+ }
4720
4730
  if (button.getAttribute(NAV_ICON_MARKER) === "") return false;
4721
4731
  button.setAttribute(NAV_ICON_MARKER, "");
4722
4732
  return true;
@@ -4734,6 +4744,19 @@ function observePluginUpdate(options) {
4734
4744
  return true;
4735
4745
  }
4736
4746
 
4747
+ /**
4748
+ * 宿主是否已声明设置图标插槽。
4749
+ * 实测宿主公开面只暴露 `spec`(`specDynamic` 仅在 SlotCore 内部使用),
4750
+ * 两个都探是为了兼容将来把宽形式提到公开面的宿主;返回值可能是 null,
4751
+ * 所以统一按 `!= null` 判定,不能写 `!== undefined`。
4752
+ */
4753
+ function hostDeclaresIconSlot(slots) {
4754
+ if (!slots) return false;
4755
+ if (typeof slots.specDynamic === "function" && slots.specDynamic("settings.section.icon") != null) return true;
4756
+ if (typeof slots.spec === "function" && slots.spec("settings.section.icon") != null) return true;
4757
+ return false;
4758
+ }
4759
+
4737
4760
  function installSettingsNavIcon(targetCtx, resolveLabel) {
4738
4761
  if (typeof document === "undefined") return;
4739
4762
  ensureNavIconStyle(document);
@@ -4771,7 +4794,74 @@ function observePluginUpdate(options) {
4771
4794
  }, "im-connect: settings nav icon");
4772
4795
  }
4773
4796
 
4774
- installSettingsNavIcon(ctx, () => t("settings.label"));
4797
+ const hasIconSlot = hostDeclaresIconSlot(ctx.slots);
4798
+
4799
+ if (!hasIconSlot) {
4800
+ installSettingsNavIcon(ctx, () => t("settings.label"));
4801
+ }
4802
+
4803
+ function ImNavIcon({ size = 16 }) {
4804
+ return React.createElement(
4805
+ "svg",
4806
+ {
4807
+ xmlns: "http://www.w3.org/2000/svg",
4808
+ viewBox: "0 0 16 16",
4809
+ width: size,
4810
+ height: size,
4811
+ fill: "none",
4812
+ stroke: "currentColor",
4813
+ strokeWidth: 1.3,
4814
+ strokeLinecap: "round",
4815
+ strokeLinejoin: "round",
4816
+ },
4817
+ React.createElement("path", { d: "M5 6.75H11" }),
4818
+ React.createElement("path", { d: "M5 9H8" }),
4819
+ React.createElement("path", { d: "M2.37067 11.2497C1.5872 9.89252 1.32042 8.29798 1.61945 6.7597C1.91847 5.22141 2.76317 3.84293 3.99801 2.87809C5.23285 1.91325 6.7747 1.427 8.33964 1.50888C9.90458 1.59076 11.3873 2.23526 12.5147 3.32369C13.6422 4.41232 14.3384 5.8717 14.4751 7.43304C14.6118 8.99438 14.1797 10.5525 13.2585 11.8205C12.3372 13.0885 10.9889 13.9809 9.4617 14.3334C8.18666 14.6277 6.8587 14.529 5.64964 14.0601C5.17095 13.8745 4.76937 13.4929 4.26509 13.3963C3.67389 13.2832 2.95232 13.5595 2.0377 14.3334" }),
4820
+ );
4821
+ }
4822
+
4823
+ /**
4824
+ * 在宿主声明了 `settings.section.icon` 后注册插件图标,并跟随入口位置启停。
4825
+ * 注册动作必须自带清理:槽位声明被撤销后宿主会重跑 inject 回调,不返回 disposer
4826
+ * 会让本地 unregIcon 变成永久非空、图标再也注册不回去。
4827
+ * 注册失败只影响图标本身(宿主回退自带字形),不得把宿主 settings 壳的注册流程带崩。
4828
+ */
4829
+ function installSettingsIconSlot(targetCtx, controller, IconComponent) {
4830
+ targetCtx.slots.inject("settings.section.icon", () => {
4831
+ let unregIcon = null;
4832
+ const syncIcon = () => {
4833
+ const shouldShow = controller && typeof controller.isSettingsSectionEnabled === "function"
4834
+ ? controller.isSettingsSectionEnabled()
4835
+ : true;
4836
+ if (shouldShow && !unregIcon) {
4837
+ try {
4838
+ const res = targetCtx.slots.register({
4839
+ name: "settings.section.icon",
4840
+ id: "im-assistant",
4841
+ locale: IM_LOCALE_NS,
4842
+ }, IconComponent);
4843
+ unregIcon = typeof res === "function" ? res : () => {};
4844
+ } catch { /* 注册抛错时留空 unregIcon,等下一次位置变化重试 */ }
4845
+ } else if (!shouldShow && unregIcon) {
4846
+ try { unregIcon(); } catch {}
4847
+ unregIcon = null;
4848
+ }
4849
+ };
4850
+ syncIcon();
4851
+ const unlisten = controller && typeof controller.onLocationChange === "function"
4852
+ ? controller.onLocationChange(() => syncIcon())
4853
+ : null;
4854
+ return () => {
4855
+ if (typeof unlisten === "function") {
4856
+ try { unlisten(); } catch {}
4857
+ }
4858
+ if (unregIcon) {
4859
+ try { unregIcon(); } catch {}
4860
+ unregIcon = null;
4861
+ }
4862
+ };
4863
+ });
4864
+ }
4775
4865
 
4776
4866
  let unregSettings = null;
4777
4867
  const mountSettingsSection = () => {
@@ -4822,6 +4912,8 @@ function observePluginUpdate(options) {
4822
4912
  };
4823
4913
  });
4824
4914
 
4915
+ installSettingsIconSlot(ctx, sidebarController, ImNavIcon);
4916
+
4825
4917
  if (sidebarController && typeof sidebarController.onLocationChange === "function") {
4826
4918
  sidebarController.onLocationChange(() => syncSettingsSection());
4827
4919
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michengai/dsh-im-connect",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "DSH IM Connect — 将主流即时通讯平台接入本机 DeepSeek Harness · Connect major messaging platforms to local DeepSeek Harness agents",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.22.0",