dsh-client-auto-continue 0.11.7 → 0.11.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.
@@ -24,12 +24,12 @@ export interface SettingsScopeSnapshot<T> {
24
24
  writable: boolean;
25
25
  mode: 'host' | 'memory';
26
26
  }
27
- /** Stable subset shared by the legacy and DSH 0.1.2 settings scopes. */
27
+ /** Stable subset shared by settings scopes and DSH 0.1.7 configuration forms. */
28
28
  export interface SettingsScope<T> {
29
29
  getSnapshot(): SettingsScopeSnapshot<T>;
30
30
  subscribe(listener: () => void): () => void;
31
- set(field: string, value: unknown): Promise<void>;
32
- unset(field: string): Promise<void>;
31
+ set(field: string, value: unknown): Promise<void | boolean>;
32
+ unset(field: string): Promise<void | boolean>;
33
33
  }
34
34
  export declare const createSnapshotStore: <T>(init: T, options?: {
35
35
  flush?: "raf" | "sync";
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Since 0.8.0 the auto-continue ENGINE runs inside the host process (single
5
5
  * instance — see src/host/engine.ts), so this half only:
6
- * - registers the `auto-continue` settings card (`settings.plugin.item`),
6
+ * - registers the `auto-continue` settings card in the available plugin UI,
7
7
  * - subscribes to the host status bridge (SSE) and shows browser
8
8
  * notifications with action buttons (Resume now / Pause 1h) via the bridge
9
9
  * action endpoint,
@@ -12,12 +12,22 @@
12
12
  import type { Context as ClientContext } from '@deepseek-ai/cordis';
13
13
  import { type SettingsCardKey } from './locales.ts';
14
14
  declare module '@deepseek-ai/dsh-client-ui-slots' {
15
+ interface SlotMap {
16
+ /** DSH 0.1.7's bundle configuration seat; only the owner props we consume. */
17
+ 'plugins.bundle.config': {
18
+ kind: 'keyed';
19
+ scope: 'root';
20
+ owner: {
21
+ readonly view: 'summary' | 'page';
22
+ };
23
+ };
24
+ }
15
25
  interface LocaleNamespaceMap {
16
26
  /** auto-continue settings-card copy. */
17
27
  'auto-continue': SettingsCardKey;
18
28
  }
19
29
  }
20
- /** Services required by this plugin. */
30
+ /** Settings services are injected separately: neither exists in every DSH cohort. */
21
31
  export declare const inject: string[];
22
32
  export { pausedSessions, readTodayStats, resetTodayStats, unpauseSession, } from './bridge.ts';
23
33
  /**
@@ -1,4 +1,4 @@
1
- import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
1
+ import type { InjectFace, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
2
2
  import { type AutoContinueSettings } from './engine.ts';
3
3
  import { type SettingsScope, type SnapshotStore } from './dsh-store-compat.ts';
4
4
  import { type CardActions, type CardFieldState, type CardShell } from './settings-form.ts';
@@ -51,9 +51,13 @@ export declare class AutoContinueSettingsCardController {
51
51
  * @returns the card's snapshot and its form actions.
52
52
  */
53
53
  inject(): AutoContinueSettingsCardFace;
54
+ /** Release this card's subscription to the provider-owned settings form. */
55
+ dispose(): void;
54
56
  }
55
57
  /** Props the renderer binds for the auto-continue plugin-configuration card. */
56
- export type AutoContinueSettingsCardProps = PropsRuntime<'settings.plugin.item'> & PropsLocale<'auto-continue'> & InjectFace<AutoContinueSettingsCardFace>;
58
+ export type AutoContinueSettingsCardProps = PropsLocale<'auto-continue'> & InjectFace<AutoContinueSettingsCardFace>;
59
+ /** The bundle page supplies no list container, unlike the legacy settings slot. */
60
+ export declare function AutoContinueSettingsPage(props: AutoContinueSettingsCardProps): import("react").JSX.Element;
57
61
  /**
58
62
  * Render the auto-continue card.
59
63
  * @param props - locale copy, the card snapshot, and its form actions.
@@ -84,6 +84,7 @@ export declare class CardForm<T> {
84
84
  private readonly specs;
85
85
  private readonly staged;
86
86
  private readonly listeners;
87
+ private readonly unsubscribe;
87
88
  private saving;
88
89
  private failed;
89
90
  /**
@@ -91,6 +92,8 @@ export declare class CardForm<T> {
91
92
  * @param specs - the section fields this card edits.
92
93
  */
93
94
  constructor(scope: SettingsScope<T>, specs: CardFieldSpec[]);
95
+ /** Release this editor's listeners without disposing the provider's shared form. */
96
+ dispose(): void;
94
97
  /** Publish a projection of this form, rebuilt whenever the scope or a draft changes. */
95
98
  bind<S>(project: () => S, createStore: (init: S) => SnapshotStore<S>): SnapshotStore<S>;
96
99
  /** Read the card-level state: what the Host serves, and what a save would do. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-client-auto-continue",
3
3
  "description": "DSH Web UI plugin: automatically sends a localized continue prompt when a request is interrupted by network errors or other non-human causes",
4
- "version": "0.11.7",
4
+ "version": "0.11.8",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",
@@ -46,7 +46,7 @@
46
46
  "build": "node build.mjs && tsc -p tsconfig.build.json",
47
47
  "watch": "node build.mjs --watch",
48
48
  "typecheck": "tsc --noEmit",
49
- "test": "node tests/simulate-host.mjs && node tests/settings-host-compat.mjs && node tests/simulate-client-loader.mjs && node tests/locale-mirror-bounded.mjs && node tests/settings-card-ui.mjs && node tests/prepare-github-package.mjs",
49
+ "test": "node tests/simulate-host.mjs && node tests/settings-host-compat.mjs && node tests/simulate-client-loader.mjs && node tests/client-settings-services.mjs && node tests/locale-mirror-bounded.mjs && node tests/settings-card-ui.mjs && node tests/prepare-github-package.mjs",
50
50
  "prepack": "npm run build"
51
51
  },
52
52
  "keywords": [
@@ -27,12 +27,12 @@ export interface SettingsScopeSnapshot<T> {
27
27
  mode: 'host' | 'memory';
28
28
  }
29
29
 
30
- /** Stable subset shared by the legacy and DSH 0.1.2 settings scopes. */
30
+ /** Stable subset shared by settings scopes and DSH 0.1.7 configuration forms. */
31
31
  export interface SettingsScope<T> {
32
32
  getSnapshot(): SettingsScopeSnapshot<T>;
33
33
  subscribe(listener: () => void): () => void;
34
- set(field: string, value: unknown): Promise<void>;
35
- unset(field: string): Promise<void>;
34
+ set(field: string, value: unknown): Promise<void | boolean>;
35
+ unset(field: string): Promise<void | boolean>;
36
36
  }
37
37
 
38
38
  interface SnapshotStoreModule {
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Since 0.8.0 the auto-continue ENGINE runs inside the host process (single
5
5
  * instance — see src/host/engine.ts), so this half only:
6
- * - registers the `auto-continue` settings card (`settings.plugin.item`),
6
+ * - registers the `auto-continue` settings card in the available plugin UI,
7
7
  * - subscribes to the host status bridge (SSE) and shows browser
8
8
  * notifications with action buttons (Resume now / Pause 1h) via the bridge
9
9
  * action endpoint,
@@ -21,8 +21,10 @@ import { en, zh, type SettingsCardKey } from './locales.ts';
21
21
  import {
22
22
  AutoContinueSettingsCard,
23
23
  AutoContinueSettingsCardController,
24
+ AutoContinueSettingsPage,
24
25
  } from './settings-card.tsx';
25
26
  import { startBridge } from './bridge.ts';
27
+ import type { SettingsScope } from './dsh-store-compat.ts';
26
28
 
27
29
  /** Dictionary namespace owned by this plugin. */
28
30
  const NS = 'auto-continue';
@@ -31,14 +33,27 @@ const NS = 'auto-continue';
31
33
  const SETTINGS_NS = 'auto-continue';
32
34
 
33
35
  declare module '@deepseek-ai/dsh-client-ui-slots' {
36
+ interface SlotMap {
37
+ /** DSH 0.1.7's bundle configuration seat; only the owner props we consume. */
38
+ 'plugins.bundle.config': {
39
+ kind: 'keyed';
40
+ scope: 'root';
41
+ owner: { readonly view: 'summary' | 'page' };
42
+ };
43
+ }
34
44
  interface LocaleNamespaceMap {
35
45
  /** auto-continue settings-card copy. */
36
46
  'auto-continue': SettingsCardKey;
37
47
  }
38
48
  }
39
49
 
40
- /** Services required by this plugin. */
41
- export const inject = ['slots', 'locale', 'settingsScope'];
50
+ /** Shared subset of DSH 0.1.7's provider, without a new runtime dependency. */
51
+ type ConfigFormsContext = ClientContext & {
52
+ configForms: { get<T>(entryId: string): SettingsScope<T> };
53
+ };
54
+
55
+ /** Settings services are injected separately: neither exists in every DSH cohort. */
56
+ export const inject = ['slots', 'locale'];
42
57
 
43
58
  // 浏览器侧辅助(设置卡片用): 桥状态读取与暂停解除。
44
59
  export {
@@ -55,8 +70,22 @@ export {
55
70
  */
56
71
  export function apply(ctx: ClientContext): void {
57
72
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'auto-continue: dictionaries');
73
+ ctx.effect(() => startBridge(), 'auto-continue: host bridge');
74
+
75
+ // Cordis waits for ALL top-level dependencies. Requiring settingsScope here
76
+ // would leave DSH 0.1.7 pending forever; requiring configForms breaks older
77
+ // hosts. Separate child fibers also follow late providers and their teardown.
78
+ ctx.inject(['settingsScope'], (settingsCtx) => {
79
+ mountSettings(settingsCtx, settingsCtx.settingsScope.bind<AutoContinueSettings>({ namespace: SETTINGS_NS }));
80
+ });
81
+ ctx.inject(['configForms'], (settingsCtx) => {
82
+ const forms = (settingsCtx as ConfigFormsContext).configForms;
83
+ mountSettings(settingsCtx, forms.get<AutoContinueSettings>(SETTINGS_NS));
84
+ });
85
+ }
58
86
 
59
- const scope = ctx.settingsScope.bind<AutoContinueSettings>({ namespace: SETTINGS_NS });
87
+ /** Attach this consumer's subscriptions and card to the provider's lifecycle. */
88
+ function mountSettings(ctx: ClientContext, scope: SettingsScope<AutoContinueSettings>): void {
60
89
  /**
61
90
  * Mirror the browser locale into the host config, with a hard per-page budget.
62
91
  *
@@ -105,15 +134,11 @@ export function apply(ctx: ClientContext): void {
105
134
  ctx.on('locale/change', syncLocale);
106
135
  syncLocale();
107
136
 
108
- // 状态桥: 订阅 host 的通知与运行时状态, 弹浏览器通知并驱动卡片面板。
109
- ctx.effect(() => startBridge(), 'auto-continue: host bridge');
110
-
111
- // Plugin configuration card: one staged form over the `auto-continue`
112
- // settings namespace, contributed to the plugin-configuration section
113
- // (Settings → Plugins). Since DSH 0.1.0-rc.7 `settings.plugin.item` is a
114
- // keyed slot dispatched by the settings namespace it edits, so the entry
115
- // registers with `key` (the namespace), like the official cards.
116
137
  const controller = new AutoContinueSettingsCardController(scope);
138
+ ctx.effect(() => () => controller.dispose(), 'auto-continue: settings form');
139
+
140
+ // Slot injection waits for the matching UI declaration. Keep the old
141
+ // settings card and the new bundle page independent of service migration.
117
142
  ctx.slots.inject('settings.plugin.item', () =>
118
143
  ctx.slots.register(
119
144
  {
@@ -125,4 +150,15 @@ export function apply(ctx: ClientContext): void {
125
150
  AutoContinueSettingsCard,
126
151
  ),
127
152
  );
153
+ ctx.slots.inject('plugins.bundle.config', () =>
154
+ ctx.slots.register(
155
+ {
156
+ name: 'plugins.bundle.config',
157
+ key: 'dsh-client-auto-continue',
158
+ locale: NS,
159
+ inject: () => controller.inject(),
160
+ },
161
+ AutoContinueSettingsPage,
162
+ ),
163
+ );
128
164
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The auto-continue settings card: edits the `auto-continue` namespace fields
3
- * from the plugin-configuration section (the `settings.plugin.item` seat).
3
+ * from the legacy settings section or the bundle's plugin-manager page.
4
4
  *
5
5
  * Self-contained card chrome (disclosure header, staged fields, save/discard
6
6
  * footer) following the plugin-card store pattern of the DSH plugin
@@ -8,7 +8,7 @@
8
8
  * tokens so the card follows the active theme.
9
9
  */
10
10
  import { useEffect, useState, type ReactNode } from 'react';
11
- import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
11
+ import type { InjectFace, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
12
12
  import { type AutoContinueSettings } from './engine.ts';
13
13
  import { createSnapshotStore, type SettingsScope, type SnapshotStore } from './dsh-store-compat.ts';
14
14
  import {
@@ -148,11 +148,25 @@ export class AutoContinueSettingsCardController {
148
148
  inject(): AutoContinueSettingsCardFace {
149
149
  return { hooks: { autoContinueSettingsCard: this.store }, ...this.form.actions() };
150
150
  }
151
+
152
+ /** Release this card's subscription to the provider-owned settings form. */
153
+ dispose(): void {
154
+ this.form.dispose();
155
+ }
151
156
  }
152
157
 
153
158
  /** Props the renderer binds for the auto-continue plugin-configuration card. */
154
159
  export type AutoContinueSettingsCardProps =
155
- PropsRuntime<'settings.plugin.item'> & PropsLocale<'auto-continue'> & InjectFace<AutoContinueSettingsCardFace>;
160
+ PropsLocale<'auto-continue'> & InjectFace<AutoContinueSettingsCardFace>;
161
+
162
+ /** The bundle page supplies no list container, unlike the legacy settings slot. */
163
+ export function AutoContinueSettingsPage(props: AutoContinueSettingsCardProps) {
164
+ return (
165
+ <ul style={{ listStyle: 'none', margin: 0, padding: 0 }}>
166
+ <AutoContinueSettingsCard {...props} />
167
+ </ul>
168
+ );
169
+ }
156
170
 
157
171
  const REPOSITORY_URL = 'https://github.com/HsiangNianian/dsh-auto-continue';
158
172
  const REPOSITORY_SLUG = 'HsiangNianian/dsh-auto-continue';
@@ -128,6 +128,7 @@ export class CardForm<T> {
128
128
  private readonly specs: Map<string, CardFieldSpec>;
129
129
  private readonly staged = new Map<string, StagedEdit>();
130
130
  private readonly listeners = new Set<() => void>();
131
+ private readonly unsubscribe: () => void;
131
132
  private saving = false;
132
133
  private failed = false;
133
134
 
@@ -140,7 +141,13 @@ export class CardForm<T> {
140
141
  specs: CardFieldSpec[],
141
142
  ) {
142
143
  this.specs = new Map(specs.map((spec) => [spec.field, spec]));
143
- this.scope.subscribe(() => this.publish());
144
+ this.unsubscribe = this.scope.subscribe(() => this.publish());
145
+ }
146
+
147
+ /** Release this editor's listeners without disposing the provider's shared form. */
148
+ dispose(): void {
149
+ this.unsubscribe();
150
+ this.listeners.clear();
144
151
  }
145
152
 
146
153
  /** Publish a projection of this form, rebuilt whenever the scope or a draft changes. */