@treeseed/dsh-chapters 0.2.11 → 0.2.13

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/client.js CHANGED
@@ -182,7 +182,19 @@ window.__ModuleLoader__.load({
182
182
  * autorun and pausing it silently would be the loop dying with nobody told.
183
183
  */
184
184
  const ACTIVE_POLL_MS = 1e4;
185
- const QUIET_POLL_MS = 6e4;
185
+ /**
186
+ * #229: the quiet heartbeat is CONFIG-GATED (`promptQuietHeartbeatSec`) and defaults to ZERO.
187
+ * Measured on the maintainer's live log after 0.2.11 installed correctly (gaps exactly 60.0s): every
188
+ * pull is two durable nodes — a host `command/run` + `command/done` pair — and the user's rule is
189
+ * absolute: never repeated chapters-prompt executions. The sanctioned moments (mount discovery once
190
+ * per page load, the turn-end pulse, visibility return with an untrusted cache, forced confirms)
191
+ * remain; the ambient drumbeat does not exist unless configured. This module is client-safe (no node
192
+ * builtins), so the wiring injects the config value at boot via `configureQuietHeartbeat`.
193
+ */
194
+ let QUIET_POLL_MS = 0;
195
+ function configureQuietHeartbeat(seconds) {
196
+ QUIET_POLL_MS = typeof seconds === "number" && Number.isFinite(seconds) && seconds > 0 ? Math.trunc(seconds * 1e3) : 0;
197
+ }
186
198
  function pollSpacingFor(s) {
187
199
  if (s.turnEndPulse === true) return ACTIVE_POLL_MS;
188
200
  if (s.edges) {
@@ -191,7 +203,8 @@ window.__ModuleLoader__.load({
191
203
  }
192
204
  const active = s.status === "analyzing" || s.autorun === "armed";
193
205
  if (!active && s.hidden) return null;
194
- return active ? ACTIVE_POLL_MS : QUIET_POLL_MS;
206
+ if (!active) return QUIET_POLL_MS > 0 ? QUIET_POLL_MS : null;
207
+ return ACTIVE_POLL_MS;
195
208
  }
196
209
  /**
197
210
  * #203: whether a freshly mounted bar pulls, or renders its cache and stays silent. The maintainer's
@@ -205,7 +218,7 @@ window.__ModuleLoader__.load({
205
218
  if (!c.hasCache) return true;
206
219
  if (c.status === "off") return false;
207
220
  if (c.autorun === "armed" || c.status === "analyzing") return true;
208
- return c.ageMs > QUIET_POLL_MS;
221
+ return QUIET_POLL_MS > 0 && c.ageMs > QUIET_POLL_MS;
209
222
  }
210
223
  /**
211
224
  * #203: fold a cached wire event back into row state through the SAME reducer the live path uses —
@@ -272,6 +285,7 @@ window.__ModuleLoader__.load({
272
285
  }
273
286
  scalars[key] !== void 0 ? scalars[key] += ` ${value}` : scalars[key] = value;
274
287
  }
288
+ configureQuietHeartbeat(Number.parseInt((scalars["heartbeat"] ?? "").trim(), 10) || 0);
275
289
  const turnRaw = scalars["turn"] ?? "";
276
290
  const turnSeq = /^\d+$/.test(turnRaw) ? Number(turnRaw) : null;
277
291
  const errorRaw = scalars["error"] ?? "";
@@ -440,11 +454,12 @@ window.__ModuleLoader__.load({
440
454
  ".dsh-chapters_promptBar{isolation:isolate;box-sizing:border-box;width:100%;border-radius:var(--dsw-radius-md);height:36px;box-shadow:var(--dsw-elevation-panel);border:0;align-items:center;gap:10px;padding:4px 5px 4px 12px;display:flex;position:relative}",
441
455
  ".dsh-chapters_promptBar::before{z-index:-1;border-radius:inherit;background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);content:\"\";pointer-events:none;position:absolute;inset:0}",
442
456
  ".dsh-chapters_promptExpanded::before{align-items:flex-start;position:absolute;inset:0}",
457
+ ".dsh-chapters_promptExpanded{height:auto;min-height:36px;padding-top:8px;padding-bottom:8px}",
443
458
  ".dsh-chapters_promptGlyph{color:var(--dsw-alias-label-tertiary);flex:none;display:inline-flex}",
444
459
  ".dsh-chapters_promptLabel{color:var(--dsw-alias-label-primary);flex:none;font-size:13px;font-weight:500;line-height:24px}",
445
- ".dsh-chapters_promptText{min-width:0;color:var(--dsw-alias-label-primary-dimmed);font-size:13px;line-height:20px;cursor:pointer;border:0;background:0 0;padding:0;text-align:left;flex:1}",
460
+ ".dsh-chapters_promptText{min-width:0;color:var(--dsw-alias-label-primary-dimmed);font-size:13px;line-height:20px;cursor:pointer;border:0;background:0 0;padding:0;text-align:left;flex:1 1 100%}",
446
461
  ".dsh-chapters_promptEllipsis{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;display:block}",
447
- ".dsh-chapters_promptFull{white-space:pre-wrap;overflow:auto;max-height:9rem;display:block}",
462
+ ".dsh-chapters_promptFull{white-space:pre-wrap;overflow-wrap:break-word;word-break:normal;line-height:20px;font-size:13px;color:var(--dsw-alias-label-primary);display:block;max-height:9rem;overflow-y:auto}",
448
463
  ".dsh-chapters_promptError{color:var(--dsw-alias-state-error-primary);font-size:12px;line-height:20px;flex:none;max-width:34%}",
449
464
  ".dsh-chapters_promptNote{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:20px;min-width:0}",
450
465
  ".dsh-chapters_promptIntent{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:20px}",
@@ -630,6 +645,7 @@ window.__ModuleLoader__.load({
630
645
  let timer;
631
646
  const effectiveStatus = () => replyStatus.current === "unknown" ? stateRef.current.status : replyStatus.current;
632
647
  const spacingNow = () => {
648
+ if (stateRef.current.autorun === "armed") return ACTIVE_POLL_MS;
633
649
  const pe = turnEndPulse(turnBoundary?.lastTurn, seenTurnRef.current);
634
650
  if (pe.pulse) seenTurnRef.current = pe.seen;
635
651
  return pollSpacingFor({
@@ -657,7 +673,8 @@ window.__ModuleLoader__.load({
657
673
  if (!(opts?.mount === true && duePull())) return;
658
674
  }
659
675
  const spacing = spacingNow();
660
- if (opts?.force === true || spacing !== null && !(opts?.mount === true && !duePull())) await refresh();
676
+ const mountDiscovery = opts?.mount === true && duePull();
677
+ if (opts?.force === true || mountDiscovery || spacing !== null && opts?.mount !== true) await refresh();
661
678
  if (replyStatus.current === "off") return;
662
679
  const next = spacingNow();
663
680
  if (next !== null) timer = setTimeout(() => {
@@ -792,7 +809,10 @@ window.__ModuleLoader__.load({
792
809
  className: "dsh-chapters_promptText",
793
810
  "aria-label": state.expanded ? "Put this suggested prompt in the input box" : "Show the full suggested prompt",
794
811
  onClick: populate
795
- }, state.expanded ? (0, react.createElement)("span", { className: "dsh-chapters_promptFull" }, state.text ?? "") : (0, react.createElement)("span", { className: "dsh-chapters_promptEllipsis" }, lineFor(state))), ...state.note === "" ? [] : [(0, react.createElement)("span", {
812
+ }, state.expanded ? (0, react.createElement)("span", { className: "dsh-chapters_promptFull" }, state.text ?? "") : (0, react.createElement)("span", {
813
+ className: "dsh-chapters_promptEllipsis",
814
+ title: state.text ?? void 0
815
+ }, lineFor(state))), ...state.note === "" ? [] : [(0, react.createElement)("span", {
796
816
  key: "note",
797
817
  className: "dsh-chapters_promptNote",
798
818
  role: "status"