@fractalsynapse/dsh-chapters 0.2.22 → 0.2.24

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/docs/contract.md CHANGED
@@ -727,6 +727,9 @@ the bar's state rides a plugin record and a projection, and the steady state cos
727
727
  - Append sites: every durable row write — the runner's `analyzing`/`ready`/`failed`/quiet-`off`
728
728
  transitions (it holds the live session) and the bar-access mutations (`setAutorun`, `setOff`,
729
729
  `setOn`, `runNow`'s consumption), which gain an optional live-session parameter for the purpose.
730
+ `runNow` also refuses a DELIVERED offer (#289): text equal to a later human-authored turn means
731
+ it already ran; the refusal retires the row (a write verb may heal) and the `state` READ renders
732
+ such an offer resting without mutating anything.
730
733
  - The function comes ONLY from the host's own module instance — `createRequire(process.argv[1])
731
734
  → resolve('@deepseek-ai/dsh-session') → await import(resolved)`. The plugin's OWN copy at the
732
735
  IDENTICAL version throws `Receiver must be an instance of class Session` against a host session
package/lib/client.js CHANGED
@@ -110,16 +110,19 @@ window.__ModuleLoader__.load({
110
110
  turnSeq: null,
111
111
  error: null,
112
112
  expanded: false,
113
- autorun: "disarmed"
113
+ autorun: "disarmed",
114
+ running: false
114
115
  };
115
116
  if (ev.status === "analyzing") return {
116
117
  ...state,
117
118
  status: "analyzing",
118
119
  text: null,
119
- error: null
120
+ error: null,
121
+ running: false
120
122
  };
121
123
  return {
122
124
  ...state,
125
+ running: false,
123
126
  status: ev.status,
124
127
  text: ev.status === "ready" ? ev.text ?? null : null,
125
128
  intent: ev.status === "ready" ? ev.intent ?? "worker-step" : "worker-step",
@@ -138,10 +141,18 @@ window.__ModuleLoader__.load({
138
141
  ...state,
139
142
  autorun: ev.on ? "armed" : "disarmed"
140
143
  };
141
- case "running": return {
142
- ...state,
143
- running: ev.running
144
- };
144
+ case "running":
145
+ if (ev.running === state.running) return state;
146
+ return ev.running ? {
147
+ ...state,
148
+ running: true,
149
+ text: null,
150
+ error: null,
151
+ expanded: false
152
+ } : {
153
+ ...state,
154
+ running: false
155
+ };
145
156
  case "human/prompt": return {
146
157
  ...state,
147
158
  autorun: "disarmed",
@@ -167,6 +178,7 @@ window.__ModuleLoader__.load({
167
178
  }
168
179
  /** The status label. `failed` keeps the ready label so the error span is the delta, not a mystery row. */
169
180
  function barLabel(s) {
181
+ if (s.running) return "Agent is running — a fresh suggestion lands when the turn ends";
170
182
  if (s.status === "analyzing") return "Analyzing situation…";
171
183
  if (s.status === "ready" || s.status === "failed") return "Recommended Next Step";
172
184
  return null;
@@ -236,6 +248,7 @@ window.__ModuleLoader__.load({
236
248
  }
237
249
  function barVisible(s) {
238
250
  if (s.status === "off") return false;
251
+ if (s.running) return true;
239
252
  if (s.status === "ready" && (s.text === null || s.text === "")) return false;
240
253
  if (s.hiddenTurnSeq !== null && s.hiddenTurnSeq === s.turnSeq) return false;
241
254
  return true;
@@ -462,7 +475,9 @@ window.__ModuleLoader__.load({
462
475
  ".dsh-chapters_promptLabel{color:var(--dsw-alias-label-primary);flex:none;font-size:13px;font-weight:500;line-height:24px}",
463
476
  ".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%}",
464
477
  ".dsh-chapters_promptEllipsis{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;display:block}",
465
- ".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}",
478
+ ".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;position:relative}",
479
+ ".dsh-chapters_promptCollapse{position:absolute;top:2px;right:2px;width:22px;height:22px;border:none;border-radius:4px;background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary);cursor:pointer;font-size:13px;line-height:22px;padding:0}",
480
+ ".dsh-chapters_promptCollapse:hover{color:var(--dsw-alias-label-primary)}",
466
481
  ".dsh-chapters_promptError{color:var(--dsw-alias-state-error-primary);font-size:12px;line-height:20px;flex:none;max-width:34%}",
467
482
  ".dsh-chapters_promptNote{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:20px;min-width:0}",
468
483
  ".dsh-chapters_promptIntent{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:20px}",
@@ -637,12 +652,12 @@ window.__ModuleLoader__.load({
637
652
  const pushEvs = pushEventsOf(pushed);
638
653
  if (pushEvs !== null) return {
639
654
  ...promptBarReducer(promptBarReducer(s, pushEvs.polled), pushEvs.autorun),
640
- running: running ?? true
655
+ running: running === true
641
656
  };
642
657
  const c = cachedState(sessionId);
643
658
  return {
644
659
  ...c !== void 0 ? stateFromCache(c.ev, c.autorun) : s,
645
- running: running ?? true
660
+ running: running === true
646
661
  };
647
662
  });
648
663
  const pulling = (0, react.useRef)(false);
@@ -783,9 +798,9 @@ window.__ModuleLoader__.load({
783
798
  if (typeof document !== "undefined") document.removeEventListener("visibilitychange", onVisible);
784
799
  };
785
800
  }, [refresh]);
786
- const prevRunning = (0, react.useRef)(running ?? true);
801
+ const prevRunning = (0, react.useRef)(running === true);
787
802
  (0, react.useEffect)(() => {
788
- const next = running ?? true;
803
+ const next = running === true;
789
804
  const prev = prevRunning.current;
790
805
  prevRunning.current = next;
791
806
  dispatch({
@@ -821,7 +836,10 @@ window.__ModuleLoader__.load({
821
836
  error: out.trim().slice(0, 200),
822
837
  turnSeq: state.turnSeq
823
838
  });
824
- else dispatch({ t: "collapse" });
839
+ else dispatch({
840
+ t: "running",
841
+ running: true
842
+ });
825
843
  }).catch((error) => {
826
844
  console.warn(`[client:prompt] run failed: ${String(error?.message ?? error).slice(0, 160)}`);
827
845
  }).finally(() => {
@@ -900,12 +918,19 @@ window.__ModuleLoader__.load({
900
918
  }, "edits the goal · run it yourself")] : [], (0, react.createElement)("button", {
901
919
  type: "button",
902
920
  className: "dsh-chapters_promptText",
903
- "aria-label": state.expanded ? "Put this suggested prompt in the input box" : "Show the full suggested prompt",
921
+ "aria-label": state.expanded ? "Click to send this prompt to the chat input for editing" : "Click to expand the full suggested prompt",
922
+ title: state.expanded ? "Click to send this prompt to the chat input for editing" : "Click to expand the full suggested prompt",
923
+ disabled: state.running,
904
924
  onClick: populate
905
- }, state.expanded ? (0, react.createElement)("span", { className: "dsh-chapters_promptFull" }, state.text ?? "") : (0, react.createElement)("span", {
906
- className: "dsh-chapters_promptEllipsis",
907
- title: state.text ?? void 0
908
- }, lineFor(state))), ...state.note === "" ? [] : [(0, react.createElement)("span", {
925
+ }, state.expanded ? (0, react.createElement)("span", { className: "dsh-chapters_promptFull" }, (0, react.createElement)("button", {
926
+ type: "button",
927
+ className: "dsh-chapters_promptCollapse",
928
+ "aria-label": "Collapse the suggested prompt",
929
+ title: "Collapse",
930
+ onClick: () => {
931
+ dispatch({ t: "collapse" });
932
+ }
933
+ }, "▴"), state.text ?? "") : (0, react.createElement)("span", { className: "dsh-chapters_promptEllipsis" }, lineFor(state))), ...state.note === "" ? [] : [(0, react.createElement)("span", {
909
934
  key: "note",
910
935
  className: "dsh-chapters_promptNote",
911
936
  role: "status"
@@ -941,7 +966,7 @@ window.__ModuleLoader__.load({
941
966
  glyph: "✕",
942
967
  onClick: () => {
943
968
  (async () => {
944
- if (exec !== void 0) await exec("/chapters-prompt off");
969
+ if (exec !== void 0) await exec("/chapters-prompt off-session");
945
970
  dispatch({ t: "off" });
946
971
  if (sessionId !== void 0) {
947
972
  const offEntry = {