dsh-auto-collapse 0.1.7 → 0.1.8

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/README.en.md CHANGED
@@ -25,8 +25,19 @@
25
25
  - **Configurable status text**: in Settings → Plugins → Plugin configuration, edit the status prompt (default `Deep sleeping...`); leaving it blank restores the official copy (“深度求索中...” in current builds). The host-appended elapsed suffix (e.g. `33秒`) is preserved.
26
26
  - **Fully reversible**: uninstalling (HMR stop) restores every collapsed/hidden/rewritten node.
27
27
 
28
+ ## Compatibility
29
+
30
+ | Plugin version | DSH compatibility |
31
+ |---|---|
32
+ | 0.1.8 | **DSH 0.1.2-rc.1+** (reconnectable settings lifecycle, native turn-process rows, Chinese status copy) |
33
+ | 0.1.7 | DSH 0.1.2-rc.1+ (initial support; the settings card can be absent under startup races, so upgrade to 0.1.8) |
34
+ | ≤ 0.1.6 | DSH 0.1.1.x |
35
+
36
+ Since 0.1.7 the plugin no longer depends on the removed `@deepseek-ai/dsh-settings` exports (the host half wires an optional consumer). Since 0.1.8 the client waits for and reconnects `settingsScope` / `slots` through `ctx.inject()`, so late services cannot permanently drop the settings card. Client injection relies on 0.1.2's `dsh-client-modules` and has not been verified on 0.1.1. DSH 0.1.1 users should stay on 0.1.6.
37
+
28
38
  ## Install
29
39
 
40
+
30
41
  Published npm package (recommended; uses the prebuilt release):
31
42
 
32
43
  ```bash
package/README.md CHANGED
@@ -26,6 +26,16 @@
26
26
  - **可配置状态提示词**:在 设置 → 插件 → 插件配置 中可以编辑“状态提示词”,默认 `Deep sleeping...`;留空保存后恢复官方原文(当前版本为“深度求索中...”)。宿主追加的用时后缀(如 `33秒`)保留。
27
27
  - **可逆**:卸载(HMR stop)时完整还原所有折叠/隐藏/改写。
28
28
 
29
+ ## 兼容性
30
+
31
+ | 插件版本 | 适配的 DSH |
32
+ |---|---|
33
+ | 0.1.8 | **DSH 0.1.2-rc.1+**(settings 可重连生命周期、原生回合摘要行、中文状态文案) |
34
+ | 0.1.7 | DSH 0.1.2-rc.1+(初版适配;启动时序下设置卡可能缺席,建议升级 0.1.8) |
35
+ | ≤ 0.1.6 | DSH 0.1.1.x |
36
+
37
+ 0.1.7 起不再依赖被移除的 `@deepseek-ai/dsh-settings` 导出(宿主半通过可选消费者接线);0.1.8 起客户端使用 `ctx.inject()` 等待并重连 `settingsScope` / `slots`,避免服务晚到时永久丢失设置卡。客户端注入基于 0.1.2 的 `dsh-client-modules`,未在 0.1.1 上验证。0.1.1 用户请继续使用 0.1.6。
38
+
29
39
  ## 安装
30
40
 
31
41
  已发布 npm 包(推荐,使用构建好的版本):
package/lib/client.js CHANGED
@@ -2391,8 +2391,17 @@ var __dshcfBundle = (() => {
2391
2391
  const statuses = flow.matches('[role="status"]') ? [flow, ...flow.querySelectorAll('[role="status"]')] : [...flow.querySelectorAll('[role="status"]')];
2392
2392
  for (const status of statuses) {
2393
2393
  for (const node of status.childNodes) {
2394
- if (node instanceof Text && TURN_STATUS_COPY_RE.test(node.data)) {
2395
- let record = originals.get(node);
2394
+ if (!(node instanceof Text)) continue;
2395
+ let record = originals.get(node);
2396
+ if (record !== void 0 && node.data === record.written) {
2397
+ const next = record.original.replace(TURN_STATUS_COPY_RE, statusText);
2398
+ if (node.data !== next) {
2399
+ node.data = next;
2400
+ record.written = next;
2401
+ }
2402
+ continue;
2403
+ }
2404
+ if (TURN_STATUS_COPY_RE.test(node.data)) {
2396
2405
  if (record === void 0) {
2397
2406
  record = { original: node.data, written: "" };
2398
2407
  originals.set(node, record);
@@ -2521,6 +2530,7 @@ var __dshcfBundle = (() => {
2521
2530
  .dshcf-settings-save:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 1px; }
2522
2531
  `;
2523
2532
  var STYLE_ID2 = "dshcf-settings-style";
2533
+ var styleOwners = 0;
2524
2534
  function injectCardStyle() {
2525
2535
  if (typeof document === "undefined" || document.getElementById(STYLE_ID2) !== null) return;
2526
2536
  const style = document.createElement("style");
@@ -2528,6 +2538,17 @@ var __dshcfBundle = (() => {
2528
2538
  style.textContent = CARD_CSS;
2529
2539
  document.head.appendChild(style);
2530
2540
  }
2541
+ function acquireCardStyle() {
2542
+ styleOwners += 1;
2543
+ injectCardStyle();
2544
+ let released = false;
2545
+ return () => {
2546
+ if (released) return;
2547
+ released = true;
2548
+ styleOwners = Math.max(0, styleOwners - 1);
2549
+ if (styleOwners === 0 && typeof document !== "undefined") document.getElementById(STYLE_ID2)?.remove();
2550
+ };
2551
+ }
2531
2552
  function ChevronIcon(open) {
2532
2553
  const React = __require("react");
2533
2554
  const className = open ? "dshcf-settings-chevron dshcf-settings-chevronOpen" : "dshcf-settings-chevron";
@@ -2637,35 +2658,67 @@ var __dshcfBundle = (() => {
2637
2658
  ]);
2638
2659
  }
2639
2660
  function setupSettingsCard(ctx, scope) {
2640
- injectCardStyle();
2641
- return ctx.slots.inject("settings.plugin.item", () => ctx.slots.register(
2642
- {
2643
- name: "settings.plugin.item",
2644
- key: AUTO_COLLAPSE_NS,
2645
- inject: () => ({ scope })
2646
- },
2647
- StatusTextCard
2648
- ));
2661
+ const releaseStyle = acquireCardStyle();
2662
+ try {
2663
+ const offSlot = ctx.slots.inject("settings.plugin.item", () => ctx.slots.register(
2664
+ {
2665
+ name: "settings.plugin.item",
2666
+ key: AUTO_COLLAPSE_NS,
2667
+ inject: () => ({ scope })
2668
+ },
2669
+ StatusTextCard
2670
+ ));
2671
+ return () => {
2672
+ try {
2673
+ offSlot();
2674
+ } finally {
2675
+ releaseStyle();
2676
+ }
2677
+ };
2678
+ } catch (error) {
2679
+ releaseStyle();
2680
+ throw error;
2681
+ }
2649
2682
  }
2650
2683
 
2651
2684
  // src/client.ts
2652
2685
  var name = "dsh-auto-collapse";
2653
2686
  var inject = [];
2654
2687
  function apply(ctx) {
2688
+ const fallbackStatusText = () => DEFAULT_STATUS_TEXT2;
2689
+ let readStatusText = fallbackStatusText;
2690
+ const controller = new FoldController(() => readStatusText());
2655
2691
  ctx.effect(() => {
2656
- const settingsScope = ctx.get?.("settingsScope");
2657
- const slots = ctx.get?.("slots");
2658
- const scope = settingsScope?.bind({ namespace: AUTO_COLLAPSE_NS });
2659
- const controller = new FoldController(statusTextProvider(scope));
2660
2692
  controller.start();
2661
- const offScope = scope?.subscribe(() => controller.refresh());
2662
- const offSettings = slots === void 0 || scope === void 0 ? void 0 : setupSettingsCard({ slots }, scope);
2663
- return () => {
2664
- offScope?.();
2665
- offSettings?.();
2666
- controller.stop();
2667
- };
2668
- }, "dsh-auto-collapse: fold observer + settings card");
2693
+ return () => controller.stop();
2694
+ }, "dsh-auto-collapse: fold observer");
2695
+ ctx.inject?.(["settingsScope", "slots"], (serviceCtx) => {
2696
+ serviceCtx.effect(() => {
2697
+ const settingsScope = serviceCtx.get?.("settingsScope");
2698
+ const slots = serviceCtx.get?.("slots");
2699
+ if (settingsScope === void 0 || slots === void 0) return;
2700
+ const scope = settingsScope.bind({ namespace: AUTO_COLLAPSE_NS });
2701
+ const scopedStatusText = statusTextProvider(scope);
2702
+ const offScope = scope.subscribe(() => controller.refresh());
2703
+ let offSettings;
2704
+ try {
2705
+ offSettings = setupSettingsCard({ slots }, scope);
2706
+ } catch (error) {
2707
+ offScope();
2708
+ throw error;
2709
+ }
2710
+ readStatusText = scopedStatusText;
2711
+ controller.refresh();
2712
+ return () => {
2713
+ offScope();
2714
+ offSettings();
2715
+ if (readStatusText === scopedStatusText) {
2716
+ readStatusText = fallbackStatusText;
2717
+ controller.refresh();
2718
+ }
2719
+ };
2720
+ }, "dsh-auto-collapse: settings scope + plugin card");
2721
+ });
2669
2722
  }
2670
2723
  return __toCommonJS(client_exports);
2671
2724
  })();
@@ -1,7 +1,8 @@
1
1
  export declare const name = "dsh-auto-collapse";
2
2
  /**
3
3
  * 不声明必需服务:slots/settingsScope 只是可选增强能力,不能阻止核心折叠
4
- * 插件启动。运行时通过 ctx.get() 读取,服务不存在时仅跳过设置卡片与配置订阅。
4
+ * 插件启动。下方通过 ctx.inject() 等待两个服务,支持晚于插件出现
5
+ * 以及卸载后重连;服务永久缺席时仅跳过设置卡片与配置订阅。
5
6
  */
6
7
  export declare const inject: string[];
7
8
  /** 客户端根上下文的最小结构化类型(仅用 cordis 标准 effect,无运行时依赖)。 */
@@ -9,5 +10,7 @@ export interface FoldClientCtx {
9
10
  effect(fn: () => unknown, label?: string): unknown;
10
11
  /** Cordis 动态客户端上下文提供的可选服务查询。 */
11
12
  get?<T>(name: string): T | undefined;
13
+ /** 可选服务生命周期:服务齐备时进入,detach 时自动清理回调上的 effect。 */
14
+ inject?(services: readonly string[], setup: (ctx: FoldClientCtx) => void): void;
12
15
  }
13
16
  export declare function apply(ctx: FoldClientCtx): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-auto-collapse",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "DeepSeek Harness Web 客户端插件:把会话里的工具卡片与 Think 推理块折叠成一行,折叠态实时显示当前正在进行的工作(工具名 + 正在执行的命令/参数、或思考内容),运行中带流光动画;点击展开/收起。让界面只保留模型说的话。",
5
5
  "type": "module",
6
6
  "repository": {