@fractalsynapse/dsh-chapters 0.2.26 → 0.2.28
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 +77 -15
- package/lib/client.js.map +1 -1
- package/lib/index.js +19 -1
- package/lib/index.js.map +1 -1
- package/lib/prompt-runner.d.ts +13 -0
- package/lib/prompt-runner.js +16 -0
- package/lib/prompt-runner.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -187,6 +187,16 @@ window.__ModuleLoader__.load({
|
|
|
187
187
|
return null;
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
190
|
+
* #309: the row button's one sentence, as a pure function of what the click would DO —
|
|
191
|
+
* collapsed invites the reading; expanded-into-an-empty-composer invites the handoff;
|
|
192
|
+
* expanded-with-the-user-typing names the precondition instead of lying about the gesture.
|
|
193
|
+
* One predicate per decision (#59): aria-label and the tooltip render this same string.
|
|
194
|
+
*/
|
|
195
|
+
function rowTooltip(expanded, composerHasText) {
|
|
196
|
+
if (!expanded) return "Click to expand the full suggested prompt";
|
|
197
|
+
return composerHasText ? "Clear existing prompt to send this prompt to chat input" : "Click to send this prompt to the chat input for editing";
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
190
200
|
* #193: the pull cadence, as a decision instead of an interval constant. Every pull is two recorded
|
|
191
201
|
* host lifecycle events (`command/run` + `command/done`) the UI renders as history nodes — cadence
|
|
192
202
|
* IS the litter, so it belongs in this module with a row for every arm. Active = the state can
|
|
@@ -210,16 +220,29 @@ window.__ModuleLoader__.load({
|
|
|
210
220
|
function configureQuietHeartbeat(seconds) {
|
|
211
221
|
QUIET_POLL_MS = typeof seconds === "number" && Number.isFinite(seconds) && seconds > 0 ? Math.trunc(seconds * 1e3) : 0;
|
|
212
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* #304: the analyzing belt backs off 10s → 20s → 40s → 60s (cap) while a generation is in
|
|
225
|
+
* flight and nobody is armed. The first wait stays eager (short generations — every rig leg —
|
|
226
|
+
* land in the old 10s rhythm); long and zombie generations stop paying 2 history nodes per
|
|
227
|
+
* poll. The ARMED loop ignores the belt entirely: a stalled round is worse than any cadence.
|
|
228
|
+
* streak counts consecutive analyzing OBSERVATIONS (undefined/0 = eager).
|
|
229
|
+
*/
|
|
230
|
+
function analyzingBeltMs(streak) {
|
|
231
|
+
const n = streak === void 0 || streak < 1 ? 0 : Math.min(streak, 3);
|
|
232
|
+
return n === 0 ? ACTIVE_POLL_MS : n === 1 ? 2e4 : n === 2 ? 4e4 : 6e4;
|
|
233
|
+
}
|
|
213
234
|
function pollSpacingFor(s) {
|
|
214
235
|
if (s.turnEndPulse === true) return ACTIVE_POLL_MS;
|
|
215
236
|
if (s.edges) {
|
|
216
|
-
if (s.
|
|
237
|
+
if (s.autorun === "armed") return ACTIVE_POLL_MS;
|
|
238
|
+
if (s.status === "analyzing") return analyzingBeltMs(s.analyzingStreak);
|
|
217
239
|
return null;
|
|
218
240
|
}
|
|
219
241
|
const active = s.status === "analyzing" || s.autorun === "armed";
|
|
220
242
|
if (!active && s.hidden) return null;
|
|
221
243
|
if (!active) return QUIET_POLL_MS > 0 ? QUIET_POLL_MS : null;
|
|
222
|
-
return ACTIVE_POLL_MS;
|
|
244
|
+
if (s.autorun === "armed") return ACTIVE_POLL_MS;
|
|
245
|
+
return analyzingBeltMs(s.analyzingStreak);
|
|
223
246
|
}
|
|
224
247
|
/**
|
|
225
248
|
* #203: whether a freshly mounted bar pulls, or renders its cache and stays silent. The maintainer's
|
|
@@ -642,6 +665,30 @@ window.__ModuleLoader__.load({
|
|
|
642
665
|
});
|
|
643
666
|
});
|
|
644
667
|
}
|
|
668
|
+
/**
|
|
669
|
+
* The composer, by the name the HOST gives it (placeholder "Message or run a task, / commands, …",
|
|
670
|
+
* locales.ts:400) — NOT a bare `[contenteditable][role=textbox]` first(), which on this app matches
|
|
671
|
+
* the sidebar's "Search session names" input (measured lesson, tests/e2e/prompt-bar.spec.ts:41: a
|
|
672
|
+
* whole click-to-draft assertion was reading the wrong element). The host's own editable element
|
|
673
|
+
* carries `data-composer-input` (measured: ComposerContentEditable.tsx:46) — stable across styles,
|
|
674
|
+
* locales and restyles, so the probe matches THAT and never a first(). Shared by the three sites
|
|
675
|
+
* that touch the editor: the #309 occupancy guard, the focus-before-insert, and the
|
|
676
|
+
* write-verification — one probe, one truth. Absent attribute ⇒ null ⇒ the guard ALLOWS the
|
|
677
|
+
* handoff (unknown is never a reason to block the feature; the post-write verify is the backstop).
|
|
678
|
+
*/
|
|
679
|
+
const composerBox = () => {
|
|
680
|
+
try {
|
|
681
|
+
return document.querySelector("[data-composer-input]");
|
|
682
|
+
} catch {
|
|
683
|
+
return null;
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
/** #309: does the chat input hold the user's in-flight text? Whitespace-only counts as empty. */
|
|
687
|
+
const composerHasText = () => {
|
|
688
|
+
const el = composerBox();
|
|
689
|
+
if (el === null) return false;
|
|
690
|
+
return ("value" in el ? String(el.value ?? "") : el.innerText ?? "").trim() !== "";
|
|
691
|
+
};
|
|
645
692
|
function PromptDock(props) {
|
|
646
693
|
const { sessionId, inputActions, exec } = props;
|
|
647
694
|
const sessionSnapshot = (props.useSession ?? (() => void 0))((snapshot) => snapshot);
|
|
@@ -662,6 +709,7 @@ window.__ModuleLoader__.load({
|
|
|
662
709
|
};
|
|
663
710
|
});
|
|
664
711
|
const pulling = (0, react.useRef)(false);
|
|
712
|
+
const analyzingStreak = (0, react.useRef)(0);
|
|
665
713
|
const probed = (0, react.useRef)(false);
|
|
666
714
|
const pulled = (0, react.useRef)(false);
|
|
667
715
|
const alive = (0, react.useRef)(true);
|
|
@@ -697,7 +745,9 @@ window.__ModuleLoader__.load({
|
|
|
697
745
|
const ev = parseBarState(text);
|
|
698
746
|
if (ev !== null) {
|
|
699
747
|
answered.current = true;
|
|
700
|
-
|
|
748
|
+
const st = ev.status ?? replyStatus.current;
|
|
749
|
+
replyStatus.current = st;
|
|
750
|
+
analyzingStreak.current = st === "analyzing" ? analyzingStreak.current + 1 : 0;
|
|
701
751
|
dispatch(ev);
|
|
702
752
|
}
|
|
703
753
|
const autorun = parseBarAutorun(text);
|
|
@@ -752,7 +802,8 @@ window.__ModuleLoader__.load({
|
|
|
752
802
|
running: stateRef.current.running,
|
|
753
803
|
hidden: typeof document !== "undefined" && document.hidden === true,
|
|
754
804
|
edges: edgesRef.current,
|
|
755
|
-
turnEndPulse: pe.pulse
|
|
805
|
+
turnEndPulse: pe.pulse,
|
|
806
|
+
analyzingStreak: analyzingStreak.current
|
|
756
807
|
});
|
|
757
808
|
};
|
|
758
809
|
const duePull = () => {
|
|
@@ -864,9 +915,16 @@ window.__ModuleLoader__.load({
|
|
|
864
915
|
return;
|
|
865
916
|
}
|
|
866
917
|
if (state.text === null || state.text === "") return;
|
|
918
|
+
if (composerHasText()) {
|
|
919
|
+
dispatch({
|
|
920
|
+
t: "note",
|
|
921
|
+
note: "The chat input has text — clear it first, then this click hands the suggestion over."
|
|
922
|
+
});
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
867
925
|
if (typeof inputActions?.insertText === "function") {
|
|
868
926
|
try {
|
|
869
|
-
|
|
927
|
+
composerBox()?.focus();
|
|
870
928
|
} catch {}
|
|
871
929
|
const refuse = (why) => {
|
|
872
930
|
console.warn(`[client:prompt] click-to-draft refused: ${why}`);
|
|
@@ -897,7 +955,8 @@ window.__ModuleLoader__.load({
|
|
|
897
955
|
const head = state.text.slice(0, 24);
|
|
898
956
|
setTimeout(() => {
|
|
899
957
|
try {
|
|
900
|
-
const
|
|
958
|
+
const el = composerBox();
|
|
959
|
+
const dom = el === null ? false : ("value" in el ? String(el.value ?? "") : el.innerText ?? "").includes(head);
|
|
901
960
|
const stored = Object.entries(localStorage).some(([, v]) => String(v).includes(head));
|
|
902
961
|
if (!dom && !stored) refuse("the write was accepted but nothing holds the text");
|
|
903
962
|
} catch {}
|
|
@@ -914,14 +973,17 @@ window.__ModuleLoader__.load({
|
|
|
914
973
|
return (0, react.createElement)("div", {
|
|
915
974
|
className: "dsh-chapters_promptDock",
|
|
916
975
|
"data-prompt-bar": "true"
|
|
917
|
-
}, (0, react.createElement)("div", { className: `dsh-chapters_promptBar${state.expanded ? " dsh-chapters_promptExpanded" : ""}` }, (0, react.createElement)("span", { className: "dsh-chapters_promptGlyph" }, (0, react.createElement)(Glyph)), (0, react.createElement)("span", { className: "dsh-chapters_promptLabel" }, barLabel(state) ?? ""), (
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
976
|
+
}, (0, react.createElement)("div", { className: `dsh-chapters_promptBar${state.expanded ? " dsh-chapters_promptExpanded" : ""}` }, (0, react.createElement)("span", { className: "dsh-chapters_promptGlyph" }, (0, react.createElement)(Glyph)), (0, react.createElement)("span", { className: "dsh-chapters_promptLabel" }, barLabel(state) ?? ""), (() => {
|
|
977
|
+
const rowTip = rowTooltip(state.expanded, composerHasText());
|
|
978
|
+
return withTooltip(rowTip, (0, react.createElement)("button", {
|
|
979
|
+
type: "button",
|
|
980
|
+
className: "dsh-chapters_promptText",
|
|
981
|
+
"aria-label": rowTip,
|
|
982
|
+
...nativeTitle(rowTip),
|
|
983
|
+
disabled: state.running,
|
|
984
|
+
onClick: populate
|
|
985
|
+
}, state.expanded ? (0, react.createElement)("span", { className: "dsh-chapters_promptFull" }, state.text ?? "") : (0, react.createElement)("span", { className: "dsh-chapters_promptEllipsis" }, lineFor(state))));
|
|
986
|
+
})(), ...state.note === "" ? [] : [(0, react.createElement)("span", {
|
|
925
987
|
key: "note",
|
|
926
988
|
className: "dsh-chapters_promptNote",
|
|
927
989
|
role: "status"
|
|
@@ -932,7 +994,7 @@ window.__ModuleLoader__.load({
|
|
|
932
994
|
}, state.error)], (0, react.createElement)("div", { className: "dsh-chapters_promptActions" }, ...state.expanded ? [(0, react.createElement)(Action, {
|
|
933
995
|
key: "collapse",
|
|
934
996
|
label: "Collapse the suggested prompt",
|
|
935
|
-
glyph: "
|
|
997
|
+
glyph: "▾",
|
|
936
998
|
className: "dsh-chapters_promptCollapse",
|
|
937
999
|
onClick: () => {
|
|
938
1000
|
dispatch({ t: "collapse" });
|