@linxin666/dsh-pet 0.4.4 → 0.4.5

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/lib/index.js CHANGED
@@ -5191,7 +5191,7 @@ var PetService = class extends Service {
5191
5191
  this.ledger.setRemarks(selected.remarks);
5192
5192
  } else if (section.petId !== void 0) this.syncSettingsFromPet();
5193
5193
  const next = { ...this.ledger.snapshot.display };
5194
- next.visible = section.visible && (section.enabled ?? true);
5194
+ next.visible = section.visible;
5195
5195
  next.size = Math.round(Math.min(DISPLAY_SIZE_MAX, Math.max(32, section.size)));
5196
5196
  next.right = Math.round(Math.min(DISPLAY_INSET_MAX, Math.max(0, section.right)));
5197
5197
  next.bottom = Math.round(Math.min(DISPLAY_INSET_MAX, Math.max(0, section.bottom)));
@@ -5263,7 +5263,10 @@ var PetService = class extends Service {
5263
5263
  ...decoration === void 0 ? {} : { decoration },
5264
5264
  ...announcement === void 0 ? {} : { announcement },
5265
5265
  affinity: this.ledger.affinityView(Date.now()),
5266
- display: { ...this.ledger.snapshot.display },
5266
+ display: {
5267
+ ...this.ledger.snapshot.display,
5268
+ visible: this.isEnabled() && this.ledger.snapshot.display.visible
5269
+ },
5267
5270
  pet: {
5268
5271
  id: entry.id,
5269
5272
  displayName: entry.displayName,
@@ -6224,6 +6227,7 @@ function displayField(key, live, persisted, committed) {
6224
6227
  * @returns the resolved settings section.
6225
6228
  */
6226
6229
  function petSettingsSection(config, fallbackPetId, persisted = {}, committed = {}) {
6230
+ const enabled = readLive(config.enabled, PET_FORM_DEFAULTS.enabled);
6227
6231
  return {
6228
6232
  visible: displayField("visible", config.visible, persisted, committed),
6229
6233
  size: displayField("size", config.size, persisted, committed),
@@ -6231,7 +6235,7 @@ function petSettingsSection(config, fallbackPetId, persisted = {}, committed = {
6231
6235
  bottom: displayField("bottom", config.bottom, persisted, committed),
6232
6236
  bubbleScale: displayField("bubbleScale", config.bubbleScale, persisted, committed),
6233
6237
  petId: readLive(config.petId, fallbackPetId),
6234
- enabled: readLive(config.enabled, PET_FORM_DEFAULTS.enabled),
6238
+ enabled,
6235
6239
  decorationEnabled: readLive(config.decorationEnabled, PET_FORM_DEFAULTS.decorationEnabled)
6236
6240
  };
6237
6241
  }
@@ -38,5 +38,7 @@ declare module '@deepseek-ai/cordis' {
38
38
  };
39
39
  }
40
40
  }
41
+ /** How long the deferred form keeps retrying before it settles on the fallback. */
42
+ export declare const BINDER_RETRY_MS = 250;
41
43
  export declare function apply(ctx: ClientContext): void;
42
44
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnE,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,4CAA4C,CAAA;AAqFzF,wEAAwE;AACxE,eAAO,MAAM,MAAM,UAAwF,CAAA;AAE3G,qEAAqE;AACrE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACxE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC7D,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACtF,YAAY,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf;;;;WAIG;QACH,aAAa,CAAC,EAAE;YACd,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE;gBAAE,SAAS,EAAE,MAAM,CAAC;gBAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK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62,38 +62,199 @@ const PET_SETTINGS_NS = 'pet';
62
62
  /** Required services (sessions powers bubble-to-session navigation). */
63
63
  export const inject = ['slots', 'locale', 'connection', 'configForms', 'remote', 'sessions', 'uiWorkspace'];
64
64
  /**
65
- * The configuration form the settings card stages and saves through: the
66
- * family binder when dsh-web-settings is mounted, otherwise the shared form of
67
- * this plugin's own profile entry.
68
- *
69
- * The two are not interchangeable by name. A plugin's settings ARE its own
70
- * config on 0.1.7, so the form belongs to the profile entry that carries the
71
- * plugin — and only the family binder knows which entry that is, because the
72
- * family bundle renames child rows ('pet' becomes 'web-ui-pet' there) while a
73
- * standalone install keeps the package's own id.
74
- * @param ctx - client root context.
75
- * @returns the form for the pet's settings page.
65
+ * The profile entry ids a pet install is served under, most specific first. The
66
+ * family bundle renames child rows, so a standalone install and an aggregate
67
+ * one answer to different ids for the same 'pet' namespace.
76
68
  */
77
69
  const AGGREGATE_ENTRY_ID = 'web-ui-pet';
78
70
  const PET_ENTRY_IDS = [AGGREGATE_ENTRY_ID, 'ui-pet', PET_SETTINGS_NS];
79
- function servedEntryId(forms) {
80
- let served;
81
- try {
82
- served = forms.describe().getSnapshot().view?.namespaces.map(view => view.ns);
71
+ /** How long the deferred form keeps retrying before it settles on the fallback. */
72
+ export const BINDER_RETRY_MS = 250;
73
+ const BINDER_ATTEMPTS = 24;
74
+ /** The snapshot an unresolved (or resolvable-but-unbound) form publishes. */
75
+ function pendingSnapshot(status) {
76
+ return { status, value: undefined, base: undefined, user: undefined, revision: undefined, writable: false, mode: 'host' };
77
+ }
78
+ /**
79
+ * A ConfigForm that late-binds to the family settings binder.
80
+ *
81
+ * The binder service (dsh-web-settings) is not guaranteed to be published by the
82
+ * time this plugin's apply() runs: the aggregate bundle mounts its inlined
83
+ * children — including the binder — inside an async mount that awaits the
84
+ * active-rows fetch, while standalone loader entries like this one apply
85
+ * synchronously in that window. A single early probe then permanently falls
86
+ * back to `configForms.get('pet')`, which is never a served row id under the
87
+ * aggregate (the row is `web-ui-pet`), so the settings card renders "not
88
+ * exposed" forever even though the Host serves the namespace.
89
+ *
90
+ * This form resolves through the binder as soon as the service appears and
91
+ * delegates the whole ConfigForm surface to it, re-publishing to its own
92
+ * subscribers on every swap. Until a form is resolved it publishes a loading
93
+ * (then unavailable) snapshot so the card shows a transient state, never a
94
+ * false "not exposed". If the binder never appears it retries for a bounded
95
+ * window, then permanently binds the non-bridge fallback by SERVED entry id.
96
+ */
97
+ class DeferredSettingsForm {
98
+ ctx;
99
+ current;
100
+ listeners = new Set();
101
+ unsubscribeCurrent;
102
+ retryTimer;
103
+ attempts = 0;
104
+ disposed = false;
105
+ fallback;
106
+ fallbackUnsubscribe;
107
+ constructor(ctx) {
108
+ this.ctx = ctx;
109
+ this.fallback = ctx.configForms.get(this.resolveFallbackEntryId());
110
+ // No binder yet: the aggregate publishes it after an async mount, so keep
111
+ // probing. A shared form that can answer for itself is adopted at once.
112
+ if (!this.resolve() && !this.fallbackSettled())
113
+ this.scheduleRetry();
114
+ else if (this.current === undefined)
115
+ this.adoptFallback();
83
116
  }
84
- catch {
85
- served = undefined;
117
+ /**
118
+ * True while the shared mirror reports the pet namespace unavailable — the
119
+ * only state in which waiting can still help. A fallback that is ready (or
120
+ * merely loading, which the mirror fills in on its own) is adopted at once.
121
+ */
122
+ fallbackSettled() {
123
+ try {
124
+ return this.fallback.getSnapshot().status !== 'unavailable';
125
+ }
126
+ catch {
127
+ return false;
128
+ }
86
129
  }
87
- if (!served || served.length === 0)
130
+ /**
131
+ * Bind the fallback to a SERVED row id when the mirror can name one; a mirror
132
+ * that cannot is left to report its own unavailable state.
133
+ */
134
+ resolveFallbackEntryId() {
135
+ try {
136
+ const served = this.ctx.configForms.describe().getSnapshot().view?.namespaces.map(view => view.ns);
137
+ if (served && served.length > 0) {
138
+ const hit = PET_ENTRY_IDS.find(id => served.includes(id));
139
+ if (hit !== undefined)
140
+ return hit;
141
+ }
142
+ }
143
+ catch {
144
+ // fall through to the family namespace; the form reports unavailable.
145
+ }
88
146
  return PET_SETTINGS_NS;
89
- return PET_ENTRY_IDS.find(id => served.includes(id)) ?? PET_SETTINGS_NS;
90
- }
91
- function petSettingsForm(ctx) {
92
- const binder = ctx.get('webUiSettings');
93
- if (binder !== undefined && typeof binder.bind === 'function') {
94
- return binder.bind({ namespace: PET_SETTINGS_NS });
95
147
  }
96
- return ctx.configForms.get(servedEntryId(ctx.configForms));
148
+ /**
149
+ * Adopt the family binder the moment it is published.
150
+ * @returns true when a binder was bound, false when none is available yet.
151
+ */
152
+ resolve() {
153
+ if (this.disposed)
154
+ return false;
155
+ let binder;
156
+ try {
157
+ binder = this.ctx.get('webUiSettings');
158
+ }
159
+ catch {
160
+ binder = undefined;
161
+ }
162
+ if (binder === undefined || typeof binder.bind !== 'function')
163
+ return false;
164
+ let bound;
165
+ try {
166
+ bound = binder
167
+ .bind({ namespace: PET_SETTINGS_NS });
168
+ }
169
+ catch {
170
+ return false;
171
+ }
172
+ this.current = bound;
173
+ // Mirror the bound form's changes to our own subscribers; a later re-resolve
174
+ // swaps this subscription to the new form.
175
+ this.unsubscribeCurrent?.();
176
+ this.unsubscribeCurrent = bound.subscribe(() => this.publish());
177
+ this.publish();
178
+ return true;
179
+ }
180
+ /**
181
+ * Adopt the shared per-entry form. It is used immediately unless it reports
182
+ * the namespace unavailable, in which case the binder may still be on its way
183
+ * and the retry window takes over (see scheduleRetry).
184
+ */
185
+ adoptFallback() {
186
+ this.current = this.fallback;
187
+ this.fallbackUnsubscribe ??= this.fallback.subscribe(() => this.publish());
188
+ this.unsubscribeCurrent = this.fallbackUnsubscribe;
189
+ this.publish();
190
+ }
191
+ /** Retry the binder lookup a few times across the aggregate's async mount. */
192
+ scheduleRetry() {
193
+ if (this.disposed)
194
+ return;
195
+ if (this.attempts >= BINDER_ATTEMPTS) {
196
+ this.adoptFallback();
197
+ return;
198
+ }
199
+ this.attempts += 1;
200
+ this.retryTimer = window.setTimeout(() => {
201
+ this.retryTimer = undefined;
202
+ if (this.disposed)
203
+ return;
204
+ if (this.resolve())
205
+ return;
206
+ // The binder still absent: keep waiting only while the shared form cannot
207
+ // answer for itself, otherwise a standalone install stalls for the window.
208
+ if (this.fallbackSettled()) {
209
+ this.attempts = BINDER_ATTEMPTS;
210
+ this.adoptFallback();
211
+ return;
212
+ }
213
+ this.scheduleRetry();
214
+ }, BINDER_RETRY_MS);
215
+ }
216
+ publish() {
217
+ for (const listener of this.listeners)
218
+ listener();
219
+ }
220
+ /** The resolved form, or a placeholder snapshot when still pending. */
221
+ snapshot() {
222
+ return this.current?.getSnapshot() ?? pendingSnapshot(this.attempts >= BINDER_ATTEMPTS ? 'unavailable' : 'loading');
223
+ }
224
+ getSnapshot() {
225
+ return this.snapshot();
226
+ }
227
+ subscribe(listener) {
228
+ this.listeners.add(listener);
229
+ return () => { this.listeners.delete(listener); };
230
+ }
231
+ mutate(ops, expectedRevision) {
232
+ return this.current?.mutate(ops, expectedRevision) ?? Promise.resolve(false);
233
+ }
234
+ set(field, value) {
235
+ return this.current?.set(field, value) ?? Promise.resolve(false);
236
+ }
237
+ unset(field) {
238
+ return this.current?.unset(field) ?? Promise.resolve(false);
239
+ }
240
+ /** Release the retry timer and mirror subscription; not part of ConfigForm. */
241
+ dispose() {
242
+ if (this.disposed)
243
+ return;
244
+ this.disposed = true;
245
+ if (this.retryTimer !== undefined) {
246
+ window.clearTimeout(this.retryTimer);
247
+ this.retryTimer = undefined;
248
+ }
249
+ this.unsubscribeCurrent?.();
250
+ this.unsubscribeCurrent = undefined;
251
+ this.current = undefined;
252
+ this.listeners.clear();
253
+ // The shared per-entry form carries no disposer of its own (ConfigForm is a
254
+ // pure read/write surface); only this form's own subscriptions are released.
255
+ this.fallbackUnsubscribe?.();
256
+ this.fallbackUnsubscribe = undefined;
257
+ }
97
258
  }
98
259
  /**
99
260
  * Client plugin body: register dictionaries, mount the global pet entry and
@@ -129,7 +290,7 @@ export function apply(ctx) {
129
290
  // M3). Registration is idempotent (id wins), so re-applies stay clean.
130
291
  defaultPetRendererRegistry.register(live2dRenderer);
131
292
  defaultPetRendererRegistry.register(frames2dRenderer);
132
- const settingsForm = petSettingsForm(ctx);
293
+ const settingsForm = new DeferredSettingsForm(ctx);
133
294
  const enabled = () => {
134
295
  const snapshot = settingsForm.getSnapshot();
135
296
  return snapshot.status === 'ready'
@@ -430,6 +591,9 @@ export function apply(ctx) {
430
591
  const unsubscribeSettings = settingsForm.subscribe(syncUi);
431
592
  ctx.effect(() => () => {
432
593
  unsubscribeSettings();
594
+ // Release the deferred form's retry timer and its mirror subscription so a
595
+ // disposed fiber can never bind or publish after teardown.
596
+ settingsForm.dispose();
433
597
  killUi();
434
598
  }, 'pet: client lifecycle');
435
599
  syncUi();
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAI5D,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAsC,KAAK,SAAS,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAG1G,OAAO,EAA6G,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAG/J,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAC9D,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,YAAY,GACb,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,MAAM,GACP,MAAM,eAAe,CAAA;AACtB,YAAY,EACV,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,cAAc,GACf,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,KAAK,GACN,MAAM,YAAY,CAAA;AACnB,YAAY,EACV,aAAa,EACb,Y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,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;IACxB,yDAAyD;IACzD,KAAK,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;IACzB,wDAAwD;IACxD,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;IAC1B,4EAA4E;IAC5E,WAAW,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;IAC/B,2EAA2E;IAC3E,KAAK,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CACtC;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;aAWjB,CAAA;AAkDF;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,MAAM,EACrB,SAAS,GAAE,OAAO,CAAC,gBAAgB,CAAM,EACzC,SAAS,GAAE,OAAO,CAAC,gBAAgB,CAAM,GACxC,kBAAkB,CA2BpB;AA4CD,0EAA0E;AAC1E,eAAO,MAAM,KAAK,kBAA6C,CAAA;AAE/D,4FAA4F;AAC5F,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,mBAAmB,CAAC,GAAG,aAAa,CAAA;AAE9F,iBAAS,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,eAAoB,GAAG,IAAI,CA8EnE;AAED,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,MAAM;QACd;;;;WAIG;QACH,wBAAwB,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI,CAAA;KACtE;CACF"}
@@ -128,6 +128,22 @@ function displayField(key, live, persisted, committed) {
128
128
  * @returns the resolved settings section.
129
129
  */
130
130
  export function petSettingsSection(config, fallbackPetId, persisted = {}, committed = {}) {
131
+ // `visible` and `enabled` answer two DIFFERENT questions and are kept
132
+ // apart on purpose (#1762):
133
+ //
134
+ // - `visible` is the pet's own hide/show intent, persisted in its pet.json
135
+ // and written by the sprite's hide/summon control and by the aggregate
136
+ // shell's fallback switch.
137
+ // - `enabled` is the plugin master switch, which hides the pet whatever that
138
+ // own intent says.
139
+ //
140
+ // The effective "is it on screen" state is the conjunction, and it belongs at
141
+ // the single point that PRODUCES the view (see PetService.state), never here
142
+ // and never written back to pet.json. Folding it into this field is what made
143
+ // the master switch one-way: switching it off stored the derived `false` as
144
+ // the user's own intent, so switching it on again (or restarting) read that
145
+ // stored `false` back and the pet never returned.
146
+ const enabled = readLive(config.enabled, PET_FORM_DEFAULTS.enabled);
131
147
  return {
132
148
  visible: displayField('visible', config.visible, persisted, committed),
133
149
  size: displayField('size', config.size, persisted, committed),
@@ -135,7 +151,7 @@ export function petSettingsSection(config, fallbackPetId, persisted = {}, commit
135
151
  bottom: displayField('bottom', config.bottom, persisted, committed),
136
152
  bubbleScale: displayField('bubbleScale', config.bubbleScale, persisted, committed),
137
153
  petId: readLive(config.petId, fallbackPetId),
138
- enabled: readLive(config.enabled, PET_FORM_DEFAULTS.enabled),
154
+ enabled,
139
155
  decorationEnabled: readLive(config.decorationEnabled, PET_FORM_DEFAULTS.decorationEnabled),
140
156
  };
141
157
  }
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGtD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACpF,OAAO,EAAwC,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AAC1F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAS9C,OAAO,EAAgC,KAAK,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACxF,OAAO,EAWL,KAAK,gBAAgB,EACt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jE,iCAAiC;IAC3B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,OAAO,EAAE,gBAAgB,CAAA;KAAE,CAAC;IAOpF;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAMrB;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAc5G,6GAA6G;IACvG,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,OAAO,EAAE,gBAAgB,CAAA;KAAE,CAAC;IAYnG,2EAA2E;IACrE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAS/F;;;;;OAKG;IACH,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IA2BvD,oFAAoF;IACpF,OAAO,CAAC,mBAAmB;IAgB3B,qFAAqF;IACrF,OAAO,CAAC,UAAU;IAIlB,8EAA8E;IAC9E,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,IAAI;IAsFZ,OAAO,CAAC,KAAK;CAOd"}
@@ -605,7 +605,13 @@ export class PetService extends Service {
605
605
  this.syncSettingsFromPet();
606
606
  }
607
607
  const next = { ...this.ledger.snapshot.display };
608
- next.visible = section.visible && (section.enabled ?? true);
608
+ // The pet's own hide/show intent, stored verbatim. The master switch is
609
+ // applied when the state view is produced (see the state view below), not
610
+ // here: writing the conjunction into pet.json turned `enabled: false` into
611
+ // a persisted "the user hid the pet" and the switch could never be undone -
612
+ // re-enabling it (or restarting) read that stored `false` straight back
613
+ // (#1762).
614
+ next.visible = section.visible;
609
615
  next.size = Math.round(Math.min(DISPLAY_SIZE_MAX, Math.max(DISPLAY_SIZE_MIN, section.size)));
610
616
  next.right = Math.round(Math.min(DISPLAY_INSET_MAX, Math.max(0, section.right)));
611
617
  next.bottom = Math.round(Math.min(DISPLAY_INSET_MAX, Math.max(0, section.bottom)));
@@ -710,7 +716,11 @@ export class PetService extends Service {
710
716
  ...(decoration === undefined ? {} : { decoration }),
711
717
  ...(announcement === undefined ? {} : { announcement }),
712
718
  affinity: this.ledger.affinityView(Date.now()),
713
- display: { ...this.ledger.snapshot.display },
719
+ // The one place the two visibility answers are combined: the pet's own
720
+ // hide/show intent AND the plugin master switch. Producing the effective
721
+ // value here - rather than storing it - keeps the switch reversible and
722
+ // keeps pet.json describing only what the user chose (#1762).
723
+ display: { ...this.ledger.snapshot.display, visible: this.isEnabled() && this.ledger.snapshot.display.visible },
714
724
  pet: {
715
725
  id: entry.id,
716
726
  displayName: entry.displayName,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-pet",
3
3
  "description": "Multi-pet companion plugin for the dsh web GUI: a registry-driven floating pet that reacts to model activity, with per-pet naming, petting/feeding interactions and an affinity score",
4
- "version": "0.4.4",
4
+ "version": "0.4.5",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -49,7 +49,7 @@ vi.mock('@deepseek-ai/dsh-client-store', () => ({
49
49
  },
50
50
  }))
51
51
  import type { Context as ClientContext } from '@deepseek-ai/cordis'
52
- import { apply } from './index.ts'
52
+ import { apply, BINDER_RETRY_MS } from './index.ts'
53
53
 
54
54
  beforeAll(() => {
55
55
  document.documentElement.lang = 'zh'
@@ -65,6 +65,8 @@ interface FakeClientLifecycle {
65
65
  setEnabled(enabled: boolean): void
66
66
  /** Namespaces the family settings binder was asked for (empty without one). */
67
67
  boundNamespaces(): string[]
68
+ /** Publish the family settings binder, as the aggregate's async mount does. */
69
+ publishFamilyBinder(enabled: boolean): void
68
70
  }
69
71
 
70
72
  const activeLifecycles: FakeClientLifecycle[] = []
@@ -79,6 +81,12 @@ interface FakeContextOptions {
79
81
  familyBinder?: boolean
80
82
  /** Initial value of the settings section the bound form answers with. */
81
83
  enabled?: boolean
84
+ /**
85
+ * What the shared per-entry form answers before any family binder exists.
86
+ * The aggregate renames the pet row to 'web-ui-pet', so the family alias
87
+ * 'pet' is never a served key there and the fallback reports unavailable.
88
+ */
89
+ fallbackStatus?: 'ready' | 'unavailable'
82
90
  }
83
91
 
84
92
  function fakeContext(options: FakeContextOptions = {}): FakeClientLifecycle {
@@ -87,6 +95,39 @@ function fakeContext(options: FakeContextOptions = {}): FakeClientLifecycle {
87
95
  const sessionListeners = new Set<() => void>()
88
96
  const boundNamespaces: string[] = []
89
97
  let settingsValue: { enabled?: boolean } | undefined = options.enabled === undefined ? undefined : { enabled: options.enabled }
98
+ // The family binder is published later in the aggregate race; the shared form
99
+ // answers 'unavailable' until then, exactly as the wrongly-keyed fallback does.
100
+ let binderPublished = options.familyBinder === true
101
+ const fallbackStatus = options.fallbackStatus ?? 'ready'
102
+ // The shared per-entry form a standalone install answers with: the plugin's
103
+ // own row id IS served, so it carries the same values as the bound scope. A
104
+ // test that sets fallbackStatus to 'unavailable' models the aggregate, where
105
+ // the family alias is never a served key and the form can only report that.
106
+ const fallbackScope = {
107
+ getSnapshot: () => (fallbackStatus === 'ready'
108
+ ? {
109
+ status: 'ready',
110
+ writable: true,
111
+ value: settingsValue,
112
+ base: undefined,
113
+ user: {},
114
+ revision: 1,
115
+ mode: 'host',
116
+ }
117
+ : {
118
+ status: 'unavailable',
119
+ writable: false,
120
+ value: undefined,
121
+ base: undefined,
122
+ user: {},
123
+ revision: undefined,
124
+ mode: 'host',
125
+ }),
126
+ subscribe: (listener: () => void) => {
127
+ settingsListeners.add(listener)
128
+ return () => { settingsListeners.delete(listener) }
129
+ },
130
+ }
90
131
  const scope = {
91
132
  getSnapshot: () => ({
92
133
  status: 'ready',
@@ -119,8 +160,15 @@ function fakeContext(options: FakeContextOptions = {}): FakeClientLifecycle {
119
160
  locale: { register: () => () => {} },
120
161
  // The family binder is optional (dsh-web-settings may be absent); both
121
162
  // answers are the shared per-entry form of this plugin's own profile entry.
122
- get: (name: string) => name === 'webUiSettings' && options.familyBinder === true ? familyBinder : undefined,
123
- configForms: { get: () => scope },
163
+ get: (name: string) => name === 'webUiSettings' && binderPublished ? familyBinder : undefined,
164
+ configForms: {
165
+ get: () => fallbackScope,
166
+ // The aggregate's mirror names the renamed row; the family alias never
167
+ // appears there, so the fallback lookup cannot resolve it.
168
+ describe: () => ({
169
+ getSnapshot: () => ({ view: { namespaces: [{ ns: 'web-ui-pet' }] } }),
170
+ }),
171
+ },
124
172
  slots: {
125
173
  // Cordis runs the factory when the slot mounts and its returned
126
174
  // disposer when the fiber disposes; mirror that so slot content
@@ -158,6 +206,10 @@ function fakeContext(options: FakeContextOptions = {}): FakeClientLifecycle {
158
206
  sessionsListenerCount: () => sessionListeners.size,
159
207
  setEnabled: (enabled: boolean) => { settingsValue = { enabled } },
160
208
  boundNamespaces: () => boundNamespaces,
209
+ publishFamilyBinder: (enabled: boolean) => {
210
+ binderPublished = true
211
+ settingsValue = { enabled }
212
+ },
161
213
  }
162
214
  activeLifecycles.push(lifecycle)
163
215
  return lifecycle
@@ -256,6 +308,32 @@ describe('pet client apply', () => {
256
308
  expect(document.body.querySelectorAll('[data-dsh-pet-root]')).toHaveLength(1)
257
309
  })
258
310
 
311
+ it('binds the family binder published AFTER apply, instead of keeping the dead fallback', () => {
312
+ // Given a page where the aggregate mounts its inlined children behind an
313
+ // async fetch: at apply() time the family settings binder does not exist
314
+ // yet, and the shared mirror cannot resolve the 'pet' alias (the aggregate
315
+ // serves the renamed 'web-ui-pet' row), so a single early probe falls back
316
+ // to a permanently unavailable form.
317
+ vi.useFakeTimers()
318
+ const lifecycle = fakeContext({ fallbackStatus: 'unavailable' })
319
+
320
+ // When the pet client plugin applies inside that window
321
+ apply(lifecycle.ctx)
322
+
323
+ // Then no binder was bound yet and the pet surface is not yet up
324
+ expect(lifecycle.boundNamespaces()).toEqual([])
325
+ expect(document.body.querySelectorAll('[data-dsh-pet-root]')).toHaveLength(0)
326
+
327
+ // And when the aggregate finally publishes the binder, the settings form
328
+ // rebinds to the real namespace and the pet surface comes up.
329
+ lifecycle.publishFamilyBinder(true)
330
+ vi.advanceTimersByTime(BINDER_RETRY_MS)
331
+
332
+ expect(lifecycle.boundNamespaces()).toEqual(['pet'])
333
+ expect(document.body.querySelectorAll('[data-dsh-pet-root]')).toHaveLength(1)
334
+ vi.useRealTimers()
335
+ })
336
+
259
337
  it('user gets the pet settings form through the family binder when the group plugin is mounted', () => {
260
338
  // Given a client context that provides the dsh-web-settings family binder
261
339
  // and answers 'disabled' through the form that binder returns