@michengai/dsh-im-connect 0.1.48 → 0.1.49

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
@@ -4,6 +4,10 @@
4
4
 
5
5
  Recent published versions are listed below. Git tags and GitHub Releases now mirror these entries; historical sections retain links to their original release commits.
6
6
 
7
+ ## 0.1.49 - 2026-09-14
8
+
9
+ - Fix an older sidebar tab registration removing its replacement during cleanup, preserving shared tabs when plugins hand over ownership.
10
+
7
11
  ## 0.1.48 - 2026-09-14
8
12
 
9
13
  - Fix the Channels sidebar entry disappearing when used with the archive and automation plugins.
@@ -4,6 +4,10 @@
4
4
 
5
5
  以下记录近期发布的版本。Git 标签与 GitHub Release 现已和这些条目同步;历史条目继续保留原始发布提交链接。
6
6
 
7
+ ## 0.1.49 - 2026-09-14
8
+
9
+ - 修复侧栏旧页签注册在清理时误删同名新页签的问题,确保插件交接时保留共享页签。
10
+
7
11
  ## 0.1.48 - 2026-09-14
8
12
 
9
13
  - 修复与归档、定时任务插件组合使用时,侧栏频道入口可能消失的问题。
package/README.md CHANGED
@@ -327,6 +327,12 @@ dsh plugin --profile web add .
327
327
 
328
328
  When changing channel or session logic, keep the engine platform-agnostic, keep adapters from creating agents, and keep web tasks separate from IM channels.
329
329
 
330
+ ### Native sidebar coordination protocol
331
+
332
+ IM and Automation share tabs through the active `sidebar.workspaces` entry and the `__dshNativeTabs` registry on the entry or component. This is an inter-plugin convention, not an official stable DSH API. When replacing or restoring a sidebar component or handing over a registry without a host slot notification, the changing plugin should dispatch `dsh-native-sidebar-change` on `window` in a microtask after updating its state (a plain `Event`, with no payload). Receivers reread the active entry. Inserting a tab alone must not forward the event, to avoid notification loops.
333
+
334
+ Cleanup restores only components still owned by the plugin, removes its own registry and tabs, and releases event, slot, and tab subscriptions. Changes to the event name, registry structure, or notification semantics require coordinated compatibility updates. IM retries startup every 250ms for at most 20 attempts and stops early after inserting a tab. This only covers startup ordering; it cannot guarantee reconnection when an older plugin silently replaces a component after retries end.
335
+
330
336
  ## Validation
331
337
 
332
338
  For real management-authentication tests, set `DSH_CONNECTION_CONTRACT_ROOT` to the isolated `@deepseek-ai/dsh-client-connection` package root. The Gateway-coexistence case also uses `DSH_CHAT_CONTRACT_ROOT` from the image contracts. Local runs skip these contracts when unconfigured; CI supplies both. Tests use temporary HTTP servers and credentials, not a live Cloudflare deployment.
@@ -339,6 +345,8 @@ npm test
339
345
 
340
346
  `prepublishOnly` runs the tests before publishing.
341
347
 
348
+ Sidebar tests read the built `lib/client.js`; run `npm run build` before invoking individual tests directly. The lifecycle harness verifies attachment and disposal with simulated slots, notifications, and timers. It does not render React or replace validation of real messages, archiving, scheduled tasks, or Desktop.
349
+
342
350
 
343
351
  ## Result recovery after disconnects and restarts
344
352
 
package/README.zh-CN.md CHANGED
@@ -327,6 +327,12 @@ dsh plugin --profile web add .
327
327
 
328
328
  修改渠道或会话逻辑时,必须保持:引擎不写死平台名、渠道不创建 agent、网页任务与 IM 频道分列。
329
329
 
330
+ ### 原生侧栏协作协议
331
+
332
+ IM 与定时插件通过 `sidebar.workspaces` 当前显示项及条目/组件上的 `__dshNativeTabs` 注册表共享页签。这是插件间约定,不是 DSH 官方稳定 API。直接替换或恢复侧栏组件、交接注册表且宿主不会发送槽位通知时,变更方应在状态更新完成后通过微任务派发 `window` 事件 `dsh-native-sidebar-change`(普通 `Event`,无负载)。接收方重新读取当前显示项;仅插入页签不转发该事件,避免通知循环。
333
+
334
+ 清理时只恢复自己仍持有的组件、移除自己拥有的注册表和页签,并解除事件、槽位及页签订阅。事件名、注册表结构或通知语义变更需要协作插件同步兼容。IM 每 250ms、最多 20 次的启动重试在成功插入页签后提前结束;它只兼容启动加载顺序,不能保证旧插件在重试结束后无声替换组件时重新接入。
335
+
330
336
  ## 验证
331
337
 
332
338
  真实管理认证测试需要把 `DSH_CONNECTION_CONTRACT_ROOT` 指向隔离安装的 `@deepseek-ai/dsh-client-connection` 包根目录;与 Gateway 共存的用例同时使用图片契约的 `DSH_CHAT_CONTRACT_ROOT`。未配置时本地会跳过对应契约测试,CI 已配置执行。测试使用临时 HTTP 服务和临时凭据,不代表真实 Cloudflare 部署联调。
@@ -339,6 +345,8 @@ npm test
339
345
 
340
346
  `prepublishOnly` 会在发布前自动执行测试。
341
347
 
348
+ 侧栏测试读取构建后的 `lib/client.js`;直接运行单项测试前先执行 `npm run build`。生命周期 Harness 验证模拟插槽、通知与计时器下的接入和卸载,不执行 React 渲染,也不代替真实消息、归档、定时任务或 Desktop 验收。
349
+
342
350
 
343
351
  ## 断线与重启后的结果补发
344
352
 
package/client.js CHANGED
@@ -1968,7 +1968,11 @@ window.__ModuleLoader__.load({
1968
1968
  tabs.set(tab.id, tab);
1969
1969
  rebuild();
1970
1970
  emit();
1971
- return () => { tabs.delete(tab.id); rebuild(); emit(); };
1971
+ return () => {
1972
+ // 同名页签可能已被其他注册替换,旧清理函数只能移除自己持有的项。
1973
+ if (tabs.get(tab.id) !== tab) return;
1974
+ tabs.delete(tab.id); rebuild(); emit();
1975
+ };
1972
1976
  },
1973
1977
  addSessionFilter(filter) {
1974
1978
  sessionFilters.push(filter);
package/lib/client.js CHANGED
@@ -2262,7 +2262,11 @@ window.__ModuleLoader__.load({
2262
2262
  tabs.set(tab.id, tab);
2263
2263
  rebuild();
2264
2264
  emit();
2265
- return () => { tabs.delete(tab.id); rebuild(); emit(); };
2265
+ return () => {
2266
+ // 同名页签可能已被其他注册替换,旧清理函数只能移除自己持有的项。
2267
+ if (tabs.get(tab.id) !== tab) return;
2268
+ tabs.delete(tab.id); rebuild(); emit();
2269
+ };
2266
2270
  },
2267
2271
  addSessionFilter(filter) {
2268
2272
  sessionFilters.push(filter);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michengai/dsh-im-connect",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
4
4
  "description": "DeepSeek Harness IM 助理:把本机 agent 接到微信、企微、钉钉、飞书、QQ、Telegram,会话与网页任务分列。",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.22.0",